grape 2.0.0 → 2.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +77 -1
  3. data/README.md +362 -316
  4. data/UPGRADING.md +197 -7
  5. data/grape.gemspec +5 -6
  6. data/lib/grape/api/instance.rb +14 -11
  7. data/lib/grape/api.rb +19 -10
  8. data/lib/grape/content_types.rb +0 -2
  9. data/lib/grape/cookies.rb +2 -1
  10. data/lib/grape/dry_types.rb +0 -2
  11. data/lib/grape/dsl/desc.rb +22 -20
  12. data/lib/grape/dsl/headers.rb +1 -1
  13. data/lib/grape/dsl/inside_route.rb +46 -15
  14. data/lib/grape/dsl/parameters.rb +5 -4
  15. data/lib/grape/dsl/routing.rb +20 -4
  16. data/lib/grape/dsl/validations.rb +13 -0
  17. data/lib/grape/endpoint.rb +14 -17
  18. data/lib/grape/{util/env.rb → env.rb} +0 -5
  19. data/lib/grape/error_formatter/txt.rb +11 -10
  20. data/lib/grape/exceptions/base.rb +3 -3
  21. data/lib/grape/exceptions/validation.rb +0 -2
  22. data/lib/grape/exceptions/validation_array_errors.rb +1 -0
  23. data/lib/grape/exceptions/validation_errors.rb +2 -4
  24. data/lib/grape/extensions/hash.rb +5 -1
  25. data/lib/grape/http/headers.rb +18 -34
  26. data/lib/grape/{util/json.rb → json.rb} +1 -3
  27. data/lib/grape/locale/en.yml +3 -0
  28. data/lib/grape/middleware/auth/base.rb +0 -2
  29. data/lib/grape/middleware/auth/dsl.rb +0 -2
  30. data/lib/grape/middleware/base.rb +1 -3
  31. data/lib/grape/middleware/error.rb +55 -50
  32. data/lib/grape/middleware/formatter.rb +16 -13
  33. data/lib/grape/middleware/globals.rb +1 -3
  34. data/lib/grape/middleware/stack.rb +4 -5
  35. data/lib/grape/middleware/versioner/accept_version_header.rb +0 -2
  36. data/lib/grape/middleware/versioner/header.rb +17 -163
  37. data/lib/grape/middleware/versioner/param.rb +2 -4
  38. data/lib/grape/middleware/versioner/path.rb +1 -3
  39. data/lib/grape/namespace.rb +3 -4
  40. data/lib/grape/path.rb +24 -29
  41. data/lib/grape/request.rb +4 -12
  42. data/lib/grape/router/base_route.rb +39 -0
  43. data/lib/grape/router/greedy_route.rb +20 -0
  44. data/lib/grape/router/pattern.rb +39 -30
  45. data/lib/grape/router/route.rb +22 -59
  46. data/lib/grape/router.rb +32 -37
  47. data/lib/grape/util/accept_header_handler.rb +105 -0
  48. data/lib/grape/util/base_inheritable.rb +4 -4
  49. data/lib/grape/util/cache.rb +0 -3
  50. data/lib/grape/util/endpoint_configuration.rb +1 -1
  51. data/lib/grape/util/header.rb +13 -0
  52. data/lib/grape/util/inheritable_values.rb +0 -2
  53. data/lib/grape/util/lazy/block.rb +29 -0
  54. data/lib/grape/util/lazy/object.rb +45 -0
  55. data/lib/grape/util/lazy/value.rb +38 -0
  56. data/lib/grape/util/lazy/value_array.rb +21 -0
  57. data/lib/grape/util/lazy/value_enumerable.rb +34 -0
  58. data/lib/grape/util/lazy/value_hash.rb +21 -0
  59. data/lib/grape/util/media_type.rb +70 -0
  60. data/lib/grape/util/reverse_stackable_values.rb +1 -6
  61. data/lib/grape/util/stackable_values.rb +1 -6
  62. data/lib/grape/util/strict_hash_configuration.rb +3 -3
  63. data/lib/grape/validations/attributes_doc.rb +38 -36
  64. data/lib/grape/validations/attributes_iterator.rb +1 -0
  65. data/lib/grape/validations/contract_scope.rb +71 -0
  66. data/lib/grape/validations/params_scope.rb +22 -19
  67. data/lib/grape/validations/types/array_coercer.rb +0 -2
  68. data/lib/grape/validations/types/build_coercer.rb +69 -71
  69. data/lib/grape/validations/types/dry_type_coercer.rb +1 -11
  70. data/lib/grape/validations/types/json.rb +0 -2
  71. data/lib/grape/validations/types/primitive_coercer.rb +0 -2
  72. data/lib/grape/validations/types/set_coercer.rb +0 -3
  73. data/lib/grape/validations/types.rb +0 -3
  74. data/lib/grape/validations/validators/base.rb +1 -0
  75. data/lib/grape/validations/validators/default_validator.rb +5 -1
  76. data/lib/grape/validations/validators/exactly_one_of_validator.rb +1 -1
  77. data/lib/grape/validations/validators/length_validator.rb +42 -0
  78. data/lib/grape/validations/validators/values_validator.rb +6 -1
  79. data/lib/grape/validations.rb +3 -7
  80. data/lib/grape/version.rb +1 -1
  81. data/lib/grape/{util/xml.rb → xml.rb} +1 -1
  82. data/lib/grape.rb +30 -274
  83. metadata +30 -37
  84. data/lib/grape/eager_load.rb +0 -20
  85. data/lib/grape/middleware/versioner/parse_media_type_patch.rb +0 -24
  86. data/lib/grape/router/attribute_translator.rb +0 -63
  87. data/lib/grape/util/lazy_block.rb +0 -27
  88. data/lib/grape/util/lazy_object.rb +0 -43
  89. data/lib/grape/util/lazy_value.rb +0 -91
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Grape
4
+ module Validations
5
+ module Validators
6
+ class LengthValidator < Base
7
+ def initialize(attrs, options, required, scope, **opts)
8
+ @min = options[:min]
9
+ @max = options[:max]
10
+
11
+ super
12
+
13
+ raise ArgumentError, 'min must be an integer greater than or equal to zero' if !@min.nil? && (!@min.is_a?(Integer) || @min.negative?)
14
+ raise ArgumentError, 'max must be an integer greater than or equal to zero' if !@max.nil? && (!@max.is_a?(Integer) || @max.negative?)
15
+ raise ArgumentError, "min #{@min} cannot be greater than max #{@max}" if !@min.nil? && !@max.nil? && @min > @max
16
+ end
17
+
18
+ def validate_param!(attr_name, params)
19
+ param = params[attr_name]
20
+
21
+ raise ArgumentError, "parameter #{param} does not support #length" unless param.respond_to?(:length)
22
+
23
+ return unless (!@min.nil? && param.length < @min) || (!@max.nil? && param.length > @max)
24
+
25
+ raise Grape::Exceptions::Validation.new(params: [@scope.full_name(attr_name)], message: build_message)
26
+ end
27
+
28
+ def build_message
29
+ if options_key?(:message)
30
+ @option[:message]
31
+ elsif @min && @max
32
+ format I18n.t(:length, scope: 'grape.errors.messages'), min: @min, max: @max
33
+ elsif @min
34
+ format I18n.t(:length_min, scope: 'grape.errors.messages'), min: @min
35
+ else
36
+ format I18n.t(:length_max, scope: 'grape.errors.messages'), max: @max
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -85,7 +85,12 @@ module Grape
85
85
  end
