grape-roar 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -1
- data/README.md +16 -11
- data/UPGRADING.md +11 -0
- data/grape-roar.gemspec +1 -1
- data/lib/grape/roar/version.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- data/spec/support/article.rb +1 -1
- data/spec/support/article_representer.rb +2 -2
- data/spec/support/order.rb +1 -1
- data/spec/support/order_representer.rb +2 -2
- data/spec/support/product_representer.rb +3 -3
- data/spec/support/user_representer.rb +2 -2
- metadata +17 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f093829bf015a0d7e28dfde89dd892ef75f476ad
|
4
|
+
data.tar.gz: 510c6d4ca8038ca89c9ffceb08ab4e4f331fdbea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96fc420d047ff343877c733b2cba4c5a3e5dbec12dd10a4aaa8848145cf60313209cab853e60210783d6c58fc67cfd94d702f6d0e11a349b6d115e75ef2bc557
|
7
|
+
data.tar.gz: aa92afe084b80dc6b09677b073a233c04d69ee65b7a0f17b699ffb92da87be20c8a103334fad6a2132ebfd0184deed23d60a4df01b1029eb00769bee6bf0ff3a
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
Grape::Roar
|
2
2
|
------------
|
3
3
|
|
4
|
-
|
4
|
+
[![Gem Version](http://img.shields.io/gem/v/grape-roar.svg)](http://badge.fury.io/rb/grape-roar)
|
5
|
+
[![Build Status](http://img.shields.io/travis/dblock/grape-roar.svg)](https://travis-ci.org/dblock/grape-roar)
|
6
|
+
[![Dependency Status](https://gemnasium.com/dblock/grape-roar.svg)](https://gemnasium.com/dblock/grape-roar)
|
7
|
+
[![Code Climate](https://codeclimate.com/github/dblock/grape-roar.svg)](https://codeclimate.com/github/dblock/grape-roar)
|
5
8
|
|
6
|
-
[
|
9
|
+
Use [Roar](https://github.com/apotonick/roar) with [Grape](https://github.com/intridea/grape).
|
7
10
|
|
8
11
|
Demo
|
9
12
|
----
|
@@ -21,6 +24,8 @@ gem 'roar'
|
|
21
24
|
gem 'grape-roar'
|
22
25
|
```
|
23
26
|
|
27
|
+
If you're upgrading from an older version of this gem, please see [UPGRADING](UPGRADING.md).
|
28
|
+
|
24
29
|
Usage
|
25
30
|
-----
|
26
31
|
|
@@ -35,12 +40,12 @@ end
|
|
35
40
|
|
36
41
|
### Use Grape's Present
|
37
42
|
|
38
|
-
|
43
|
+
Include Grape::Roar::Representer into a representer module *after* any Roar mixins, then use Grape's `present` keyword.
|
39
44
|
|
40
45
|
```ruby
|
41
46
|
module ProductRepresenter
|
42
|
-
include Roar::
|
43
|
-
include Roar::
|
47
|
+
include Roar::JSON
|
48
|
+
include Roar::Hypermedia
|
44
49
|
include Grape::Roar::Representer
|
45
50
|
|
46
51
|
property :title
|
@@ -58,8 +63,8 @@ Presenting collections works the same way. The following example returns an embe
|
|
58
63
|
|
59
64
|
```ruby
|
60
65
|
module ProductsRepresenter
|
61
|
-
include Roar::
|
62
|
-
include Roar::
|
66
|
+
include Roar::JSON::HAL
|
67
|
+
include Roar::Hypermedia
|
63
68
|
include Grape::Roar::Representer
|
64
69
|
|
65
70
|
collection :entries, extend: ProductPresenter, as: :products, embedded: true
|
@@ -78,8 +83,8 @@ The formatter invokes `to_json` on presented objects and provides access to the
|
|
78
83
|
|
79
84
|
```ruby
|
80
85
|
module ProductRepresenter
|
81
|
-
include Roar::
|
82
|
-
include Roar::
|
86
|
+
include Roar::JSON
|
87
|
+
include Roar::Hypermedia
|
83
88
|
include Grape::Roar::Representer
|
84
89
|
|
85
90
|
link :self do |opts|
|
@@ -95,8 +100,8 @@ If you prefer to use a decorator class instead of modules.
|
|
95
100
|
|
96
101
|
```ruby
|
97
102
|
class ProductRepresenter < Grape::Roar::Decorator
|
98
|
-
include Roar::
|
99
|
-
include Roar::
|
103
|
+
include Roar::JSON
|
104
|
+
include Roar::Hypermedia
|
100
105
|
|
101
106
|
link :self do |opts|
|
102
107
|
"#{request(opts).url}/#{represented.id}"
|
data/UPGRADING.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Upgrading Grape-Roar
|
2
|
+
====================
|
3
|
+
|
4
|
+
### Upgrading to >= 0.3.0
|
5
|
+
|
6
|
+
This version requires Roar 1.0 or newer.
|
7
|
+
|
8
|
+
* Make presenter changes according to the [roar changelog](https://github.com/apotonick/roar/blob/master/CHANGES.markdown), specifically replace `Roar::Representer::Feature::Hypermedia` with `Roar::Hypermedia` and `Roar::Representer::JSON` with `Roar::JSON` and adjust any `require` paths.
|
9
|
+
* Ensure that `Grape::Roar::Representer` is included *after* any `Roar::JSON` or `Roar::Hypermedia` mixins. You would otherwise get a `TypeError: class or module required` from within `Roar::Representable`.
|
10
|
+
|
11
|
+
|
data/grape-roar.gemspec
CHANGED
data/lib/grape/roar/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/support/article.rb
CHANGED
data/spec/support/order.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'roar/
|
1
|
+
require 'roar/json/hal'
|
2
2
|
|
3
3
|
module ProductRepresenter
|
4
|
-
include Roar::
|
5
|
-
include Roar::
|
4
|
+
include Roar::JSON
|
5
|
+
include Roar::Hypermedia
|
6
6
|
include Grape::Roar::Representer
|
7
7
|
|
8
8
|
property :title
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-roar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Doubrovkine
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: roar
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '1.0'
|
41
41
|
description: Use Roar with Grape
|
42
42
|
email:
|
43
43
|
- dblock@dblock.org
|
@@ -45,17 +45,18 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
49
|
-
- .rspec
|
50
|
-
- .rubocop.yml
|
51
|
-
- .rubocop_todo.yml
|
52
|
-
- .travis.yml
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- ".rubocop.yml"
|
51
|
+
- ".rubocop_todo.yml"
|
52
|
+
- ".travis.yml"
|
53
53
|
- CHANGELOG.md
|
54
54
|
- CONTRIBUTING.md
|
55
55
|
- Gemfile
|
56
56
|
- LICENSE
|
57
57
|
- README.md
|
58
58
|
- Rakefile
|
59
|
+
- UPGRADING.md
|
59
60
|
- grape-roar.gemspec
|
60
61
|
- lib/grape-roar.rb
|
61
62
|
- lib/grape/roar.rb
|
@@ -85,17 +86,17 @@ require_paths:
|
|
85
86
|
- lib
|
86
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
88
|
requirements:
|
88
|
-
- -
|
89
|
+
- - ">="
|
89
90
|
- !ruby/object:Gem::Version
|
90
91
|
version: '0'
|
91
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
93
|
requirements:
|
93
|
-
- -
|
94
|
+
- - ">="
|
94
95
|
- !ruby/object:Gem::Version
|
95
96
|
version: '0'
|
96
97
|
requirements: []
|
97
98
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.2.2
|
99
100
|
signing_key:
|
100
101
|
specification_version: 4
|
101
102
|
summary: Enable Resource-Oriented Architectures in Grape API DSL
|