rusty_json 1.2.3 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80f45d09c233b8bd9a51eb44b6b1d494c50e5f6b
4
- data.tar.gz: b90b6666fde5e38f12031528ce5f4051594d6790
3
+ metadata.gz: 470b083bc42ad5151477ba6991b1d626fc4887c0
4
+ data.tar.gz: f3cac54e39d2ae8eb3339e060a99b830918ed282
5
5
  SHA512:
6
- metadata.gz: 97bd1d4de345fd9da6052628fe12f8c2aa1026380d35bd5c4121c4d26912289fe8489e804520accbf9675856d4cedec138c1b2d50ebf230b317a42d6f5390778
7
- data.tar.gz: 11f8b29588bafd836a4b557ee7c09e1b69e75a7e68419a390bfcdaddca72f101f77c0bbff66bd9a48949355ed05e77aa2b5e672ad35d6f02dcbfc6b6cc6e686c
6
+ metadata.gz: 65a5294a5503e023ffff0c80b647d98216dfabe720ecbd7df0c3856273bd062ca4a04a4384164b59042229a80592a9283edfa3a5be88ef4784e8aa0b908f7e94
7
+ data.tar.gz: ae207c607952accdd83e44021a3ff1e19e4c0df0a77c0af52ec7e330e6b8cff56b2bfec01b69cd98015737df3e00f4ae867200169f226d630c897e53340033f5
@@ -18,6 +18,7 @@ module RustyJson
18
18
  def initialize(name, json)
19
19
  @name = name
20
20
  @json = json
21
+ @structs = Set.new
21
22
  end
22
23
 
23
24
  # parse takes the given JSON string and turns it into a string of
@@ -47,11 +48,22 @@ module RustyJson
47
48
  end
48
49
  end
49
50
 
51
+ def possible_new_struct(s)
52
+ match = @structs.find{|st| s == st}
53
+ s = match || s
54
+ if match.nil?
55
+ @structs << s
56
+ end
57
+ s
58
+ end
59
+
50
60
  def parse_hash(key_path, hash)
51
61
  name = ActiveSupport::Inflector.singularize(key_path.map { |key| parse_name(key) }.join(''))
52
62
  struct = RustStruct.new(name)
53
63
  hash.each do |key, value|
54
- struct.add_value(clean_name(key), *parse_object(key_path + [key], value))
64
+ val = *parse_object(key_path + [key], value)
65
+ val[0] = possible_new_struct(val[0]) if val[0].is_a? RustStruct
66
+ struct.add_value(clean_name(key), *val)
55
67
  end
56
68
  [struct, nil]
57
69
  end
@@ -1,3 +1,3 @@
1
1
  module RustyJson
2
- VERSION = "1.2.3"
2
+ VERSION = "1.2.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rusty_json
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris MacNaughton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-24 00:00:00.000000000 Z
11
+ date: 2015-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler