decontaminate 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 29c7ecced8931be41ad5db4879c6387d734f7acf
4
- data.tar.gz: bb3bf6fe5d28be34cbf82853ebb211aa52cf41b9
3
+ metadata.gz: bf63bfebfa517d4e27965dee7e1793a1413c3758
4
+ data.tar.gz: 45604b7b1828c9e8c3b7d8271926188d03b09e94
5
5
  SHA512:
6
- metadata.gz: c675f357de093cef4949c21ad4456128ad6ed9464b408e5960a3676b515425b6bff5e9bb86b53537a3c5d33067001b79bbb52f37a7c875d76f0e0768218f5143
7
- data.tar.gz: 1b8f16c664a0b38864f2b3511f8d3bf01f7d840b524ddbc0b36568dcb7a5e68540e15d187b843a1a61fb3c6b2bd0d34e24558e7dfbc43024869465d477f3b823
6
+ metadata.gz: 4ac44a8b13febd6e54446280107433e7ef07814376fafc200c1d59bb8ae6c40d848389f4cc8eb50b0cd934437e1582a02e687d2995dc1f9944628aa0c6f62838
7
+ data.tar.gz: eab601d9add7eea91c77f120ca4219bd0bead3ad0493c3e016260a1bfaf023f00d9ca6c590a6d075a42ee978815077e77e65f0641f6c716892d99c4794e98edc
@@ -9,7 +9,8 @@ module Decontaminate
9
9
  end
10
10
 
11
11
  def decode(xml_node)
12
- children = xml_node.xpath xpath
12
+ children = xml_node && xml_node.xpath(xpath)
13
+ return [] unless children
13
14
  children.map do |child|
14
15
  decoder.decode child
15
16
  end
@@ -9,8 +9,8 @@ module Decontaminate
9
9
  end
10
10
 
11
11
  def decode(xml_node)
12
- child = xml_node.at_xpath xpath
13
- decoder.decode child
12
+ child = xml_node && xml_node.at_xpath(xpath)
13
+ child && decoder.decode(child)
14
14
  end
15
15
  end
16
16
  end
@@ -9,7 +9,7 @@ module Decontaminate
9
9
  end
10
10
 
11
11
  def decode(xml_node)
12
- child = xml_node.at_xpath xpath
12
+ child = xml_node && xml_node.at_xpath(xpath)
13
13
  decontaminator.new(child).as_json
14
14
  end
15
15
  end
@@ -9,16 +9,17 @@ module Decontaminate
9
9
  end
10
10
 
11
11
  def decode(xml_node)
12
- child = xml_node.at_xpath xpath
13
- text = child && coerce_node_to_text(child)
12
+ child = xml_node && xml_node.at_xpath(xpath)
13
+ return unless child
14
+ text = coerce_node_to_text child
14
15
 
15
16
  case type
16
17
  when :string
17
18
  text
18
19
  when :integer
19
- text && text.to_i
20
+ text.to_i
20
21
  when :float
21
- text && text.to_f
22
+ text.to_f
22
23
  when :boolean
23
24
  coerce_string_to_boolean text
24
25
  end
@@ -88,7 +88,7 @@ module Decontaminate
88
88
  def as_json
89
89
  acc = {}
90
90
 
91
- root_node = xml_node.at_xpath root
91
+ root_node = xml_node && xml_node.at_xpath(root)
92
92
  decoders.each do |key, decoder|
93
93
  acc[key] = decoder.decode root_node
94
94
  end
@@ -1,3 +1,3 @@
1
1
  module Decontaminate
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decontaminate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexis King
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-16 00:00:00.000000000 Z
11
+ date: 2015-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport