grape 0.6.1 → 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.

Files changed (79) hide show
  1. checksums.yaml +9 -9
  2. data/.gitignore +7 -0
  3. data/.rubocop.yml +5 -0
  4. data/.travis.yml +3 -3
  5. data/CHANGELOG.md +42 -3
  6. data/CONTRIBUTING.md +118 -0
  7. data/Gemfile +4 -4
  8. data/README.md +312 -52
  9. data/Rakefile +6 -1
  10. data/UPGRADING.md +124 -0
  11. data/lib/grape.rb +2 -0
  12. data/lib/grape/api.rb +95 -44
  13. data/lib/grape/cookies.rb +0 -2
  14. data/lib/grape/endpoint.rb +63 -39
  15. data/lib/grape/error_formatter/base.rb +0 -3
  16. data/lib/grape/error_formatter/json.rb +0 -2
  17. data/lib/grape/error_formatter/txt.rb +0 -2
  18. data/lib/grape/error_formatter/xml.rb +0 -2
  19. data/lib/grape/exceptions/base.rb +0 -2
  20. data/lib/grape/exceptions/incompatible_option_values.rb +0 -3
  21. data/lib/grape/exceptions/invalid_formatter.rb +0 -3
  22. data/lib/grape/exceptions/invalid_versioner_option.rb +0 -4
  23. data/lib/grape/exceptions/invalid_with_option_for_represent.rb +0 -2
  24. data/lib/grape/exceptions/missing_mime_type.rb +0 -4
  25. data/lib/grape/exceptions/missing_option.rb +0 -3
  26. data/lib/grape/exceptions/missing_vendor_option.rb +0 -3
  27. data/lib/grape/exceptions/unknown_options.rb +0 -4
  28. data/lib/grape/exceptions/unknown_validator.rb +0 -2
  29. data/lib/grape/exceptions/validation_errors.rb +6 -5
  30. data/lib/grape/formatter/base.rb +0 -3
  31. data/lib/grape/formatter/json.rb +0 -2
  32. data/lib/grape/formatter/serializable_hash.rb +15 -16
  33. data/lib/grape/formatter/txt.rb +0 -2
  34. data/lib/grape/formatter/xml.rb +0 -2
  35. data/lib/grape/http/request.rb +2 -4
  36. data/lib/grape/locale/en.yml +1 -1
  37. data/lib/grape/middleware/auth/oauth2.rb +15 -6
  38. data/lib/grape/middleware/base.rb +7 -7
  39. data/lib/grape/middleware/error.rb +11 -6
  40. data/lib/grape/middleware/formatter.rb +80 -78
  41. data/lib/grape/middleware/globals.rb +13 -0
  42. data/lib/grape/middleware/versioner/accept_version_header.rb +0 -2
  43. data/lib/grape/middleware/versioner/header.rb +5 -3
  44. data/lib/grape/middleware/versioner/param.rb +2 -4
  45. data/lib/grape/middleware/versioner/path.rb +3 -4
  46. data/lib/grape/namespace.rb +0 -1
  47. data/lib/grape/parser/base.rb +0 -3
  48. data/lib/grape/parser/json.rb +0 -2
  49. data/lib/grape/parser/xml.rb +0 -2
  50. data/lib/grape/path.rb +1 -3
  51. data/lib/grape/route.rb +0 -3
  52. data/lib/grape/util/hash_stack.rb +1 -1
  53. data/lib/grape/validations.rb +72 -22
  54. data/lib/grape/validations/coerce.rb +5 -4
  55. data/lib/grape/validations/default.rb +5 -3
  56. data/lib/grape/validations/presence.rb +1 -1
  57. data/lib/grape/validations/regexp.rb +0 -2
  58. data/lib/grape/validations/values.rb +2 -1
  59. data/lib/grape/version.rb +1 -1
  60. data/spec/grape/api_spec.rb +385 -96
  61. data/spec/grape/endpoint_spec.rb +162 -15
  62. data/spec/grape/entity_spec.rb +25 -0
  63. data/spec/grape/exceptions/validation_errors_spec.rb +19 -0
  64. data/spec/grape/middleware/auth/oauth2_spec.rb +60 -15
  65. data/spec/grape/middleware/base_spec.rb +3 -8
  66. data/spec/grape/middleware/error_spec.rb +2 -2
  67. data/spec/grape/middleware/exception_spec.rb +4 -4
  68. data/spec/grape/middleware/formatter_spec.rb +7 -4
  69. data/spec/grape/middleware/versioner/param_spec.rb +8 -7
  70. data/spec/grape/path_spec.rb +24 -14
  71. data/spec/grape/util/hash_stack_spec.rb +8 -8
  72. data/spec/grape/validations/coerce_spec.rb +75 -33
  73. data/spec/grape/validations/default_spec.rb +57 -0
  74. data/spec/grape/validations/presence_spec.rb +13 -11
  75. data/spec/grape/validations/values_spec.rb +76 -2
  76. data/spec/grape/validations_spec.rb +443 -20
  77. data/spec/spec_helper.rb +2 -2
  78. data/spec/support/content_type_helpers.rb +11 -0
  79. metadata +9 -38
@@ -4,8 +4,6 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'support'))
4
4
 
5
5
  require 'grape'
6
6
 
7
- # require 'grape-entity'
8
-
9
7
  require 'rubygems'
