xmlhash 1.3.5 → 1.3.6
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 +7 -0
- data/History.txt +5 -0
- data/Rakefile +1 -0
- data/ext/xmlhash/xmlhash.c +1 -1
- data/lib/xmlhash.rb +9 -2
- data/test/test_xmlhash.rb +57 -56
- metadata +20 -29
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 57b370bdc50c90e41133a4e21022f8fd6b5f5fc1
         | 
| 4 | 
            +
              data.tar.gz: b834afbf06b454a31617d5f4e798d5f15f11a2f1
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 807cf8ecd2ad560ed1d302f5b4276acca584a9a85ac16bf12d8ef2b2464f78fd9e7e1379d7c351c190162d4a83c317a8dc91f994e7d43e5296d8a82b9dcf7893
         | 
| 7 | 
            +
              data.tar.gz: 163da7fe46fd438db9200e113f57a75f37cc6ecad11ebefdfe3401626a49f3822e38d68725350fc30ad947899cc79aa82c3aff0da73fe7fbc78b99f85b03509b
         | 
    
        data/History.txt
    CHANGED
    
    | @@ -1,3 +1,8 @@ | |
| 1 | 
            +
            === 1.3.6 / 2013-09-11
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            * Wrap libxml2 parsing in a synchronize block - otherwise the stacking
         | 
| 4 | 
            +
              will not work and it's too much work to make it reentrant
         | 
| 5 | 
            +
             | 
| 1 6 | 
             
            === 1.3.5 / 2012-12-21 ("final edition")
         | 
| 2 7 |  | 
| 3 8 | 
             
            * Initialize result so we don't return something random in case of parse error
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -7,6 +7,7 @@ require 'rake/extensiontask' | |
| 7 7 | 
             
            Hoe.spec 'xmlhash' do
         | 
| 8 8 | 
             
              developer('Stephan Kulow', 'coolo@suse.com')
         | 
| 9 9 | 
             
              self.readme_file = 'README.txt'
         | 
| 10 | 
            +
              self.license('MIT')
         | 
| 10 11 | 
             
              self.spec_extras = { :extensions => ["ext/xmlhash/extconf.rb"] }
         | 
| 11 12 | 
             
              self.extra_dev_deps << ['rake-compiler', '>= 0']
         | 
| 12 13 | 
             
              self.extra_deps << ['pkg-config']
         | 
    
        data/ext/xmlhash/xmlhash.c
    CHANGED
    
    | @@ -238,7 +238,7 @@ void Init_xmlhash() | |
| 238 238 | 
             
              LIBXML_TEST_VERSION
         | 
| 239 239 | 
             
              mXmlhash = rb_define_module("Xmlhash");
         | 
| 240 240 | 
             
              m_xmlClass = rb_define_class_under(mXmlhash, "XMLHash", rb_cHash);
         | 
