grape 0.1.1 → 0.1.3

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 (115) hide show
  1. data/.gitignore +1 -1
  2. data/.yardoc/checksums +13 -0
  3. data/.yardoc/objects/Grape.dat +0 -0
  4. data/.yardoc/objects/Grape/API.dat +0 -0
  5. data/.yardoc/objects/Grape/API/auth_c.dat +0 -0
  6. data/.yardoc/objects/Grape/API/build_endpoint_c.dat +0 -0
  7. data/.yardoc/objects/Grape/API/call_c.dat +0 -0
  8. data/.yardoc/objects/Grape/API/compile_path_c.dat +0 -0
  9. data/.yardoc/objects/Grape/API/default_format_c.dat +0 -0
  10. data/.yardoc/objects/Grape/API/delete_c.dat +0 -0
  11. data/.yardoc/objects/Grape/API/get_c.dat +0 -0
  12. data/.yardoc/objects/Grape/API/group_c.dat +0 -0
  13. data/.yardoc/objects/Grape/API/head_c.dat +0 -0
  14. data/.yardoc/objects/Grape/API/helpers_c.dat +0 -0
  15. data/.yardoc/objects/Grape/API/http_basic_c.dat +0 -0
  16. data/.yardoc/objects/Grape/API/inherited_c.dat +0 -0
  17. data/.yardoc/objects/Grape/API/logger_c.dat +0 -0
  18. data/.yardoc/objects/Grape/API/namespace_c.dat +0 -0
  19. data/.yardoc/objects/Grape/API/nest_c.dat +0 -0
  20. data/.yardoc/objects/Grape/API/post_c.dat +0 -0
  21. data/.yardoc/objects/Grape/API/prefix_c.dat +0 -0
  22. data/.yardoc/objects/Grape/API/put_c.dat +0 -0
  23. data/.yardoc/objects/Grape/API/reset_21_c.dat +0 -0
  24. data/.yardoc/objects/Grape/API/resource_c.dat +0 -0
  25. data/.yardoc/objects/Grape/API/resources_c.dat +0 -0
  26. data/.yardoc/objects/Grape/API/route_c.dat +0 -0
  27. data/.yardoc/objects/Grape/API/route_set_c.dat +0 -0
  28. data/.yardoc/objects/Grape/API/scope_c.dat +0 -0
  29. data/.yardoc/objects/Grape/API/set_c.dat +0 -0
  30. data/.yardoc/objects/Grape/API/settings_c.dat +0 -0
  31. data/.yardoc/objects/Grape/API/settings_stack_c.dat +0 -0
  32. data/.yardoc/objects/Grape/API/version_c.dat +0 -0
  33. data/.yardoc/objects/Grape/Endpoint.dat +0 -0
  34. data/.yardoc/objects/Grape/Endpoint/block_3D_c.dat +0 -0
  35. data/.yardoc/objects/Grape/Endpoint/block_c.dat +0 -0
  36. data/.yardoc/objects/Grape/Endpoint/call_c.dat +0 -0
  37. data/.yardoc/objects/Grape/Endpoint/call_i.dat +0 -0
  38. data/.yardoc/objects/Grape/Endpoint/env_i.dat +0 -0
  39. data/.yardoc/objects/Grape/Endpoint/error_21_i.dat +0 -0
  40. data/.yardoc/objects/Grape/Endpoint/generate_c.dat +0 -0
  41. data/.yardoc/objects/Grape/Endpoint/header_i.dat +0 -0
  42. data/.yardoc/objects/Grape/Endpoint/params_i.dat +0 -0
  43. data/.yardoc/objects/Grape/Endpoint/request_i.dat +0 -0
  44. data/.yardoc/objects/Grape/Endpoint/status_i.dat +0 -0
  45. data/.yardoc/objects/Grape/Endpoint/version_i.dat +0 -0
  46. data/.yardoc/objects/Grape/Middleware.dat +0 -0
  47. data/.yardoc/objects/Grape/Middleware/Auth.dat +0 -0
  48. data/.yardoc/objects/Grape/Middleware/Auth/Basic.dat +0 -0
  49. data/.yardoc/objects/Grape/Middleware/Auth/Basic/authenticator_i.dat +0 -0
  50. data/.yardoc/objects/Grape/Middleware/Auth/Basic/basic_request_i.dat +0 -0
  51. data/.yardoc/objects/Grape/Middleware/Auth/Basic/before_i.dat +0 -0
  52. data/.yardoc/objects/Grape/Middleware/Auth/Basic/credentials_i.dat +0 -0
  53. data/.yardoc/objects/Grape/Middleware/Auth/Basic/initialize_i.dat +0 -0
  54. data/.yardoc/objects/Grape/Middleware/Auth/OAuth2.dat +0 -0
  55. data/.yardoc/objects/Grape/Middleware/Auth/OAuth2/before_i.dat +0 -0
  56. data/.yardoc/objects/Grape/Middleware/Auth/OAuth2/default_options_i.dat +0 -0
  57. data/.yardoc/objects/Grape/Middleware/Auth/OAuth2/error_out_i.dat +0 -0
  58. data/.yardoc/objects/Grape/Middleware/Auth/OAuth2/parse_authorization_header_i.dat +0 -0
  59. data/.yardoc/objects/Grape/Middleware/Auth/OAuth2/token_class_i.dat +0 -0
  60. data/.yardoc/objects/Grape/Middleware/Auth/OAuth2/verify_token_i.dat +0 -0
  61. data/.yardoc/objects/Grape/Middleware/Base.dat +0 -0
  62. data/.yardoc/objects/Grape/Middleware/Base/after_i.dat +0 -0
  63. data/.yardoc/objects/Grape/Middleware/Base/app_i.dat +0 -0
  64. data/.yardoc/objects/Grape/Middleware/Base/before_i.dat +0 -0
  65. data/.yardoc/objects/Grape/Middleware/Base/call_21_i.dat +0 -0
  66. data/.yardoc/objects/Grape/Middleware/Base/call_i.dat +0 -0
  67. data/.yardoc/objects/Grape/Middleware/Base/default_options_i.dat +0 -0
  68. data/.yardoc/objects/Grape/Middleware/Base/env_i.dat +0 -0
  69. data/.yardoc/objects/Grape/Middleware/Base/initialize_i.dat +0 -0
  70. data/.yardoc/objects/Grape/Middleware/Base/options_i.dat +0 -0
  71. data/.yardoc/objects/Grape/Middleware/Base/request_i.dat +0 -0
  72. data/.yardoc/objects/Grape/Middleware/Base/response_i.dat +0 -0
  73. data/.yardoc/objects/Grape/Middleware/Error.dat +0 -0
  74. data/.yardoc/objects/Grape/Middleware/Error/call_21_i.dat +0 -0
  75. data/.yardoc/objects/Grape/Middleware/Error/error_response_i.dat +0 -0
  76. data/.yardoc/objects/Grape/Middleware/Formatter.dat +0 -0
  77. data/.yardoc/objects/Grape/Middleware/Formatter/CONTENT_TYPES.dat +0 -0
  78. data/.yardoc/objects/Grape/Middleware/Formatter/after_i.dat +0 -0
  79. data/.yardoc/objects/Grape/Middleware/Formatter/before_i.dat +0 -0
  80. data/.yardoc/objects/Grape/Middleware/Formatter/content_types_i.dat +0 -0
  81. data/.yardoc/objects/Grape/Middleware/Formatter/default_options_i.dat +0 -0
  82. data/.yardoc/objects/Grape/Middleware/Formatter/encode_json_i.dat +0 -0
  83. data/.yardoc/objects/Grape/Middleware/Formatter/encode_txt_i.dat +0 -0
  84. data/.yardoc/objects/Grape/Middleware/Formatter/format_from_extension_i.dat +0 -0
  85. data/.yardoc/objects/Grape/Middleware/Formatter/format_from_header_i.dat +0 -0
  86. data/.yardoc/objects/Grape/Middleware/Formatter/headers_i.dat +0 -0
  87. data/.yardoc/objects/Grape/Middleware/Formatter/mime_array_i.dat +0 -0
  88. data/.yardoc/objects/Grape/Middleware/Formatter/mime_types_i.dat +0 -0
  89. data/.yardoc/objects/Grape/Middleware/Prefixer.dat +0 -0
  90. data/.yardoc/objects/Grape/Middleware/Prefixer/before_i.dat +0 -0
  91. data/.yardoc/objects/Grape/Middleware/Prefixer/prefix_i.dat +0 -0
  92. data/.yardoc/objects/Grape/Middleware/Versioner.dat +0 -0
  93. data/.yardoc/objects/Grape/Middleware/Versioner/before_i.dat +0 -0
  94. data/.yardoc/objects/Grape/Middleware/Versioner/default_options_i.dat +0 -0
  95. data/.yardoc/objects/Grape/MiddlewareStack.dat +0 -0
  96. data/.yardoc/objects/Grape/MiddlewareStack/initialize_i.dat +0 -0
  97. data/.yardoc/objects/Grape/MiddlewareStack/stack_i.dat +0 -0
  98. data/.yardoc/objects/Grape/MiddlewareStack/to_app_i.dat +0 -0
  99. data/.yardoc/objects/Grape/MiddlewareStack/use_i.dat +0 -0
  100. data/.yardoc/objects/root.dat +0 -0
  101. data/.yardoc/proxy_types +2 -0
  102. data/Gemfile +2 -1
  103. data/Gemfile.lock +6 -0
  104. data/README.markdown +3 -3
  105. data/VERSION +1 -1
  106. data/grape.gemspec +108 -6
  107. data/lib/grape/api.rb +59 -21
  108. data/lib/grape/middleware/base.rb +1 -1
  109. data/lib/grape/middleware/error.rb +1 -1
  110. data/spec/grape/api_spec.rb +85 -4
  111. data/spec/grape/endpoint_spec.rb +13 -1
  112. data/spec/grape/middleware/auth/basic_spec.rb +2 -2
  113. metadata +161 -49
  114. data/lib/grape/middleware_stack.rb +0 -35
  115. data/spec/grape/middleware_stack_spec.rb +0 -47
