grape 1.2.4 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -4
  3. data/README.md +144 -4
  4. data/grape.gemspec +3 -1
  5. data/lib/grape.rb +94 -66
  6. data/lib/grape/api.rb +46 -4
  7. data/lib/grape/api/instance.rb +23 -12
  8. data/lib/grape/dsl/desc.rb +11 -2
  9. data/lib/grape/dsl/validations.rb +4 -3
  10. data/lib/grape/eager_load.rb +18 -0
  11. data/lib/grape/endpoint.rb +3 -3
  12. data/lib/grape/error_formatter.rb +1 -1
  13. data/lib/grape/exceptions/validation_errors.rb +4 -2
  14. data/lib/grape/formatter.rb +1 -1
  15. data/lib/grape/middleware/auth/base.rb +2 -4
  16. data/lib/grape/middleware/base.rb +2 -0
  17. data/lib/grape/middleware/helpers.rb +10 -0
  18. data/lib/grape/parser.rb +1 -1
  19. data/lib/grape/util/base_inheritable.rb +34 -0
  20. data/lib/grape/util/inheritable_values.rb +5 -25
  21. data/lib/grape/util/lazy_block.rb +25 -0
  22. data/lib/grape/util/lazy_value.rb +5 -0
  23. data/lib/grape/util/reverse_stackable_values.rb +7 -36
  24. data/lib/grape/util/stackable_values.rb +19 -22
  25. data/lib/grape/validations/attributes_iterator.rb +5 -3
  26. data/lib/grape/validations/multiple_attributes_iterator.rb +11 -0
  27. data/lib/grape/validations/params_scope.rb +12 -12
  28. data/lib/grape/validations/single_attribute_iterator.rb +13 -0
  29. data/lib/grape/validations/validator_factory.rb +6 -11
  30. data/lib/grape/validations/validators/all_or_none.rb +6 -13
  31. data/lib/grape/validations/validators/at_least_one_of.rb +5 -13
  32. data/lib/grape/validations/validators/base.rb +11 -10
  33. data/lib/grape/validations/validators/coerce.rb +4 -0
  34. data/lib/grape/validations/validators/default.rb +1 -1
  35. data/lib/grape/validations/validators/exactly_one_of.rb +6 -23
  36. data/lib/grape/validations/validators/multiple_params_base.rb +14 -10
  37. data/lib/grape/validations/validators/mutual_exclusion.rb +6 -18
  38. data/lib/grape/version.rb +1 -1
  39. data/spec/grape/api/defines_boolean_in_params_spec.rb +37 -0
  40. data/spec/grape/api_remount_spec.rb +158 -0
  41. data/spec/grape/api_spec.rb +72 -0
  42. data/spec/grape/endpoint_spec.rb +1 -1
  43. data/spec/grape/exceptions/base_spec.rb +4 -0
  44. data/spec/grape/exceptions/validation_errors_spec.rb +6 -4
  45. data/spec/grape/integration/rack_spec.rb +22 -6
  46. data/spec/grape/middleware/base_spec.rb +8 -0
  47. data/spec/grape/middleware/formatter_spec.rb +11 -1
  48. data/spec/grape/validations/multiple_attributes_iterator_spec.rb +29 -0
  49. data/spec/grape/validations/params_scope_spec.rb +13 -0
  50. data/spec/grape/validations/single_attribute_iterator_spec.rb +33 -0
  51. data/spec/grape/validations/validators/all_or_none_spec.rb +138 -30
  52. data/spec/grape/validations/validators/at_least_one_of_spec.rb +173 -29
  53. data/spec/grape/validations/validators/coerce_spec.rb +6 -2
  54. data/spec/grape/validations/validators/exactly_one_of_spec.rb +202 -38
  55. data/spec/grape/validations/validators/mutual_exclusion_spec.rb +184 -27
  56. data/spec/grape/validations_spec.rb +32 -20
  57. metadata +103 -115
  58. data/Appraisals +0 -28
  59. data/Dangerfile +0 -2
  60. data/Gemfile +0 -33
  61. data/Gemfile.lock +0 -231
  62. data/Guardfile +0 -10
  63. data/RELEASING.md +0 -111
  64. data/Rakefile +0 -25
  65. data/benchmark/simple.rb +0 -27
  66. data/benchmark/simple_with_type_coercer.rb +0 -22
  67. data/gemfiles/multi_json.gemfile +0 -35
  68. data/gemfiles/multi_xml.gemfile +0 -35
  69. data/gemfiles/rack_1.5.2.gemfile.lock +0 -232
  70. data/gemfiles/rack_edge.gemfile +0 -35
  71. data/gemfiles/rails_3.gemfile +0 -36
  72. data/gemfiles/rails_3.gemfile.lock +0 -288
  73. data/gemfiles/rails_4.gemfile +0 -35
  74. data/gemfiles/rails_4.gemfile.lock +0 -280
  75. data/gemfiles/rails_5.gemfile +0 -35
  76. data/gemfiles/rails_5.gemfile.lock +0 -312
  77. data/gemfiles/rails_edge.gemfile +0 -35
  78. data/pkg/grape-1.2.0.gem +0 -0
  79. data/pkg/grape-1.2.1.gem +0 -0
  80. data/pkg/grape-1.2.3.gem +0 -0