| 241 | 
            -
              rb_define_singleton_method(mXmlhash, " | 
| 241 | 
            +
              rb_define_singleton_method(mXmlhash, "parse_int", &parse_xml_hash, 1);
         | 
| 242 242 | 
             
              m_stack = rb_ary_new();
         | 
| 243 243 | 
             
              rb_global_variable(&m_stack);
         | 
| 244 244 | 
             
              m_cstring = rb_ary_new();
         | 
    
        data/lib/xmlhash.rb
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            require 'xmlhash/xmlhash'
         | 
| 2 2 |  | 
| 3 3 | 
             
            module Xmlhash
         | 
| 4 | 
            -
              VERSION = '1.3. | 
| 4 | 
            +
              VERSION = '1.3.6'
         | 
| 5 5 |  | 
| 6 6 | 
             
              class XMLHash < Hash
         | 
| 7 7 |  | 
| @@ -61,5 +61,12 @@ module Xmlhash | |
| 61 61 | 
             
                def inspect
         | 
| 62 62 | 
             
                  "X(#{super})"
         | 
| 63 63 | 
             
                end
         | 
| 64 | 
            +
             | 
| 65 | 
            +
              end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
              def self.parse(str)
         | 
| 68 | 
            +
                @@mutex ||= Mutex.new
         | 
| 69 | 
            +
                @@mutex.synchronize { parse_int(str) }
         | 
| 64 70 | 
             
              end
         | 
| 65 | 
            -
             | 
| 71 | 
            +
             | 
| 72 | 
            +
            end
         | 
    
        data/test/test_xmlhash.rb
    CHANGED
    
    | @@ -4,9 +4,7 @@ require "test/unit" | |
| 4 4 | 
             
            require "xmlhash"
         | 
| 5 5 | 
             
            require 'json'
         | 
| 6 6 |  | 
| 7 | 
            -
             | 
| 8 | 
            -
              def test_xml
         | 
| 9 | 
            -
                xml = <<eos
         | 
| 7 | 
            +
            Xml = <<eos
         | 
| 10 8 | 
             
            <request id="93651">
         | 
| 11 9 | 
             
              <action type="submit">
         | 
| 12 10 | 
             
                <source project="server:dns" package="pdns" rev="65"/>
         | 
| @@ -16,28 +14,7 @@ class TestXmlhash < Test::Unit::TestCase | |
| 16 14 | 
             
                <comment/>
         | 
| 17 15 | 
             
              </state>
         | 
| 18 16 | 
             
              <review state="accepted" by_group="legal-auto" who="licensedigger" when="2011-11-25T15:09:55">
         | 
| 19 | 
            -
                <comment> | 
| 20 | 
            -
              "dest": {
         | 
| 21 | 
            -
                "ldb": {
         | 
| 22 | 
            -
                  "review": "done", 
         | 
| 23 | 
            -
                  "rpm_license": "GPLv2+", 
         | 
| 24 | 
            -
                  "status": "production", 
         | 
| 25 | 
            -
                  "version": "3.0.rc1"
         | 
| 26 | 
            -
                }, 
         | 
| 27 | 
            -
                "license": "GPLv2+", 
         | 
| 28 | 
            -
                "version": "2.9.22"
         | 
| 29 | 
            -
              }, 
         | 
| 30 | 
            -
              "hint": [
         | 
| 31 | 
            -
                "src('3.0') and dest('2.9.22') version numbers differ"
         | 
| 32 | 
            -
              ], 
         | 
| 33 | 
            -
              "plugin": "0.35", 
         | 
| 34 | 
            -
              "src": {
         | 
| 35 | 
            -
                "auto-co": "/api.opensuse.org/server:dns/pdns%3.0%r65", 
         | 
| 36 | 
            -
                "license": "GPLv2+", 
         | 
| 37 | 
            -
                "rev": "65", 
         | 
| 38 | 
            -
                "version": "3.0"
         | 
| 39 | 
            -
              }
         | 
| 40 | 
            -
            } --></comment>
         | 
| 17 | 
            +
                <comment>Big comment</comment>
         | 
| 41 18 | 
             
              </review>
         | 
| 42 19 | 
             
              <review state="new" by_group="factory-auto"/>
         | 
| 43 20 | 
             
              <history name="review" who="coolo" when="2011-11-25T15:02:53"/>
         | 
| @@ -48,30 +25,54 @@ class TestXmlhash < Test::Unit::TestCase | |
| 48 25 | 
             
            </request>
         | 
| 49 26 | 
             
            eos
         | 
| 50 27 |  | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
             | 
| 55 | 
            -
             | 
| 56 | 
            -
             | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 28 | 
            +
            Output = {"history" =>
         | 
| 29 | 
            +
                          [{"name" => "review", "when" => "2011-11-25T15:02:53", "who" => "coolo"},
         | 
| 30 | 
            +
                           {"comment" => "please make sure to wait before these depencencies are in openSUSE:Factory: libopendbx-devel, libopendbx1, libopendbxplus1, opendbx-backend-pgsql",
         | 
| 31 | 
            +
                            "name" => "declined", "when" => "2011-11-25T16:17:30", "who" => "coolo"}
         | 
| 32 | 
            +
                          ],
         | 
| 33 | 
            +
                      "review" =>
         | 
| 34 | 
            +
                          [
         | 
| 35 | 
            +
                              {"comment" => "Big comment",
         | 
| 36 | 
            +
                               "by_group" => "legal-auto",
         | 
| 37 | 
            +
                               "when" => "2011-11-25T15:09:55",
         | 
| 38 | 
            +
                               "who" => "licensedigger",
         | 
| 39 | 
            +
                               "state" => "accepted"
         | 
| 40 | 
            +
                              },
         | 
| 41 | 
            +
                              {"by_group" => "factory-auto",
         | 
| 42 | 
            +
                               "state" => "new"}
         | 
| 43 | 
            +
                          ], "action" => {"type" => "submit", "target" => {"project" => "openSUSE:Factory", "package" => "pdns"}, "source" => {"rev" => "65", "project" => "server:dns", "package" => "pdns"}}, "id" => "93651", "description" => "update and factory fix (forwarded request 86230 from -miska-)", "state" => {"comment" => {}, "name" => "revoked", "when" => "2011-12-19T13:20:50", "who" => "coolo"}}
         | 
