roar 0.11.19 → 0.12.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.
- data/.travis.yml +3 -1
- data/gemfiles/Gemfile.representable-1.6.ruby-1.9 +5 -0
- data/lib/roar/representer/feature/coercion.rb +1 -2
- data/lib/roar/representer/json/hal.rb +6 -0
- data/lib/roar/version.rb +1 -1
- data/roar.gemspec +1 -1
- data/test/coercion_feature_test.rb +2 -0
- data/test/decorator_test.rb +20 -12
- data/test/hypermedia_test.rb +0 -57
- metadata +5 -4
data/.travis.yml
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
matrix:
|
2
2
|
include:
|
3
3
|
- rvm: 1.9.3
|
4
|
-
gemfile: gemfiles/Gemfile.representable-1.
|
4
|
+
gemfile: gemfiles/Gemfile.representable-1.6.ruby-1.9
|
5
|
+
- rvm: 2.0.0
|
6
|
+
gemfile: gemfiles/Gemfile.representable-1.6.ruby-1.9
|
5
7
|
# - rvm: 1.8.7
|
6
8
|
# gemfile: gemfiles/Gemfile.representable-1.5.ruby-1.8
|
7
9
|
notifications:
|
@@ -32,6 +32,12 @@ module Roar::Representer
|
|
32
32
|
include Links # overwrites #links_definition_options.
|
33
33
|
extend ClassMethods # overwrites #links_definition_options, again.
|
34
34
|
include Resources
|
35
|
+
|
36
|
+
def representable_mapper(*) # TODO: make this easier to override.
|
37
|
+
super.tap do |map|
|
38
|
+
map.extend Resources
|
39
|
+
end
|
40
|
+
end
|
35
41
|
end
|
36
42
|
end
|
37
43
|
|
data/lib/roar/version.rb
CHANGED
data/roar.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_runtime_dependency "representable", "~> 1.
|
22
|
+
s.add_runtime_dependency "representable", "~> 1.6.0"
|
23
23
|
|
24
24
|
s.add_development_dependency "rake", ">= 0.10.1"
|
25
25
|
s.add_development_dependency "test_xml", ">= 0.1.6"
|
data/test/decorator_test.rb
CHANGED
@@ -25,21 +25,23 @@ class DecoratorTest < MiniTest::Spec
|
|
25
25
|
let (:model_with_links) { model.singleton_class.instance_eval { attr_accessor :links }; model }
|
26
26
|
|
27
27
|
describe "JSON" do
|
28
|
-
let (:
|
28
|
+
let (:decorator_class) { rpr_mod = rpr
|
29
29
|
Class.new(Roar::Decorator) do
|
30
30
|
include rpr_mod
|
31
31
|
end }
|
32
|
+
let (:decorator) { decorator_class.new(model) }
|
32
33
|
|
33
34
|
it "rendering links works" do
|
34
|
-
decorator.
|
35
|
+
decorator.to_hash.must_equal({"links"=>[{:rel=>:self, :href=>"http://self"}]})
|
35
36
|
end
|
36
37
|
|
37
38
|
it "sets links on decorator" do
|
38
|
-
decorator.
|
39
|
+
decorator.from_hash("links"=>[{:rel=>:self, :href=>"http://next"}])
|
40
|
+
decorator.links.must_equal("self"=>link(:rel=>:self, :href=>"http://next"))
|
39
41
|
end
|
40
42
|
|
41
43
|
it "does not set links on represented" do
|
42
|
-
|
44
|
+
decorator_class.new(model_with_links).from_hash("links"=>[{:rel=>:self, :href=>"http://self"}])
|
43
45
|
model_with_links.links.must_equal nil
|
44
46
|
end
|
45
47
|
|
@@ -62,18 +64,21 @@ class DecoratorTest < MiniTest::Spec
|
|
62
64
|
link(:self) { "http://self" } # TODO: test with HAL, too.
|
63
65
|
#self.representation_wrap = :song # FIXME: why isn't this working?
|
64
66
|
end
|
65
|
-
let (:
|
67
|
+
let (:decorator_class) { rpr_mod = rpr
|
66
68
|
Class.new(Roar::Decorator) do
|
67
69
|
include rpr_mod
|
68
70
|
self.representation_wrap = :song
|
69
|
-
end
|
71
|
+
end
|
72
|
+
}
|
73
|
+
let (:decorator) { decorator_class.new(model) }
|
70
74
|
|
71
75
|
it "rendering links works" do
|
72
|
-
decorator.
|
76
|
+
decorator.to_xml.must_equal_xml "<song><link rel=\"self\" href=\"http://self\"/></song>"
|
73
77
|
end
|
74
78
|
|
75
79
|
it "sets links on decorator" do
|
76
|
-
decorator.
|
80
|
+
decorator.from_xml(%{<song><link rel="self" href="http://next"/></song>})
|
81
|
+
decorator.links.must_equal("self"=>link(:rel=>:self, :href=>"http://next"))
|
77
82
|
end
|
78
83
|
end
|
79
84
|
|
@@ -82,17 +87,20 @@ class DecoratorTest < MiniTest::Spec
|
|
82
87
|
representer_for([Roar::Representer::JSON::HAL]) do
|
83
88
|
link(:self) { "http://self" }
|
84
89
|
end
|
85
|
-
let (:
|
90
|
+
let (:decorator_class) { rpr_mod = rpr
|
86
91
|
Class.new(Roar::Decorator) do
|
87
92
|
include rpr_mod
|
88
|
-
end
|
93
|
+
end
|
94
|
+
}
|
95
|
+
let (:decorator) { decorator_class.new(model) }
|
89
96
|
|
90
97
|
it "rendering links works" do
|
91
|
-
decorator.
|
98
|
+
decorator.to_hash.must_equal({"_links"=>{"self"=>{:href=>"http://self"}}})
|
92
99
|
end
|
93
100
|
|
94
101
|
it "sets links on decorator" do
|
95
|
-
decorator.
|
102
|
+
decorator.from_hash({"_links"=>{"self"=>{:href=>"http://next"}}})
|
103
|
+
decorator.links.must_equal("self"=>link(:rel=>:self, :href=>"http://next"))
|
96
104
|
end
|
97
105
|
|
98
106
|
describe "Decorator::HypermediaClient" do
|
data/test/hypermedia_test.rb
CHANGED
@@ -165,60 +165,6 @@ class HyperlinkTest < MiniTest::Spec
|
|
165
165
|
end
|
166
166
|
|
167
167
|
describe "Config inheritance" do
|
168
|
-
# TODO: this section will soon be moved to uber.
|
169
|
-
describe "inheritance when including" do
|
170
|
-
# TODO: test all the below issues AND if cloning works.
|
171
|
-
module TestMethods
|
172
|
-
def representer_for(modules=[Roar::Representer::Feature::Hypermedia, Representable], &block)
|
173
|
-
Module.new do
|
174
|
-
extend TestMethods
|
175
|
-
include *modules
|
176
|
-
module_exec(&block)
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
include TestMethods
|
181
|
-
|
182
|
-
it "inherits to uninitialized child" do
|
183
|
-
representer_for do # child
|
184
|
-
include(representer_for do # parent
|
185
|
-
representable_attrs.inheritable_array(:links) << "bar"
|
186
|
-
end)
|
187
|
-
end.representable_attrs.inheritable_array(:links).must_equal(["bar"])
|
188
|
-
end
|
189
|
-
|
190
|
-
it "works with uninitialized parent" do
|
191
|
-
representer_for do # child
|
192
|
-
representable_attrs.inheritable_array(:links) << "bar"
|
193
|
-
|
194
|
-
include(representer_for do # parent
|
195
|
-
end)
|
196
|
-
end.representable_attrs.inheritable_array(:links).must_equal(["bar"])
|
197
|
-
end
|
198
|
-
|
199
|
-
it "inherits when both are initialized" do
|
200
|
-
representer_for do # child
|
201
|
-
representable_attrs.inheritable_array(:links) << "bar"
|
202
|
-
|
203
|
-
include(representer_for do # parent
|
204
|
-
representable_attrs.inheritable_array(:links) << "stadium"
|
205
|
-
end)
|
206
|
-
end.representable_attrs.inheritable_array(:links).must_equal(["bar", "stadium"])
|
207
|
-
end
|
208
|
-
|
209
|
-
it "clones parent inheritables" do # FIXME: actually we don't clone here!
|
210
|
-
representer_for do # child
|
211
|
-
representable_attrs.inheritable_array(:links) << "bar"
|
212
|
-
|
213
|
-
include(parent = representer_for do # parent
|
214
|
-
representable_attrs.inheritable_array(:links) << "stadium"
|
215
|
-
end)
|
216
|
-
|
217
|
-
parent.representable_attrs.inheritable_array(:links) << "park" # modify parent array.
|
218
|
-
|
219
|
-
end.representable_attrs.inheritable_array(:links).must_equal(["bar", "stadium"])
|
220
|
-
end
|
221
|
-
|
222
168
|
it "doesn't mess up with inheritable_array" do # FIXME: remove this test when uber is out.
|
223
169
|
OpenStruct.new.extend( Module.new do
|
224
170
|
include Roar::Representer::JSON
|
@@ -241,9 +187,6 @@ class HyperlinkTest < MiniTest::Spec
|
|
241
187
|
include Roar::Representer::Feature::Hypermedia
|
242
188
|
link(:bla) { "boo" }
|
243
189
|
end).to_hash.must_equal({"links"=>[{:rel=>:self, :href=>"bo"}, {:rel=>:bla, :href=>"boo"}]})
|
244
|
-
|
245
|
-
|
246
|
-
end
|
247
190
|
end
|
248
191
|
end
|
249
192
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
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-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: representable
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.6.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: 1.6.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rake
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- TODO.markdown
|
174
174
|
- gemfiles/Gemfile.representable-1.5.ruby-1.8
|
175
175
|
- gemfiles/Gemfile.representable-1.5.ruby-1.9
|
176
|
+
- gemfiles/Gemfile.representable-1.6.ruby-1.9
|
176
177
|
- lib/roar.rb
|
177
178
|
- lib/roar/decorator.rb
|
178
179
|
- lib/roar/representer.rb
|