86
86
 
87
87
  def required_for_root_scope?
88
- @required && @scope.root?
88
+ return false unless @required
89
+
90
+ scope = @scope
91
+ scope = scope.parent while scope.lateral?
92
+
93
+ scope.root?
89
94
  end
90
95
 
91
96
  def validation_exception(attr_name, message)
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grape
4
- # Registry to store and locate known Validators.
5
4
  module Validations
6
5
  module_function
7
6
 
@@ -12,7 +11,7 @@ module Grape
12
11
  # Register a new validator, so it can be used to validate parameters.
13
12
  # @param short_name [String] all lower-case, no spaces
14
13
  # @param klass [Class] the validator class. Should inherit from
15
- # Validations::Base.
14
+ # Grape::Validations::Validators::Base.
16
15
  def register_validator(short_name, klass)
17
16
  validators[short_name] = klass
18
17
  end
@@ -21,14 +20,11 @@ module Grape
21
20
  validators.delete(short_name)
22
21
  end
23
22
 
24
- # Find a validator and if not found will try to load it
25
23
  def require_validator(short_name)
26
24
  str_name = short_name.to_s
27
- validators.fetch(str_name) do
28
- Grape::Validations::Validators.const_get("#{str_name.camelize}Validator")
29
- end
25
+ validators.fetch(str_name) { Grape::Validations::Validators.const_get(:"#{str_name.camelize}Validator") }
30
26
  rescue NameError
