multi_xml 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of multi_xml might be problematic. Click here for more details.

@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- multi_xml (0.1.2)
4
+ multi_xml (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -5,6 +5,8 @@ require 'time'
5
5
  require 'yaml'
6
6
 
7
7
  module MultiXml
8
+ class ParseError < StandardError; end
9
+
8
10
  class << self
9
11
 
10
12
  REQUIREMENT_MAP = [
@@ -89,7 +91,11 @@ module MultiXml
89
91
  # <tt>:symbolize_keys</tt> :: If true, will use symbols instead of strings for the keys.
90
92
  def parse(xml, options={})
91
93
  xml.strip!
92
- hash = typecast_xml_value(undasherize_keys(parser.parse(xml))) || {}
94
+ begin
95
+ hash = typecast_xml_value(undasherize_keys(parser.parse(xml))) || {}
96
+ rescue StandardError => exception
97
+ raise ParseError, exception.inspect
98
+ end
93
99
  hash = symbolize_keys(hash) if options[:symbolize_keys]
94
100
  hash
95
101
  end
@@ -215,6 +221,7 @@ module MultiXml
215
221
  end
216
222
  end
217
223
  end
224
+
218
225
  end
219
226
 
220
227
  library_files = Dir[File.join(File.dirname(__FILE__), "/multi_xml/**/*.rb")].sort
@@ -1,3 +1,3 @@
1
1
  module MultiXml
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -55,8 +55,19 @@ describe "MultiXml" do
55
55
  end
56
56
  end
57
57
 
58
- context "an XML document" do
58
+ context "an invalid XML document" do
59
+ before do
60
+ @xml = '<open></close>'
61
+ end
62
+
63
+ it "should raise MultiXml::ParseError" do
64
+ lambda do
65
+ MultiXml.parse(@xml)
66
+ end.should raise_error(MultiXml::ParseError)
67
+ end
68
+ end
59
69
 
70
+ context "a valid XML document" do
60
71
  before do
61
72
  @xml = '<user/>'
62
73
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_xml
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Erik Michaels-Ober
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-16 00:00:00 -07:00
18
+ date: 2010-10-18 00:00:00 -07:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency