grape 0.19.1 → 0.19.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grape might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a67815e028381f58318d1696015bc15108c15d17
4
- data.tar.gz: 52eb9bc3836e2261415148134369dc1e847d8acc
3
+ metadata.gz: ba880f34333ebf1f118e85d3abed4f9865cbd93e
4
+ data.tar.gz: 3e7bc61918013dfa379825b2b1cba9153d36ee7d
5
5
  SHA512:
6
- metadata.gz: 65f9e5ba3c187e41e720bcdeb8727add1d53ba8f4ca68a70e122f87144bb31fc5d20a00583f9a54b41deb7d55a9fdfc9d27dcd26d91b2108e30a0ade4877b6ba
7
- data.tar.gz: a35afb5adb3a6dc7a7cc356081d6e9bbb011e22010d388906d3a719722fff6cbdf6eb86697667695d80b6ca1ee2f045410ff214c363371e3fd569c82c51eb73b
6
+ metadata.gz: 85064ad017499b0e385a9fefc63664dc41ebdaf1d23f7fa9fe3a323a1143775f9f022159162297103e74925838045589abc75f972eb7e36f1d269c1a19f7d568
7
+ data.tar.gz: 8b6b07647b936108df041c67cdf3ce0141873263b2af13ddc20e7b880ed747f687313c6bf4279c7de86098cdf87ca5acf5389e0e3363c75a9cb46a9ce5e2d9f9
data/Appraisals CHANGED
@@ -18,3 +18,7 @@ end
18
18
  appraise 'rails-edge' do
19
19
  gem 'arel', github: 'rails/arel'
20
20
  end
