grape 0.4.0 → 0.4.1
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.
- data/CHANGELOG.md +7 -1
- data/README.md +2 -2
- data/lib/grape.rb +1 -0
- data/lib/grape/endpoint.rb +1 -0
- data/lib/grape/version.rb +1 -1
- data/spec/grape/api_spec.rb +40 -6
- metadata +36 -6
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
0.4.1 (4/1/2013)
|
2
|
+
================
|
3
|
+
|
4
|
+
* [#375](https://github.com/intridea/grape/pull/375): Fix: throwing an `:error` inside a middleware doesn't respect the `format` settings - [@dblock](https://github.com/dblock).
|
5
|
+
* Your contribution here.
|
6
|
+
|
1
7
|
0.4.0 (3/17/2013)
|
2
8
|
=================
|
3
9
|
|
@@ -11,7 +17,7 @@
|
|
11
17
|
* [#357](https://github.com/intridea/grape/pull/357): Grape now requires Rack 1.3.0 or newer - [@jhecking](https://github.com/jhecking).
|
12
18
|
* [#320](https://github.com/intridea/grape/issues/320): API `namespace` now supports `requirements` - [@niedhui](https://github.com/niedhui).
|
13
19
|
* [#353](https://github.com/intridea/grape/issues/353): Revert to standard Ruby logger formatter, `require active_support/all` if you want old behavior - [@rhunter](https://github.com/rhunter), [@dblock](https://github.com/dblock).
|
14
|
-
* Fix: `undefined method
|
20
|
+
* Fix: `undefined method 'call' for nil:NilClass` for an API method implementation without a block, now returns an empty string - [@dblock](https://github.com/dblock).
|
15
21
|
|
16
22
|
0.3.2 (2/28/2013)
|
17
23
|
=================
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ content negotiation, versioning and much more.
|
|
12
12
|
|
13
13
|
## Stable Release
|
14
14
|
|
15
|
-
You're reading the documentation for the stable
|
15
|
+
You're reading the documentation for the stable 0.4.1 release of Grape.
|
16
16
|
|
17
17
|
## Project Tracking
|
18
18
|
|
@@ -1139,7 +1139,7 @@ describe Twitter::API do
|
|
1139
1139
|
end
|
1140
1140
|
```
|
1141
1141
|
|
1142
|
-
In Rails, HTTP request tests would go into the `spec/
|
1142
|
+
In Rails, HTTP request tests would go into the `spec/requests` group. You may want your API code to go into
|
1143
1143
|
`app/api` - you can match that layout under `spec` by adding the following in `spec/spec_helper.rb`.
|
1144
1144
|
|
1145
1145
|
```ruby
|
data/lib/grape.rb
CHANGED
@@ -8,6 +8,7 @@ require 'rack/auth/digest/md5'
|
|
8
8
|
require 'hashie'
|
9
9
|
require 'active_support/core_ext/hash/indifferent_access'
|
10
10
|
require 'active_support/ordered_hash'
|
11
|
+
require 'active_support/core_ext/object/conversions'
|
11
12
|
require 'grape/util/deep_merge'
|
12
13
|
require 'grape/util/content_types'
|
13
14
|
require 'multi_json'
|
data/lib/grape/endpoint.rb
CHANGED
@@ -395,6 +395,7 @@ module Grape
|
|
395
395
|
|
396
396
|
b.use Rack::Head
|
397
397
|
b.use Grape::Middleware::Error,
|
398
|
+
:format => settings[:format],
|
398
399
|
:default_status => settings[:default_error_status] || 403,
|
399
400
|
:rescue_all => settings[:rescue_all],
|
400
401
|
:rescued_errors => aggregate_setting(:rescued_errors),
|
data/lib/grape/version.rb
CHANGED
data/spec/grape/api_spec.rb
CHANGED
@@ -1739,7 +1739,7 @@ describe Grape::API do
|
|
1739
1739
|
end
|
1740
1740
|
end
|
1741
1741
|
end
|
1742
|
-
|
1742
|
+
describe '.format' do
|
1743
1743
|
context ':txt' do
|
1744
1744
|
before(:each) do
|
1745
1745
|
subject.format :txt
|
@@ -1801,33 +1801,48 @@ describe Grape::API do
|
|
1801
1801
|
get '/meaning_of_life', {}, { 'HTTP_ACCEPT' => 'text/html' }
|
1802
1802
|
last_response.body.should == { :meaning_of_life => 42 }.to_json
|
1803
1803
|
end
|
1804
|
+
it 'raised :error from middleware' do
|
1805
|
+
middleware = Class.new(Grape::Middleware::Base) do
|
1806
|
+
def before
|
1807
|
+
throw :error, :message => "Unauthorized", :status => 42
|
1808
|
+
end
|
1809
|
+
end
|
1810
|
+
subject.use middleware
|
1811
|
+
subject.get do
|
1812
|
+
|
1813
|
+
end
|
1814
|
+
get "/"
|
1815
|
+
last_response.status.should == 42
|
1816
|
+
last_response.body.should == { :error => "Unauthorized" }.to_json
|
1817
|
+
end
|
1818
|
+
|
1804
1819
|
end
|
1805
1820
|
context ':serializable_hash' do
|
1806
1821
|
before(:each) do
|
1807
|
-
class
|
1822
|
+
class SerializableHashExample
|
1808
1823
|
def serializable_hash
|
1809
|
-
{:abc => 'def'}
|
1824
|
+
{ :abc => 'def' }
|
1810
1825
|
end
|
1811
1826
|
end
|
1812
1827
|
subject.format :serializable_hash
|
1813
1828
|
end
|
1814
1829
|
it 'instance' do
|
1815
1830
|
subject.get '/example' do
|
1816
|
-
|
1831
|
+
SerializableHashExample.new
|
1817
1832
|
end
|
1818
1833
|
get '/example'
|
1819
1834
|
last_response.body.should == '{"abc":"def"}'
|
1820
1835
|
end
|
1821
1836
|
it 'root' do
|
1822
1837
|
subject.get '/example' do
|
1823
|
-
{ "root" =>
|
1838
|
+
{ "root" => SerializableHashExample.new }
|
1824
1839
|
end
|
1825
1840
|
get '/example'
|
1826
1841
|
last_response.body.should == '{"root":{"abc":"def"}}'
|
1827
1842
|
end
|
1828
1843
|
it 'array' do
|
1829
1844
|
subject.get '/examples' do
|
1830
|
-
[
|
1845
|
+
[ SerializableHashExample.new, SerializableHashExample.new ]
|
1831
1846
|
end
|
1832
1847
|
get '/examples'
|
1833
1848
|
last_response.body.should == '[{"abc":"def"},{"abc":"def"}]'
|
@@ -1879,6 +1894,25 @@ XML
|
|
1879
1894
|
<string>example1</string>
|
1880
1895
|
<string>example2</string>
|
1881
1896
|
</strings>
|
1897
|
+
XML
|
1898
|
+
end
|
1899
|
+
it 'raised :error from middleware' do
|
1900
|
+
middleware = Class.new(Grape::Middleware::Base) do
|
1901
|
+
def before
|
1902
|
+
throw :error, :message => "Unauthorized", :status => 42
|
1903
|
+
end
|
1904
|
+
end
|
1905
|
+
subject.use middleware
|
1906
|
+
subject.get do
|
1907
|
+
|
1908
|
+
end
|
1909
|
+
get "/"
|
1910
|
+
last_response.status.should == 42
|
1911
|
+
last_response.body.should == <<-XML
|
1912
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
1913
|
+
<error>
|
1914
|
+
<message>Unauthorized</message>
|
1915
|
+
</error>
|
1882
1916
|
XML
|
1883
1917
|
end
|
1884
1918
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -378,7 +378,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
378
378
|
version: '0'
|
379
379
|
segments:
|
380
380
|
- 0
|
381
|
-
hash: -
|
381
|
+
hash: -2839578735981182036
|
382
382
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
383
383
|
none: false
|
384
384
|
requirements:
|
@@ -387,12 +387,42 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
387
387
|
version: '0'
|
388
388
|
segments:
|
389
389
|
- 0
|
390
|
-
hash: -
|
390
|
+
hash: -2839578735981182036
|
391
391
|
requirements: []
|
392
392
|
rubyforge_project: grape
|
393
|
-
rubygems_version: 1.8.
|
393
|
+
rubygems_version: 1.8.25
|
394
394
|
signing_key:
|
395
395
|
specification_version: 3
|
396
396
|
summary: A simple Ruby framework for building REST-like APIs.
|
397
|
-
test_files:
|
397
|
+
test_files:
|
398
|
+
- spec/grape/api_spec.rb
|
399
|
+
- spec/grape/endpoint_spec.rb
|
400
|
+
- spec/grape/entity_spec.rb
|
401
|
+
- spec/grape/exceptions/invalid_formatter_spec.rb
|
402
|
+
- spec/grape/exceptions/invalid_versioner_option_spec.rb
|
403
|
+
- spec/grape/exceptions/missing_mime_type_spec.rb
|
404
|
+
- spec/grape/exceptions/missing_option_spec.rb
|
405
|
+
- spec/grape/exceptions/unknown_options_spec.rb
|
406
|
+
- spec/grape/exceptions/unknown_validator_spec.rb
|
407
|
+
- spec/grape/middleware/auth/basic_spec.rb
|
408
|
+
- spec/grape/middleware/auth/digest_spec.rb
|
409
|
+
- spec/grape/middleware/auth/oauth2_spec.rb
|
410
|
+
- spec/grape/middleware/base_spec.rb
|
411
|
+
- spec/grape/middleware/error_spec.rb
|
412
|
+
- spec/grape/middleware/exception_spec.rb
|
413
|
+
- spec/grape/middleware/formatter_spec.rb
|
414
|
+
- spec/grape/middleware/versioner/header_spec.rb
|
415
|
+
- spec/grape/middleware/versioner/param_spec.rb
|
416
|
+
- spec/grape/middleware/versioner/path_spec.rb
|
417
|
+
- spec/grape/middleware/versioner_spec.rb
|
418
|
+
- spec/grape/util/hash_stack_spec.rb
|
419
|
+
- spec/grape/validations/coerce_spec.rb
|
420
|
+
- spec/grape/validations/presence_spec.rb
|
421
|
+
- spec/grape/validations/regexp_spec.rb
|
422
|
+
- spec/grape/validations/zh-CN.yml
|
423
|
+
- spec/grape/validations_spec.rb
|
424
|
+
- spec/shared/versioning_examples.rb
|
425
|
+
- spec/spec_helper.rb
|
426
|
+
- spec/support/basic_auth_encode_helpers.rb
|
427
|
+
- spec/support/versioned_helpers.rb
|
398
428
|
has_rdoc:
|