data/Dangerfile DELETED
@@ -1,2 +0,0 @@
1
- danger.import_dangerfile(gem: 'ruby-grape-danger')
2
- toc.check
data/Gemfile DELETED
@@ -1,33 +0,0 @@
1
- # when changing this file, run appraisal install ; rubocop -a gemfiles/*.gemfile
2
-
3
- source 'https://rubygems.org'
4
-
5
- gemspec
6
-
7
- group :development, :test do
8
- gem 'bundler'
9
- gem 'hashie'
10
- gem 'rake'
11
- gem 'rubocop', '0.51.0'
12
- end
13
-
14
- group :development do
15
- gem 'appraisal'
16
- gem 'benchmark-ips'
17
- gem 'guard'
18
- gem 'guard-rspec'
19
- gem 'guard-rubocop'
20
- end
21
-
22
- group :test do
23
- gem 'cookiejar'
24
- gem 'coveralls_reborn'
25
- gem 'danger-toc', '~> 0.1.2'
26
- gem 'grape-entity', '~> 0.6'
27
- gem 'maruku'
28
- gem 'mime-types'
29
- gem 'rack-jsonp', require: 'rack/jsonp'
30
- gem 'rack-test', '~> 0.6.3'
31
- gem 'rspec', '~> 3.0'
32
- gem 'ruby-grape-danger', '~> 0.1.0', require: false
33
- end
@@ -1,231 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- grape (1.2.4)
5
- activesupport
6
- builder
7
- mustermann-grape (~> 1.0.0)
8
- rack (>= 1.3.0)
9
- rack-accept
10
- virtus (>= 1.0.0)
11
-
12
- GEM
13
- remote: https://rubygems.org/
14
- specs:
15
- activesupport (5.2.1)
16
- concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (>= 0.7, < 2)
18
- minitest (~> 5.1)
19
- tzinfo (~> 1.1)
20
- addressable (2.5.2)
21
- public_suffix (>= 2.0.2, < 4.0)
22
- appraisal (2.2.0)
23
- bundler
24
- rake
25
- thor (>= 0.14.0)
26
- ast (2.4.0)
27
- axiom-types (0.1.1)
28
- descendants_tracker (~> 0.0.4)
29
- ice_nine (~> 0.11.0)
30
- thread_safe (~> 0.3, >= 0.3.1)
31
- benchmark-ips (2.7.2)
32
- builder (3.2.3)
33
- claide (1.0.2)
34
- claide-plugins (0.9.2)
35
- cork
36
- nap
37
- open4 (~> 1.3)
38
- coderay (1.1.2)
39
- coercible (1.0.0)
40
- descendants_tracker (~> 0.0.1)
41
- colored (1.2)
42
- colored2 (3.1.2)
43
- concurrent-ruby (1.1.5)
44
- cookiejar (0.3.3)
45
- cork (0.3.0)
46
- colored2 (~> 3.1)
47
- coveralls_reborn (0.12.0)
48
- json (~> 2.1)
49
- simplecov (~> 0.16.1)
50
- term-ansicolor (~> 1.6)
51
- thor (~> 0.20.0)
52
- tins (~> 1.16)
53
- danger (4.0.5)
54
- claide (~> 1.0)
55
- claide-plugins (>= 0.9.2)
56
- colored (~> 1.2)
57
- cork (~> 0.1)
58
- faraday (~> 0.9)
59
- faraday-http-cache (~> 1.0)
60
- git (~> 1)
61
- kramdown (~> 1.5)
62
- octokit (~> 4.2)
63
- terminal-table (~> 1)
64
- danger-changelog (0.2.1)
65
- danger-plugin-api (~> 1.0)
66
- danger-plugin-api (1.0.0)
67
- danger (> 2.0)
68
- danger-toc (0.1.3)
69
- activesupport
70
- danger-plugin-api (~> 1.0)
71
- kramdown
72
- descendants_tracker (0.0.4)
73
- thread_safe (~> 0.3, >= 0.3.1)
74
- diff-lcs (1.3)
75
- docile (1.3.1)
76
- equalizer (0.0.11)
77
- faraday (0.15.4)
78
- multipart-post (>= 1.2, < 3)
79
- faraday-http-cache (1.3.1)
80
- faraday (~> 0.8)
81
- ffi (1.9.25)
82
- formatador (0.2.5)
83
- git (1.5.0)
84
- grape-entity (0.7.1)
85
- activesupport (>= 4.0)
86
- multi_json (>= 1.3.2)
87
- guard (2.15.0)
88
- formatador (>= 0.2.4)
89
- listen (>= 2.7, < 4.0)
90
- lumberjack (>= 1.0.12, < 2.0)
91
- nenv (~> 0.1)
92
- notiffany (~> 0.0)
93
- pry (>= 0.9.12)
94
- shellany (~> 0.0)
95
- thor (>= 0.18.1)
96
- guard-compat (1.2.1)
97
- guard-rspec (4.7.3)
98
- guard (~> 2.1)
99
- guard-compat (~> 1.1)
100
- rspec (>= 2.99.0, < 4.0)
101
- guard-rubocop (1.3.0)
102
- guard (~> 2.0)
103
- rubocop (~> 0.20)
104
- hashie (3.6.0)
105
- i18n (1.6.0)
106
- concurrent-ruby (~> 1.0)
107
- ice_nine (0.11.2)
108
- json (2.2.0)
109
- kramdown (1.17.0)
110
- listen (3.1.5)
111
- rb-fsevent (~> 0.9, >= 0.9.4)
112
- rb-inotify (~> 0.9, >= 0.9.7)
113
- ruby_dep (~> 1.2)
114
- lumberjack (1.0.13)
115
- maruku (0.7.3)
116
- method_source (0.9.2)
117
- mime-types (3.2.2)
118
- mime-types-data (~> 3.2015)
119
- mime-types-data (3.2018.0812)
120
- minitest (5.11.3)
121
- multi_json (1.13.1)
122
- multipart-post (2.0.0)
123
- mustermann (1.0.3)
124
- mustermann-grape (1.0.0)
125
- mustermann (~> 1.0.0)
126
- nap (1.1.0)
127
- nenv (0.3.0)
128
- notiffany (0.1.1)
129
- nenv (~> 0.1)
130
- shellany (~> 0.0)
131
- octokit (4.13.0)
132
- sawyer (~> 0.8.0, >= 0.5.3)
133
- open4 (1.3.4)
134
- parallel (1.12.1)
135
- parser (2.5.3.0)
136
- ast (~> 2.4.0)
137
- powerpack (0.1.2)
138
- pry (0.12.2)
139
- coderay (~> 1.1.0)
140
- method_source (~> 0.9.0)
141
- public_suffix (3.0.3)
142
- rack (2.0.6)
143
- rack-accept (0.4.5)
144
- rack (>= 0.4)
145
- rack-jsonp (1.3.1)
146
- rack
147
- rack-test (0.6.3)
148
- rack (>= 1.0)
149
- rainbow (2.2.2)
150
- rake
151
- rake (12.3.2)
152
- rb-fsevent (0.10.3)
153
- rb-inotify (0.9.10)
154
- ffi (>= 0.5.0, < 2)
155
- rspec (3.8.0)
156
- rspec-core (~> 3.8.0)
157
- rspec-expectations (~> 3.8.0)
158
- rspec-mocks (~> 3.8.0)
159
- rspec-core (3.8.0)
160
- rspec-support (~> 3.8.0)
161
- rspec-expectations (3.8.2)
162
- diff-lcs (>= 1.2.0, < 2.0)
163
- rspec-support (~> 3.8.0)
164
- rspec-mocks (3.8.0)
165
- diff-lcs (>= 1.2.0, < 2.0)
166
- rspec-support (~> 3.8.0)
167
- rspec-support (3.8.0)
168
- rubocop (0.51.0)
169
- parallel (~> 1.10)
170
- parser (>= 2.3.3.1, < 3.0)
171
- powerpack (~> 0.1)
172
- rainbow (>= 2.2.2, < 3.0)
173
- ruby-progressbar (~> 1.7)
174
- unicode-display_width (~> 1.0, >= 1.0.1)
175
- ruby-grape-danger (0.1.1)
176
- danger (~> 4.0.1)
177
- danger-changelog (~> 0.2.0)
178
- ruby-progressbar (1.10.0)
179
- ruby_dep (1.5.0)
180
- sawyer (0.8.1)
181
- addressable (>= 2.3.5, < 2.6)
182
- faraday (~> 0.8, < 1.0)
183
- shellany (0.0.1)
184
- simplecov (0.16.1)
185
- docile (~> 1.1)
186
- json (>= 1.8, < 3)
187
- simplecov-html (~> 0.10.0)
188
- simplecov-html (0.10.2)
189
- term-ansicolor (1.7.1)
190
- tins (~> 1.0)
191
- terminal-table (1.8.0)
192
- unicode-display_width (~> 1.1, >= 1.1.1)
193
- thor (0.20.3)
194
- thread_safe (0.3.6)
195
- tins (1.20.2)
196
- tzinfo (1.2.5)
197
- thread_safe (~> 0.1)
198
- unicode-display_width (1.4.0)
199
- virtus (1.0.5)
200
- axiom-types (~> 0.1)
201
- coercible (~> 1.0)
202
- descendants_tracker (~> 0.0, >= 0.0.3)
203
- equalizer (~> 0.0, >= 0.0.9)
204
-
205
- PLATFORMS
206
- ruby
207
-
208
- DEPENDENCIES
209
- appraisal
210
- benchmark-ips
211
- bundler
212
- cookiejar
213
- coveralls_reborn
214
- danger-toc (~> 0.1.2)
215
- grape!
216
- grape-entity (~> 0.6)
217
- guard
218
- guard-rspec
219
- guard-rubocop
220
- hashie
221
- maruku
222
- mime-types
223
- rack-jsonp
224
- rack-test (~> 0.6.3)
225
- rake
226
- rspec (~> 3.0)
227
- rubocop (= 0.51.0)
228
- ruby-grape-danger (~> 0.1.0)
229
-
230
- BUNDLED WITH
231
- 1.17.1
data/Guardfile DELETED
@@ -1,10 +0,0 @@
1
- guard :rspec, all_on_start: true, cmd: 'bundle exec rspec' do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
- watch('spec/spec_helper.rb') { 'spec' }
5
- end
6
-
7
- guard :rubocop do
8
- watch(/.+\.rb$/)
9
- watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
10
- end
@@ -1,111 +0,0 @@
1
- Releasing Grape
2
- ===============
3
-
4
- There're no particular rules about when to release Grape. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
5
-
6
- ### Release
7
-
8
- Run tests, check that all tests succeed locally.
9
-
10
- ```
11
- bundle install
12
- rake
13
- ```
14
-
15
- Check that the last build succeeded in [Travis CI](https://travis-ci.org/ruby-grape/grape) for all supported platforms.
16
-
17
- Those with r/w permissions to the [master Grape repository](https://github.com/ruby-grape/grape) generally have large Grape-based projects. Point one to Grape HEAD and run all your API tests to catch any obvious regressions.
18
-
19
- ```
20
- gem grape, github: 'ruby-grape/grape'
21
- ```
22
-
23
- Increment the version, modify [lib/grape/version.rb](lib/grape/version.rb).
24
-
25
- * Increment the third number if the release has bug fixes and/or very minor features, only (eg. change `0.5.1` to `0.5.2`).
26
- * Increment the second number if the release contains major features or breaking API changes (eg. change `0.5.1` to `0.6.0`).
27
-
28
- Modify the "Stable Release" section in [README.md](README.md). Change the text to reflect that this is going to be the documentation for a stable release. Remove references to the previous release of Grape. Keep the file open, you'll have to undo this change after the release.
29
-
30
- ```
31
- ## Stable Release
32
-
33
- You're reading the documentation for the stable release of Grape, 0.6.0.
34
- ```
35
-
36
- Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version.
37
-
38
- ```
39
- #### 0.6.0 (2013/9/16)
40
- ```
41
-
42
- Remove the line with "Your contribution here.", since there will be no more contributions to this release.
43
-
44
- Commit your changes.
45
-
46
- ```
47
- git add README.md CHANGELOG.md lib/grape/version.rb
48
- git commit -m "Preparing for release, 0.6.0."
49
- git push origin master
50
- ```
51
-
52
- Release.
53
-
54
- ```
55
- $ rake release
56
-
57
- grape 0.6.0 built to pkg/grape-0.6.0.gem.
58
- Tagged v0.6.0.
59
- Pushed git commits and tags.
60
- Pushed grape 0.6.0 to rubygems.org.
61
- ```
62
-
63
- ### Prepare for the Next Version
64
-
65
- Modify the "Stable Release" section in [README.md](README.md). Change the text to reflect that this is going to be the next release.
66
-
67
- ```
68
- ## Stable Release
69
-
70
- You're reading the documentation for the next release of Grape, which should be 0.6.1.
71
- The current stable release is [0.6.0](https://github.com/ruby-grape/grape/blob/v0.6.0/README.md).
72
- ```
73
-
74
- Add the next release to [CHANGELOG.md](CHANGELOG.md).
75
-
76
- ```
77
- #### 0.6.1 (Next)
78
-
79
- * Your contribution here.
80
- ```
81
-
82
- Bump the minor version in lib/grape/version.rb.
83
-
84
- ```ruby
85
- module Grape
86
- VERSION = '0.6.1'
87
- end
88
- ```
89
-
90
- Commit your changes.
91
-
92
- ```
93
- git add CHANGELOG.md README.md lib/grape/version.rb
94
- git commit -m "Preparing for next development iteration, 0.6.1."
95
- git push origin master
96
- ```
97
-
98
- ### Make an Announcement
99
-
100
- Make an announcement on the [ruby-grape@googlegroups.com](mailto:ruby-grape@googlegroups.com) mailing list. The general format is as follows.
101
-
102
- ```
103
- Grape 0.6.0 has been released.
104
-
105
- There were 8 contributors to this release, not counting documentation.
106
-
107
- Please note the breaking API change in ...
108
-
109
- [copy/paste CHANGELOG here]
110
-
111
- ```
data/Rakefile DELETED
@@ -1,25 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- Bundler.setup :default, :test, :development
4
-
5
- Bundler::GemHelper.install_tasks
6
-
7
- require 'rspec/core/rake_task'
8
- RSpec::Core::RakeTask.new(:spec) do |spec|
9
- spec.pattern = 'spec/**/*_spec.rb'
10
- spec.exclude_pattern = 'spec/integration/**/*_spec.rb'
11
- end
12
-
13
- RSpec::Core::RakeTask.new(:rcov) do |spec|
14
- spec.pattern = 'spec/**/*_spec.rb'
15
- spec.rcov = true
16
- end
17
-
18
- task :spec
19
-
20
- require 'rainbow/ext/string' unless String.respond_to?(:color)
21
-
22
- require 'rubocop/rake_task'
23
- RuboCop::RakeTask.new
24
-
25
- task default: %i[rubocop spec]
@@ -1,27 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- require 'grape'
3
- require 'benchmark/ips'
4
-
5
- class API < Grape::API
6
- prefix :api
7
- version 'v1', using: :path
8
- get '/' do
9
- 'hello'
10
- end
11
- end
12
-
13
- options = {
14
- method: 'GET'
15
- }
16
-
17
- env = Rack::MockRequest.env_for('/api/v1', options)
18
-
19
- 10.times do |i|
20
- env["HTTP_HEADER#{i}"] = '123'
21
- end
22
-
23
- Benchmark.ips do |ips|
24
- ips.report('simple') do
25
- API.call env
26
- end
27
- end
@@ -1,22 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- require 'grape'
3
- require 'benchmark/ips'
4
-
5
- api = Class.new(Grape::API) do
6
- prefix :api
7
- version 'v1', using: :path
8
- params do
9
- requires :param, type: Array[String]
10
- end
11
- get '/' do
12
- 'hello'
13
- end
14
- end
15
-
16
- env = Rack::MockRequest.env_for('/api/v1?param=value', method: 'GET')
17
-
18
- Benchmark.ips do |ips|
19
- ips.report('simple_with_type_coercer') do
20
- api.call(env)
21
- end
22
- end