brianmario-yajl-ruby 0.3.4 → 0.4.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.
- data/.gitignore +4 -0
- data/CHANGELOG.rdoc +13 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +39 -3
- data/Rakefile +4 -12
- data/VERSION.yml +2 -2
- data/benchmark/http.rb +28 -0
- data/benchmark/stream.rb +40 -0
- data/benchmark/subjects/contacts.json +1 -0
- data/benchmark/subjects/item.json +1 -0
- data/benchmark/subjects/ohai.json +1216 -0
- data/benchmark/subjects/twitter_search.json +1 -0
- data/benchmark/subjects/unicode.json +3315 -0
- data/benchmark/subjects/yelp.json +1 -0
- data/ext/extconf.rb +1 -0
- data/ext/yajl.c +86 -40
- data/ext/yajl.h +45 -0
- data/lib/yajl/http_stream.rb +67 -0
- data/lib/yajl.rb +32 -0
- data/specs/active_support_spec.rb +50 -0
- data/specs/fixtures/fail.15.json +1 -0
- data/specs/fixtures/fail.16.json +1 -0
- data/specs/fixtures/fail.17.json +1 -0
- data/specs/fixtures/fail.26.json +1 -0
- data/specs/fixtures/fail11.json +1 -0
- data/specs/fixtures/fail12.json +1 -0
- data/specs/fixtures/fail13.json +1 -0
- data/specs/fixtures/fail14.json +1 -0
- data/specs/fixtures/fail19.json +1 -0
- data/specs/fixtures/fail20.json +1 -0
- data/specs/fixtures/fail21.json +1 -0
- data/specs/fixtures/fail22.json +1 -0
- data/specs/fixtures/fail23.json +1 -0
- data/specs/fixtures/fail24.json +1 -0
- data/specs/fixtures/fail25.json +1 -0
- data/specs/fixtures/fail27.json +2 -0
- data/specs/fixtures/fail28.json +2 -0
- data/specs/fixtures/fail3.json +1 -0
- data/specs/fixtures/fail4.json +1 -0
- data/specs/fixtures/fail5.json +1 -0
- data/specs/fixtures/fail6.json +1 -0
- data/specs/fixtures/fail9.json +1 -0
- data/specs/fixtures/pass.array.json +6 -0
- data/specs/fixtures/pass.codepoints_from_unicode_org.json +1 -0
- data/specs/fixtures/pass.contacts.json +1 -0
- data/specs/fixtures/pass.db100.xml.json +1 -0
- data/specs/fixtures/pass.db1000.xml.json +1 -0
- data/specs/fixtures/pass.dc_simple_with_comments.json +11 -0
- data/specs/fixtures/pass.deep_arrays.json +1 -0
- data/specs/fixtures/pass.difficult_json_c_test_case.json +1 -0
- data/specs/fixtures/pass.difficult_json_c_test_case_with_comments.json +1 -0
- data/specs/fixtures/pass.doubles.json +1 -0
- data/specs/fixtures/pass.empty_array.json +1 -0
- data/specs/fixtures/pass.empty_string.json +1 -0
- data/specs/fixtures/pass.escaped_bulgarian.json +4 -0
- data/specs/fixtures/pass.escaped_foobar.json +1 -0
- data/specs/fixtures/pass.item.json +1 -0
- data/specs/fixtures/pass.json-org-sample1.json +23 -0
- data/specs/fixtures/pass.json-org-sample2.json +11 -0
- data/specs/fixtures/pass.json-org-sample3.json +26 -0
- data/specs/fixtures/pass.json-org-sample4-nows.json +88 -0
- data/specs/fixtures/pass.json-org-sample4.json +89 -0
- data/specs/fixtures/pass.json-org-sample5.json +27 -0
- data/specs/fixtures/pass.map-spain.xml.json +1 -0
- data/specs/fixtures/pass.ns-invoice100.xml.json +1 -0
- data/specs/fixtures/pass.ns-soap.xml.json +1 -0
- data/specs/fixtures/pass.numbers-fp-4k.json +6 -0
- data/specs/fixtures/pass.numbers-fp-64k.json +61 -0
- data/specs/fixtures/pass.numbers-int-4k.json +11 -0
- data/specs/fixtures/pass.numbers-int-64k.json +154 -0
- data/specs/fixtures/pass.twitter-search.json +1 -0
- data/specs/fixtures/pass.twitter-search2.json +1 -0
- data/specs/fixtures/pass.unicode.json +3315 -0
- data/specs/fixtures/pass.yelp.json +1 -0
- data/specs/fixtures/pass1.json +56 -0
- data/specs/fixtures/pass2.json +1 -0
- data/specs/fixtures/pass3.json +6 -0
- data/specs/fixtures_spec.rb +25 -0
- data/specs/one_off_spec.rb +11 -0
- data/specs/spec_helper.rb +4 -0
- data/yajl-ruby.gemspec +115 -0
- metadata +79 -2
| @@ -0,0 +1,50 @@ | |
| 1 | 
            +
            # encoding: UTF-8
         | 
| 2 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/spec_helper.rb')
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe "ActiveSupport test cases" do
         | 