@@ -1,35 +0,0 @@
1
- require 'grape'
2
-
3
- module Grape
4
- class MiddlewareStack
5
- attr_reader :stack
6
-
7
- def initialize
8
- @stack = []
9
- end
10
-
11
- # Add a new middleware to the stack. Syntax
12
- # is identical to normal middleware <tt>#use</tt>
13
- # functionality.
14
- #
15
- # @param [Class] klass The middleware class.
16
- def use(klass, *args)
17
- if index = @stack.index(@stack.find{|a| a.first == klass})
18
- @stack[index] = [klass, *args]
19
- else
20
- @stack << [klass, *args]
21
- end
22
- end
23
-
24
- # Apply this middleware stack to a
25
- # Rack application.
26
- def to_app(app)
27
- b = Rack::Builder.new
28
- for middleware in stack
29
- b.use *middleware
30
- end
31
- b.run app
32
- b.to_app
33
- end
34
- end
35
- end
@@ -1,47 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Grape::MiddlewareStack do
4
- subject { Grape::MiddlewareStack.new }
5
-
6
- it 'should be able to add middlewares' do
7
- subject.use Grape::Middleware::Error
8
- subject.stack.first.should == [Grape::Middleware::Error]
9
- end
10
-
11
- context 'class uniqueness' do
12
- it 'should not increase the stack size when doubling up on a use' do
13
- 2.times{ subject.use Grape::Middleware::Error }
14
- subject.stack.size.should == 1
15
- end
16
-
17
- it 'should increase the stack size when a novel class is added' do
18
- subject.use Grape::Middleware::Error
19
- subject.use Grape::Middleware::Prefixer
20
- subject.use Grape::Middleware::Error
21
- subject.stack.should == [[Grape::Middleware::Error], [Grape::Middleware::Prefixer]]
22
- end
23
- end
24
-
25
- describe '#run' do
26
- class ExampleMiddleware
27
- def initialize(app, say = 'what')
28
- @app = app
29
- @say = say
30
- end
31
-
32
- def call(env)
33
- (env['say'] ||= []) << @say
34
- @app.call(env)
35
- end
36
- end
37
-
38
- before do
39
- subject.use ExampleMiddleware
40
- subject.use ExampleMiddleware, 'yo'
41
- end
42
-
43
- it 'should call the middlewares in the stack' do
44
- subject.to_app(lambda{|env| env['say'].should == ['yo']}).call({})
45
- end
46
- end
47
- end