| 44 | 
            +
             | 
| 45 | 
            +
             | 
| 46 | 
            +
            class TestXmlhash < Test::Unit::TestCase
         | 
| 47 | 
            +
              def test_xml
         | 
| 48 | 
            +
             | 
| 59 49 |  | 
| 60 50 | 
             
                1000.times {
         | 
| 61 | 
            -
                  ret = Xmlhash.parse( | 
| 51 | 
            +
                  ret = Xmlhash.parse(Xml)
         | 
| 62 52 | 
             
                  GC.start
         | 
| 63 | 
            -
                  assert_equal ret,  | 
| 53 | 
            +
                  assert_equal ret, Output
         | 
| 64 54 | 
             
                }
         | 
| 65 | 
            -
             | 
| 55 | 
            +
             | 
| 66 56 | 
             
                10000.times {
         | 
| 67 | 
            -
                  ret = Xmlhash.parse( | 
| 68 | 
            -
                  assert_equal ret,  | 
| 69 | 
            -
             | 
| 57 | 
            +
                  ret = Xmlhash.parse(Xml)
         | 
| 58 | 
            +
                  assert_equal ret, Output
         | 
| 59 | 
            +
                }
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              end
         | 
| 70 62 |  | 
| 63 | 
            +
              def test_threading
         | 
| 64 | 
            +
                10.times do
         | 
| 65 | 
            +
                  Thread.new do
         | 
| 66 | 
            +
                    100.times do
         | 
| 67 | 
            +
                      ret = Xmlhash.parse(Xml)
         | 
| 68 | 
            +
                      assert_equal ret, Output
         | 
| 69 | 
            +
                    end
         | 
| 70 | 
            +
                  end
         | 
| 71 | 
            +
                end
         | 
| 71 72 | 
             
              end
         | 
| 72 73 |  | 
| 73 74 | 
             
              def test_entry
         | 
| 74 | 
            -
             | 
| 75 | 
            +
                xml = <<eos
         | 
| 75 76 | 
             
            <?xml version='1.0' encoding='UTF-8'?>
         | 
| 76 77 | 
             
            <directory count="4">
         | 
| 77 78 | 
             
               <entry name="Apache"/>
         | 
| @@ -82,12 +83,12 @@ eos | |
| 82 83 | 
             
            eos
         | 
| 83 84 |  | 
| 84 85 | 
             
                rubyoutput = {"count" => "4",
         | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 86 | 
            +
                              "entry" =>
         | 
| 87 | 
            +
                                  [{"name" => "Apache"},
         | 
| 88 | 
            +
                                   {"name" => "Apache:APR_Pool_Debug"},
         | 
| 89 | 
            +
                                   {"name" => "Apache:MirrorBrain"},
         | 
| 90 | 
            +
                                   {"name" => "Apache:Modules"}]}
         | 
| 91 | 
            +
             | 
| 91 92 | 
             
                ret = Xmlhash.parse(xml)
         | 
| 92 93 | 
             
                assert_equal ret, rubyoutput
         | 
| 93 94 |  | 
| @@ -96,16 +97,16 @@ eos | |
| 96 97 | 
             
              end
         | 
| 97 98 |  | 
| 98 99 | 
             
              def test_encoding
         | 
| 99 | 
            -
             | 
| 100 | 
            +
                xml = "<?xml version='1.0' encoding='UTF-8'?><name>Adrian Schröter</name>"
         | 
| 100 101 |  | 
| 101 | 
            -
             | 
| 102 | 
            -
             | 
| 102 | 
            +
                ret = Xmlhash.parse(xml)
         | 
| 103 | 
            +
                assert_equal ret, "Adrian Schröter"
         | 
| 103 104 |  | 
| 104 | 
            -
             | 
| 105 | 
            -
             | 
| 106 | 
            -
             | 
| 105 | 
            +
                xml = "<?xml version='1.0' encoding='UTF-8'?><name value='Adrian Schröter'/>"
         | 
| 106 | 
            +
                ret = Xmlhash.parse(xml)
         | 
| 107 | 
            +
                assert_equal ret, {"value" => "Adrian Schröter"}
         | 
| 107 108 |  | 
| 108 | 
            -
             | 
| 109 | 
            +
                assert_equal ret.get("value"), "Adrian Schröter"
         | 
| 109 110 | 
             
              end
         | 
| 110 111 |  | 
| 111 112 | 
             
              def test_cdata
         | 
| @@ -117,7 +118,7 @@ eos | |
| 117 118 | 
             
            eos
         | 
| 118 119 |  | 
| 119 120 | 
             
                ret = Xmlhash.parse(xml)
         | 
| 120 | 
            -
                assert_equal ret['diff'], {"lines" => "1", "_content" => "DummyContent" | 
| 121 | 
            +
                assert_equal ret['diff'], {"lines" => "1", "_content" => "DummyContent"}
         | 
| 121 122 | 
             
              end
         | 
| 122 123 |  | 
| 123 124 | 
             
              def test_empty
         | 
| @@ -133,7 +134,7 @@ eos | |
| 133 134 | 
             
              end
         | 
| 134 135 |  | 
| 135 136 | 
             
              def test_utf8
         | 
| 136 | 
            -
             | 
| 137 | 
            +
                xml = '<package name="libconfig" project="home:coolo">
         | 
| 137 138 | 
             
              <title>libconfig – C/C++ Configuration File Library</title>
         | 
| 138 139 | 
             
              <description>Libconfig is a simple library for processing structured configuration files, like this one: test.cfg. This file format is more compact and more readable than XML. And unlike XML, it is type-aware, so it is not necessary to do string parsing in application code.
         | 
| 139 140 |  | 
| @@ -154,7 +155,7 @@ The library includes bindings for both the C and C++ languages. It works on POSI | |
| 154 155 | 
             
                xml.encode!('ISO-8859-1')
         | 
| 155 156 | 
             
                xh = Xmlhash.parse(xml)
         | 
| 156 157 | 
             
                assert_equal "ISO-8859-1", xh['title'].encoding.to_s
         | 
| 157 | 
            -
             | 
| 158 | 
            +
             | 
| 158 159 | 
             
                xml = '<?xml version="1.0" encoding="ISO-8859-1"?>
         | 
| 159 160 | 
             
                <package><title>äÓþ</title></package>'
         | 
| 160 161 | 
             
                xml.encode!('US-ASCII')
         | 
    
        metadata
    CHANGED
    
    | @@ -1,83 +1,74 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: xmlhash
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.3. | 
| 5 | 
            -
              prerelease: 
         | 
| 4 | 
            +
              version: 1.3.6
         | 
| 6 5 | 
             
            platform: ruby
         | 
| 7 6 | 
             
            authors:
         | 
| 8 7 | 
             
            - Stephan Kulow
         | 
| 9 8 | 
             
            autorequire: 
         | 
| 10 9 | 
             
            bindir: bin
         | 
| 11 10 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 11 | 
            +
            date: 2013-09-11 00:00:00.000000000 Z
         | 
| 13 12 | 
             
            dependencies:
         | 
| 14 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 14 | 
             
              name: pkg-config
         | 
| 16 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 17 | 
            -
                none: false
         | 
| 18 16 | 
             
                requirements:
         | 
| 19 | 
            -
                - -  | 
| 17 | 
            +
                - - '>='
         | 
| 20 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 21 19 | 
             
                    version: '0'
         | 
| 22 20 | 
             
              type: :runtime
         | 
| 23 21 | 
             
              prerelease: false
         | 
| 24 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            -
                none: false
         | 
| 26 23 | 
             
                requirements:
         | 
| 27 | 
            -
                - -  | 
| 24 | 
            +
                - - '>='
         | 
| 28 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 29 26 | 
             
                    version: '0'
         | 
| 30 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 31 28 | 
             
              name: rdoc
         | 
| 32 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 33 | 
            -
                none: false
         | 
| 34 30 | 
             
                requirements:
         | 
| 35 31 | 
             
                - - ~>
         | 
| 36 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 37 | 
            -
                    version: ' | 
| 33 | 
            +
                    version: '4.0'
         | 
| 38 34 | 
             
              type: :development
         | 
| 39 35 | 
             
              prerelease: false
         | 
| 40 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 41 | 
            -
                none: false
         | 
| 42 37 | 
             
                requirements:
         | 
| 43 38 | 
             
                - - ~>
         | 
| 44 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 45 | 
            -
                    version: ' | 
| 40 | 
            +
                    version: '4.0'
         | 
| 46 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 47 42 | 
             
              name: rake-compiler
         | 
| 48 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 49 | 
            -
                none: false
         | 
| 50 44 | 
             
                requirements:
         | 
| 51 | 
            -
                - -  | 
| 45 | 
            +
                - - '>='
         | 
| 52 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 53 47 | 
             
                    version: '0'
         | 
| 54 48 | 
             
              type: :development
         | 
| 55 49 | 
             
              prerelease: false
         | 
| 56 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 57 | 
            -
                none: false
         | 
| 58 51 | 
             
                requirements:
         | 
| 59 | 
            -
                - -  | 
| 52 | 
            +
                - - '>='
         | 
| 60 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 54 | 
             
                    version: '0'
         | 
| 62 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 63 56 | 
             
              name: hoe
         | 
| 64 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 65 | 
            -
                none: false
         | 
| 66 58 | 
             
                requirements:
         | 
| 67 59 | 
             
                - - ~>
         | 
| 68 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            -
                    version: '3. | 
| 61 | 
            +
                    version: '3.7'
         | 
| 70 62 | 
             
              type: :development
         | 
| 71 63 | 
             
              prerelease: false
         | 
| 72 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            -
                none: false
         | 
| 74 65 | 
             
                requirements:
         | 
| 75 66 | 
             
                - - ~>
         | 
| 76 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            -
                    version: '3. | 
| 78 | 
            -
            description:  | 
| 79 | 
            -
             | 
| 80 | 
            -
              string into a ruby hash | 
| 68 | 
            +
                    version: '3.7'
         | 
| 69 | 
            +
            description: |-
         | 
| 70 | 
            +
              A small C module that wraps libxml2's xmlreader to parse a XML
         | 
| 71 | 
            +
              string into a ruby hash
         | 
| 81 72 | 
             
            email:
         | 
| 82 73 | 
             
            - coolo@suse.com
         | 
| 83 74 | 
             
            executables: []
         | 
| @@ -101,7 +92,9 @@ files: | |
| 101 92 | 
             
            - test/test_xmlhash.rb
         | 
| 102 93 | 
             
            - .gemtest
         | 
| 103 94 | 
             
            homepage: https://github.com/coolo/xmlhash
         | 
| 104 | 
            -
            licenses: | 
| 95 | 
            +
            licenses:
         | 
| 96 | 
            +
            - MIT
         | 
| 97 | 
            +
            metadata: {}
         | 
| 105 98 | 
             
            post_install_message: 
         | 
| 106 99 | 
             
            rdoc_options:
         | 
| 107 100 | 
             
            - --main
         | 
| @@ -109,22 +102,20 @@ rdoc_options: | |
| 109 102 | 
             
            require_paths:
         | 
| 110 103 | 
             
            - lib
         | 
| 111 104 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 112 | 
            -
              none: false
         | 
| 113 105 | 
             
              requirements:
         | 
| 114 | 
            -
              - -  | 
| 106 | 
            +
              - - '>='
         | 
| 115 107 | 
             
                - !ruby/object:Gem::Version
         | 
| 116 108 | 
             
                  version: '0'
         | 
| 117 109 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 118 | 
            -
              none: false
         | 
| 119 110 | 
             
              requirements:
         | 
| 120 | 
            -
              - -  | 
| 111 | 
            +
              - - '>='
         | 
| 121 112 | 
             
                - !ruby/object:Gem::Version
         | 
| 122 113 | 
             
                  version: '0'
         | 
| 123 114 | 
             
            requirements: []
         | 
| 124 115 | 
             
            rubyforge_project: xmlhash
         | 
| 125 | 
            -
            rubygems_version:  | 
| 116 | 
            +
            rubygems_version: 2.0.3
         | 
| 126 117 | 
             
            signing_key: 
         | 
| 127 | 
            -
            specification_version:  | 
| 118 | 
            +
            specification_version: 4
         | 
| 128 119 | 
             
            summary: A small C module that wraps libxml2's xmlreader to parse a XML string into
         | 
| 129 120 | 
             
              a ruby hash
         | 
| 130 121 | 
             
            test_files:
         |