| 5 | 
            +
              TESTS = {
         | 
| 6 | 
            +
                %q({"returnTo":{"\/categories":"\/"}})        => {"returnTo" => {"/categories" => "/"}},
         | 
| 7 | 
            +
                %q({"return\\"To\\":":{"\/categories":"\/"}}) => {"return\"To\":" => {"/categories" => "/"}},
         | 
| 8 | 
            +
                %q({"returnTo":{"\/categories":1}})          => {"returnTo" => {"/categories" => 1}},
         | 
| 9 | 
            +
                %({"returnTo":[1,"a"]})                    => {"returnTo" => [1, "a"]},
         | 
| 10 | 
            +
                %({"returnTo":[1,"\\"a\\",", "b"]})        => {"returnTo" => [1, "\"a\",", "b"]},
         | 
| 11 | 
            +
                %({"a": "'", "b": "5,000"})                  => {"a" => "'", "b" => "5,000"},
         | 
| 12 | 
            +
                %({"a": "a's, b's and c's", "b": "5,000"})   => {"a" => "a's, b's and c's", "b" => "5,000"},
         | 
| 13 | 
            +
                # multibyte
         | 
| 14 | 
            +
                %({"matzue": "松江", "asakusa": "浅草"}) => {"matzue" => "松江", "asakusa" => "浅草"},
         | 
| 15 | 
            +
                %({"a": "2007-01-01"})                       => {'a' => "2007-01-01"}, 
         | 
| 16 | 
            +
                %({"a": "2007-01-01 01:12:34 Z"})            => {'a' => "2007-01-01 01:12:34 Z"}, 
         | 
| 17 | 
            +
                # no time zone
         | 
| 18 | 
            +
                %({"a": "2007-01-01 01:12:34"})              => {'a' => "2007-01-01 01:12:34"}, 
         | 
| 19 | 
            +
                # needs to be *exact*
         | 
| 20 | 
            +
                %({"a": " 2007-01-01 01:12:34 Z "})          => {'a' => " 2007-01-01 01:12:34 Z "},
         | 
| 21 | 
            +
                %({"a": "2007-01-01 : it's your birthday"})  => {'a' => "2007-01-01 : it's your birthday"},
         | 
| 22 | 
            +
                %([])    => [],
         | 
| 23 | 
            +
                %({})    => {},
         | 
| 24 | 
            +
                %({"a":1})     => {"a" => 1},
         | 
| 25 | 
            +
                %({"a": ""})    => {"a" => ""},
         | 
| 26 | 
            +
                %({"a":"\\""}) => {"a" => "\""},
         | 
| 27 | 
            +
                %({"a": null})  => {"a" => nil},
         | 
| 28 | 
            +
                %({"a": true})  => {"a" => true},
         | 
| 29 | 
            +
                %({"a": false}) => {"a" => false},
         | 
| 30 | 
            +
                %q({"a": "http:\/\/test.host\/posts\/1"}) => {"a" => "http://test.host/posts/1"},
         | 
| 31 | 
            +
                %q({"a": "\u003cunicode\u0020escape\u003e"}) => {"a" => "<unicode escape>"},
         | 
| 32 | 
            +
                %q({"a": "\\\\u0020skip double backslashes"}) => {"a" => "\\u0020skip double backslashes"},
         | 
| 33 | 
            +
                %q({"a": "\u003cbr /\u003e"}) => {'a' => "<br />"},
         | 
| 34 | 
            +
                %q({"b":["\u003ci\u003e","\u003cb\u003e","\u003cu\u003e"]}) => {'b' => ["<i>","<b>","<u>"]}
         | 
| 35 | 
            +
              }
         | 
| 36 | 
            +
              
         | 
| 37 | 
            +
              TESTS.each do |json, expected|
         | 
| 38 | 
            +
                it "should be able to parse #{json}" do
         | 
| 39 | 
            +
                  lambda {
         | 
| 40 | 
            +
                    Yajl::Stream.parse(StringIO.new(json)).should == expected
         | 
| 41 | 
            +
                  }.should_not raise_error(Yajl::ParseError)
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              it "should fail parsing {: 1}" do
         | 
| 46 | 
            +
                lambda {
         | 
| 47 | 
            +
                  Yajl::Stream.parse(StringIO.new("{: 1}"))
         | 
| 48 | 
            +
                  }.should raise_error(Yajl::ParseError)
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
            end
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            ["Illegal backslash escape: \x15"]
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            ["Illegal backslash escape: \'"]
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            ["Illegal backslash escape: \017"]
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            ["tab\   character\   in\  string\  "]
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {"Illegal expression": 1 + 2}
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {"Illegal invocation": alert()}
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {"Numbers cannot have leading zeroes": 013}
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {"Numbers cannot be hex": 0x14}
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {"Missing colon" null}
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {"Double colon":: null}
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {"Comma instead of colon", null}
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            ["Colon instead of comma": false]
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            ["Bad value", truth]
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            ['single quote']
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            ["tab	character	in	string	"]
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {unquoted_key: "keys must be quoted"}
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            ["extra comma",]
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            ["double extra comma",,]
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            [   , "<-- missing value"]
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            {"Extra comma": true,}
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            "\u004d\u0430\u4e8c\ud800\udf02"
         |