roar 1.0.2 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/ISSUE_TEMPLATE.md +20 -0
- data/.travis.yml +16 -11
- data/CHANGES.markdown +86 -57
- data/CONTRIBUTING.md +31 -0
- data/Gemfile +7 -4
- data/LICENSE +1 -1
- data/README.markdown +133 -255
- data/Rakefile +3 -1
- data/examples/example.rb +0 -0
- data/examples/example_server.rb +0 -0
- data/lib/roar/client.rb +8 -3
- data/lib/roar/decorator.rb +2 -2
- data/lib/roar/http_verbs.rb +0 -16
- data/lib/roar/hypermedia.rb +30 -56
- data/lib/roar/json/collection.rb +10 -2
- data/lib/roar/json/hal.rb +74 -83
- data/lib/roar/json.rb +5 -5
- data/lib/roar/version.rb +1 -1
- data/lib/roar/xml.rb +1 -1
- data/lib/roar.rb +3 -3
- data/roar.gemspec +7 -5
- data/test/client_test.rb +1 -1
- data/test/coercion_feature_test.rb +7 -2
- data/test/decorator_test.rb +17 -7
- data/test/hal_json_test.rb +101 -94
- data/test/hypermedia_feature_test.rb +13 -31
- data/test/hypermedia_test.rb +26 -92
- data/test/{decorator_client_test.rb → integration/decorator_client_test.rb} +5 -4
- data/test/{faraday_http_transport_test.rb → integration/faraday_http_transport_test.rb} +1 -0
- data/test/{http_verbs_test.rb → integration/http_verbs_test.rb} +3 -2
- data/test/integration/json_collection_test.rb +35 -0
- data/test/{net_http_transport_test.rb → integration/net_http_transport_test.rb} +1 -0
- data/test/integration/runner.rb +2 -3
- data/test/integration/server.rb +6 -0
- data/test/json_representer_test.rb +2 -29
- data/test/lonely_test.rb +1 -2
- data/test/ssl_client_certs_test.rb +1 -1
- data/test/test_helper.rb +21 -3
- data/test/xml_representer_test.rb +6 -5
- metadata +21 -37
- data/gemfiles/Gemfile.representable-1.7 +0 -6
- data/gemfiles/Gemfile.representable-1.8 +0 -6
- data/gemfiles/Gemfile.representable-2.0 +0 -5
- data/gemfiles/Gemfile.representable-2.1 +0 -5
- data/gemfiles/Gemfile.representable-head +0 -6
- data/lib/roar/json/collection_json.rb +0 -208
- data/lib/roar/json/json_api.rb +0 -233
- data/test/collection_json_test.rb +0 -132
- data/test/hal_links_test.rb +0 -31
- data/test/json_api_test.rb +0 -451
- data/test/lib/runner.rb +0 -134
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a6cecfd29cd502ae30718cbf9b8ca3a5befc380b0af976b547eafa0f70cfeae3
|
4
|
+
data.tar.gz: dbb230511da49e696f96259bc46f89a2f401f6cbe954dbe1f3c5768f4c65dbc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef524e4b90b8cc57a6d36aedf89d4e378f08239e07344da0de0132e9aee99c27bbe885f16eaa3e8322158d23557e25b8bc507bbc3f5cf9e899352829fad299b7
|
7
|
+
data.tar.gz: e0316e4a6dd737d12df3dffda56996cd7f1c915d67b1c771f5c633de541869bce3d4e2077d529a27ef5c107d30e2cb741834e717769e72e183fe6222c5eadab3
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Note: If you have a question about Roar, would like help using
|
2
|
+
Roar, want to request a feature, or do anything else other than
|
3
|
+
submit a bug report, please use the Trailblazer gitter channel.
|
4
|
+
|
5
|
+
### Complete Description of Issue
|
6
|
+
|
7
|
+
|
8
|
+
### Steps to reproduce
|
9
|
+
|
10
|
+
|
11
|
+
### Expected behavior
|
12
|
+
Tell us what should happen
|
13
|
+
|
14
|
+
### Actual behavior
|
15
|
+
Tell us what happens instead
|
16
|
+
|
17
|
+
### System configuration
|
18
|
+
**Roar version**:
|
19
|
+
|
20
|
+
### Full Backtrace of Exception (if any)
|
data/.travis.yml
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
language: ruby
|
2
|
+
before_install:
|
3
|
+
- gem install bundler
|
4
|
+
matrix:
|
5
|
+
allow_failures:
|
6
|
+
- rvm: ruby-head
|
7
|
+
fast_finish: true
|
8
|
+
include:
|
9
|
+
- rvm: 2.3.8
|
10
|
+
- rvm: 2.4.6
|
11
|
+
- rvm: 2.5.5
|
12
|
+
- rvm: 2.6.3
|
13
|
+
- rvm: jruby-9.1.15.0
|
14
|
+
env:
|
15
|
+
- JRUBY_OPTS="--client -J-XX:+TieredCompilation -J-XX:TieredStopAtLevel=1 -J-Xss2m -Xcompile.invokedynamic=false -J-Xmx1536m"
|
16
|
+
- rvm: ruby-head
|
data/CHANGES.markdown
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
# 1.1.1
|
2
|
+
|
3
|
+
* Allow Representable 3.x.
|
4
|
+
|
5
|
+
# 1.1.0
|
6
|
+
|
7
|
+
* Require Representable 3.0.x
|
8
|
+
* Remove CollectionJSON support until we get more feedback.
|
9
|
+
* Move JSON API support (`Roar::JSON::JSONAPI`) to the separate [roar-jsonapi](https://github.com/trailblazer/roar-jsonapi) gem.
|
10
|
+
* When using `links[]`, you now need to provide the string name, as in `decorator.links["self"]`. Symbols are not supported, anymore.
|
11
|
+
* `::links` now accepts a String or Symbol as its first argument, enabling more straight-forward definition of CURIE links: e.g. `links 'doc:link_collection' do; end` (@edejong).
|
12
|
+
* Clients can now parse lonely collections. (@hilary)
|
13
|
+
|
14
|
+
|
15
|
+
# 1.0.4
|
16
|
+
|
17
|
+
* Require Representable < 2.4.
|
18
|
+
|
19
|
+
# 1.0.3
|
20
|
+
|
21
|
+
* Make `:as` work with `HAL`.
|
22
|
+
|
1
23
|
# 1.0.2
|
2
24
|
|
3
25
|
* Roar runs on Rubinius.
|
@@ -9,7 +31,7 @@
|
|
9
31
|
|
10
32
|
# 1.0.1
|
11
33
|
|
12
|
-
* Allow calling `::has_one`, `::links` and `::has_many` in any order in JSON
|
34
|
+
* Allow calling `::has_one`, `::links` and `::has_many` in any order in JSON API. This requires Representable >= 2.1.4.
|
13
35
|
|
14
36
|
# 1.0.0
|
15
37
|
|
@@ -23,25 +45,24 @@
|
|
23
45
|
|
24
46
|
## Added
|
25
47
|
|
26
|
-
* `Roar::JSON::JSONAPI` supports JSON
|
27
|
-
|
48
|
+
* `Roar::JSON::JSONAPI` supports JSON API. A big thanks to @oliverbarnes for his continuous help, support and research on how to implement this standard.
|
28
49
|
|
29
50
|
## Relevant
|
30
51
|
|
31
52
|
* `Hyperlink#to_hash` now returns stringified keys.
|
32
53
|
* Removed `Representer#before_serialize` hook. Override `#serialize` yourself.
|
33
|
-
* Represented#links now returns `nil` when no parsing has happened.
|
54
|
+
* `Represented#links` now returns `nil` when no parsing has happened.
|
34
55
|
* Removed class methods `::from_json`, `::from_hash`, `::from_xml` and `::deserialize`. Please build the instance yourself and use something along `Song.new.from_json`.
|
35
56
|
|
36
57
|
## Internals
|
37
58
|
|
38
|
-
* Remove the concept of
|
59
|
+
* Remove the concept of `links_array`. `Hyperlink` instances for rendering or that have been parsed are always stored in a `LinkCollection` that is available via `#links`.
|
39
60
|
* `Hypermedia` is now 43% simpler.
|
40
61
|
* `HyperlinkCollection#each` now has different semantics for 1- or 2-arity.
|
41
62
|
|
42
63
|
# 0.12.8
|
43
64
|
|
44
|
-
* Last release to support
|
65
|
+
* Last release to support Representable < 2.0.
|
45
66
|
|
46
67
|
# 0.12.7
|
47
68
|
|
@@ -49,11 +70,11 @@
|
|
49
70
|
|
50
71
|
# 0.12.6
|
51
72
|
|
52
|
-
* Remove deprecations (most of 'em) from
|
73
|
+
* Remove deprecations (most of 'em) from Representable 1.8. Sorry for that.
|
53
74
|
|
54
75
|
# 0.12.5
|
55
76
|
|
56
|
-
* Roar runs with
|
77
|
+
* Roar runs with Representable <= 1.8.
|
57
78
|
|
58
79
|
# 0.12.4
|
59
80
|
|
@@ -71,23 +92,22 @@
|
|
71
92
|
* They now yield the request object to add headers etc before request is sent.
|
72
93
|
* They NO LONGER support positional arguments but one hash with `uri: "https://roar.de", body:, .. as: ..` and so on.
|
73
94
|
|
74
|
-
|
75
95
|
# 0.12.2
|
76
96
|
|
77
97
|
* Fix a bug where hyperlinks from nested objects weren't rendered in XML.
|
78
98
|
|
79
99
|
# 0.12.1
|
80
100
|
|
81
|
-
Allow
|
101
|
+
Allow Representable >= 1.6.
|
82
102
|
|
83
103
|
# 0.11.18
|
84
104
|
|
85
|
-
* Updating to
|
105
|
+
* Updating to Representable 1.5.2.
|
86
106
|
|
87
107
|
# 0.11.17
|
88
108
|
|
89
109
|
* Fixing HAL + Decorator.
|
90
|
-
* Requiring
|
110
|
+
* Requiring Representable 1.5.0.
|
91
111
|
|
92
112
|
# 0.11.16
|
93
113
|
|
@@ -95,15 +115,15 @@ Allow representable >= 1.6.
|
|
95
115
|
|
96
116
|
# 0.11.15
|
97
117
|
|
98
|
-
* Fixing [#66](https://github.com/
|
118
|
+
* Fixing [#66](https://github.com/trailblazer/roar/issues/66).
|
99
119
|
|
100
120
|
# 0.11.14
|
101
121
|
|
102
|
-
* Fixing Gemfile
|
122
|
+
* Fixing `Gemfile`.
|
103
123
|
|
104
124
|
# 0.11.13
|
105
125
|
|
106
|
-
* Adding `Roar::Decorator`, see [
|
126
|
+
* Adding `Roar::Decorator`, see [Representable docs](https://github.com/apotonick/Representable#decorator-vs-extend) for now.
|
107
127
|
|
108
128
|
# 0.11.12
|
109
129
|
|
@@ -113,104 +133,113 @@ Allow representable >= 1.6.
|
|
113
133
|
|
114
134
|
* Allow use of `::link(string)`.
|
115
135
|
|
116
|
-
|
136
|
+
# 0.11.10
|
117
137
|
|
118
138
|
* Fix a syntax error for Ruby 1.8.
|
119
|
-
* Store link definitions in `
|
139
|
+
* Store link definitions in `Representable_attrs(:links)` now and no longer in the `LinksDefinition` instance itself. removing `#links_definition` in favor of `#link_configs`.
|
120
140
|
|
121
|
-
|
141
|
+
# 0.11.9
|
122
142
|
|
123
143
|
* When using `Feature::Client` hyperlinks are no longer rendered in POST and PUT since we pass `links: false`.
|
124
144
|
* `Transport::NetHttp` now sets both `Accept:` and `Content-type:` header since Rails services seems to get confused.
|
125
145
|
|
126
|
-
|
146
|
+
# 0.11.8
|
127
147
|
|
128
148
|
* Fixed `JSON::HAL::Links` so that it keys links with `links` and not `_links`. The latter is still done by `JSON::HAL`.
|
129
149
|
|
130
|
-
|
150
|
+
# 0.11.7
|
131
151
|
|
132
152
|
* Maintenance release: Fixing the horrible bug fix from 0.11.6 and make it a bit less horrible.
|
133
153
|
|
134
|
-
|
154
|
+
# 0.11.6
|
135
155
|
|
136
156
|
* "Fixing" a bug where `links_definition_option` was missing when no link was set in a representer. Note that this is a quick and horrible bugfix and will soon be cleaned up.
|
137
157
|
|
138
|
-
|
158
|
+
# 0.11.5
|
139
159
|
|
140
|
-
* Introducing HAL::links method to map arrays of link objects in the HAL format. This completes the HAL/JSON specification.
|
160
|
+
* Introducing `HAL::links` method to map arrays of link objects in the HAL format. This completes the HAL/JSON specification.
|
141
161
|
|
142
|
-
|
162
|
+
# 0.11.4
|
143
163
|
|
144
164
|
* Links can now return a hash of attributes as `link :self do {:href => fruit_path(self), :title => "Yummy stuff"} end`.
|
145
165
|
|
146
|
-
|
166
|
+
# 0.11.3
|
147
167
|
|
148
168
|
* Fixed an installation issue under Windows.
|
149
169
|
|
150
|
-
|
170
|
+
# 0.11.2
|
151
171
|
|
152
172
|
* The request body in POST, PUT and PATCH is now actually sent in HttpVerbs. Thanks to @nleguen for finding this embarrassing bug. That's what happens when you don't have proper tests, kids!
|
153
173
|
|
154
|
-
|
174
|
+
# 0.11.1
|
175
|
+
|
176
|
+
* Since some users don't have access to my local hard-drive we now really require Representable 1.2.2.
|
177
|
+
|
178
|
+
# 0.11.0
|
155
179
|
|
156
|
-
*
|
180
|
+
* Using Representable 1.2.2 now. Be warned that in 1.2 parsing and rendering slightly changed. When a property is not found in the incoming document, it is ignored and thus might not be initialised in your represented model (empty collections are still set to an empty array). Also, the way `false` and `nil` values are rendered changed.
|
157
181
|
|
158
|
-
|
182
|
+
Quoted from the Representable CHANGES file:
|
159
183
|
|
160
|
-
*
|
161
|
-
*
|
162
|
-
* You can include nil values now in your representations since #property respects :represent_nil => true.
|
184
|
+
* A property with false value will now be included in the rendered representation. Same applies to parsing, false values will now be included. That particularly means properties that used to be unset (i.e. nil) after parsing might be false now.
|
185
|
+
* You can include nil values now in your representations since #property respects `:represent_nil => true`.
|
163
186
|
|
164
|
-
* The `:except` option
|
165
|
-
* Hyperlinks can now have arbitrary attributes.
|
166
|
-
|
167
|
-
When parsing, the options are avaible via `OpenStruct` compliant readers.
|
168
|
-
<code>link = Hyperlink.from_json({\"rel\":\"self\",\"data-url\":\"http://self\"} )
|
169
|
-
link.rel #=> "self"
|
170
|
-
link.send("data-url") #=> "http://self"
|
171
|
-
</code>
|
187
|
+
* The `:except` option was deprecated in favor of `:exclude`.
|
188
|
+
* Hyperlinks can now have arbitrary attributes.
|
189
|
+
To render, just provide `#link` with the options
|
172
190
|
|
173
|
-
|
191
|
+
```ruby
|
192
|
+
link :self, :title => "Mee!", "data-remote" => true
|
193
|
+
```
|
194
|
+
|
195
|
+
When parsing, the options are available via `OpenStruct` compliant readers.
|
196
|
+
|
197
|
+
```ruby
|
198
|
+
link = Hyperlink.from_json('{"rel":"self","data-url":"http://self"'})
|
199
|
+
link.rel #=> "self"
|
200
|
+
link.send("data-url") #=> "http://self"
|
201
|
+
```
|
202
|
+
|
203
|
+
# 0.10.2
|
174
204
|
|
175
205
|
* You can now pass values from outside to the render method (e.g. `#to_json`), they will be available as block parameters inside `#link`.
|
176
206
|
|
177
|
-
|
207
|
+
# 0.10.1
|
178
208
|
|
179
209
|
* Adding the Coercion feature.
|
180
210
|
|
181
|
-
|
211
|
+
# 0.10.0
|
182
212
|
|
183
|
-
* Requiring
|
213
|
+
* Requiring Representable 0.1.3.
|
184
214
|
* Added JSON-HAL support.
|
185
215
|
* Links are no longer rendered when `href` is `nil` or `false`.
|
186
216
|
* `Representer.link` class method now accepts either the `rel` value, only, or a hash of link attributes (defined in `Hypermedia::Hyperlink.params`), like `link :rel => :self, :title => "You're good" do..`
|
187
217
|
* API CHANGE: `Representer#links` no longer returns the `href` value but the link object. Use it like `object.links[:self].href` to retrieve the URL.
|
188
218
|
* `#from_json` won't throw an exception anymore when passed an empty json document.
|
189
219
|
|
190
|
-
|
220
|
+
# 0.9.2
|
191
221
|
|
192
|
-
* Using
|
222
|
+
* Using Representable 1.1.
|
193
223
|
|
194
|
-
|
224
|
+
# 0.9.1
|
195
225
|
|
196
|
-
* Removed
|
197
|
-
* Using
|
226
|
+
* Removed `Representer#to_attributes` and `#from_attributes`.
|
227
|
+
* Using Representable 1.0.1 now.
|
198
228
|
|
199
|
-
|
229
|
+
# 0.9.0
|
200
230
|
|
201
|
-
* Using
|
231
|
+
* Using Representable 0.12.x.
|
202
232
|
* `Representer::Base` is now simply `Representer`.
|
203
233
|
* Removed all the class methods from `HttpVerbs` except for `get`.
|
204
234
|
|
235
|
+
# 0.8.3
|
205
236
|
|
206
|
-
|
207
|
-
|
208
|
-
* Maintenance release for representable compat.
|
237
|
+
* Maintenance release for Representable compat.
|
209
238
|
|
210
|
-
|
239
|
+
# 0.8.2
|
211
240
|
|
212
241
|
* Removing `restfulie` dependency - we now use `Net::HTTP`.
|
213
242
|
|
214
|
-
|
243
|
+
# 0.8.1
|
215
244
|
|
216
|
-
* Added the
|
245
|
+
* Added the `:except` and `:include` options to `#from_*`.
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
## How to contribute to Roar
|
2
|
+
|
3
|
+
#### **Did you find a bug?**
|
4
|
+
|
5
|
+
* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/trailblazer/roar/issues).
|
6
|
+
|
7
|
+
* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/trailblazer/roar/issues/new). Be sure to follow the issue template.
|
8
|
+
|
9
|
+
#### **Did you write a patch that fixes a bug?**
|
10
|
+
|
11
|
+
* Open a new GitHub pull request with the patch.
|
12
|
+
|
13
|
+
* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
|
14
|
+
|
15
|
+
* All code in pull requests is assumed to be MIT licensed. Do not submit a pull request if that isn't the case.
|
16
|
+
|
17
|
+
#### **Do you intend to add a new feature or change an existing one?**
|
18
|
+
|
19
|
+
* Suggest your change in the [Trailblazer Gitter Room](https://gitter.im/trailblazer/chat) and start writing code.
|
20
|
+
|
21
|
+
* Do not open an issue on GitHub until you have collected positive feedback about the change. GitHub issues are primarily intended for bug reports and fixes.
|
22
|
+
|
23
|
+
#### **Do you have questions using Roar?**
|
24
|
+
|
25
|
+
* Ask any questions about how to use Roar in the [Trailblazer Gitter Room](https://gitter.im/trailblazer/chat). Github issues are restricted to bug reports and fixes.
|
26
|
+
|
27
|
+
* GitHub Issues should not be used as a help forum and any such issues will be closed.
|
28
|
+
|
29
|
+
#### **Do you want to contribute to the Roar documentation?**
|
30
|
+
|
31
|
+
* Roar documentation is provided via the [Trailblazer site](http://trailblazer.to/gems/roar/) and not the repository readme. Please add your contributions to the [Trailblazer site repository](https://github.com/trailblazer/trailblazer.github.io)
|
data/Gemfile
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
source "
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
ruby RUBY_VERSION
|
2
4
|
|
3
|
-
# Specify your gem's dependencies in roar.gemspec
|
4
5
|
gemspec
|
5
6
|
|
6
|
-
|
7
|
-
|
7
|
+
gem "nokogiri", ">= 1.8.5"
|
8
|
+
|
9
|
+
gem "minitest-line"
|
10
|
+
gem "pry"
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2011 -
|
1
|
+
Copyright (c) 2011 - 2017 Nick Sutterer and the roar contributors
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|