31
- raise Grape::Exceptions::UnknownValidator.new(short_name)
27
+ raise Grape::Exceptions::UnknownValidator, short_name
32
28
  end
33
29
  end
34
30
  end
data/lib/grape/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Grape
4
4
  # The current version of Grape.
5
- VERSION = '2.0.0'
5
+ VERSION = '2.1.3'
6
6
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grape
4
- if Object.const_defined? :MultiXml
4
+ if defined?(::MultiXml)
5
5
  Xml = ::MultiXml
6
6
  else
7
7
  Xml = ::ActiveSupport::XmlMini
data/lib/grape.rb CHANGED
@@ -1,13 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'logger'
4
- require 'rack'
5
- require 'rack/builder'
6
- require 'rack/accept'
7
- require 'rack/auth/basic'
8
- require 'set'
9
- require 'bigdecimal'
10
- require 'date'
11
3
  require 'active_support'
12
4
  require 'active_support/concern'
13
5
  require 'active_support/configurable'
@@ -24,295 +16,59 @@ require 'active_support/core_ext/hash/indifferent_access'
24
16
  require 'active_support/core_ext/hash/keys'
25
17
  require 'active_support/core_ext/hash/reverse_merge'
26
18
  require 'active_support/core_ext/hash/slice'
19
+ require 'active_support/core_ext/module/delegation'
27
20
  require 'active_support/core_ext/object/blank'
28
21
  require 'active_support/core_ext/object/deep_dup'
29
22
  require 'active_support/core_ext/object/duplicable'
23
+ require 'active_support/core_ext/string/output_safety'
30
24
  require 'active_support/core_ext/string/exclude'
31
- require 'active_support/dependencies/autoload'
32
25
  require 'active_support/deprecation'
33
26
  require 'active_support/inflector'
27
+ require 'active_support/ordered_options'
34
28
  require 'active_support/notifications'
35
- require 'i18n'
29
+
30
+ require 'English'
31
+ require 'bigdecimal'
32
+ require 'date'
33
+ require 'dry-types'
34
+ require 'forwardable'
35
+ require 'json'
36
+ require 'logger'
37
+ require 'mustermann/grape'
38
+ require 'pathname'
39
+ require 'rack'
40
+ require 'rack/auth/basic'
41
+ require 'rack/builder'
42
+ require 'rack/head'
43
+ require 'set'
44
+ require 'singleton'
45
+ require 'zeitwerk'
46
+
47
+ loader = Zeitwerk::Loader.for_gem
48
+ loader.inflector.inflect(
49
+ 'api' => 'API',
50
+ 'dsl' => 'DSL'
51
+ )
52
+ railtie = "#{__dir__}/grape/railtie.rb"
53
+ loader.do_not_eager_load(railtie)
54
+ loader.setup
36
55
 
37
56
  I18n.load_path << File.expand_path('grape/locale/en.yml', __dir__)
38
57
 
39
58
  module Grape
40
59
  include ActiveSupport::Configurable
41
- extend ::ActiveSupport::Autoload
42
60
 
43
61
  def self.deprecator
44
62
  @deprecator ||= ActiveSupport::Deprecation.new('2.0', 'Grape')
45
63
  end
46
64
 
