collection_json_serializer 0.4.1 → 0.4.2
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 +4 -4
- data/README.md +8 -0
- data/lib/collection_json_serializer/builder.rb +1 -1
- data/lib/collection_json_serializer/version.rb +1 -1
- data/test/builder/builder_test.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a021b599344d995456bf77940ed4166b2622a26
|
4
|
+
data.tar.gz: 06c44a525b2a5cd7fe6b40ec0971d28008c87816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18b75cab03f284d2c40d4b630287bf5b3f7384b51653f50465448a8f6553ba240cddc0bb090cf17f2287652801d8e1b776f773f1bf19abe49f4f3c73bfea7069
|
7
|
+
data.tar.gz: 8fb503992dac16a604305d7d9a06156e7704ca489e70684a3debdc105c752b8f520a5a1c54c6087780d455f14151cb9f863eb33a006ff5a16f81c39a77f1a8d2
|
data/README.md
CHANGED
@@ -22,6 +22,14 @@ Add this line to your application's Gemfile:
|
|
22
22
|
gem 'collection_json_serializer'
|
23
23
|
```
|
24
24
|
|
25
|
+
Or if you want to use the mornings build:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
gem 'collection_json_serializer',
|
29
|
+
git: 'https://github.com/carlesjove/collection_json_serializer',
|
30
|
+
branch: 'dev'
|
31
|
+
```
|
32
|
+
|
25
33
|
And then execute:
|
26
34
|
|
27
35
|
$ bundle
|
@@ -28,7 +28,7 @@ module CollectionJson
|
|
28
28
|
def build
|
29
29
|
# There might be a more elegant way to do it, yes
|
30
30
|
add_href if @serializer.href.present?
|
31
|
-
add_items if @serializer.items?
|
31
|
+
add_items if @serializer.items?
|
32
32
|
add_links if @serializer.links?
|
33
33
|
add_template if @serializer.template?
|
34
34
|
add_queries if @serializer.queries?
|
@@ -4,6 +4,8 @@ module CollectionJson
|
|
4
4
|
class Serializer
|
5
5
|
class Builder
|
6
6
|
class TestBuilder < Minitest::Test
|
7
|
+
include TestHelper
|
8
|
+
|
7
9
|
def setup
|
8
10
|
@user1 = User.new(name: "Carles Jove", email: "hola@carlus.cat")
|
9
11
|
@user2 = User.new(name: "Aina Jove", email: "hola@example.com")
|
@@ -194,6 +196,15 @@ module CollectionJson
|
|
194
196
|
assert_equal expected.to_json, builder.to_json
|
195
197
|
end
|
196
198
|
|
199
|
+
def test_that_a_serializer_with_no_attributes_builds_items
|
200
|
+
serializer = empty_serializer_for @user1
|
201
|
+
serializer.items.link my_link: { href: 'http://example.com' }
|
202
|
+
builder = CollectionJson::Serializer::Builder.new(serializer)
|
203
|
+
|
204
|
+
assert builder.pack[:collection][:items].present?
|
205
|
+
assert builder.pack[:collection][:items][0][:links].present?
|
206
|
+
end
|
207
|
+
|
197
208
|
def test_that_an_invalid_serializer_raises_an_error
|
198
209
|
invalid_serializer = InvalidSerializer.new(@user1)
|
199
210
|
builder = Builder.new(invalid_serializer)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collection_json_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carles Jove i Buxeda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02
|
11
|
+
date: 2015-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|