emery 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/emery/jsoner.rb +9 -0
- data/test/jsoner_test.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f274712dc6632b3ab10cc2f51259f9b1b8c4ed411c2480a2c29f3ad1024d1366
|
4
|
+
data.tar.gz: 24c03d4e4af1c063fffcab685c5c4d2e1b68723fdd2d087f0d27e7d265cb2422
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66e3dc27fcf2eb03f85dbae15d04b91758f624e4dd6aea7cd0ce4b074d128ab43dbec522b4b4b251119debcc6425152cc595caa9425074ba474cb5ddc2e66c7c
|
7
|
+
data.tar.gz: 5f7bc33da37df73954e251fdf55297d3855e857c06f71d32cef87f0dc855388f04a83ddae5941d72c443bf15e006d31c217952d308ad18cbd165bb845a8e19be
|
data/lib/emery/jsoner.rb
CHANGED
@@ -16,6 +16,15 @@ module Jsoner
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
T::UntypedType.class_eval do
|
20
|
+
def jsoner_deserialize(json_value)
|
21
|
+
json_value
|
22
|
+
end
|
23
|
+
def jsoner_serialize(value)
|
24
|
+
value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
19
28
|
T::ArrayType.class_eval do
|
20
29
|
def jsoner_deserialize(json_value)
|
21
30
|
T.check_not_nil(self, json_value)
|
data/test/jsoner_test.rb
CHANGED
@@ -213,6 +213,28 @@ class HashSerialization < Test::Unit::TestCase
|
|
213
213
|
end
|
214
214
|
end
|
215
215
|
|
216
|
+
class UntypedDeserialization < Test::Unit::TestCase
|
217
|
+
def test_deserialize_hash
|
218
|
+
data = Jsoner.from_json(Untyped, '{"one":123,"two":"some string"}')
|
219
|
+
assert_equal ({"one" => 123, "two" => "some string"}), data
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_deserialize_array
|
223
|
+
data = Jsoner.from_json(Untyped, '[123,"some string"]')
|
224
|
+
assert_equal [123, "some string"], data
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
class UntypedSerialization < Test::Unit::TestCase
|
229
|
+
def test_serialize_hash
|
230
|
+
assert_equal '{"one":123,"two":"some string"}', Jsoner.to_json(Untyped, {"one" => 123, "two" => "some string"})
|
231
|
+
end
|
232
|
+
|
233
|
+
def test_serialize_array
|
234
|
+
assert_equal '[123,"some string"]', Jsoner.to_json(Untyped, [123, "some string"])
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
216
238
|
class AnyDeserialization < Test::Unit::TestCase
|
217
239
|
def test_deserialize
|
218
240
|
data = Jsoner.from_json(T.any(String, Integer), '"the string"')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emery
|
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
|
- Vladimir Sapronov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|