badgerfish 0.0.5 → 0.1.0

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: 77ca5d8751554bd8d13c131d8f3ae5c0e8265cab
4
- data.tar.gz: 3c6305a6f019ce1dbf0a7f38b10a7e4ea931c021
3
+ metadata.gz: 2bd0c2f01a54d5bc631a46b5f1eb59216df22e0e
4
+ data.tar.gz: 63ab5d52dadf0c825279781f2b92369479635d4b
5
5
  SHA512:
6
- metadata.gz: 29c369802ee9ba3cb46969dba64bda3e800a81b3201841f8f1e4433a4cd1ede73d2751e5fb6057472e38c989e2edd8f462d9502b6adc9813b31a77ce5e62b633
7
- data.tar.gz: 8576a5a6c818667fe0cd085af4e349bb1e0fd034e48cbc45ec8f3d5252d2edf3b69d4267a0756cfecccb61ff43b1b8682dd0d4aaf4ce64ecc08ea3db8678aebe
6
+ metadata.gz: b04d5755f9ab785adb8a7ab58315285f702b01a0aa94337b2274c2661a0e73c7b14217b67d9b706f34a55ec63f0200188879e044c49d2cc016f086287e37d36a
7
+ data.tar.gz: b44c19c7f54bc5149a27df8e5d9f8c0127b047e3e71ea1ce7650eb807ec80afdd05182f185f387d389f61509731581ae90630354cb891f4963e348ae8ec24b53
@@ -30,7 +30,11 @@ module Badgerfish
30
30
  end
31
31
 
32
32
  def end_element(name)
33
- @root = @parents.pop
33
+ (@root = @parents.pop).inject(@root) do |memo, (key, value)|
34
+ memo.tap do |hash|
35
+ hash[key] = nil if value.empty?
36
+ end
37
+ end
34
38
  end
35
39
 
36
40
  def attr(name, value)
@@ -1,3 +1,3 @@
1
1
  module Badgerfish
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,17 @@
1
+ module TestBadgerfishEdgeCases
2
+ def test_badgerfish_edge_case_nr_1
3
+ xml = '<root><a></a><b/></root>'
4
+ expected_json = <<-json
5
+ {
6
+ "root": {
7
+ "a": {
8
+ "$": ""
9
+ },
10
+ "b": null
11
+ }
12
+ }
13
+ json
14
+
15
+ assert_badgerfish xml, expected_json
16
+ end
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badgerfish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Sievers
@@ -160,6 +160,7 @@ files:
160
160
  - lib/badgerfish/ox_sax_parser.rb
161
161
  - lib/badgerfish/parser.rb
162
162
  - lib/badgerfish/version.rb
163
+ - test/badgerfish/test_badgerfish_edge_cases.rb
163
164
  - test/badgerfish/test_badgerfish_ning_com.rb
164
165
  - test/test_badgerfish.rb
165
166
  - test/test_helper.rb
@@ -188,6 +189,7 @@ signing_key:
188
189
  specification_version: 4
189
190
  summary: Badgerfish xml to json convention for ruby
190
191
  test_files:
192
+ - test/badgerfish/test_badgerfish_edge_cases.rb
191
193
  - test/badgerfish/test_badgerfish_ning_com.rb
192
194
  - test/test_badgerfish.rb
193
195
  - test/test_helper.rb