brianmario-yajl-ruby 0.4.6 → 0.4.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/CHANGELOG.rdoc +10 -0
  2. data/README.rdoc +25 -23
  3. data/Rakefile +11 -1
  4. data/VERSION.yml +2 -2
  5. data/benchmark/encode.rb +1 -1
  6. data/benchmark/encode_json_and_marshal.rb +1 -1
  7. data/benchmark/encode_json_and_yaml.rb +1 -1
  8. data/benchmark/parse.rb +1 -1
  9. data/benchmark/parse_json_and_marshal.rb +1 -1
  10. data/benchmark/parse_json_and_yaml.rb +1 -1
  11. data/benchmark/subjects/unicode.json +1 -3315
  12. data/ext/api/yajl_common.h +85 -0
  13. data/ext/api/yajl_gen.h +123 -0
  14. data/ext/api/yajl_parse.h +179 -0
  15. data/ext/extconf.rb +2 -8
  16. data/ext/yajl.c +128 -260
  17. data/ext/yajl_alloc.c +65 -0
  18. data/ext/yajl_alloc.h +50 -0
  19. data/ext/yajl_buf.c +119 -0
  20. data/ext/yajl_buf.h +73 -0
  21. data/ext/yajl_bytestack.h +85 -0
  22. data/ext/yajl_encode.c +179 -0
  23. data/ext/yajl_encode.h +44 -0
  24. data/ext/yajl_ext.c +283 -0
  25. data/ext/{yajl.h → yajl_ext.h} +2 -2
  26. data/ext/yajl_gen.c +295 -0
  27. data/ext/yajl_lex.c +737 -0
  28. data/ext/yajl_lex.h +133 -0
  29. data/ext/yajl_parser.c +445 -0
  30. data/ext/yajl_parser.h +79 -0
  31. data/lib/yajl/bzip2.rb +1 -1
  32. data/lib/yajl/deflate.rb +1 -1
  33. data/lib/yajl/gzip.rb +1 -1
  34. data/lib/yajl/http_stream.rb +1 -1
  35. data/lib/yajl.rb +1 -1
  36. data/spec/encoding/encoding_spec.rb +23 -0
  37. data/spec/http/{http.bzip2.dump → fixtures/http.bzip2.dump} +0 -0
  38. data/spec/http/{http.deflate.dump → fixtures/http.deflate.dump} +0 -0
  39. data/spec/http/{http.gzip.dump → fixtures/http.gzip.dump} +0 -0
  40. data/spec/http/{http.raw.dump → fixtures/http.raw.dump} +0 -0
  41. data/spec/http/http_spec.rb +98 -0
  42. data/spec/{active_support_spec.rb → parsing/active_support_spec.rb} +1 -1
  43. data/spec/{fixtures → parsing/fixtures}/fail.15.json +0 -0
  44. data/spec/{fixtures → parsing/fixtures}/fail.16.json +0 -0
  45. data/spec/{fixtures → parsing/fixtures}/fail.17.json +0 -0
  46. data/spec/{fixtures → parsing/fixtures}/fail.26.json +0 -0
  47. data/spec/{fixtures → parsing/fixtures}/fail11.json +0 -0
  48. data/spec/{fixtures → parsing/fixtures}/fail12.json +0 -0
  49. data/spec/{fixtures → parsing/fixtures}/fail13.json +0 -0
  50. data/spec/{fixtures → parsing/fixtures}/fail14.json +0 -0
  51. data/spec/{fixtures → parsing/fixtures}/fail19.json +0 -0
  52. data/spec/{fixtures → parsing/fixtures}/fail20.json +0 -0
  53. data/spec/{fixtures → parsing/fixtures}/fail21.json +0 -0
  54. data/spec/{fixtures → parsing/fixtures}/fail22.json +0 -0
  55. data/spec/{fixtures → parsing/fixtures}/fail23.json +0 -0
  56. data/spec/{fixtures → parsing/fixtures}/fail24.json +0 -0
  57. data/spec/{fixtures → parsing/fixtures}/fail25.json +0 -0
  58. data/spec/{fixtures → parsing/fixtures}/fail27.json +0 -0
  59. data/spec/{fixtures → parsing/fixtures}/fail28.json +0 -0
  60. data/spec/{fixtures → parsing/fixtures}/fail3.json +0 -0
  61. data/spec/{fixtures → parsing/fixtures}/fail4.json +0 -0
  62. data/spec/{fixtures → parsing/fixtures}/fail5.json +0 -0
  63. data/spec/{fixtures → parsing/fixtures}/fail6.json +0 -0
  64. data/spec/{fixtures → parsing/fixtures}/fail9.json +0 -0
  65. data/spec/{fixtures → parsing/fixtures}/pass.array.json +0 -0
  66. data/spec/{fixtures → parsing/fixtures}/pass.codepoints_from_unicode_org.json +0 -0
  67. data/spec/{fixtures → parsing/fixtures}/pass.contacts.json +0 -0
  68. data/spec/{fixtures → parsing/fixtures}/pass.db100.xml.json +0 -0
  69. data/spec/{fixtures → parsing/fixtures}/pass.db1000.xml.json +0 -0
  70. data/spec/{fixtures → parsing/fixtures}/pass.dc_simple_with_comments.json +0 -0
  71. data/spec/{fixtures → parsing/fixtures}/pass.deep_arrays.json +0 -0
  72. data/spec/{fixtures → parsing/fixtures}/pass.difficult_json_c_test_case.json +0 -0
  73. data/spec/{fixtures → parsing/fixtures}/pass.difficult_json_c_test_case_with_comments.json +0 -0
  74. data/spec/{fixtures → parsing/fixtures}/pass.doubles.json +0 -0
  75. data/spec/{fixtures → parsing/fixtures}/pass.empty_array.json +0 -0
  76. data/spec/{fixtures → parsing/fixtures}/pass.empty_string.json +0 -0
  77. data/spec/{fixtures → parsing/fixtures}/pass.escaped_bulgarian.json +0 -0
  78. data/spec/{fixtures → parsing/fixtures}/pass.escaped_foobar.json +0 -0
  79. data/spec/{fixtures → parsing/fixtures}/pass.item.json +0 -0
  80. data/spec/{fixtures → parsing/fixtures}/pass.json-org-sample1.json +0 -0
  81. data/spec/{fixtures → parsing/fixtures}/pass.json-org-sample2.json +0 -0
  82. data/spec/{fixtures → parsing/fixtures}/pass.json-org-sample3.json +0 -0
  83. data/spec/{fixtures → parsing/fixtures}/pass.json-org-sample4-nows.json +0 -0
  84. data/spec/{fixtures → parsing/fixtures}/pass.json-org-sample4.json +0 -0
  85. data/spec/{fixtures → parsing/fixtures}/pass.json-org-sample5.json +0 -0
  86. data/spec/{fixtures → parsing/fixtures}/pass.map-spain.xml.json +0 -0
  87. data/spec/{fixtures → parsing/fixtures}/pass.ns-invoice100.xml.json +0 -0
  88. data/spec/{fixtures → parsing/fixtures}/pass.ns-soap.xml.json +0 -0
  89. data/spec/{fixtures → parsing/fixtures}/pass.numbers-fp-4k.json +0 -0
  90. data/spec/{fixtures → parsing/fixtures}/pass.numbers-fp-64k.json +0 -0
  91. data/spec/{fixtures → parsing/fixtures}/pass.numbers-int-4k.json +0 -0
  92. data/spec/{fixtures → parsing/fixtures}/pass.numbers-int-64k.json +0 -0
  93. data/spec/{fixtures → parsing/fixtures}/pass.twitter-search.json +0 -0
  94. data/spec/{fixtures → parsing/fixtures}/pass.twitter-search2.json +0 -0
  95. data/spec/{fixtures → parsing/fixtures}/pass.unicode.json +0 -0
  96. data/spec/{fixtures → parsing/fixtures}/pass.yelp.json +0 -0
  97. data/spec/{fixtures → parsing/fixtures}/pass1.json +0 -0
  98. data/spec/{fixtures → parsing/fixtures}/pass2.json +0 -0
  99. data/spec/{fixtures → parsing/fixtures}/pass3.json +0 -0
  100. data/spec/{fixtures_spec.rb → parsing/fixtures_spec.rb} +1 -1
  101. data/spec/{one_off_spec.rb → parsing/one_off_spec.rb} +1 -1
  102. data/yajl-ruby.gemspec +91 -72
  103. metadata +91 -71
  104. data/benchmark/subjects/yelp.json +0 -1
data/CHANGELOG.rdoc CHANGED
@@ -1,5 +1,15 @@
1
1
  = Changelog
2
2
 
3
+ 0.4.7 (May 18th, 2009)
4
+ * Bundling Yajl sources to remove the need to install them (and CMake) separately (Thank you Lloyd!!!)
5
+ This means you can now simply install the gem and be off and running
6
+ * Added some spec tests for Yajl::HttpStream
7
+ * Added some spec tests for Yajl::Stream.encode
8
+ * added some more thank you's, where credit's due - in the readme
9
+ * updated the unicode.json file to reflect a "real-life" JSON response
10
+ * reorganized spec tests into their functional areas
11
+ * added an rcov rake task to generate code coverage output
12
+
3
13
  0.4.6 (May 17th, 2009)
4
14
  * Applied a patch from benburkert (http://github.com/benburkert) to fix HTTP Basic Auth in
5
15
  Yajl::HttpStream.get
data/README.rdoc CHANGED
@@ -4,11 +4,19 @@ This gem (although not in gem form just yet) is a C binding to the excellent YAJ
4
4
 
5
5
  You can read more info at the projects website http://lloydforge.org/projects/yajl or check out it's codes at http://github.com/lloyd/yajl.
6
6
 
7
+ == How to install
8
+
9
+ Install it like any other gem hosted at the Githubs like so:
10
+
11
+ (more instructions here: http://gems.github.com)
12
+
13
+ sudo gem install brianmario-yajl-ruby
14
+
7
15
  == Example of use
8
16
 
9
- First, you're probably gonna want to include it:
17
+ First, you're probably gonna want to require it:
10
18
 
11
- include 'yajl'
19
+ require 'yajl'
12
20
 
13
21
  === Parsing
14
22
 
@@ -16,12 +24,12 @@ Then maybe parse some JSON from:
16
24
 
17
25
  a File IO
18
26
 
19
- json_contents = File.new('test.json', 'r')
27
+ json = File.new('test.json', 'r')
20
28
  hash = Yajl::Stream.parse(json)
21
29
 
22
30
  or maybe a StringIO
23
31
 
24
- json_contents = StringIO.new
32
+ json = StringIO.new
25
33
  hash = Yajl::Stream.parse(json)
26
34
 
27
35
  or maybe STDIN
@@ -104,25 +112,14 @@ There are a lot more possibilities, some of which I'm going to write other gems/
104
112
 
105
113
  Some ideas are:
106
114
  * parsing logs in JSON format
107
- * an ActiveSupport patch (http://github.com/technoweenie/rails/commit/f9abcc93a3660fcf46172c4cd8a2f36ba5a5510d)
115
+ * a Rails plugin (http://github.com/technoweenie/yajl-rails)
116
+ * builtin Rails 3 support?
108
117
  * Rack middleware (ideally the JSON body could be handed to the parser while it's still being received)
109
118
  * use with ohai
110
119
  * JSON API clients
111
120
  * Patch Marshal#load and Marshal#dump to use JSON? ;)
112
121
  * etc...
113
122
 
114
- == How to install
115
-
116
- First, Yajl uses CMake to build itself (yes, the author realizes this isn't the norm for open source and is willing and ready to accept patches, fork away kids!) so you'll need to grab it first from http://www.cmake.org.
117
-
118
- After you've got that, grab the latest version (I suggest at least 1.0.4 as it contains fixes for Unicode parsing) of Yajl itself from the Githubs at http://github.com/lloyd/yajl.
119
-
120
- After you have that installed, you should be able to install it like any other gem hosted here like so:
121
-
122
- (more instructions here: http://gems.github.com)
123
-
124
- sudo gem install brianmario-yajl-ruby
125
-
126
123
  == Benchmarks
127
124
 
128
125
  After I finished implementation - this library performs close to the same as the current JSON.parse (C gem) does on small/medium files.
@@ -176,13 +173,18 @@ NOTE: I converted the 2.4MB JSON file to YAML for this test.
176
173
  * JSON#to_json: 6.6s
177
174
  * YAML.dump(obj, io): 1309.93s
178
175
 
176
+ == Third Party Sources Bundled
177
+
178
+ This project includes code from the BSD licensed yajl project, copyright 2007-2009 Lloyd Hilaiel
179
+
179
180
  == Special Thanks
180
181
 
181
182
  I've had a lot of inspiration, and a lot of help. Thanks to everyone who's been a part of this and those to come!
182
183
 
183
- * Lloyd Hilaiel (http://github.com/lloyd) - for writing Yajl!!
184
- * Josh Ferguson (http://github.com/besquared) - for peer-pressuring me into getting back into C; it worked ;) Also tons of support over IM
185
- * Jonathan Novak (http://github.com/cypriss) - pointer-hacking help
186
- * Tom Smith (http://github.com/rtomsmith) - pointer-hacking help
187
- * Rick (http://github.com/technoweenie) - for making an ActiveSupport patch with support for this library and teasing me that it might go into Rails 3. You sure lit a fire under my ass and I got a ton of work done because of it! :)
188
- * The entire Github Crew - my inspiration, time spent writing this, finding Yajl, So many-MANY other things wouldn't have been possible without this awesome service. I owe you guys some whiskey at Kilowatt.
184
+ * Lloyd Hilaiel - http://github.com/lloyd - for writing Yajl!!
185
+ * Josh Ferguson - http://github.com/besquared - for peer-pressuring me into getting back into C; it worked ;) Also tons of support over IM
186
+ * Jonathan Novak - http://github.com/cypriss - pointer-hacking help
187
+ * Tom Smith - http://github.com/rtomsmith - pointer-hacking help
188
+ * Rick http://github.com/technoweenie - for making an ActiveSupport patch with support for this library and teasing me that it might go into Rails 3. You sure lit a fire under my ass and I got a ton of work done because of it! :)
189
+ * The entire Github Crew - http://github.com/ - my inspiration, time spent writing this, finding Yajl, So many-MANY other things wouldn't have been possible without this awesome service. I owe you guys some whiskey at Kilowatt.
190
+ * benburkert - http://github.com/benburkert
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ begin
6
6
  gem.summary = "Ruby C bindings to the excellent Yajl JSON stream-based parser library."
7
7
  gem.email = "seniorlopez@gmail.com"
8
8
  gem.homepage = "http://github.com/brianmario/yajl-ruby"
9
- gem.authors = ["Brian Lopez"]
9
+ gem.authors = ["Brian Lopez", "Lloyd Hilaiel"]
10
10
  gem.require_paths = ["lib", "ext"]
11
11
  gem.extra_rdoc_files = `git ls-files *.rdoc`.split("\n")
12
12
  gem.files = `git ls-files`.split("\n")
@@ -16,4 +16,14 @@ begin
16
16
  end
17
17
  rescue LoadError
18
18
  puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
19
+ end
20
+
21
+ require 'rake'
22
+ require 'spec/rake/spectask'
23
+
24
+ desc "Run all examples with RCov"
25
+ Spec::Rake::SpecTask.new('spec_with_rcov') do |t|
26
+ t.spec_files = FileList['spec/']
27
+ t.rcov = true
28
+ t.rcov_opts = ['--exclude', 'spec', '--spec-only']
19
29
  end
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :major: 0
3
2
  :minor: 4
4
- :patch: 6
3
+ :patch: 7
4
+ :major: 0
data/benchmark/encode.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  require 'rubygems'
3
3
  require 'benchmark'
4
- require 'yajl'
4
+ require 'yajl_ext'
5
5
  require 'json'
6
6
  # Can't use ActiveSuport::JSON.encode with the JSON gem loaded
7
7
  # require 'activesupport'
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  require 'rubygems'
3
3
  require 'benchmark'
4
- require 'yajl'
4
+ require 'yajl_ext'
5
5
  require 'json'
6
6
 
7
7
  filename = ARGV[0] || 'benchmark/subjects/contacts.json'
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  require 'rubygems'
3
3
  require 'benchmark'
4
- require 'yajl'
4
+ require 'yajl_ext'
5
5
  require 'activesupport'
6
6
  require 'json'
7
7
  require 'yaml'
data/benchmark/parse.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  require 'rubygems'
3
3
  require 'benchmark'
4
- require 'yajl'
4
+ require 'yajl_ext'
5
5
  require 'json'
6
6
  require 'activesupport'
7
7
 
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  require 'rubygems'
3
3
  require 'benchmark'
4
- require 'yajl'
4
+ require 'yajl_ext'
5
5
  require 'json'
6
6
 
7
7
  # JSON section
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  require 'rubygems'
3
3
  require 'benchmark'
4
- require 'yajl'
4
+ require 'yajl_ext'
5
5
  require 'json'
6
6
  require 'yaml'
7
7