47
- def self.lowercase_headers?
48
- Rack::CONTENT_TYPE == 'content-type'
49
- end
50
-
51
- eager_autoload do
52
- autoload :API
53
- autoload :Endpoint
54
-
55
- autoload :Namespace
56
-
57
- autoload :Path
58
- autoload :Cookies
59
- autoload :Validations
60
- autoload :ErrorFormatter
61
- autoload :Formatter
62
- autoload :Parser
63
- autoload :Request
64
- autoload :Env, 'grape/util/env'
65
- autoload :Json, 'grape/util/json'
66
- autoload :Xml, 'grape/util/xml'
67
- autoload :DryTypes
68
- end
69
-
70
- module Http
71
- extend ::ActiveSupport::Autoload
72
- eager_autoload do
73
- autoload :Headers
74
- end
75
- end
76
-
77
- module Exceptions
78
- extend ::ActiveSupport::Autoload
79
- eager_autoload do
80
- autoload :Base
81
- autoload :Validation
82
- autoload :ValidationArrayErrors
83
- autoload :ValidationErrors
84
- autoload :MissingVendorOption
85
- autoload :MissingMimeType
86
- autoload :MissingOption
87
- autoload :InvalidFormatter
88
- autoload :InvalidVersionerOption
89
- autoload :UnknownValidator
90
- autoload :UnknownOptions
91
- autoload :UnknownParameter
92
- autoload :InvalidWithOptionForRepresent
93
- autoload :IncompatibleOptionValues
94
- autoload :MissingGroupType
95
- autoload :UnsupportedGroupType
96
- autoload :InvalidMessageBody
97
- autoload :InvalidAcceptHeader
98
- autoload :InvalidVersionHeader
99
- autoload :MethodNotAllowed
100
- autoload :InvalidResponse
101
- autoload :EmptyMessageBody
102
- autoload :TooManyMultipartFiles
103
- autoload :MissingGroupTypeError, 'grape/exceptions/missing_group_type'
104
- autoload :UnsupportedGroupTypeError, 'grape/exceptions/unsupported_group_type'
105
- end
106
- end
107
-
108
- module Extensions
109
- extend ::ActiveSupport::Autoload
110
- eager_autoload do
111
- autoload :Hash
112
- end
113
- module ActiveSupport
114
- extend ::ActiveSupport::Autoload
115
- eager_autoload do
116
- autoload :HashWithIndifferentAccess
117
- end
118
- end
119
-
120
- module Hashie
121
- extend ::ActiveSupport::Autoload
122
- eager_autoload do
123
- autoload :Mash
124
- end
125
- end
126
- end
127
-
128
- module Middleware
129
- extend ::ActiveSupport::Autoload
130
- eager_autoload do
131
- autoload :Base
132
- autoload :Versioner
133
- autoload :Formatter
134
- autoload :Error
135
- autoload :Globals
136
- autoload :Stack
137
- autoload :Helpers
138
- end
139
-
140
- module Auth
141
- extend ::ActiveSupport::Autoload
142
- eager_autoload do
143
- autoload :Base
144
- autoload :DSL
145
- autoload :StrategyInfo
146
- autoload :Strategies
147
- end
148
- end
149
-
150
- module Versioner
151
- extend ::ActiveSupport::Autoload
152
- eager_autoload do
153
- autoload :Path
154
- autoload :Header
155
- autoload :Param
156
- autoload :AcceptVersionHeader
157
- end
158
- end
159
- end
160
-
161
- module Util
162
- extend ::ActiveSupport::Autoload
163
- eager_autoload do
164
- autoload :InheritableValues
165
- autoload :StackableValues
166
- autoload :ReverseStackableValues
167
- autoload :InheritableSetting
168
- autoload :StrictHashConfiguration
169
- autoload :Registrable
170
- end
171
- end
172
-
173
- module ErrorFormatter
174
- extend ::ActiveSupport::Autoload
175
- eager_autoload do
176
- autoload :Base
177
- autoload :Json
178
- autoload :Txt
179
- autoload :Xml
180
- end
181
- end
182
-
183
- module Formatter
184
- extend ::ActiveSupport::Autoload
185
- eager_autoload do
186
- autoload :Json
187
- autoload :SerializableHash
188
- autoload :Txt
189
- autoload :Xml
190
- end
191
- end
192
-
193
- module Parser
194
- extend ::ActiveSupport::Autoload
195
- eager_autoload do
196
- autoload :Json
197
- autoload :Xml
198
- end
199
- end
200
-
201
- module DSL
202
- extend ::ActiveSupport::Autoload
203
- eager_autoload do
204
- autoload :API
205
- autoload :Callbacks
206
- autoload :Settings
207
- autoload :Configuration
208
- autoload :InsideRoute
209
- autoload :Helpers
210
- autoload :Middleware
211
- autoload :Parameters
212
- autoload :RequestResponse
213
- autoload :Routing
214
- autoload :Validations
215
- autoload :Logger
216
- autoload :Desc
217
- end
218
- end
219
-
220
- class API
221
- extend ::ActiveSupport::Autoload
222
- eager_autoload do
223
- autoload :Helpers
224
- end
225
- end
226
-
227
- module Presenters
228
- extend ::ActiveSupport::Autoload
229
- eager_autoload do
230
- autoload :Presenter
231
- end
232
- end
233
-
234
- module ServeStream
235
- extend ::ActiveSupport::Autoload
236
- eager_autoload do
237
- autoload :FileBody
238
- autoload :SendfileResponse
239
- autoload :StreamResponse
240
- end
241
- end
242
-
243
- module Validations
244
- extend ::ActiveSupport::Autoload
245
-
246
- eager_autoload do
247
- autoload :AttributesIterator
248
- autoload :MultipleAttributesIterator
249
- autoload :SingleAttributeIterator
250
- autoload :Types
251
- autoload :ParamsScope
252
- autoload :ValidatorFactory
253
- autoload :Base, 'grape/validations/validators/base'
254
- end
255
-
256
- module Types
257
- extend ::ActiveSupport::Autoload
258
-
259
- eager_autoload do
260
- autoload :InvalidValue
261
- autoload :DryTypeCoercer
262
- autoload :ArrayCoercer
263
- autoload :SetCoercer
264
- autoload :PrimitiveCoercer
265
- autoload :CustomTypeCoercer
266
- autoload :CustomTypeCollectionCoercer
267
- autoload :MultipleTypeCoercer
268
- autoload :VariantCollectionCoercer
269
- end
270
- end
271
-
272
- module Validators
273
- extend ::ActiveSupport::Autoload
274
-
275
- eager_autoload do
276
- autoload :Base
277
- autoload :MultipleParamsBase
278
- autoload :AllOrNoneOfValidator
279
- autoload :AllowBlankValidator
280
- autoload :AsValidator
281
- autoload :AtLeastOneOfValidator
282
- autoload :CoerceValidator
283
- autoload :DefaultValidator
284
- autoload :ExactlyOneOfValidator
285
- autoload :ExceptValuesValidator
286
- autoload :MutualExclusionValidator
287
- autoload :PresenceValidator
288
- autoload :RegexpValidator
289
- autoload :SameAsValidator
290
- autoload :ValuesValidator
291
- end
292
- end
293
- end
294
-
295
- module Types
296
- extend ::ActiveSupport::Autoload
297
-
298
- eager_autoload do
299
- autoload :InvalidValue
300
- end
301
- end
302
-
303
65
  configure do |config|
