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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 629dad4de96ce6b80b94e883ac9dee5dff07c677d431727e83a7c379c229524b
4
- data.tar.gz: 3dc8b2cc93ff053470be638ca64659f02de7c7f07894427212c603b3f36a8ad0
3
+ metadata.gz: f274712dc6632b3ab10cc2f51259f9b1b8c4ed411c2480a2c29f3ad1024d1366
4
+ data.tar.gz: 24c03d4e4af1c063fffcab685c5c4d2e1b68723fdd2d087f0d27e7d265cb2422
5
5
  SHA512:
6
- metadata.gz: fed3812431f78ab7bb66066c19c788babe478675a1108ef038c237a2e47734dce7e572b53d3d781430da4d72eb4e4c29ab36f0cf80721395d3d971acaa6be83d
7
- data.tar.gz: 9dfc4c611a1da41452861b565c7a4042a1ea8f685ebc79d87a6186fabc0cf96ba1e005a5c6e4617a50d22619799eb46e49c42238d348f6687d8b80cacd47f661
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.3
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-03-26 00:00:00.000000000 Z
11
+ date: 2020-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json