Skip to content

Commit

Permalink
Merge branch 'master' into faster-collection-rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
dhh committed Nov 13, 2021
2 parents 00c92ef + 755b687 commit 3ae8a4c
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 89 deletions.
108 changes: 108 additions & 0 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
name: Ruby test

on: [push, pull_request]

jobs:
test:
name: Ruby test
runs-on: ubuntu-20.04
continue-on-error: ${{ matrix.experimental }}
env:
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
BUNDLE_JOBS: 4
BUNDLE_RETRY: 3
strategy:
fail-fast: false
matrix:
ruby: [
2.2.10,
2.3.8,
2.4.10,
2.5.8,
2.6.6,
2.7.1,
3.0.0
]
gemfile: [
"rails_5_0",
"rails_5_1",
"rails_5_2",
"rails_6_0",
"rails_6_1",
"rails_head"
]
experimental: [false]
exclude:
- ruby: 2.7.1
gemfile: rails_5_0
- ruby: 3.0.0
gemfile: rails_5_0
- ruby: head
gemfile: rails_5_0
- ruby: 2.7.1
gemfile: rails_5_1
- ruby: 3.0.0
gemfile: rails_5_1
- ruby: head
gemfile: rails_5_1
- ruby: 2.2.10
gemfile: rails_5_2
- ruby: 2.7.1
gemfile: rails_5_2
- ruby: 3.0.0
gemfile: rails_5_2
- ruby: head
gemfile: rails_5_2
- ruby: 2.2.10
gemfile: rails_6_0
- ruby: 2.3.8
gemfile: rails_6_0
- ruby: 2.4.10
gemfile: rails_6_0
- ruby: 3.0.0
gemfile: rails_6_0
- ruby: head
gemfile: rails_6_0
- ruby: 2.2.10
gemfile: rails_6_1
- ruby: 2.3.8
gemfile: rails_6_1
- ruby: 2.4.10
gemfile: rails_6_1
- ruby: 2.2.10
gemfile: rails_head
- ruby: 2.3.8
gemfile: rails_head
- ruby: 2.4.10
gemfile: rails_head
- ruby: 2.5.8
gemfile: rails_head
- ruby: 2.6.6
gemfile: rails_head
- ruby: 2.7.1
gemfile: rails_head
experimental: false
- ruby: 3.0.0
gemfile: rails_head
experimental: false
include:
- ruby: 2.7.1
gemfile: rails_head
experimental: true
- ruby: 3.0.0
gemfile: rails_head
experimental: true
- ruby: head
gemfile: rails_head
experimental: true

steps:
- uses: actions/checkout@v2

- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Ruby test
run: bundle exec rake
80 changes: 0 additions & 80 deletions .travis.yml

This file was deleted.

6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Contributing to Jbuilder
=====================

[![Build Status](https://api.travis-ci.org/rails/jbuilder.svg?branch=master)][travis]
[![Build Status](https://github.com/rails/jbuilder/workflows/Ruby%20test/badge.svg)][test]
[![Gem Version](https://badge.fury.io/rb/jbuilder.svg)][gem]
[![Code Climate](https://codeclimate.com/github/rails/jbuilder/badges/gpa.svg)][codeclimate]

[travis]: https://travis-ci.org/rails/jbuilder
[test]: https://github.com/rails/jbuilder/actions?query=branch%3Amaster
[gem]: https://rubygems.org/gems/jbuilder
[codeclimate]: https://codeclimate.com/github/rails/jbuilder

Expand Down Expand Up @@ -95,7 +95,7 @@ git push origin my-feature-branch -f

#### Check on Your Pull Request

Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
Go back to your pull request after a few minutes and see whether it passed muster with GitHub Actions. Everything should look green, otherwise fix issues and amend your commit as described above.

#### Be Patient

Expand Down
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,23 @@ json.array! @people, :id, :name
# => [ { "id": 1, "name": "David" }, { "id": 2, "name": "Jamie" } ]
```

You don't always have or need a collection when building an array.

```ruby
json.people do
json.child! do
json.id 1
json.name 'David'
end
json.child! do
json.id 2
json.name 'Jamie'
end
end

# => { "people": [ { "id": 1, "name": "David" }, { "id": 2, "name": "Jamie" } ] }
```

Jbuilder objects can be directly nested inside each other. Useful for composing objects.

``` ruby
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require "bundler/setup"
require "bundler/gem_tasks"
require "rake/testtask"

if !ENV["APPRAISAL_INITIALIZED"] && !ENV["TRAVIS"]
if !ENV["APPRAISAL_INITIALIZED"] && !ENV["CI"]
require "appraisal/task"
Appraisal::Task.new
task default: :appraisal
Expand Down
5 changes: 0 additions & 5 deletions lib/jbuilder/jbuilder_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,7 @@ def _cache_key(key, options)

def _fragment_name_with_digest(key, options)
if @context.respond_to?(:cache_fragment_name)
# Current compatibility, fragment_name_with_digest is private again and cache_fragment_name
# should be used instead.
@context.cache_fragment_name(key, **options)
elsif @context.respond_to?(:fragment_name_with_digest)
# Backwards compatibility for period of time when fragment_name_with_digest was made public.
@context.fragment_name_with_digest(key)
else
key
end
Expand Down

0 comments on commit 3ae8a4c

Please sign in to comment.