304
66
  config.param_builder = Grape::Extensions::ActiveSupport::HashWithIndifferentAccess::ParamBuilder
305
67
  config.compile_methods!
306
68
  end
307
69
  end
308
70
 
309
- require 'grape/content_types'
310
-
311
- require 'grape/util/lazy_value'
312
- require 'grape/util/lazy_block'
313
- require 'grape/util/endpoint_configuration'
314
- require 'grape/version'
315
-
316
71
  # https://api.rubyonrails.org/classes/ActiveSupport/Deprecation.html
317
72
  # adding Grape.deprecator to Rails App if any
318
73
  require 'grape/railtie' if defined?(Rails::Railtie) && ActiveSupport.gem_version >= Gem::Version.new('7.1')
74
+ loader.eager_load
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-11 00:00:00.000000000 Z
11
+ date: 2024-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
19
+ version: '6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5'
27
- - !ruby/object:Gem::Dependency
28
- name: builder
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
26
+ version: '6'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: dry-types
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,30 +44,30 @@ dependencies:
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: 1.0.0
47
+ version: 1.1.0
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: 1.0.0
54
+ version: 1.1.0
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rack
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: 1.3.0
61
+ version: '2'
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - ">="
81
67
  - !ruby/object:Gem::Version
82
- version: 1.3.0
68
+ version: '2'
83
69
  - !ruby/object:Gem::Dependency
