roar 0.0.1.alpha1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +10 -0
- data/CHANGES.markdown +203 -0
- data/Gemfile +6 -0
- data/LICENSE +20 -0
- data/README.markdown +734 -0
- data/Rakefile +10 -0
- data/TODO.markdown +13 -0
- data/examples/example.rb +370 -0
- data/examples/example_server.rb +34 -0
- data/gemfiles/Gemfile.representable-2.0 +5 -0
- data/gemfiles/Gemfile.representable-2.1 +5 -0
- data/lib/roar/client.rb +38 -0
- data/lib/roar/coercion.rb +20 -0
- data/lib/roar/decorator.rb +11 -0
- data/lib/roar/http_verbs.rb +88 -0
- data/lib/roar/hypermedia.rb +179 -0
- data/lib/roar/json/collection.rb +3 -0
- data/lib/roar/json/collection_json.rb +208 -0
- data/lib/roar/json/hal.rb +223 -0
- data/lib/roar/json/hash.rb +3 -0
- data/lib/roar/json/json_api.rb +228 -0
- data/lib/roar/json.rb +55 -0
- data/lib/roar/representer.rb +11 -0
- data/lib/roar/transport/faraday.rb +49 -0
- data/lib/roar/transport/net_http/request.rb +77 -0
- data/lib/roar/transport/net_http.rb +49 -0
- data/lib/roar/version.rb +1 -1
- data/lib/roar/xml.rb +54 -0
- data/lib/roar.rb +4 -1
- data/roar.gemspec +14 -5
- data/test/client_test.rb +36 -0
- data/test/coercion_feature_test.rb +23 -0
- data/test/collection_json_test.rb +130 -0
- data/test/decorator_test.rb +132 -0
- data/test/faraday_http_transport_test.rb +82 -0
- data/test/fixtures/sample.pem +31 -0
- data/test/hal_json_test.rb +160 -0
- data/test/hal_links_test.rb +31 -0
- data/test/http_verbs_test.rb +154 -0
- data/test/hypermedia_feature_test.rb +155 -0
- data/test/hypermedia_test.rb +190 -0
- data/test/integration/Gemfile +4 -0
- data/test/integration/band_representer.rb +8 -0
- data/test/integration/runner.rb +42 -0
- data/test/integration/server.rb +120 -0
- data/test/integration/ssl_server.rb +60 -0
- data/test/json_api_test.rb +395 -0
- data/test/json_representer_test.rb +149 -0
- data/test/lib/runner.rb +134 -0
- data/test/lonely_test.rb +9 -0
- data/test/net_http_transport_test.rb +78 -0
- data/test/representer_test.rb +39 -0
- data/test/ssl_client_certs_test.rb +102 -0
- data/test/test_helper.rb +60 -0
- data/test/xml_representer_test.rb +68 -0
- metadata +209 -49
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 9b58dcace50d4224e36f81444ce64ca73dfec11a
|
|
4
|
+
data.tar.gz: 419929c85da4aef8a13243364b1c918acfd5312c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: c090f6a70e513ab5ad28155a9c21a453f0e37a289acb2af3a7ade51484d8cc1a76d0c14a02cf6343b054fb9ef2dd392dcae2383b7d219c77e43513d370369c62
|
|
7
|
+
data.tar.gz: 3253825814038580793eebb22da120b3af1ce69723d81283b65953e5b30806a91b7627ebb370de30b46440b07b749465ec2db1a9235b884b5de132becf2d4c84
|
data/.travis.yml
ADDED
data/CHANGES.markdown
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# 1.0.0
|
|
2
|
+
|
|
3
|
+
## Breakage
|
|
4
|
+
|
|
5
|
+
* Removed `Representer` and `Feature` namespace. That means changes along the following.
|
|
6
|
+
* `Roar::Representer::Feature::Hypermedia` --> `Roar::Hypermedia`
|
|
7
|
+
* `Roar::Representer::JSON` --> `Roar::JSON`
|
|
8
|
+
* Removed positional arguments for `HttpVerbs#get` and friends.
|
|
9
|
+
* `HttpVerbs#get` and friends will now raise an exception when the response code is not 2xx. You can get the original response via `Roar::Transport::Error#response`. Thanks to @paulccarey for all his inspiring work and patience!
|
|
10
|
+
|
|
11
|
+
## Added
|
|
12
|
+
|
|
13
|
+
* `Roar::JSON::JsonApi` supports JSON-API. A big thanks to @oliverbarnes for his continous help, support and research on how to implement this standard.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Relevant
|
|
17
|
+
|
|
18
|
+
* `Hyperlink#to_hash` now returns stringified keys.
|
|
19
|
+
* Removed `Representer#before_serialize` hook. Override `#serialize` yourself.
|
|
20
|
+
* Represented#links now returns `nil` when no parsing has happened.
|
|
21
|
+
* Removed class methods `::from_json`, `::from_hash`, `::from_xml` and `::deserialize`. Please build the instance yourself and use something along `Song.new.from_json`.
|
|
22
|
+
|
|
23
|
+
## Internals
|
|
24
|
+
|
|
25
|
+
* 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`.
|
|
26
|
+
* `Hypermedia` is now 43% simpler.
|
|
27
|
+
* `HyperlinkCollection#each` now has different semantics for 1- or 2-arity.
|
|
28
|
+
|
|
29
|
+
# 0.12.8
|
|
30
|
+
|
|
31
|
+
* Last release to support representable < 2.0.
|
|
32
|
+
|
|
33
|
+
# 0.12.7
|
|
34
|
+
|
|
35
|
+
* Bug fix where hypermedia links were wrong when invoking serialization multiple times on the same instance.
|
|
36
|
+
|
|
37
|
+
# 0.12.6
|
|
38
|
+
|
|
39
|
+
* Remove deprecations (most of 'em) from representable-1.8. Sorry for that.
|
|
40
|
+
|
|
41
|
+
# 0.12.5
|
|
42
|
+
|
|
43
|
+
* Roar runs with representable <= 1.8.
|
|
44
|
+
|
|
45
|
+
# 0.12.4
|
|
46
|
+
|
|
47
|
+
* The `HAL` module supports [CURIE links](https://github.com/mikekelly/hal_specification/blob/f937dbc9f9e1fa25be824834794407fdcb8f116f/hal_specification.md#curies) now using the `::curie` method.
|
|
48
|
+
* Allow old and new API in HttpVerbs#get and friends.
|
|
49
|
+
|
|
50
|
+
# 0.12.3
|
|
51
|
+
|
|
52
|
+
* Allow basic authentication with `basic_auth: [:admin, :password]`.
|
|
53
|
+
* Allow HTTPS.
|
|
54
|
+
* Removed `NetHTTP#do_request`. It is in `NetHTTP::Request` now.
|
|
55
|
+
|
|
56
|
+
### Changes for `HttpVerbs#get` and friends:
|
|
57
|
+
|
|
58
|
+
* They now yield the request object to add headers etc before request is sent.
|
|
59
|
+
* They NO LONGER support positional arguments but one hash with `uri: "https://roar.de", body:, .. as: ..` and so on.
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# 0.12.2
|
|
63
|
+
|
|
64
|
+
* Fix a bug where hyperlinks from nested objects weren't rendered in XML.
|
|
65
|
+
|
|
66
|
+
# 0.12.1
|
|
67
|
+
|
|
68
|
+
Allow representable >= 1.6.
|
|
69
|
+
|
|
70
|
+
# 0.11.18
|
|
71
|
+
|
|
72
|
+
* Updating to representable-1.5.2.
|
|
73
|
+
|
|
74
|
+
# 0.11.17
|
|
75
|
+
|
|
76
|
+
* Fixing HAL + Decorator.
|
|
77
|
+
* Requiring representable-1.5.0.
|
|
78
|
+
|
|
79
|
+
# 0.11.16
|
|
80
|
+
|
|
81
|
+
* Added `Roar::Decorator::HypermediaConsumer` which propagates incoming hypermedia links to the represented object (it has to have accessors for `:links`).
|
|
82
|
+
|
|
83
|
+
# 0.11.15
|
|
84
|
+
|
|
85
|
+
* Fixing [#66](https://github.com/apotonick/roar/issues/66).
|
|
86
|
+
|
|
87
|
+
# 0.11.14
|
|
88
|
+
|
|
89
|
+
* Fixing Gemfile.
|
|
90
|
+
|
|
91
|
+
# 0.11.13
|
|
92
|
+
|
|
93
|
+
* Adding `Roar::Decorator`, see [representable docs](https://github.com/apotonick/representable#decorator-vs-extend) for now.
|
|
94
|
+
|
|
95
|
+
# 0.11.12
|
|
96
|
+
|
|
97
|
+
* Moved `::inheritable_array` from `Hypermedia` to `Representer`.
|
|
98
|
+
|
|
99
|
+
# 0.11.11
|
|
100
|
+
|
|
101
|
+
* Allow use of `::link(string)`.
|
|
102
|
+
|
|
103
|
+
## 0.11.10
|
|
104
|
+
|
|
105
|
+
* Fix a syntax error for Ruby 1.8.
|
|
106
|
+
* Store link definitions in `representable_attrs(:links)` now and no longer in the `LinksDefinition` instance itself. removing `#links_definition` in favor of `#link_configs`.
|
|
107
|
+
|
|
108
|
+
## 0.11.9
|
|
109
|
+
|
|
110
|
+
* When using `Feature::Client` hyperlinks are no longer rendered in POST and PUT since we pass `links: false`.
|
|
111
|
+
* `Transport::NetHttp` now sets both `Accept:` and `Content-type:` header since Rails services seems to get confused.
|
|
112
|
+
|
|
113
|
+
## 0.11.8
|
|
114
|
+
|
|
115
|
+
* Fixed `JSON::HAL::Links` so that it keys links with `links` and not `_links`. The latter is still done by `JSON::HAL`.
|
|
116
|
+
|
|
117
|
+
## 0.11.7
|
|
118
|
+
|
|
119
|
+
* Maintenance release: Fixing the horrible bug fix from 0.11.6 and make it a bit less horrible.
|
|
120
|
+
|
|
121
|
+
## 0.11.6
|
|
122
|
+
|
|
123
|
+
* "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.
|
|
124
|
+
|
|
125
|
+
## 0.11.5
|
|
126
|
+
|
|
127
|
+
* Introducing HAL::links method to map arrays of link objects in the HAL format. This completes the HAL/JSON specification.
|
|
128
|
+
|
|
129
|
+
## 0.11.4
|
|
130
|
+
|
|
131
|
+
* Links can now return a hash of attributes as `link :self do {:href => fruit_path(self), :title => "Yummy stuff"} end`.
|
|
132
|
+
|
|
133
|
+
## 0.11.3
|
|
134
|
+
|
|
135
|
+
* Fixed an installation issue under Windows.
|
|
136
|
+
|
|
137
|
+
## 0.11.2
|
|
138
|
+
|
|
139
|
+
* 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!
|
|
140
|
+
|
|
141
|
+
## 0.11.1
|
|
142
|
+
|
|
143
|
+
* Since some users don't have access to my local hard-drive we now really require representable-1.2.2.
|
|
144
|
+
|
|
145
|
+
## 0.11.0
|
|
146
|
+
|
|
147
|
+
* 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. Quoted from the representable CHANGES file:
|
|
148
|
+
* 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.
|
|
149
|
+
* You can include nil values now in your representations since #property respects :represent_nil => true.
|
|
150
|
+
|
|
151
|
+
* The `:except` option got deprecated in favor of `:exclude`.
|
|
152
|
+
* Hyperlinks can now have arbitrary attributes. To render, just provide `#link` with the options
|
|
153
|
+
<code>link :self, :title => "Mee!", "data-remote" => true</code>
|
|
154
|
+
When parsing, the options are avaible via `OpenStruct` compliant readers.
|
|
155
|
+
<code>link = Hyperlink.from_json({\"rel\":\"self\",\"data-url\":\"http://self\"} )
|
|
156
|
+
link.rel #=> "self"
|
|
157
|
+
link.send("data-url") #=> "http://self"
|
|
158
|
+
</code>
|
|
159
|
+
|
|
160
|
+
## 0.10.2
|
|
161
|
+
|
|
162
|
+
* You can now pass values from outside to the render method (e.g. `#to_json`), they will be available as block parameters inside `#link`.
|
|
163
|
+
|
|
164
|
+
## 0.10.1
|
|
165
|
+
|
|
166
|
+
* Adding the Coercion feature.
|
|
167
|
+
|
|
168
|
+
## 0.10.0
|
|
169
|
+
|
|
170
|
+
* Requiring representable-0.1.3.
|
|
171
|
+
* Added JSON-HAL support.
|
|
172
|
+
* Links are no longer rendered when `href` is `nil` or `false`.
|
|
173
|
+
* `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..`
|
|
174
|
+
* 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.
|
|
175
|
+
* `#from_json` won't throw an exception anymore when passed an empty json document.
|
|
176
|
+
|
|
177
|
+
## 0.9.2
|
|
178
|
+
|
|
179
|
+
* Using representable-1.1.
|
|
180
|
+
|
|
181
|
+
## 0.9.1
|
|
182
|
+
|
|
183
|
+
* Removed @Representer#to_attributes@ and @#from_attributes@.
|
|
184
|
+
* Using representable-1.0.1 now.
|
|
185
|
+
|
|
186
|
+
## 0.9.0
|
|
187
|
+
|
|
188
|
+
* Using representable-0.12.x.
|
|
189
|
+
* `Representer::Base` is now simply `Representer`.
|
|
190
|
+
* Removed all the class methods from `HttpVerbs` except for `get`.
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
## 0.8.3
|
|
194
|
+
|
|
195
|
+
* Maintenance release for representable compat.
|
|
196
|
+
|
|
197
|
+
## 0.8.2
|
|
198
|
+
|
|
199
|
+
* Removing `restfulie` dependency - we now use `Net::HTTP`.
|
|
200
|
+
|
|
201
|
+
## 0.8.1
|
|
202
|
+
|
|
203
|
+
* Added the :except and :include options to `#from_*`.
|
data/Gemfile
CHANGED
|
@@ -2,3 +2,9 @@ source "http://rubygems.org"
|
|
|
2
2
|
|
|
3
3
|
# Specify your gem's dependencies in roar.gemspec
|
|
4
4
|
gemspec
|
|
5
|
+
|
|
6
|
+
gem "representable", "~> 2.1.0"
|
|
7
|
+
# gem "representable", :path => "../representable"
|
|
8
|
+
|
|
9
|
+
# as long as this is not merged, i'll vendor the runner file.
|
|
10
|
+
# gem "sinatra-contrib", :git => "git@github.com:apotonick/sinatra-contrib.git", :branch => "runner"
|
data/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2011 - 2013 Nick Sutterer and the roar contributors
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|