grape 0.3.0 → 0.7.0
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 +15 -0
- data/.gitignore +8 -0
- data/.rubocop.yml +70 -0
- data/.travis.yml +7 -6
- data/CHANGELOG.md +134 -4
- data/CONTRIBUTING.md +118 -0
- data/Gemfile +5 -2
- data/README.md +551 -116
- data/RELEASING.md +105 -0
- data/Rakefile +29 -8
- data/UPGRADING.md +124 -0
- data/grape.gemspec +3 -3
- data/lib/grape/api.rb +207 -88
- data/lib/grape/cookies.rb +4 -8
- data/lib/grape/endpoint.rb +198 -144
- data/lib/grape/error_formatter/base.rb +5 -7
- data/lib/grape/error_formatter/json.rb +3 -5
- data/lib/grape/error_formatter/txt.rb +1 -3
- data/lib/grape/error_formatter/xml.rb +4 -6
- data/lib/grape/exceptions/base.rb +9 -9
- data/lib/grape/exceptions/incompatible_option_values.rb +10 -0
- data/lib/grape/exceptions/invalid_formatter.rb +1 -4
- data/lib/grape/exceptions/invalid_versioner_option.rb +1 -5
- data/lib/grape/exceptions/invalid_with_option_for_represent.rb +1 -6
- data/lib/grape/exceptions/missing_mime_type.rb +1 -5
- data/lib/grape/exceptions/missing_option.rb +1 -4
- data/lib/grape/exceptions/missing_vendor_option.rb +1 -4
- data/lib/grape/exceptions/unknown_options.rb +1 -5
- data/lib/grape/exceptions/unknown_validator.rb +1 -3
- data/lib/grape/exceptions/validation.rb +13 -3
- data/lib/grape/exceptions/validation_errors.rb +43 -0
- data/lib/grape/formatter/base.rb +5 -7
- data/lib/grape/formatter/json.rb +0 -3
- data/lib/grape/formatter/serializable_hash.rb +15 -15
- data/lib/grape/formatter/txt.rb +0 -2
- data/lib/grape/formatter/xml.rb +0 -2
- data/lib/grape/http/request.rb +26 -0
- data/lib/grape/locale/en.yml +8 -5
- data/lib/grape/middleware/auth/base.rb +30 -0
- data/lib/grape/middleware/auth/basic.rb +3 -20
- data/lib/grape/middleware/auth/digest.rb +2 -19
- data/lib/grape/middleware/auth/oauth2.rb +31 -24
- data/lib/grape/middleware/base.rb +7 -7
- data/lib/grape/middleware/error.rb +36 -22
- data/lib/grape/middleware/filter.rb +3 -3
- data/lib/grape/middleware/formatter.rb +99 -61
- data/lib/grape/middleware/globals.rb +13 -0
- data/lib/grape/middleware/versioner/accept_version_header.rb +67 -0
- data/lib/grape/middleware/versioner/header.rb +22 -16
- data/lib/grape/middleware/versioner/param.rb +9 -11
- data/lib/grape/middleware/versioner/path.rb +10 -13
- data/lib/grape/middleware/versioner.rb +3 -1
- data/lib/grape/namespace.rb +23 -0
- data/lib/grape/parser/base.rb +3 -5
- data/lib/grape/parser/json.rb +0 -2
- data/lib/grape/parser/xml.rb +0 -2
- data/lib/grape/path.rb +70 -0
- data/lib/grape/route.rb +10 -6
- data/lib/grape/util/content_types.rb +2 -1
- data/lib/grape/util/deep_merge.rb +5 -5
- data/lib/grape/util/hash_stack.rb +13 -2
- data/lib/grape/validations/coerce.rb +11 -10
- data/lib/grape/validations/default.rb +25 -0
- data/lib/grape/validations/presence.rb +7 -3
- data/lib/grape/validations/regexp.rb +2 -5
- data/lib/grape/validations/values.rb +17 -0
- data/lib/grape/validations.rb +161 -54
- data/lib/grape/version.rb +1 -1
- data/lib/grape.rb +19 -4
- data/spec/grape/api_spec.rb +897 -268
- data/spec/grape/endpoint_spec.rb +283 -66
- data/spec/grape/entity_spec.rb +132 -29
- data/spec/grape/exceptions/missing_mime_type_spec.rb +3 -9
- data/spec/grape/exceptions/validation_errors_spec.rb +19 -0
- data/spec/grape/middleware/auth/basic_spec.rb +8 -8
- data/spec/grape/middleware/auth/digest_spec.rb +5 -5
- data/spec/grape/middleware/auth/oauth2_spec.rb +81 -36
- data/spec/grape/middleware/base_spec.rb +8 -13
- data/spec/grape/middleware/error_spec.rb +13 -17
- data/spec/grape/middleware/exception_spec.rb +47 -27
- data/spec/grape/middleware/formatter_spec.rb +103 -41
- data/spec/grape/middleware/versioner/accept_version_header_spec.rb +121 -0
- data/spec/grape/middleware/versioner/header_spec.rb +76 -51
- data/spec/grape/middleware/versioner/param_spec.rb +18 -18
- data/spec/grape/middleware/versioner/path_spec.rb +6 -6
- data/spec/grape/middleware/versioner_spec.rb +5 -2
- data/spec/grape/path_spec.rb +229 -0
- data/spec/grape/util/hash_stack_spec.rb +31 -32
- data/spec/grape/validations/coerce_spec.rb +116 -51
- data/spec/grape/validations/default_spec.rb +123 -0
- data/spec/grape/validations/presence_spec.rb +42 -44
- data/spec/grape/validations/regexp_spec.rb +9 -9
- data/spec/grape/validations/values_spec.rb +138 -0
- data/spec/grape/validations/zh-CN.yml +4 -3
- data/spec/grape/validations_spec.rb +681 -48
- data/spec/shared/versioning_examples.rb +22 -6
- data/spec/spec_helper.rb +3 -2
- data/spec/support/basic_auth_encode_helpers.rb +0 -1
- data/spec/support/content_type_helpers.rb +11 -0
- data/spec/support/versioned_helpers.rb +13 -5
- metadata +34 -84
data/lib/grape.rb
CHANGED
@@ -6,26 +6,38 @@ require 'rack/accept'
|
|
6
6
|
require 'rack/auth/basic'
|
7
7
|
require 'rack/auth/digest/md5'
|
8
8
|
require 'hashie'
|
9
|
-
require '
|
9
|
+
require 'set'
|
10
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
11
|
+
require 'active_support/ordered_hash'
|
12
|
+
require 'active_support/core_ext/object/conversions'
|
13
|
+
require 'active_support/core_ext/array/extract_options'
|
10
14
|
require 'grape/util/deep_merge'
|
11
15
|
require 'grape/util/content_types'
|
12
16
|
require 'multi_json'
|
13
17
|
require 'multi_xml'
|
14
18
|
require 'virtus'
|
15
19
|
require 'i18n'
|
20
|
+
require 'thread'
|
16
21
|
|
17
22
|
I18n.load_path << File.expand_path('../grape/locale/en.yml', __FILE__)
|
18
23
|
|
19
24
|
module Grape
|
20
25
|
autoload :API, 'grape/api'
|
21
26
|
autoload :Endpoint, 'grape/endpoint'
|
27
|
+
|
22
28
|
autoload :Route, 'grape/route'
|
29
|
+
autoload :Namespace, 'grape/namespace'
|
30
|
+
|
31
|
+
autoload :Path, 'grape/path'
|
32
|
+
|
23
33
|
autoload :Cookies, 'grape/cookies'
|
24
34
|
autoload :Validations, 'grape/validations'
|
35
|
+
autoload :Request, 'grape/http/request'
|
25
36
|
|
26
37
|
module Exceptions
|
27
38
|
autoload :Base, 'grape/exceptions/base'
|
28
39
|
autoload :Validation, 'grape/exceptions/validation'
|
40
|
+
autoload :ValidationErrors, 'grape/exceptions/validation_errors'
|
29
41
|
autoload :MissingVendorOption, 'grape/exceptions/missing_vendor_option'
|
30
42
|
autoload :MissingMimeType, 'grape/exceptions/missing_mime_type'
|
31
43
|
autoload :MissingOption, 'grape/exceptions/missing_option'
|
@@ -34,6 +46,7 @@ module Grape
|
|
34
46
|
autoload :UnknownValidator, 'grape/exceptions/unknown_validator'
|
35
47
|
autoload :UnknownOptions, 'grape/exceptions/unknown_options'
|
36
48
|
autoload :InvalidWithOptionForRepresent, 'grape/exceptions/invalid_with_option_for_represent'
|
49
|
+
autoload :IncompatibleOptionValues, 'grape/exceptions/incompatible_option_values'
|
37
50
|
end
|
38
51
|
|
39
52
|
module ErrorFormatter
|
@@ -65,14 +78,16 @@ module Grape
|
|
65
78
|
|
66
79
|
module Auth
|
67
80
|
autoload :OAuth2, 'grape/middleware/auth/oauth2'
|
81
|
+
autoload :Base, 'grape/middleware/auth/base'
|
68
82
|
autoload :Basic, 'grape/middleware/auth/basic'
|
69
83
|
autoload :Digest, 'grape/middleware/auth/digest'
|
70
84
|
end
|
71
85
|
|
72
86
|
module Versioner
|
73
|
-
autoload :Path,
|
74
|
-
autoload :Header,
|
75
|
-
autoload :Param,
|
87
|
+
autoload :Path, 'grape/middleware/versioner/path'
|
88
|
+
autoload :Header, 'grape/middleware/versioner/header'
|
89
|
+
autoload :Param, 'grape/middleware/versioner/param'
|
90
|
+
autoload :AcceptVersionHeader, 'grape/middleware/versioner/accept_version_header'
|
76
91
|
end
|
77
92
|
end
|
78
93
|
|