21
+
22
+ appraise 'rack-edge' do
23
+ gem 'rack', github: 'rack/rack'
24
+ end
@@ -1,3 +1,24 @@
1
+ ### 0.19.2 (4/12/2017)
2
+
3
+ #### Features
4
+
5
+ * [#1555](https://github.com/ruby-grape/grape/pull/1555): Added code coverage w/Coveralls - [@dblock](https://github.com/dblock).
6
+ * [#1568](https://github.com/ruby-grape/grape/pull/1568): Add `proc` option to `values` validator to allow custom checks - [@jlfaber](https://github.com/jlfaber).
7
+ * [#1575](https://github.com/ruby-grape/grape/pull/1575): Include nil values for missing nested params in declared - [@thogg4](https://github.com/thogg4).
8
+ * [#1585](https://github.com/ruby-grape/grape/pull/1585): Bugs in declared method - make sure correct options var is used and respect include missing for non children params - [@thogg4](https://github.com/thogg4).
9
+
10
+ #### Fixes
11
+
12
+ * [#1570](https://github.com/ruby-grape/grape/pull/1570): Make versioner consider the mount destination path - [@namusyaka](https://github.com/namusyaka).
13
+ * [#1579](https://github.com/ruby-grape/grape/pull/1579): Fix delete status with a return value - [@eproulx-petalmd](https://github.com/eproulx-petalmd).
14
+ * [#1559](https://github.com/ruby-grape/grape/pull/1559): You can once again pass `nil` to optional attributes with `values` validation set - [@ghiculescu](https://github.com/ghiculescu).
15
+ * [#1562](https://github.com/ruby-grape/grape/pull/1562): Fix rainbow gem installation failure above ruby 2.3.3 on travis-ci - [@brucehsu](https://github.com/brucehsu).
16
+ * [#1561](https://github.com/ruby-grape/grape/pull/1561): Fix performance issue introduced by duplicated calls in StackableValue#[] - [@brucehsu](https://github.com/brucehsu).
17
+ * [#1564](https://github.com/ruby-grape/grape/pull/1564): Fix declared params bug with nested namespaces - [@bmarini](https://github.com/bmarini).
18
+ * [#1567](https://github.com/ruby-grape/grape/pull/1567): Fix values validator when value is empty array and apply except to input array - [@jlfaber](https://github.com/jlfaber).
19
+ * [#1569](https://github.com/ruby-grape/grape/pull/1569), [#1511](https://github.com/ruby-grape/grape/issues/1511): Upgrade mustermann-grape to 1.0.0 - [@namusyaka](https://github.com/namusyaka).
20
+ * [#1589](https://github.com/ruby-grape/grape/pull/1589): [#726](https://github.com/ruby-grape/grape/issues/726): Use default_format when Content-type is missing and respond with 406 when Content-type is invalid - [@inclooder](https://github.com/inclooder).
21
+
1
22
  ### 0.19.1 (1/9/2017)
2
23
 
3
24
  #### Features
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
  group :development, :test do
8
8
  gem 'bundler'
9
9
  gem 'rake'
10
- gem 'rubocop', '~> 0.45'
10
+ gem 'rubocop', '0.47.0'
11
11
  end
12
12
 
13
13
  group :development do
@@ -27,6 +27,7 @@ group :test do
27
27
  gem 'rspec', '~> 3.0'
28
28
  gem 'cookiejar'
29
29
  gem 'rack-jsonp', require: 'rack/jsonp'
30
- gem 'mime-types', '~> 3.0'
30
+ gem 'mime-types'
31
31
  gem 'ruby-grape-danger', '~> 0.1.0', require: false
32
+ gem 'coveralls', '~> 0.8.17', require: false
32
33
  end
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- grape (0.19.1)
4
+ grape (0.19.2)
5
5
  activesupport
6
6
  builder
7
7
  hashie (>= 2.1.0)
8
8
  multi_json (>= 1.3.2)
9
9
  multi_xml (>= 0.5.2)
10
- mustermann-grape (~> 0.4.0)
10
+ mustermann-grape (~> 1.0.0)
11
11
  rack (>= 1.3.0)
12
12
  rack-accept
13
13
  virtus (>= 1.0.0)
@@ -15,7 +15,7 @@ PATH
15
15
  GEM
16
16
  remote: https://rubygems.org/
17
17
  specs:
18
- activesupport (5.0.0.1)
18
+ activesupport (5.0.1)
19
19
  concurrent-ruby (~> 1.0, >= 1.0.2)
20
20
  i18n (~> 0.7)
21
21
  minitest (~> 5.1)
@@ -32,7 +32,7 @@ GEM
32
32
  ice_nine (~> 0.11.0)
33
33
  thread_safe (~> 0.3, >= 0.3.1)
34
34
  benchmark-ips (2.7.2)
35
- builder (3.2.2)
35
+ builder (3.2.3)
36
36
  claide (1.0.1)
37
37
  claide-plugins (0.9.2)
38
38
  cork
@@ -42,10 +42,16 @@ GEM
42
42
  coercible (1.0.0)
43
43
  descendants_tracker (~> 0.0.1)
44
44
  colored (1.2)
45
- concurrent-ruby (1.0.3)
45
+ concurrent-ruby (1.0.4)
46
46
  cookiejar (0.3.3)
47
47
  cork (0.2.0)
48
48
  colored (~> 1.2)
49
+ coveralls (0.8.19)
50
+ json (>= 1.8, < 3)
51
+ simplecov (~> 0.12.0)
52
+ term-ansicolor (~> 1.3)
53
+ thor (~> 0.19.1)
54
+ tins (~> 1.6)
49
55
  danger (4.0.3)
50
56
  claide (~> 1.0)
51
57
  claide-plugins (>= 0.9.2)
@@ -64,6 +70,7 @@ GEM
64
70
  descendants_tracker (0.0.4)
65
71
  thread_safe (~> 0.3, >= 0.3.1)
66
72
  diff-lcs (1.2.5)
73
+ docile (1.1.5)
67
74
  equalizer (0.0.11)
68
75
  faraday (0.10.0)
69
76
  multipart-post (>= 1.2, < 3)
@@ -92,9 +99,10 @@ GEM
92
99
  guard-rubocop (1.2.0)
93
100
  guard (~> 2.0)
94
101
  rubocop (~> 0.20)
95
- hashie (3.4.6)
102
+ hashie (3.5.5)
96
103
  i18n (0.7.0)
97
104
  ice_nine (0.11.2)
105
+ json (2.0.3)
98
106
  kramdown (1.13.1)
99
107
  listen (3.1.5)
100
108
  rb-fsevent (~> 0.9, >= 0.9.4)
@@ -110,10 +118,9 @@ GEM
110
118
  multi_json (1.12.1)
111
119
  multi_xml (0.6.0)
112
120
  multipart-post (2.0.0)
113
- mustermann (0.4.0)
114
- tool (~> 0.2)
115
- mustermann-grape (0.4.0)
116
- mustermann (= 0.4.0)
121
+ mustermann (1.0.0)
122
+ mustermann-grape (1.0.0)
123
+ mustermann (~> 1.0.0)
117
124
  nap (1.1.0)
118
125
  nenv (0.3.0)
119
126
  notiffany (0.1.1)
@@ -137,12 +144,12 @@ GEM
137
144
  rack
138
145
  rack-test (0.6.3)
139
146
  rack (>= 1.0)
140
- rainbow (2.1.0)
147
+ rainbow (2.2.1)
141
148
  rake (12.0.0)
142
149
  rb-fsevent (0.9.8)
143
150
  rb-inotify (0.9.7)
144
151
  ffi (>= 0.5.0)
145
- redcarpet (3.3.4)
152
+ redcarpet (3.4.0)
146
153
  rspec (3.5.0)
147
154
  rspec-core (~> 3.5.0)
148
155
  rspec-expectations (~> 3.5.0)
@@ -156,8 +163,8 @@ GEM
156
163
  diff-lcs (>= 1.2.0, < 2.0)
157
164
  rspec-support (~> 3.5.0)
158
165
  rspec-support (3.5.0)
159
- rubocop (0.46.0)
160
- parser (>= 2.3.1.1, < 3.0)
166
+ rubocop (0.47.0)
167
+ parser (>= 2.3.3.1, < 3.0)
161
168
  powerpack (~> 0.1)
162
169
  rainbow (>= 1.99.1, < 3.0)
163
170
  ruby-progressbar (~> 1.7)
@@ -171,15 +178,22 @@ GEM
171
178
  addressable (>= 2.3.5, < 2.6)
172
179
  faraday (~> 0.8, < 1.0)
173
180
  shellany (0.0.1)
181
+ simplecov (0.12.0)
182
+ docile (~> 1.1.0)
183
+ json (>= 1.8, < 3)
184
+ simplecov-html (~> 0.10.0)
185
+ simplecov-html (0.10.0)
174
186
  slop (3.6.0)
187
+ term-ansicolor (1.4.0)
188
+ tins (~> 1.0)
175
189
  terminal-table (1.7.3)
176
190
  unicode-display_width (~> 1.1.1)
177
191
  thor (0.19.4)
178
192
  thread_safe (0.3.5)
179
- tool (0.2.3)
193
+ tins (1.13.0)
180
194
  tzinfo (1.2.2)
181
195
  thread_safe (~> 0.1)
182
- unicode-display_width (1.1.2)
196
+ unicode-display_width (1.1.3)
183
197
  virtus (1.0.5)
184
198
  axiom-types (~> 0.1)
185
199
  coercible (~> 1.0)
@@ -195,21 +209,22 @@ DEPENDENCIES
195
209
  benchmark-ips
196
210
  bundler
197
211
  cookiejar
212
+ coveralls (~> 0.8.17)
198
213
  grape!
199
214
  grape-entity (~> 0.6)
200
215
  guard
201
216
  guard-rspec
202
217
  guard-rubocop
203
218
  maruku
204
- mime-types (~> 3.0)
219
+ mime-types
205
220
  rack-jsonp
206
221
  rack-test
207
222
  rake
208
223
  redcarpet
209
224
  rspec (~> 3.0)
210
- rubocop (~> 0.45)
225
+ rubocop (= 0.47.0)
211
226
  ruby-grape-danger (~> 0.1.0)
212
227
  yard
213
228
 
214
229
  BUNDLED WITH
215
- 1.13.6
230
+ 1.13.7
data/README.md CHANGED
@@ -4,6 +4,7 @@
4
4
  [![Build Status](https://travis-ci.org/ruby-grape/grape.svg?branch=master)](https://travis-ci.org/ruby-grape/grape)
5
5
  [![Dependency Status](https://gemnasium.com/ruby-grape/grape.svg)](https://gemnasium.com/ruby-grape/grape)
6
6
  [![Code Climate](https://codeclimate.com/github/ruby-grape/grape.svg)](https://codeclimate.com/github/ruby-grape/grape)
7
+ [![Coverage Status](https://coveralls.io/repos/github/ruby-grape/grape/badge.svg?branch=master)](https://coveralls.io/github/ruby-grape/grape?branch=master)
7
8
  [![Inline docs](http://inch-ci.org/github/ruby-grape/grape.svg)](http://inch-ci.org/github/ruby-grape/grape)
8
9
  [![git.legal](https://git.legal/projects/1364/badge.svg "Number of libraries approved")](https://git.legal/projects/1364)
9
10
  [![Join the chat at https://gitter.im/ruby-grape/grape](https://badges.gitter.im/ruby-grape/grape.svg)](https://gitter.im/ruby-grape/grape?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
@@ -106,7 +107,7 @@ content negotiation, versioning and much more.
106
107
 
107
108
  ## Stable Release
108
109
 
109
- You're reading the documentation for the stable release of Grape, 0.19.1.
110
+ You're reading the documentation for the stable release of Grape.
110
111
  Please read [UPGRADING](UPGRADING.md) when upgrading from a previous version.
111
112
 
112
113
  ## Project Resources
@@ -319,6 +320,19 @@ class Twitter::API < Grape::API
319
320
  end
320
321
  ```
321
322
 
323
+ Keep in mind such declarations as `before/after/rescue_from` must be placed before `mount` in a case where they should be inherited.
324
+
325
+ ```ruby
326
+ class Twitter::API < Grape::API
327
+ before do
328
+ header 'X-Base-Header', 'will be defined for all APIs that are mounted below'
329
+ end
330
+
331
+ mount Twitter::Users
332
+ mount Twitter::Search
333
+ end
334
+ ```
335
+
322
336
  ## Versioning
323
337
 
324
338
  There are four strategies in which clients can reach your API's endpoints: `:path`,
@@ -739,10 +753,10 @@ You can define validations and coercion options for your parameters using a `par
739
753
  params do
740
754
  requires :id, type: Integer
741
755
  optional :text, type: String, regexp: /\A[a-z]+\z/
742
- group :media do
756
+ group :media, type: Hash do
743
757
  requires :url
744
758
  end
745
- optional :audio do
759
+ optional :audio, type: Hash do
746
760
  requires :format, type: Symbol, values: [:mp3, :wav, :aac, :ogg], default: :mp3
747
761
  end
748
762
  mutually_exclusive :media, :audio
@@ -1137,6 +1151,20 @@ params do
1137
1151
  end
1138
1152
  ```
1139
1153
 
1154
+ Finally, for even greater control, an explicit validation Proc may be supplied using ```proc```.
1155
+ It will be called with a single argument (the input value), and should return
1156
+ a truthy value if the value passes validation. If the input is an array, the Proc will be called
1157
+ multiple times, once for each element in the array.
1158
+
1159
+ ```ruby
1160
+ params do
1161
+ requires :number, type: Integer, values: { proc: ->(v) { v.even? && v < 25 }, message: 'is odd or greater than 25' }
1162
+ end
1163
+ ```
1164
+
1165
+ While ```proc``` is convenient for single cases, consider using [Custom Validators](#custom-validators) in cases where a validation is used more than once.
1166
+
1167
+
1140
1168
  #### `regexp`
1141
1169
 
1142
1170
  Parameters can be restricted to match a specific regular expression with the `:regexp` option. If the value
@@ -1228,24 +1256,24 @@ All of these methods can be used at any nested level.
1228
1256
 
1229
1257
  ```ruby
1230
1258
  params do
1231
- requires :food do
1259
+ requires :food, type: Hash do
1232
1260
  optional :meat
1233
1261
  optional :fish
1234
1262
  optional :rice
1235
1263
  at_least_one_of :meat, :fish, :rice
1236
1264
  end
1237
- group :drink do
1265
+ group :drink, type: Hash do
1238
1266
  optional :beer
1239
1267
  optional :wine
1240
1268
  optional :juice
1241
1269
  exactly_one_of :beer, :wine, :juice
1242
1270
  end
1243
- optional :dessert do
1271
+ optional :dessert, type: Hash do
1244
1272
  optional :cake
1245
1273
  optional :icecream
1246
1274
  mutually_exclusive :cake, :icecream
1247
1275
  end
1248
- optional :recipe do
1276
+ optional :recipe, type: Hash do
1249
1277
  optional :oil
1250
1278
  optional :meat
1251
1279
  all_or_none_of :oil, :meat
@@ -1,7 +1,7 @@
1
1
  Upgrading Grape
2
2
  ===============
3
3
 
4
- ### Upgrading to >= 0.19.1 (next)
4
+ ### Upgrading to >= 0.19.1
5
5
 
6
6
  #### DELETE now defaults to status code 200 for responses with a body, or 204 otherwise
7
7
 
@@ -299,6 +299,19 @@ end
299
299
 
300
300
  See [#1029](https://github.com/ruby-grape/grape/pull/1029) for more information.
301
301
 
302
+ There is a known issue because of this change. When Grape is used with an older
303
+ than 1.2.4 version of [warden](https://github.com/hassox/warden) there may be raised
304
+ the following exception having the [rack-mount](https://github.com/jm/rack-mount) gem's
305
+ lines as last ones in the backtrace:
306
+
307
+ ```
308
+ NoMethodError: undefined method `[]' for nil:NilClass
309
+ ```
310
+
311
+ The issue can be solved by upgrading warden to 1.2.4 version.
312
+
313
+ See [#1151](https://github.com/ruby-grape/grape/issues/1151) for more information.
314
+
302
315
  #### Changes in present
303
316
 
304
317
  Using `present` with objects that responded to `merge` would cause early evaluation of the represented object, with unexpected side-effects, such as missing parameters or environment within rendering code. Grape now only merges represented objects with a previously rendered body, usually when multiple `present` calls are made in the same route.
@@ -7,7 +7,7 @@ gem 'rack', '1.5.2'
7
7
  group :development, :test do
8
8
  gem 'bundler'
9
9
  gem 'rake'
10
- gem 'rubocop', '0.39.0'
10
+ gem 'rubocop', '0.47.0'
11
11
  end
12
12
 
13
13
  group :development do
@@ -21,14 +21,15 @@ group :development do
21
21
  end
22
22
 
23
23
  group :test do
24
- gem 'grape-entity', '0.5.0'
24
+ gem 'grape-entity', '~> 0.6'
25
25
  gem 'maruku'
26
26
  gem 'rack-test'
27
27
  gem 'rspec', '~> 3.0'
28
28
  gem 'cookiejar'
29
29
  gem 'rack-jsonp', require: 'rack/jsonp'
30
- gem 'mime-types', '< 3.0'
31
- gem 'danger', '~> 2.0'
30
+ gem 'mime-types'
31
+ gem 'ruby-grape-danger', '~> 0.1.0', require: false
32
+ gem 'coveralls', '~> 0.8.17', require: false
32
33
  end
33
34
 
34
35
  gemspec path: '../'
@@ -7,7 +7,7 @@ gem 'rack', github: 'rack/rack'
7
7
  group :development, :test do
8
8
  gem 'bundler'
9
9
  gem 'rake'
10
- gem 'rubocop', '~> 0.45.0'
10
+ gem 'rubocop', '0.47.0'
11
11
  end
12
12
 
13
13
  group :development do
@@ -27,8 +27,9 @@ group :test do
27
27
  gem 'rspec', '~> 3.0'
28
28
  gem 'cookiejar'
29
29
  gem 'rack-jsonp', require: 'rack/jsonp'
30
- gem 'mime-types', '~> 3.0'
30
+ gem 'mime-types'
31
31
  gem 'ruby-grape-danger', '~> 0.1.0', require: false
32
+ gem 'coveralls', '~> 0.8.17', require: false
32
33
  end
33
34
 
34
35
  gemspec path: '../'
@@ -8,7 +8,7 @@ gem 'rack-cache', '<= 1.2'
8
8
  group :development, :test do
9
9
  gem 'bundler'
10
10
  gem 'rake'
11
- gem 'rubocop', '0.39.0'
11
+ gem 'rubocop', '0.47.0'
12
12
  end
13
13
 
14
14
  group :development do
@@ -22,14 +22,15 @@ group :development do
22
22
  end
23
23
 
24
24
  group :test do
25
- gem 'grape-entity', '0.5.0'
25
+ gem 'grape-entity', '~> 0.6'
26
26
  gem 'maruku'
27
27
  gem 'rack-test'
28
28
  gem 'rspec', '~> 3.0'
29
29
  gem 'cookiejar'
30
30
  gem 'rack-jsonp', require: 'rack/jsonp'
31
- gem 'mime-types', '< 3.0'
32
- gem 'danger', '~> 2.0'
31
+ gem 'mime-types'
32
+ gem 'ruby-grape-danger', '~> 0.1.0', require: false
33
+ gem 'coveralls', '~> 0.8.17', require: false
33
34
  end
34
35
 
35
36
  gemspec path: '../'
@@ -7,7 +7,7 @@ gem 'rails', '4.1.6'
7
7
  group :development, :test do
8
8
  gem 'bundler'
9
9
  gem 'rake'
10
- gem 'rubocop', '0.39.0'
10
+ gem 'rubocop', '0.47.0'
11
11
  end
12
12
 
13
13
  group :development do
@@ -21,14 +21,15 @@ group :development do
21
21
  end
22
22
 
23
23
  group :test do
24
- gem 'grape-entity', '0.5.0'
24
+ gem 'grape-entity', '~> 0.6'
25
25
  gem 'maruku'
26
26
  gem 'rack-test'
27
27
  gem 'rspec', '~> 3.0'
28
28
  gem 'cookiejar'
29
29
  gem 'rack-jsonp', require: 'rack/jsonp'
30
- gem 'mime-types', '< 3.0'
31
- gem 'danger', '~> 2.0'
30
+ gem 'mime-types'
31
+ gem 'ruby-grape-danger', '~> 0.1.0', require: false
32
+ gem 'coveralls', '~> 0.8.17', require: false
32
33
  end
33
34
 
34
35
  gemspec path: '../'