84
- name: rack-accept
70
+ name: zeitwerk
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
@@ -129,8 +115,8 @@ files:
129
115
  - lib/grape/dsl/routing.rb
130
116
  - lib/grape/dsl/settings.rb
131
117
  - lib/grape/dsl/validations.rb
132
- - lib/grape/eager_load.rb
133
118
  - lib/grape/endpoint.rb
119
+ - lib/grape/env.rb
134
120
  - lib/grape/error_formatter.rb
135
121
  - lib/grape/error_formatter/base.rb
136
122
  - lib/grape/error_formatter/json.rb
@@ -168,6 +154,7 @@ files:
168
154
  - lib/grape/formatter/txt.rb
169
155
  - lib/grape/formatter/xml.rb
170
156
  - lib/grape/http/headers.rb
157
+ - lib/grape/json.rb
171
158
  - lib/grape/locale/en.yml
172
159
  - lib/grape/middleware/auth/base.rb
173
160
  - lib/grape/middleware/auth/dsl.rb
@@ -184,7 +171,6 @@ files:
184
171
  - lib/grape/middleware/versioner/accept_version_header.rb
185
172
  - lib/grape/middleware/versioner/header.rb
186
173
  - lib/grape/middleware/versioner/param.rb
187
- - lib/grape/middleware/versioner/parse_media_type_patch.rb
188
174
  - lib/grape/middleware/versioner/path.rb
189
175
  - lib/grape/namespace.rb
190
176
  - lib/grape/parser.rb
@@ -195,31 +181,36 @@ files:
195
181
  - lib/grape/railtie.rb
196
182
  - lib/grape/request.rb
197
183
  - lib/grape/router.rb
198
- - lib/grape/router/attribute_translator.rb
184
+ - lib/grape/router/base_route.rb
185
+ - lib/grape/router/greedy_route.rb
199
186
  - lib/grape/router/pattern.rb
200
187
  - lib/grape/router/route.rb
201
188
  - lib/grape/serve_stream/file_body.rb
202
189
  - lib/grape/serve_stream/sendfile_response.rb
203
190
  - lib/grape/serve_stream/stream_response.rb
204
191
  - lib/grape/types/invalid_value.rb
192
+ - lib/grape/util/accept_header_handler.rb
205
193
  - lib/grape/util/base_inheritable.rb
206
194
  - lib/grape/util/cache.rb
207
195
  - lib/grape/util/endpoint_configuration.rb
208
- - lib/grape/util/env.rb
196
+ - lib/grape/util/header.rb
209
197
  - lib/grape/util/inheritable_setting.rb
210
198
  - lib/grape/util/inheritable_values.rb
211
- - lib/grape/util/json.rb
212
- - lib/grape/util/lazy_block.rb
213
- - lib/grape/util/lazy_object.rb
214
- - lib/grape/util/lazy_value.rb
199
+ - lib/grape/util/lazy/block.rb
200
+ - lib/grape/util/lazy/object.rb
201
+ - lib/grape/util/lazy/value.rb
202
+ - lib/grape/util/lazy/value_array.rb
203
+ - lib/grape/util/lazy/value_enumerable.rb
204
+ - lib/grape/util/lazy/value_hash.rb
205
+ - lib/grape/util/media_type.rb
215
206
  - lib/grape/util/registrable.rb
216
207
  - lib/grape/util/reverse_stackable_values.rb
217
208
  - lib/grape/util/stackable_values.rb
218
209
  - lib/grape/util/strict_hash_configuration.rb
219
- - lib/grape/util/xml.rb
220
210
  - lib/grape/validations.rb
221
211
  - lib/grape/validations/attributes_doc.rb
222
212
  - lib/grape/validations/attributes_iterator.rb
213
+ - lib/grape/validations/contract_scope.rb
223
214
  - lib/grape/validations/multiple_attributes_iterator.rb
224
215
  - lib/grape/validations/params_scope.rb
225
216
  - lib/grape/validations/single_attribute_iterator.rb
