multi_xml 0.1.2 → 0.1.3
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.
Potentially problematic release.
This version of multi_xml might be problematic. Click here for more details.
- data/Gemfile.lock +1 -1
- data/lib/multi_xml.rb +8 -1
- data/lib/multi_xml/version.rb +1 -1
- data/spec/multi_xml_spec.rb +12 -1
- metadata +4 -4
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/lib/multi_xml.rb
    CHANGED
    
    | @@ -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 | 
            -
                   | 
| 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
         | 
    
        data/lib/multi_xml/version.rb
    CHANGED
    
    
    
        data/spec/multi_xml_spec.rb
    CHANGED
    
    | @@ -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:  | 
| 4 | 
            +
              hash: 29
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 1
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.1. | 
| 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- | 
| 18 | 
            +
            date: 2010-10-18 00:00:00 -07:00
         | 
| 19 19 | 
             
            default_executable: 
         | 
| 20 20 | 
             
            dependencies: 
         | 
| 21 21 | 
             
            - !ruby/object:Gem::Dependency 
         |