roar 0.12.5 → 0.12.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +4 -0
- data/CHANGES.markdown +4 -0
- data/Gemfile +1 -1
- data/TODO.markdown +6 -1
- data/gemfiles/Gemfile.representable-1.8 +6 -0
- data/lib/roar/representer/feature/hypermedia.rb +9 -1
- data/lib/roar/representer/json.rb +5 -0
- data/lib/roar/representer/json/hal.rb +5 -3
- data/lib/roar/version.rb +1 -1
- data/roar.gemspec +0 -2
- data/test/collection_json_test.rb +2 -2
- data/test/decorator_test.rb +3 -3
- data/test/hal_json_test.rb +4 -4
- data/test/hal_links_test.rb +1 -1
- data/test/hypermedia_test.rb +1 -1
- data/test/test_helper.rb +0 -12
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db7cda8e7774438e2c12828c256a93501719b176
|
4
|
+
data.tar.gz: 2f61956f6ea000358e40713d958af2e8c58219a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b04289bf9e1b07ff13ffe52dea647c0c82b6154d49d5ac2e2b657498a031bf24574751a546ecce8dd76fb9511a3ded0eb2f3131eb3c1e16306849f115335da2
|
7
|
+
data.tar.gz: 28a0c35f6240627b1fe1b5924e2f7e8d8ca27761c4f56a12138fabd8768394dfe3ea63517892bdbb9f83f36ee5222c003d3d16a00cfc63e6ab1af3c03c87cad7
|
data/.travis.yml
CHANGED
@@ -4,5 +4,9 @@ matrix:
|
|
4
4
|
gemfile: gemfiles/Gemfile.representable-1.7
|
5
5
|
- rvm: 2.0.0
|
6
6
|
gemfile: gemfiles/Gemfile.representable-1.7
|
7
|
+
- rvm: 1.9.3
|
8
|
+
gemfile: gemfiles/Gemfile.representable-1.8
|
9
|
+
- rvm: 2.0.0
|
10
|
+
gemfile: gemfiles/Gemfile.representable-1.8
|
7
11
|
notifications:
|
8
12
|
irc: "irc.freenode.org#cells"
|
data/CHANGES.markdown
CHANGED
data/Gemfile
CHANGED
@@ -3,5 +3,5 @@ source "http://rubygems.org"
|
|
3
3
|
# Specify your gem's dependencies in roar.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem "representable", :path => "../representable"
|
6
|
+
#gem "representable", :path => "../representable"
|
7
7
|
gem "sinatra-contrib", :git => "git@github.com:apotonick/sinatra-contrib.git", :branch => "runner"
|
data/TODO.markdown
CHANGED
@@ -3,4 +3,9 @@
|
|
3
3
|
* alias Roar::Representer to Representer
|
4
4
|
* remove #before_serialize and just overwrite #serialize
|
5
5
|
* abstract ::links_definition_options and move them out of the generic representers (JSON, XML).
|
6
|
-
* make 1.8 tests work, again (hash ordering!)
|
6
|
+
* make 1.8 tests work, again (hash ordering!)
|
7
|
+
|
8
|
+
* release 1.0
|
9
|
+
* representable 1.8, only.
|
10
|
+
* revise Hypermedia
|
11
|
+
* work on HAL-Object
|
@@ -137,7 +137,15 @@ module Roar
|
|
137
137
|
private
|
138
138
|
def create_links_definition
|
139
139
|
return if representable_attrs.find { |d| d.is_a?(LinksDefinition) }
|
140
|
-
|
140
|
+
|
141
|
+
options = links_definition_options # TODO: remove in 1.0.
|
142
|
+
if Roar.representable_1_8?
|
143
|
+
opt = options.last
|
144
|
+
opt[:exec_context] = :decorator
|
145
|
+
opt.delete(:decorator_scope)
|
146
|
+
end
|
147
|
+
|
148
|
+
representable_attrs << LinksDefinition.new(*options)
|
141
149
|
end
|
142
150
|
end
|
143
151
|
|
@@ -3,6 +3,11 @@ require 'roar/representer/feature/hypermedia'
|
|
3
3
|
require 'representable/json'
|
4
4
|
|
5
5
|
module Roar
|
6
|
+
require 'representable/version'
|
7
|
+
def self.representable_1_8? # TODO: remove me in 1.0.
|
8
|
+
Representable::VERSION =~ /^1.8/
|
9
|
+
end
|
10
|
+
|
6
11
|
module Representer
|
7
12
|
module JSON
|
8
13
|
def self.included(base)
|
@@ -60,12 +60,14 @@ module Roar::Representer
|
|
60
60
|
module Resources
|
61
61
|
# Write the property to the +_embedded+ hash when it's a resource.
|
62
62
|
def compile_fragment(bin, doc)
|
63
|
-
|
63
|
+
embedded = ::Roar.representable_1_8? ? bin[:embedded] : bin.options[:embedded]
|
64
|
+
return super unless embedded
|
64
65
|
super(bin, doc[:_embedded] ||= {})
|
65
66
|
end
|
66
67
|
|
67
68
|
def uncompile_fragment(bin, doc)
|
68
|
-
|
69
|
+
embedded = Roar.representable_1_8? ? bin[:embedded] : bin.options[:embedded]
|
70
|
+
return super unless embedded
|
69
71
|
super(bin, doc["_embedded"] || {})
|
70
72
|
end
|
71
73
|
end
|
@@ -132,7 +134,7 @@ module Roar::Representer
|
|
132
134
|
include Representable::JSON::Hash
|
133
135
|
|
134
136
|
values :extend => lambda { |item, *| item.is_a?(Array) ? LinkArrayRepresenter : Roar::Representer::JSON::HyperlinkRepresenter },
|
135
|
-
:
|
137
|
+
:instance => lambda { |fragment, *| fragment.is_a?(LinkArray) ? fragment : Roar::Representer::Feature::Hypermedia::Hyperlink.new }
|
136
138
|
|
137
139
|
def to_hash(options)
|
138
140
|
super.tap do |hsh| # TODO: cool: super(:exclude => [:rel]).
|
data/lib/roar/version.rb
CHANGED
data/roar.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
1
|
$:.push File.expand_path("../lib", __FILE__)
|
3
2
|
require "roar/version"
|
4
3
|
|
@@ -12,7 +11,6 @@ Gem::Specification.new do |s|
|
|
12
11
|
s.summary = %q{Resource-oriented architectures in Ruby.}
|
13
12
|
s.description = %q{Streamlines the development of RESTful, resource-oriented architectures in Ruby.}
|
14
13
|
s.license = 'MIT'
|
15
|
-
s.rubyforge_project = "roar"
|
16
14
|
|
17
15
|
s.files = `git ls-files`.split("\n")
|
18
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
@@ -108,12 +108,12 @@ class CollectionJsonTest < MiniTest::Spec
|
|
108
108
|
song = subject.items.first
|
109
109
|
song.title.must_equal "scarifice"
|
110
110
|
song.length.must_equal 43
|
111
|
-
song.links.must_equal("download" => link({:rel
|
111
|
+
song.links.must_equal("download" => link({:rel=>"download", :href=>"//songs/scarifice.mp3"}), "stats" => link({:rel=>"stats", :href=>"//songs/scarifice/stats"}))
|
112
112
|
song.href.must_equal link(:href => "//songs/scarifice")
|
113
113
|
end
|
114
114
|
|
115
115
|
it "provides #links" do
|
116
|
-
subject.links.must_equal({"feed" => link(:rel =>
|
116
|
+
subject.links.must_equal({"feed" => link(:rel => "feed", :href => "//songs/feed")})
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
data/test/decorator_test.rb
CHANGED
@@ -78,7 +78,7 @@ class DecoratorTest < MiniTest::Spec
|
|
78
78
|
|
79
79
|
it "sets links on decorator" do
|
80
80
|
decorator.from_xml(%{<song><link rel="self" href="http://next"/></song>})
|
81
|
-
decorator.links.must_equal("self"=>link(:rel
|
81
|
+
decorator.links.must_equal("self"=>link(:rel=>"self", :href=>"http://next"))
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
@@ -100,7 +100,7 @@ class DecoratorTest < MiniTest::Spec
|
|
100
100
|
|
101
101
|
it "sets links on decorator" do
|
102
102
|
decorator.from_hash({"_links"=>{"self"=>{:href=>"http://next"}}})
|
103
|
-
decorator.links.must_equal("self"=>link(:rel
|
103
|
+
decorator.links.must_equal("self"=>link(:rel=>"self", :href=>"http://next"))
|
104
104
|
end
|
105
105
|
|
106
106
|
describe "Decorator::HypermediaClient" do
|
@@ -112,7 +112,7 @@ class DecoratorTest < MiniTest::Spec
|
|
112
112
|
|
113
113
|
it "propagates links to represented" do
|
114
114
|
decorator.new(model_with_links).from_hash("_links"=>{"self"=>{:href=>"http://self"}})
|
115
|
-
model_with_links.links[:self].must_equal(link(:rel
|
115
|
+
model_with_links.links[:self].must_equal(link(:rel=>"self", :href=>"http://self"))
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
data/test/hal_json_test.rb
CHANGED
@@ -24,17 +24,17 @@ class HalJsonTest < MiniTest::Spec
|
|
24
24
|
describe "parsing" do
|
25
25
|
it "parses link array" do # TODO: remove me.
|
26
26
|
obj = subject.from_json("{\"_links\":{\"self\":[{\"lang\":\"en\",\"href\":\"http://en.hit\"},{\"lang\":\"de\",\"href\":\"http://de.hit\"}]}}")
|
27
|
-
obj.links.must_equal "self" => [link(
|
27
|
+
obj.links.must_equal "self" => [link("rel" => "self", "href" => "http://en.hit", "lang" => "en"), link("rel" => "self", "href" => "http://de.hit", "lang" => "de")]
|
28
28
|
end
|
29
29
|
|
30
30
|
it "parses single links" do # TODO: remove me.
|
31
31
|
obj = subject.from_json("{\"_links\":{\"next\":{\"href\":\"http://next\"}}}")
|
32
|
-
obj.links.must_equal "next" => link(
|
32
|
+
obj.links.must_equal "next" => link("rel" => "next", "href" => "http://next")
|
33
33
|
end
|
34
34
|
|
35
35
|
it "parses link and link array" do
|
36
36
|
obj = subject.from_json("{\"_links\":{\"next\":{\"href\":\"http://next\"}, \"self\":[{\"lang\":\"en\",\"href\":\"http://en.hit\"},{\"lang\":\"de\",\"href\":\"http://de.hit\"}]}}")
|
37
|
-
obj.links.must_equal "next" => link(
|
37
|
+
obj.links.must_equal "next" => link("rel" => "next", "href" => "http://next"), "self" => [link("rel" => "self", "href" => "http://en.hit", "lang" => "en"), link("rel" => "self", "href" => "http://de.hit", "lang" => "de")]
|
38
38
|
end
|
39
39
|
|
40
40
|
it "parses empty link array" do
|
@@ -73,7 +73,7 @@ class HalJsonTest < MiniTest::Spec
|
|
73
73
|
describe "#prepare_links!" do
|
74
74
|
it "should map link arrays correctly" do
|
75
75
|
subject.send :prepare_links!
|
76
|
-
subject.links.must_equal "self" => [link(
|
76
|
+
subject.links.must_equal "self" => [link("rel" => :self, "href" => "http://en.hit", "lang" => "en"),link("rel" => :self, "href" => "http://de.hit", "lang" => "de")], "next" => link("href" => "http://next", "rel" => :next)
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
data/test/hal_links_test.rb
CHANGED
@@ -24,7 +24,7 @@ class HalLinkTest < MiniTest::Spec
|
|
24
24
|
|
25
25
|
describe "#from_json" do
|
26
26
|
it "uses 'links' key" do
|
27
|
-
subject.from_json("{\"links\":{\"self\":{\"href\":\"//lifer\"}}}").links.values.must_equal [link(
|
27
|
+
subject.from_json("{\"links\":{\"self\":{\"href\":\"//lifer\"}}}").links.values.must_equal [link("href" => "//lifer", "rel" => "self")]
|
28
28
|
end
|
29
29
|
end
|
30
30
|
end
|
data/test/hypermedia_test.rb
CHANGED
@@ -56,7 +56,7 @@ class HypermediaTest < MiniTest::Spec
|
|
56
56
|
describe "#from_json" do
|
57
57
|
it "parses" do
|
58
58
|
subject.from_json "{\"links\":[{\"rel\":\"self\",\"href\":\"//self\"}]}"
|
59
|
-
subject.links.must_equal({"self" => link(
|
59
|
+
subject.links.must_equal({"self" => link("rel" => "self", "href" => "//self")})
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
data/test/test_helper.rb
CHANGED
@@ -51,15 +51,3 @@ MiniTest::Spec.class_eval do
|
|
51
51
|
%w(get post put delete).each(&block)
|
52
52
|
end
|
53
53
|
end
|
54
|
-
|
55
|
-
Roar::Representer::Feature::Hypermedia::Hyperlink.class_eval do
|
56
|
-
def ==(other)
|
57
|
-
stringify_hash(table) == stringify_hash(other.table)
|
58
|
-
end
|
59
|
-
|
60
|
-
def stringify_hash(hash)
|
61
|
-
hash.collect do |k,v|
|
62
|
-
[k.to_s, v.to_s]
|
63
|
-
end.sort
|
64
|
-
end
|
65
|
-
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Sutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: representable
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- examples/example.rb
|
142
142
|
- examples/example_server.rb
|
143
143
|
- gemfiles/Gemfile.representable-1.7
|
144
|
+
- gemfiles/Gemfile.representable-1.8
|
144
145
|
- lib/roar.rb
|
145
146
|
- lib/roar/decorator.rb
|
146
147
|
- lib/roar/representer.rb
|
@@ -195,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
196
|
- !ruby/object:Gem::Version
|
196
197
|
version: '0'
|
197
198
|
requirements: []
|
198
|
-
rubyforge_project:
|
199
|
+
rubyforge_project:
|
199
200
|
rubygems_version: 2.2.1
|
200
201
|
signing_key:
|
201
202
|
specification_version: 4
|
@@ -221,3 +222,4 @@ test_files:
|
|
221
222
|
- test/representer_test.rb
|
222
223
|
- test/test_helper.rb
|
223
224
|
- test/xml_representer_test.rb
|
225
|
+
has_rdoc:
|