dish 0.0.3 → 0.0.4
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 +2 -1
- data/lib/dish/plate.rb +4 -0
- data/lib/dish/version.rb +1 -1
- data/test/coercion_test.rb +2 -1
- data/test/dish_test.rb +6 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 617dbc0f6b27306fc59b7b9779c60470c050c0da
|
4
|
+
data.tar.gz: fcd386da110affa4a0e381e7dc7acac6277c76b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e356555d49c23b40f8c581a5f35dd3270bfab0d169a94cb0ada1a45e7872371b6a7048c5a1d9db8c8d77492bf88f650feddfa25fd5c6ea5df4e9bb2157b2417a
|
7
|
+
data.tar.gz: 0be9973a4b2a2a6c0cb7863c87ef2ab506b727c45c525a0514173b5f10d51fb02f59741fcac060edcaee3ca97788b8add3b1d3bad4cf2b11f8672a0424c169bb
|
data/README.md
CHANGED
@@ -6,6 +6,7 @@
|
|
6
6
|
|
7
7
|
Very simple conversion of hashes to plain Ruby objects.
|
8
8
|
This is great for consuming JSON API's which is what I use it for.
|
9
|
+
Also works in [RubyMotion](http://www.rubymotion.com/).
|
9
10
|
|
10
11
|
## Installation
|
11
12
|
|
@@ -69,7 +70,7 @@ Values can automatically be coerced, for example into a custom `Dish` object or
|
|
69
70
|
class Author < Dish::Plate; end
|
70
71
|
|
71
72
|
class Product < Dish::Plate
|
72
|
-
coerce :updated_at, ->
|
73
|
+
coerce :updated_at, ->(value) { Time.parse(value) }
|
73
74
|
coerce :authors, Author
|
74
75
|
end
|
75
76
|
|
data/lib/dish/plate.rb
CHANGED
data/lib/dish/version.rb
CHANGED
data/test/coercion_test.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "test_helper"
|
2
|
+
require "time" # for Time.parse in Ruby 1.9.3
|
2
3
|
|
3
4
|
class DishTest < Test::Unit::TestCase
|
4
5
|
def test_coercion
|
@@ -36,7 +37,7 @@ class DishTest < Test::Unit::TestCase
|
|
36
37
|
class Author < Dish::Plate; end
|
37
38
|
|
38
39
|
class Product < Dish::Plate
|
39
|
-
coerce :updated_at, ->
|
40
|
+
coerce :updated_at, ->(value) { Time.parse(value) }
|
40
41
|
coerce :authors, Author
|
41
42
|
end
|
42
43
|
|
data/test/dish_test.rb
CHANGED
@@ -20,6 +20,12 @@ class DishTest < Test::Unit::TestCase
|
|
20
20
|
assert_equal false, book.active?
|
21
21
|
assert_nil book.other
|
22
22
|
assert_equal false, book.other?
|
23
|
+
assert_respond_to book, :title
|
24
|
+
assert_respond_to book, :authors
|
25
|
+
refute_respond_to book, :doesnotexist
|
26
|
+
assert_nothing_raised do
|
27
|
+
m = book.method(:title)
|
28
|
+
end
|
23
29
|
end
|
24
30
|
|
25
31
|
def test_key_type_indifference
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lasse Bunk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
requirements: []
|
87
87
|
rubyforge_project:
|
88
|
-
rubygems_version: 2.2.
|
88
|
+
rubygems_version: 2.2.2
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: Super simple conversion of hashes to plain Ruby objects
|