grape 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -2
- data/Gemfile.lock +1 -1
- data/README.md +2 -3
- data/UPGRADING.md +34 -0
- data/lib/grape/api/instance.rb +4 -0
- data/lib/grape/version.rb +1 -1
- data/pkg/grape-1.2.0.gem +0 -0
- data/spec/grape/named_api_spec.rb +19 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98967e931efbc7d185d03dc983f3c1b248178e1e19de4b3179f4ed3fc7971efb
|
4
|
+
data.tar.gz: '009bd8cec6cfb9e2eb18864635b9785a36b1540efc4c838d5995c18b8b9e2b62'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d43afee6bb67478c37c818bc7c14e0e39d04b7d1c6fed6232e5b7b42099acb1bea99c729770f93b2e8e08c028db764267eb26ce4c7d880e39e974a6f5014e01
|
7
|
+
data.tar.gz: 2ae00e36c84235da52059161f224c383ce9826878034d101c8bbaf91c94575e3c762e6d622bbd2d37b4f52c40a162c71c3c675d2e929ed4d8a161ae3364f5528
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,26 @@
|
|
1
|
-
### 1.2.
|
1
|
+
### 1.2.2 (Next)
|
2
2
|
|
3
3
|
#### Features
|
4
4
|
|
5
5
|
* Your contribution here.
|
6
|
+
|
7
|
+
#### Fixes
|
8
|
+
|
9
|
+
* Your contribution here.
|
10
|
+
|
11
|
+
### 1.2.1 (11/28/2018)
|
12
|
+
|
13
|
+
#### Features
|
14
|
+
|
15
|
+
|
16
|
+
#### Fixes
|
17
|
+
|
18
|
+
* [#1825](https://github.com/ruby-grape/grape/pull/1825): `to_s` on a mounted class now responses with the API name - [@myxoh](https://github.com/myxoh).
|
19
|
+
|
20
|
+
### 1.2.0 (11/26/2018)
|
21
|
+
|
22
|
+
#### Features
|
23
|
+
|
6
24
|
* [#1813](https://github.com/ruby-grape/grape/pull/1813): Add ruby 2.5 support, drop 2.2. Update rails version in travis - [@darren987469](https://github.com/darren987469).
|
7
25
|
* [#1803](https://github.com/ruby-grape/grape/pull/1803): Adds the ability to re-mount all endpoints in any location - [@myxoh](https://github.com/myxoh).
|
8
26
|
* [#1795](https://github.com/ruby-grape/grape/pull/1795): Fix vendor/subtype parsing of an invalid Accept header - [@bschmeck](https://github.com/bschmeck).
|
@@ -10,7 +28,6 @@
|
|
10
28
|
|
11
29
|
#### Fixes
|
12
30
|
|
13
|
-
* Your contribution here.
|
14
31
|
* [#1796](https://github.com/ruby-grape/grape/pull/1796): Fix crash when available locales are enforced but fallback locale unavailable - [@Morred](https://github.com/Morred).
|
15
32
|
* [#1776](https://github.com/ruby-grape/grape/pull/1776): Validate response returned by the exception handler - [@darren987469](https://github.com/darren987469).
|
16
33
|
* [#1787](https://github.com/ruby-grape/grape/pull/1787): Add documented but not implemented ability to `.insert` a middleware in the stack - [@michaellennox](https://github.com/michaellennox).
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/grape.svg)](http://badge.fury.io/rb/grape)
|
4
4
|
[![Build Status](https://travis-ci.org/ruby-grape/grape.svg?branch=master)](https://travis-ci.org/ruby-grape/grape)
|
5
|
-
[![Dependency Status](https://gemnasium.com/ruby-grape/grape.svg)](https://gemnasium.com/ruby-grape/grape)
|
6
5
|
[![Code Climate](https://codeclimate.com/github/ruby-grape/grape.svg)](https://codeclimate.com/github/ruby-grape/grape)
|
7
6
|
[![Coverage Status](https://coveralls.io/repos/github/ruby-grape/grape/badge.svg?branch=master)](https://coveralls.io/github/ruby-grape/grape?branch=master)
|
8
7
|
[![Inline docs](https://inch-ci.org/github/ruby-grape/grape.svg)](https://inch-ci.org/github/ruby-grape/grape)
|
@@ -147,9 +146,9 @@ content negotiation, versioning and much more.
|
|
147
146
|
|
148
147
|
## Stable Release
|
149
148
|
|
150
|
-
You're reading the documentation for the next release of Grape, which should be **1.
|
149
|
+
You're reading the documentation for the next release of Grape, which should be **1.2.2**.
|
151
150
|
Please read [UPGRADING](UPGRADING.md) when upgrading from a previous version.
|
152
|
-
The current stable release is [1.1
|
151
|
+
The current stable release is [1.2.1](https://github.com/ruby-grape/grape/blob/v1.2.1/README.md).
|
153
152
|
|
154
153
|
## Project Resources
|
155
154
|
|
data/UPGRADING.md
CHANGED
@@ -1,10 +1,27 @@
|
|
1
1
|
Upgrading Grape
|
2
2
|
===============
|
3
3
|
|
4
|
+
### Upgrading to >= 1.2.1
|
5
|
+
|
6
|
+
#### Obtaining the name of a mounted class
|
7
|
+
|
8
|
+
In order to make obtaining the name of a mounted class simpler, we've delegated `.to_s` to `base.name`
|
9
|
+
|
10
|
+
**Deprecated in 1.2.0**
|
11
|
+
```ruby
|
12
|
+
payload[:endpoint].options[:for].name
|
13
|
+
```
|
14
|
+
**New**
|
15
|
+
```ruby
|
16
|
+
payload[:endpoint].options[:for].to_s
|
17
|
+
```
|
18
|
+
|
4
19
|
### Upgrading to >= 1.2.0
|
5
20
|
|
6
21
|
#### Changes in the Grape::API class
|
7
22
|
|
23
|
+
##### Patching the class
|
24
|
+
|
8
25
|
In an effort to make APIs re-mountable, The class `Grape::API` no longer refers to an API instance,
|
9
26
|
rather, what used to be `Grape::API` is now `Grape::API::Instance` and `Grape::API` was replaced
|
10
27
|
with a class that can contain several instances of `Grape::API`.
|
@@ -29,6 +46,23 @@ class Grape::API::Instance
|
|
29
46
|
end
|
30
47
|
```
|
31
48
|
|
49
|
+
##### `name` (and other caveats) of the mounted API
|
50
|
+
|
51
|
+
After the patch, the mounted API is no longer a Named class inheriting from `Grape::API`, it is an anonymous class
|
52
|
+
which inherit from `Grape::API::Instance`.
|
53
|
+
What this means in practice, is:
|
54
|
+
- Generally: you can access the named class from the instance calling the getter `base`.
|
55
|
+
- In particular: If you need the `name`, you can use `base`.`name`
|
56
|
+
|
57
|
+
**Deprecated**
|
58
|
+
```ruby
|
59
|
+
payload[:endpoint].options[:for].name
|
60
|
+
```
|
61
|
+
**New**
|
62
|
+
```ruby
|
63
|
+
payload[:endpoint].options[:for].base.name
|
64
|
+
```
|
65
|
+
|
32
66
|
#### Changes in rescue_from returned object
|
33
67
|
|
34
68
|
Grape will now check the object returned from `rescue_from` and ensure that it is a `Rack::Response`. That makes sure response is valid and avoids exposing service information. Change any code that invoked `Rack::Response.new(...).finish` in a custom `rescue_from` block to `Rack::Response.new(...)` to comply with the validation.
|
data/lib/grape/api/instance.rb
CHANGED
data/lib/grape/version.rb
CHANGED
data/pkg/grape-1.2.0.gem
CHANGED
Binary file
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'A named API' do
|
4
|
+
subject(:api_name) { NamedAPI.endpoints.last.options[:for].to_s }
|
5
|
+
|
6
|
+
let(:api) do
|
7
|
+
Class.new(Grape::API) do
|
8
|
+
get 'test' do
|
9
|
+
'response'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
before { stub_const('NamedAPI', api) }
|
15
|
+
|
16
|
+
it 'can access the name of the API' do
|
17
|
+
expect(api_name).to eq 'NamedAPI'
|
18
|
+
end
|
19
|
+
end
|
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: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -321,6 +321,7 @@ files:
|
|
321
321
|
- spec/grape/middleware/versioner/param_spec.rb
|
322
322
|
- spec/grape/middleware/versioner/path_spec.rb
|
323
323
|
- spec/grape/middleware/versioner_spec.rb
|
324
|
+
- spec/grape/named_api_spec.rb
|
324
325
|
- spec/grape/parser_spec.rb
|
325
326
|
- spec/grape/path_spec.rb
|
326
327
|
- spec/grape/presenters/presenter_spec.rb
|
@@ -398,6 +399,7 @@ test_files:
|
|
398
399
|
- spec/grape/api/patch_method_helpers_spec.rb
|
399
400
|
- spec/grape/api/optional_parameters_in_route_spec.rb
|
400
401
|
- spec/grape/api/invalid_format_spec.rb
|
402
|
+
- spec/grape/named_api_spec.rb
|
401
403
|
- spec/grape/exceptions/validation_spec.rb
|
402
404
|
- spec/grape/exceptions/validation_errors_spec.rb
|
403
405
|
- spec/grape/exceptions/missing_option_spec.rb
|