10
8
  require 'bundler'
11
9
  Bundler.setup :default, :test
@@ -20,6 +18,8 @@ Dir["#{File.dirname(__FILE__)}/support/*.rb"].each do |file|
20
18
  require file
21
19
  end
22
20
 
21
+ I18n.enforce_available_locales = false
22
+
23
23
  RSpec.configure do |config|
24
24
  config.include Rack::Test::Methods
25
25
  end
@@ -0,0 +1,11 @@
1
+ module ContentTypeHelpers
2
+ %w(put patch post delete).each do |method|
3
+ define_method :"#{method}_with_json" do |uri, params = {}, env = {}, &block|
4
+ params = params.to_json
5
+ env["CONTENT_TYPE"] ||= "application/json"
6
+ send(method, uri, params, env, &block)
7
+ end
8
+ end
9
+ end
10
+
11
+ include(ContentTypeHelpers)
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: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-19 00:00:00.000000000 Z
11
+ date: 2014-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -247,12 +247,14 @@ files:
247
247
  - .travis.yml
248
248
  - .yardopts
249
249
  - CHANGELOG.md
250
+ - CONTRIBUTING.md
250
251
  - Gemfile
251
252
  - Guardfile
252
253
  - LICENSE
253
254
  - README.md
254
255
  - RELEASING.md
255
256
  - Rakefile
257
+ - UPGRADING.md
256
258
  - grape.gemspec
257
259
  - lib/grape.rb
258
260
  - lib/grape/api.rb
@@ -289,6 +291,7 @@ files:
289
291
  - lib/grape/middleware/error.rb
290
292
  - lib/grape/middleware/filter.rb
291
293
  - lib/grape/middleware/formatter.rb
294
+ - lib/grape/middleware/globals.rb
292
295
  - lib/grape/middleware/versioner.rb
293
296
  - lib/grape/middleware/versioner/accept_version_header.rb
294
297
  - lib/grape/middleware/versioner/header.rb
@@ -319,6 +322,7 @@ files:
319
322
  - spec/grape/exceptions/missing_option_spec.rb
320
323
  - spec/grape/exceptions/unknown_options_spec.rb
321
324
  - spec/grape/exceptions/unknown_validator_spec.rb
325
+ - spec/grape/exceptions/validation_errors_spec.rb
322
326
  - spec/grape/middleware/auth/basic_spec.rb
323
327
  - spec/grape/middleware/auth/digest_spec.rb
324
328
  - spec/grape/middleware/auth/oauth2_spec.rb
@@ -343,6 +347,7 @@ files:
343
347
  - spec/shared/versioning_examples.rb
344
348
  - spec/spec_helper.rb
345
349
  - spec/support/basic_auth_encode_helpers.rb
350
+ - spec/support/content_type_helpers.rb
346
351
  - spec/support/versioned_helpers.rb
347
352
  homepage: https://github.com/intridea/grape
348
353
  licenses:
@@ -364,43 +369,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
364
369
  version: '0'
365
370
  requirements: []
366
371
  rubyforge_project: grape
367
- rubygems_version: 2.0.7
372
+ rubygems_version: 2.2.2
368
373
  signing_key:
369
374
  specification_version: 4
370
375
  summary: A simple Ruby framework for building REST-like APIs.
371
- test_files:
372
- - spec/grape/api_spec.rb
373
- - spec/grape/endpoint_spec.rb
374
- - spec/grape/entity_spec.rb
375
- - spec/grape/exceptions/invalid_formatter_spec.rb
376
- - spec/grape/exceptions/invalid_versioner_option_spec.rb
377
- - spec/grape/exceptions/missing_mime_type_spec.rb
378
- - spec/grape/exceptions/missing_option_spec.rb
379
- - spec/grape/exceptions/unknown_options_spec.rb
380
- - spec/grape/exceptions/unknown_validator_spec.rb
381
- - spec/grape/middleware/auth/basic_spec.rb
382
- - spec/grape/middleware/auth/digest_spec.rb
383
- - spec/grape/middleware/auth/oauth2_spec.rb
384
- - spec/grape/middleware/base_spec.rb
385
- - spec/grape/middleware/error_spec.rb
386
- - spec/grape/middleware/exception_spec.rb
387
- - spec/grape/middleware/formatter_spec.rb
388
- - spec/grape/middleware/versioner/accept_version_header_spec.rb
389
- - spec/grape/middleware/versioner/header_spec.rb
390
- - spec/grape/middleware/versioner/param_spec.rb
391
- - spec/grape/middleware/versioner/path_spec.rb
392
- - spec/grape/middleware/versioner_spec.rb
393
- - spec/grape/path_spec.rb
394
- - spec/grape/util/hash_stack_spec.rb
395
- - spec/grape/validations/coerce_spec.rb
396
- - spec/grape/validations/default_spec.rb
397
- - spec/grape/validations/presence_spec.rb
398
- - spec/grape/validations/regexp_spec.rb
399
- - spec/grape/validations/values_spec.rb
400
- - spec/grape/validations/zh-CN.yml
401
- - spec/grape/validations_spec.rb
402
- - spec/shared/versioning_examples.rb
403
- - spec/spec_helper.rb
404
- - spec/support/basic_auth_encode_helpers.rb
405
- - spec/support/versioned_helpers.rb
376
+ test_files: []
406
377
  has_rdoc: