roar 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c60a365b03b4c4196033eccc186b649c50f8f40a
4
- data.tar.gz: 4e5dfbfe2caa91f334c2568d6a563c223776cdab
3
+ metadata.gz: d5ead9158cbf50f06b53c2b3a965be1f055f2657
4
+ data.tar.gz: 7dede5c38e3e177de16473e463cb73c867597cb5
5
5
  SHA512:
6
- metadata.gz: f2ea14d0d3b644f2f0f4c0677e35419a91955e97f6357a283a2f21206c19a35fd19ef8c166f3b4540449fc09cf3c70ab54688c4266bfca1aa00c2a33bf6e3769
7
- data.tar.gz: ee6b42fc8b33f3e21955d6ee4ba658a4903503c4208cfc766017123ddceb802a906c759a845dbe9e9a202cd3465f0ad9db5e1c835a61adeb420a2f4308a0d07b
6
+ metadata.gz: 3991cfb442a827e6a6168b1791543ff0272bd4ab2255f617fc92c8a283f63175b95dc1d76fa06df1a90ee59904a28ee6637d0e54576d56994223aa4af838df34
7
+ data.tar.gz: b3822f0031b4f61d05d2d89359fc2291b6cc0fb1793a9073c3ebe385453894f50a378a83e9e73c93131d06e1832220335b7ce9bee9a8f480ce9def9919c52278
@@ -7,5 +7,3 @@ rvm:
7
7
  gemfile:
8
8
  - gemfiles/Gemfile.representable-2.0
9
9
  - gemfiles/Gemfile.representable-2.1
10
- notifications:
11
- irc: "irc.freenode.org#cells"
@@ -1,3 +1,7 @@
1
+ # 1.0.3
2
+
3
+ * Make `:as` work with `HAL`.
4
+
1
5
  # 1.0.2
2
6
 
3
7
  * Roar runs on Rubinius.
@@ -3,6 +3,8 @@
3
3
  _Resource-Oriented Architectures in Ruby._
4
4
 
5
5
  [![Build Status](https://travis-ci.org/apotonick/roar.svg?branch=master)](https://travis-ci.org/apotonick/roar)
6
+ [![Gem Version](https://badge.fury.io/rb/roar.svg)](http://badge.fury.io/rb/roar)
7
+ [![Gitter Chat](https://badges.gitter.im/trailblazer/chat.svg)](https://gitter.im/trailblazer/chat)
6
8
 
7
9
  ## Introduction
8
10
 
@@ -14,12 +16,6 @@ Roar comes with built-in JSON, JSON-HAL, JSON-API and XML support. Its highly mo
14
16
 
15
17
  Roar is completely framework-agnostic and loves being used in web kits like Rails, Webmachine, Sinatra, Padrino, etc. If you use Rails, consider [roar-rails](https://github.com/apotonick/roar-rails) for an enjoyable integration.
16
18
 
17
- <a href="https://leanpub.com/trailblazer">
18
- ![](https://raw.githubusercontent.com/apotonick/trailblazer/master/doc/trb.jpg)
19
- </a>
20
-
21
- Roar is part of the [Trailblazer project](https://github.com/apotonick/trailblazer). Please [buy the book](https://leanpub.com/trailblazer) to support the development. Several chapters will be dedicated to Roar, its integration into operations, hypermedia formats and client-side usage.
22
-
23
19
  ## Representable
24
20
 
25
21
  Roar is just a thin layer on top of the [representable](https://github.com/apotonick/representable) gem. While Roar gives you a DSL and behaviour for creating hypermedia APIs, representable implements all the mapping functionality.
@@ -56,8 +56,9 @@ module Roar
56
56
  super.tap do |hash|
57
57
  embedded = {}
58
58
  representable_attrs.find_all do |dfn|
59
- next unless dfn[:embedded] and fragment = hash.delete(dfn.name)
60
- embedded[dfn.name] = fragment
59
+ name = dfn[:as].(nil) # DISCUSS: should we simplify that in Representable?
60
+ next unless dfn[:embedded] and fragment = hash.delete(name)
61
+ embedded[name] = fragment
61
62
  end
62
63
 
63
64
  hash["_embedded"] = embedded if embedded.any?
@@ -1,3 +1,3 @@
1
1
  module Roar
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
@@ -156,6 +156,21 @@ class JsonHalTest < MiniTest::Spec
156
156
  it { Album.new(Artist.new("Bare, Jr."), [Song.new("Tobacco Spit")]).extend(representer).to_hash.must_equal({"_embedded"=>{"artist"=>{"name"=>"Bare, Jr."}, "songs"=>[{"title"=>"Tobacco Spit"}]}}) }
157
157
  it { Album.new.extend(representer).to_hash.must_equal({}) }
158
158
  end
159
+
160
+ describe "as: alias" do
161
+ representer! do
162
+ property :artist, as: :my_artist, class: Artist, embedded: true do
163
+ property :name
164
+ end
165
+
166
+ collection :songs, as: :my_songs, class: Song, embedded: true do
167
+ property :title
168
+ end
169
+ end
170
+
171
+ it { Album.new(Artist.new("Bare, Jr."), [Song.new("Tobacco Spit")]).extend(representer).to_hash.must_equal({"_embedded"=>{"my_artist"=>{"name"=>"Bare, Jr."}, "my_songs"=>[{"title"=>"Tobacco Spit"}]}}) }
172
+ it { Album.new.extend(representer).from_hash({"_embedded"=>{"my_artist"=>{"name"=>"Bare, Jr."}, "my_songs"=>[{"title"=>"Tobacco Spit"}]}}).inspect.must_equal "#<struct JsonHalTest::Album artist=#<struct JsonHalTest::Artist name=\"Bare, Jr.\">, songs=[#<struct JsonHalTest::Song title=\"Tobacco Spit\">]>" }
173
+ end
159
174
  end
160
175
 
161
176
 
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: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sutterer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-24 00:00:00.000000000 Z
11
+ date: 2015-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: representable