@@ -246,6 +237,7 @@ files:
246
237
  - lib/grape/validations/validators/default_validator.rb
247
238
  - lib/grape/validations/validators/exactly_one_of_validator.rb
248
239
  - lib/grape/validations/validators/except_values_validator.rb
240
+ - lib/grape/validations/validators/length_validator.rb
249
241
  - lib/grape/validations/validators/multiple_params_base.rb
250
242
  - lib/grape/validations/validators/mutual_exclusion_validator.rb
251
243
  - lib/grape/validations/validators/presence_validator.rb
@@ -253,14 +245,15 @@ files:
253
245
  - lib/grape/validations/validators/same_as_validator.rb
254
246
  - lib/grape/validations/validators/values_validator.rb
255
247
  - lib/grape/version.rb
248
+ - lib/grape/xml.rb
256
249
  homepage: https://github.com/ruby-grape/grape
257
250
  licenses:
258
251
  - MIT
259
252
  metadata:
260
253
  bug_tracker_uri: https://github.com/ruby-grape/grape/issues
261
- changelog_uri: https://github.com/ruby-grape/grape/blob/v2.0.0/CHANGELOG.md
262
- documentation_uri: https://www.rubydoc.info/gems/grape/2.0.0
263
- source_code_uri: https://github.com/ruby-grape/grape/tree/v2.0.0
254
+ changelog_uri: https://github.com/ruby-grape/grape/blob/v2.1.3/CHANGELOG.md
255
+ documentation_uri: https://www.rubydoc.info/gems/grape/2.1.3
256
+ source_code_uri: https://github.com/ruby-grape/grape/tree/v2.1.3
264
257
  post_install_message:
265
258
  rdoc_options: []
266
259
  require_paths:
@@ -269,14 +262,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
269
262
  requirements:
270
263
  - - ">="
271
264
  - !ruby/object:Gem::Version
272
- version: 2.6.0
265
+ version: 2.7.0
273
266
  required_rubygems_version: !ruby/object:Gem::Requirement
274
267
  requirements:
275
268
  - - ">="
276
269
  - !ruby/object:Gem::Version
277
270
  version: '0'
278
271
  requirements: []
279
- rubygems_version: 3.4.6
272
+ rubygems_version: 3.5.13
280
273
  signing_key:
281
274
  specification_version: 4
282
275
  summary: A simple Ruby framework for building REST-like APIs.
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Grape.eager_load!
4
- Grape::Http.eager_load!
5
- Grape::Exceptions.eager_load!
6
- Grape::Extensions.eager_load!
7
- Grape::Extensions::ActiveSupport.eager_load!
8
- Grape::Extensions::Hashie.eager_load!
9
- Grape::Middleware.eager_load!
10
- Grape::Middleware::Auth.eager_load!
11
- Grape::Middleware::Versioner.eager_load!
12
- Grape::Util.eager_load!
13
- Grape::ErrorFormatter.eager_load!
14
- Grape::Formatter.eager_load!
15
- Grape::Parser.eager_load!
16
- Grape::DSL.eager_load!
17
- Grape::API.eager_load!
18
- Grape::Presenters.eager_load!
19
- Grape::ServeStream.eager_load!
20
- Rack::Head # AutoLoads the Rack::Head
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'English'
4
- module Rack
5
- module Accept
6
- module Header
7
- ALLOWED_CHARACTERS = %r{^([a-z*]+)/([a-z0-9*&\^\-_#{$ERROR_INFO}.+]+)(?:;([a-z0-9=;]+))?$}.freeze
8
- class << self
9
- # Corrected version of https://github.com/mjackson/rack-accept/blob/master/lib/rack/accept/header.rb#L40-L44
10
- def parse_media_type(media_type)
11
- # see http://tools.ietf.org/html/rfc6838#section-4.2 for allowed characters in media type names
12
- m = media_type&.match(ALLOWED_CHARACTERS)
13
- m ? [m[1], m[2], m[3] || ''] : []
14
- end
15
- end
16
- end
17
-
18
- class MediaType
19
- def parse_media_type(media_type)
20
- Header.parse_media_type(media_type)
21
- end
22
- end
23
- end
24
- end