grape-rabl 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/danger-comment.yml +11 -0
- data/.github/workflows/danger.yml +13 -0
- data/.github/workflows/test.yml +60 -0
- data/.rubocop.yml +3 -1
- data/.rubocop_todo.yml +17 -21
- data/CHANGELOG.md +27 -18
- data/CONTRIBUTING.md +12 -1
- data/Dangerfile +2 -0
- data/Gemfile +10 -3
- data/README.md +300 -203
- data/RELEASING.md +50 -35
- data/Rakefile +2 -0
- data/UPGRADING.md +4 -0
- data/grape-rabl.gemspec +4 -3
- data/lib/grape/rabl.rb +2 -0
- data/lib/grape-rabl/configuration.rb +4 -1
- data/lib/grape-rabl/formatter.rb +25 -7
- data/lib/grape-rabl/render.rb +3 -1
- data/lib/grape-rabl/tilt.rb +2 -0
- data/lib/grape-rabl/version.rb +3 -1
- data/lib/grape-rabl.rb +2 -0
- data/spec/grape_rabl_configuration.rb +2 -0
- data/spec/grape_rabl_formatter_spec.rb +135 -1
- data/spec/grape_rabl_layout_spec.rb +10 -8
- data/spec/grape_rabl_partials_spec.rb +5 -3
- data/spec/grape_rabl_spec.rb +19 -21
- data/spec/grape_rabl_xml_spec.rb +5 -3
- data/spec/spec_helper.rb +11 -4
- data/spec/support/my_helper.rb +2 -0
- data/spec/views/_partial.rabl +2 -0
- data/spec/views/admin.rabl +2 -0
- data/spec/views/helper.rabl +2 -0
- data/spec/views/info.rabl +2 -0
- data/spec/views/layout_test/layouts/another.rabl +2 -0
- data/spec/views/layout_test/layouts/application.rabl +2 -0
- data/spec/views/layout_test/user.rabl +2 -0
- data/spec/views/project.rabl +2 -0
- data/spec/views/user.rabl +2 -0
- metadata +10 -28
- data/.coveralls.yml +0 -2
- data/.travis.yml +0 -13
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d1558b633e4d2bf6350bdfbb8b66007abf6c3bcb6fa3164cde86e086a2e78c03
|
|
4
|
+
data.tar.gz: 4157fccf4ea55393a8b4f0074c871a1e1c153b24723852cf2e163c67d4af8bf0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f796e497daf4317f7f9e29e218b8623b3c2890c358e304237aaf2a11e379891811885fd85faf6aa68bf7340cee74ea0c0d6cf376f33bde8609cd3c6d073736ff
|
|
7
|
+
data.tar.gz: c36abcb5a1427d7c2c252caadb1360fe7938bc9cdd1054fd2f9d313f0b376811591574c1125b8f4c8c0d33686a52a7caa425d8be9bb8ef702e313e0fe4cd8c36
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on: [push, pull_request]
|
|
4
|
+
|
|
5
|
+
permissions:
|
|
6
|
+
contents: read
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ${{ matrix.os || 'ubuntu-latest' }}
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
include:
|
|
15
|
+
- { ruby: '2.7', grape: '1', os: 'ubuntu-22.04' }
|
|
16
|
+
- { ruby: '2.7', grape: '2', os: 'ubuntu-22.04' }
|
|
17
|
+
- { ruby: '3.3', grape: '1' }
|
|
18
|
+
- { ruby: '3.3', grape: '2' }
|
|
19
|
+
- { ruby: '3.3', grape: '3' }
|
|
20
|
+
- { ruby: '3.3', grape: '4' }
|
|
21
|
+
- { ruby: '3.4', grape: '4' }
|
|
22
|
+
- { ruby: '4.0', grape: '4' }
|
|
23
|
+
- { ruby: 'ruby-head', grape: '4', experimental: true }
|
|
24
|
+
name: Ruby ${{ matrix.ruby }} / Grape ${{ matrix.grape }}
|
|
25
|
+
continue-on-error: ${{ matrix.experimental || false }}
|
|
26
|
+
env:
|
|
27
|
+
GRAPE_VERSION: ${{ matrix.grape }}
|
|
28
|
+
steps:
|
|
29
|
+
- uses: actions/checkout@v7
|
|
30
|
+
- uses: ruby/setup-ruby@v1
|
|
31
|
+
with:
|
|
32
|
+
ruby-version: ${{ matrix.ruby }}
|
|
33
|
+
bundler-cache: true
|
|
34
|
+
- run: bundle exec rake spec
|
|
35
|
+
- uses: coverallsapp/github-action@v2
|
|
36
|
+
if: matrix.ruby != 'ruby-head'
|
|
37
|
+
with:
|
|
38
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
39
|
+
file: coverage/lcov/grape-rabl.lcov
|
|
40
|
+
format: lcov
|
|
41
|
+
flag-name: test-${{ strategy.job-index }}
|
|
42
|
+
parallel: true
|
|
43
|
+
coverage:
|
|
44
|
+
name: Finish Coveralls
|
|
45
|
+
needs: test
|
|
46
|
+
runs-on: ubuntu-latest
|
|
47
|
+
steps:
|
|
48
|
+
- uses: coverallsapp/github-action@v2
|
|
49
|
+
with:
|
|
50
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
51
|
+
parallel-finished: true
|
|
52
|
+
lint:
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
steps:
|
|
55
|
+
- uses: actions/checkout@v7
|
|
56
|
+
- uses: ruby/setup-ruby@v1
|
|
57
|
+
with:
|
|
58
|
+
ruby-version: '3.3'
|
|
59
|
+
bundler-cache: true
|
|
60
|
+
- run: bundle exec rake rubocop
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
|
@@ -1,40 +1,32 @@
|
|
|
1
1
|
# This configuration was generated by
|
|
2
2
|
# `rubocop --auto-gen-config`
|
|
3
|
-
# on
|
|
3
|
+
# on 2026-10-26 10:48:33 UTC using RuboCop version 1.92.1.
|
|
4
4
|
# The point is for the user to remove these configuration records
|
|
5
5
|
# one by one as the offenses are removed from the code base.
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
|
8
8
|
|
|
9
|
-
# Offense count:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
- 'spec/grape_rabl_spec.rb'
|
|
13
|
-
|
|
14
|
-
# Offense count: 8
|
|
15
|
-
# Configuration parameters: CountComments, ExcludedMethods.
|
|
9
|
+
# Offense count: 11
|
|
10
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
11
|
+
# AllowedMethods: refine
|
|
16
12
|
Metrics/BlockLength:
|
|
17
|
-
Max:
|
|
18
|
-
|
|
19
|
-
# Offense count: 23
|
|
20
|
-
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
|
21
|
-
# URISchemes: http, https
|
|
22
|
-
Metrics/LineLength:
|
|
23
|
-
Max: 148
|
|
13
|
+
Max: 165
|
|
24
14
|
|
|
25
15
|
# Offense count: 1
|
|
26
|
-
# Configuration parameters: CountComments.
|
|
16
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
27
17
|
Metrics/MethodLength:
|
|
28
18
|
Max: 13
|
|
29
19
|
|
|
30
20
|
# Offense count: 1
|
|
31
|
-
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
|
21
|
+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
|
22
|
+
# CheckDefinitionPathHierarchyRoots: lib, spec, test, src
|
|
32
23
|
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
|
33
24
|
Naming/FileName:
|
|
34
25
|
Exclude:
|
|
35
26
|
- 'lib/grape-rabl.rb'
|
|
36
27
|
|
|
37
28
|
# Offense count: 5
|
|
29
|
+
# Configuration parameters: AllowedConstants.
|
|
38
30
|
Style/Documentation:
|
|
39
31
|
Exclude:
|
|
40
32
|
- 'spec/**/*'
|
|
@@ -46,11 +38,15 @@ Style/Documentation:
|
|
|
46
38
|
- 'lib/grape/rabl.rb'
|
|
47
39
|
|
|
48
40
|
# Offense count: 1
|
|
49
|
-
|
|
41
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
42
|
+
# Configuration parameters: AllowIfModifier.
|
|
43
|
+
Style/IfInsideElse:
|
|
50
44
|
Exclude:
|
|
51
45
|
- 'lib/grape-rabl/formatter.rb'
|
|
52
46
|
|
|
53
47
|
# Offense count: 1
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
48
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
49
|
+
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, AllowRBSInlineAnnotation, AllowCopDirectives, AllowedPatterns, SplitStrings.
|
|
50
|
+
# URISchemes: http, https
|
|
51
|
+
Layout/LineLength:
|
|
52
|
+
Max: 131
|
data/CHANGELOG.md
CHANGED
|
@@ -1,30 +1,40 @@
|
|
|
1
|
-
####
|
|
1
|
+
#### 0.6.0 (2026-10-27)
|
|
2
|
+
|
|
3
|
+
* [#59](https://github.com/ruby-grape/grape-rabl/pull/59): Document optional Swagger generation with explicit response schemas while retaining Rabl rendering - [@dblock](https://github.com/dblock).
|
|
4
|
+
* [#58](https://github.com/ruby-grape/grape-rabl/pull/58): Support static and request-aware configured template roots while preserving explicit request roots and cache isolation - [@dblock](https://github.com/dblock).
|
|
5
|
+
* [#57](https://github.com/ruby-grape/grape-rabl/pull/57): Remove the obsolete Code Climate badge, use HTTPS and RubyGems for the gem badge, and scope the CI badge to master pushes - [@dblock](https://github.com/dblock).
|
|
6
|
+
* [#56](https://github.com/ruby-grape/grape-rabl/pull/56): Merge Coveralls coverage across the stable Ruby/Grape matrix and refresh the coverage badge - [@dblock](https://github.com/dblock).
|
|
7
|
+
* [#55](https://github.com/ruby-grape/grape-rabl/pull/55): Replace deprecated `Tilt::Cache` with a synchronized Hash cache for templates and layouts - [@dblock](https://github.com/dblock).
|
|
8
|
+
* [#54](https://github.com/ruby-grape/grape-rabl/pull/54): Replaced Travis CI with GitHub Actions, modernized RuboCop and coverage reporting, and added a Ruby 2.7-4.0/Grape 1.x-4.x compatibility matrix; Ruby 2.7 or newer is now required - [@dblock](https://github.com/dblock).
|
|
9
|
+
* [#54](https://github.com/ruby-grape/grape-rabl/pull/54): Fixed fallback rendering with newer Grape versions, including Grape 4.x - [@dblock](https://github.com/dblock).
|
|
10
|
+
|
|
11
|
+
#### 0.5.0
|
|
2
12
|
|
|
3
13
|
* [#34](https://github.com/ruby-grape/grape-rabl/pulls/34): If no RABL template is specified, fallback to the default response format as determined by Grape - [@chrisbloom7](https://github.com/chrisbloom7).
|
|
4
14
|
|
|
5
|
-
####
|
|
15
|
+
#### 0.4.3
|
|
6
16
|
|
|
7
17
|
* [#44](https://github.com/ruby-grape/grape-rabl/issues/44): Don't require unused hashie - [@tsuwatch](https://github.com/tsuwatch).
|
|
8
18
|
* [#44](https://github.com/ruby-grape/grape-rabl/issues/44): Support Ruby >= 2.2 - [@tsuwatch](https://github.com/tsuwatch).
|
|
9
19
|
* [#45](https://github.com/ruby-grape/grape-rabl/pull/45): Added danger, PR linter - [@dblock](https://github.com/dblock).
|
|
10
20
|
|
|
11
|
-
####
|
|
21
|
+
#### 0.4.2
|
|
12
22
|
|
|
13
23
|
* [#43](https://github.com/ruby-grape/grape-rabl/pull/43): Fix template caching for multiple formats - [@kushkella](https://github.com/kushkella).
|
|
14
24
|
|
|
15
|
-
####
|
|
25
|
+
#### 0.4.1
|
|
16
26
|
|
|
17
27
|
* [#39](https://github.com/ruby-grape/grape-rabl/issues/39): Automatically require 'grape/rabl' - [@martinezcoder](https://github.com/martinezcoder).
|
|
18
28
|
|
|
19
|
-
####
|
|
29
|
+
#### 0.4.0
|
|
20
30
|
|
|
21
31
|
* [#37](https://github.com/ruby-grape/grape-rabl/issues/37): Make grape-rabl thread-safe - [@kushkella](https://github.com/kushkella).
|
|
22
32
|
|
|
23
|
-
####
|
|
33
|
+
#### 0.3.1
|
|
24
34
|
|
|
25
35
|
* [#35](https://github.com/ruby-grape/grape-rabl/issues/35): The `render` method will no longer modify endpoint options at runtime - [@yesmeck](https://github.com/yesmeck).
|
|
26
36
|
|
|
27
|
-
####
|
|
37
|
+
#### 0.3.0
|
|
28
38
|
|
|
29
39
|
* [#22](https://github.com/ruby-grape/grape-rabl/pull/22): Enable using a layout template in Rabl - [@koko1000ban](https://github.com/koko1000ban).
|
|
30
40
|
* Implemented Rubocop, Ruby style linter - [@dblock](https://github.com/dblock).
|
|
@@ -32,23 +42,22 @@
|
|
|
32
42
|
* Enable using locals with `.render` - [@hobofan](https://github.com/hobofan).
|
|
33
43
|
* Enable support for template caching - [@kushkella](https://github.com/kushkella).
|
|
34
44
|
|
|
35
|
-
|
|
36
|
-
#### v0.2.2
|
|
45
|
+
#### 0.2.2
|
|
37
46
|
|
|
38
47
|
* [#20](https://github.com/ruby-grape/grape-rabl/pull/20): Relaxed dependency on a specific version of Grape - [@cheef](https://github.com/cheef).
|
|
39
48
|
|
|
40
|
-
####
|
|
49
|
+
#### 0.2.1
|
|
41
50
|
|
|
42
51
|
* [#11](https://github.com/ruby-grape/grape-rabl/pull/11): Fix: render template according to request format - [@alovak](https://github.com/alovak).
|
|
43
52
|
|
|
44
|
-
####
|
|
53
|
+
#### 0.2.0
|
|
45
54
|
|
|
46
55
|
* [#10](https://github.com/ruby-grape/grape-rabl/pull/10): Allow to use partials in Grape - [@ichilton](https://github.com/ichilton).
|
|
47
56
|
* Stick to gem conventions - [@LTe](https://github.com/lte).
|
|
48
57
|
* [#13](https://github.com/ruby-grape/grape-rabl/pull/13): Update for Grape 0.3 compatibility - [@alovak](https://github.com/alovak).
|
|
49
58
|
* Format fix - [@LTe](https://github.com/LTe).
|
|
50
59
|
|
|
51
|
-
####
|
|
60
|
+
#### 0.1.0
|
|
52
61
|
|
|
53
62
|
* Updated w/released Grape 0.2.3 - [@dblock](https://github.com/dblock).
|
|
54
63
|
* Added link to Rabl - [@dblock](https://github.com/dblock).
|
|
@@ -56,31 +65,31 @@
|
|
|
56
65
|
* Grape 0.2.3 - [@dblock](https://github.com/dblock).
|
|
57
66
|
* Updated Grape dependency via .gemspec - [@dblock](https://github.com/dblock).
|
|
58
67
|
|
|
59
|
-
####
|
|
68
|
+
#### 0.0.6
|
|
60
69
|
|
|
61
70
|
* [#6](https://github.com/ruby-grape/grape-rabl/pull/6): Use Grape formatter syntax instead of monkey-patching - [@dblock](https://github.com/dblock).
|
|
62
71
|
* Close block code in README - [@LTe](https://github.com/LTe).
|
|
63
72
|
* Change home to user - [@LTe](https://github.com/LTe).
|
|
64
73
|
|
|
65
|
-
####
|
|
74
|
+
#### 0.0.5
|
|
66
75
|
|
|
67
76
|
* Respect `default_format` for rabl response - [@LTe](https://github.com/LTe).
|
|
68
77
|
|
|
69
|
-
####
|
|
78
|
+
#### 0.0.4
|
|
70
79
|
|
|
71
80
|
* Require `grape/rabl` - [@LTe](https://github.com/LTe).
|
|
72
81
|
|
|
73
|
-
####
|
|
82
|
+
#### 0.0.3
|
|
74
83
|
|
|
75
84
|
* Template without `.rabl` - [@LTe](https://github.com/LTe).
|
|
76
85
|
|
|
77
|
-
####
|
|
86
|
+
#### 0.0.2
|
|
78
87
|
|
|
79
88
|
* Add Travis - [@LTe](https://github.com/LTe).
|
|
80
89
|
* Remove ruby debug - [@LTe](https://github.com/LTe).
|
|
81
90
|
* Works with rubinius - [@LTe](https://github.com/LTe).
|
|
82
91
|
* Add dependency status - [@LTe](https://github.com/LTe).
|
|
83
92
|
|
|
84
|
-
####
|
|
93
|
+
#### 0.0.1
|
|
85
94
|
|
|
86
95
|
* Initial public release - [@LTe](https://github.com/lte).
|
data/CONTRIBUTING.md
CHANGED
|
@@ -32,6 +32,17 @@ bundle install
|
|
|
32
32
|
bundle exec rake
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
CI runs on GitHub Actions with Grape 1.x and 2.x on Ruby 2.7, Grape 1.x through 4.x on Ruby 3.3, and Grape 4.x on Ruby 3.4, Ruby 4.0, and ruby-head (allowed to fail). Ruby 2.7 jobs use Ubuntu 22.04; newer Rubies use the latest Ubuntu runner.
|
|
36
|
+
|
|
37
|
+
Select a Grape major version locally using `GRAPE_VERSION`. Resolve the bundle again when switching versions:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
GRAPE_VERSION=4 bundle update
|
|
41
|
+
GRAPE_VERSION=4 bundle exec rake
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Use `GRAPE_VERSION=1`, `2`, or `3` for the other supported majors. The Grape 1.x bundle selects Rack 2.x because Grape 1.x is not compatible with Rack 3.x. Without `GRAPE_VERSION`, Bundler selects the latest Grape compatible with your Ruby.
|
|
45
|
+
|
|
35
46
|
#### Write Tests
|
|
36
47
|
|
|
37
48
|
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [spec/grape-rabl](spec/grape-rabl).
|
|
@@ -107,7 +118,7 @@ git push origin my-feature-branch -f
|
|
|
107
118
|
|
|
108
119
|
#### Check on Your Pull Request
|
|
109
120
|
|
|
110
|
-
Go back to your pull request after a few minutes and
|
|
121
|
+
Go back to your pull request after a few minutes and check its GitHub Actions results. Everything should look green, otherwise fix issues and amend your commit as described above.
|
|
111
122
|
|
|
112
123
|
#### Be Patient
|
|
113
124
|
|
data/Dangerfile
CHANGED
data/Gemfile
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
source 'https://rubygems.org'
|
|
2
4
|
|
|
3
5
|
gemspec
|
|
4
6
|
|
|
7
|
+
gem 'grape', "~> #{ENV['GRAPE_VERSION']}.0" if ENV['GRAPE_VERSION']
|
|
8
|
+
gem 'rack', '~> 2.2' if ENV['GRAPE_VERSION'] == '1'
|
|
9
|
+
|
|
5
10
|
group :development do
|
|
6
|
-
gem 'rubocop', '
|
|
11
|
+
gem 'rubocop', '~> 1.92.0', require: false
|
|
12
|
+
gem 'ruby-grape-danger', '~> 0.3.0', require: false
|
|
7
13
|
end
|
|
8
14
|
|
|
9
15
|
group :test do
|
|
10
|
-
gem '
|
|
16
|
+
gem 'builder'
|
|
11
17
|
gem 'json'
|
|
12
18
|
gem 'rabl'
|
|
13
19
|
gem 'rack-test'
|
|
14
20
|
gem 'rake'
|
|
15
21
|
gem 'rspec'
|
|
16
|
-
gem '
|
|
22
|
+
gem 'simplecov', require: false
|
|
23
|
+
gem 'simplecov-lcov', require: false
|
|
17
24
|
end
|