wankel 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/LICENSE +20 -0
  4. data/README.md +43 -0
  5. data/Rakefile +63 -0
  6. data/benchmark/subjects/item.json +1 -0
  7. data/benchmark/subjects/ohai.json +1216 -0
  8. data/benchmark/subjects/twitter_search.json +1 -0
  9. data/benchmark/subjects/twitter_stream.json +430 -0
  10. data/ext/wankel/extconf.rb +15 -0
  11. data/ext/wankel/wankel.c +50 -0
  12. data/ext/wankel/wankel.h +17 -0
  13. data/ext/wankel/wankel_encoder.c +232 -0
  14. data/ext/wankel/wankel_encoder.h +13 -0
  15. data/ext/wankel/wankel_parser.c +345 -0
  16. data/ext/wankel/wankel_parser.h +26 -0
  17. data/ext/wankel/wankel_sax_encoder.c +290 -0
  18. data/ext/wankel/wankel_sax_encoder.h +13 -0
  19. data/ext/wankel/wankel_sax_parser.c +232 -0
  20. data/ext/wankel/wankel_sax_parser.h +23 -0
  21. data/ext/wankel/yajl_helpers.c +124 -0
  22. data/ext/wankel/yajl_helpers.h +22 -0
  23. data/lib/wankel/ex_sax_parser.rb +75 -0
  24. data/lib/wankel.rb +19 -0
  25. data/logo.png +0 -0
  26. data/test/encoding/encoding_test.rb +230 -0
  27. data/test/encoding/sax_encoder_test.rb +89 -0
  28. data/test/parsing/active_support_test.rb +66 -0
  29. data/test/parsing/fixtures/fail.15.json +1 -0
  30. data/test/parsing/fixtures/fail.16.json +1 -0
  31. data/test/parsing/fixtures/fail.17.json +1 -0
  32. data/test/parsing/fixtures/fail.26.json +1 -0
  33. data/test/parsing/fixtures/fail11.json +1 -0
  34. data/test/parsing/fixtures/fail12.json +1 -0
  35. data/test/parsing/fixtures/fail13.json +1 -0
  36. data/test/parsing/fixtures/fail14.json +1 -0
  37. data/test/parsing/fixtures/fail19.json +1 -0
  38. data/test/parsing/fixtures/fail20.json +1 -0
  39. data/test/parsing/fixtures/fail21.json +1 -0
  40. data/test/parsing/fixtures/fail22.json +1 -0
  41. data/test/parsing/fixtures/fail23.json +1 -0
  42. data/test/parsing/fixtures/fail24.json +1 -0
  43. data/test/parsing/fixtures/fail25.json +1 -0
  44. data/test/parsing/fixtures/fail27.json +2 -0
  45. data/test/parsing/fixtures/fail28.json +2 -0
  46. data/test/parsing/fixtures/fail3.json +1 -0
  47. data/test/parsing/fixtures/fail4.json +1 -0
  48. data/test/parsing/fixtures/fail5.json +1 -0
  49. data/test/parsing/fixtures/fail6.json +1 -0
  50. data/test/parsing/fixtures/fail9.json +1 -0
  51. data/test/parsing/fixtures/pass.array.json +6 -0
  52. data/test/parsing/fixtures/pass.codepoints_from_unicode_org.json +1 -0
  53. data/test/parsing/fixtures/pass.contacts.json +1 -0
  54. data/test/parsing/fixtures/pass.db100.xml.json +1 -0
  55. data/test/parsing/fixtures/pass.db1000.xml.json +1 -0
  56. data/test/parsing/fixtures/pass.dc_simple_with_comments.json +11 -0
  57. data/test/parsing/fixtures/pass.deep_arrays.json +1 -0
  58. data/test/parsing/fixtures/pass.difficult_json_c_test_case.json +1 -0
  59. data/test/parsing/fixtures/pass.difficult_json_c_test_case_with_comments.json +1 -0
  60. data/test/parsing/fixtures/pass.doubles.json +1 -0
  61. data/test/parsing/fixtures/pass.empty_array.json +1 -0
  62. data/test/parsing/fixtures/pass.empty_string.json +1 -0
  63. data/test/parsing/fixtures/pass.escaped_bulgarian.json +4 -0
  64. data/test/parsing/fixtures/pass.escaped_foobar.json +1 -0
  65. data/test/parsing/fixtures/pass.item.json +1 -0
  66. data/test/parsing/fixtures/pass.json-org-sample1.json +23 -0
  67. data/test/parsing/fixtures/pass.json-org-sample2.json +11 -0
  68. data/test/parsing/fixtures/pass.json-org-sample3.json +26 -0
  69. data/test/parsing/fixtures/pass.json-org-sample4-nows.json +88 -0
  70. data/test/parsing/fixtures/pass.json-org-sample4.json +89 -0
  71. data/test/parsing/fixtures/pass.json-org-sample5.json +27 -0
  72. data/test/parsing/fixtures/pass.map-spain.xml.json +1 -0
  73. data/test/parsing/fixtures/pass.ns-invoice100.xml.json +1 -0
  74. data/test/parsing/fixtures/pass.ns-soap.xml.json +1 -0
  75. data/test/parsing/fixtures/pass.numbers-fp-4k.json +6 -0
  76. data/test/parsing/fixtures/pass.numbers-fp-64k.json +61 -0
  77. data/test/parsing/fixtures/pass.numbers-int-4k.json +11 -0
  78. data/test/parsing/fixtures/pass.numbers-int-64k.json +154 -0
  79. data/test/parsing/fixtures/pass.twitter-search.json +1 -0
  80. data/test/parsing/fixtures/pass.twitter-search2.json +1 -0
  81. data/test/parsing/fixtures/pass.unicode.json +3315 -0
  82. data/test/parsing/fixtures/pass.yelp.json +1 -0
  83. data/test/parsing/fixtures/pass1.json +56 -0
  84. data/test/parsing/fixtures/pass2.json +1 -0
  85. data/test/parsing/fixtures/pass3.json +6 -0
  86. data/test/parsing/fixtures_test.rb +43 -0
  87. data/test/parsing/multiple_values_test.rb +100 -0
  88. data/test/parsing/one_off_test.rb +65 -0
  89. data/test/parsing/sax_parser_test.rb +125 -0
  90. data/test/performance.rb +135 -0
  91. data/test/test_helper.rb +36 -0
  92. data/test/wankel_test.rb +53 -0
  93. data/wankel.gemspec +23 -0
  94. metadata +259 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 16c5766bc7c52d73c0ab261c2b2557ce5c70a8a4
4
+ data.tar.gz: 88451d7b6edb81df276df3612507dd78158332ca
5
+ SHA512:
6
+ metadata.gz: 1e6e09d98f7bfe3684b7d47648c21c762529362ceaa02d390483b6a0c1824e28f5606169e72f7749b1a7ec2d4ed55eb82a03c87f08a8c66043df871ef17384ba
7
+ data.tar.gz: a9cdb73774d316c51a43d1550cc7ddcce2706c044eb0ec51c652e83e7f60c4257054bb8e849d096e3d3aeeabab473c2d5534a39a2b952a54c78b6a1f64cc3ce1
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ .rvmrc
6
+ coverage
7
+ *.bundle
8
+ *.o
9
+ *.log
10
+ Makefile
11
+ tmp
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Jonathan Bracy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ <a href="vikingjs.org">![Wankel](/logo.png)</a>
2
+
3
+ Wankel is a Ruby gem that provides C bindings to the [YAJL 2](http://lloyd.github.io/yajl/)
4
+ C Library.
5
+
6
+ Wankel provides a gerneral parsing and encoding, but also a SAX style parser for
7
+ stream parsing and generation.
8
+
9
+ Features
10
+ --------
11
+
12
+ * SAX style JSON parsing and encoding
13
+ * JSON parsing and encoding directly to and from an IO stream (file, socket, etc)
14
+ or String.
15
+ * Parse and encode *multiple* JSON objects to and from streams or strings
16
+ continuously.
17
+ * JSON gem compatibility API - allows wankel to be used as a drop-in
18
+ replacement for the JSON gem
19
+
20
+ Dependencies
21
+ ------------
22
+
23
+ Wankel only dependency is (YAJL)[http://lloyd.github.io/yajl/] version 2.
24
+
25
+ You can install it with homebrew via:
26
+
27
+ ``` bash
28
+ brew install yajl
29
+ ```
30
+
31
+ Installation
32
+ ------------
33
+
34
+ Wankel is installed via Rubygems:
35
+
36
+ ```
37
+ gem install wankel
38
+ ```
39
+
40
+ Examples
41
+ --------
42
+
43
+ TODO
data/Rakefile ADDED
@@ -0,0 +1,63 @@
1
+ require "rake/extensiontask"
2
+ require "rake/testtask"
3
+ require "rubygems/package_task"
4
+ require "rdoc/task"
5
+ require 'fileutils'
6
+
7
+ if ENV['COVERALLS_REPO_TOKEN']
8
+ require 'simplecov'
9
+ require 'coveralls'
10
+ require 'coveralls/rake/task'
11
+ Coveralls::RakeTask.new
12
+ end
13
+
14
+ spec = Gem::Specification.load("wankel.gemspec")
15
+
16
+ # Setup compile tasks
17
+ Rake::ExtensionTask.new do |ext|
18
+ ext.gem_spec = spec
19
+ ext.name = 'wankel'
20
+ ext.ext_dir = 'ext/wankel'
21
+ ext.lib_dir = 'lib/wankel'
22
+ ext.config_options << '--coverage' if ENV['COVERALLS_REPO_TOKEN']
23
+ end
24
+
25
+ # Test Task
26
+ Rake::TestTask.new do |t|
27
+ t.libs << 'lib' << 'test'
28
+ t.test_files = FileList['test/**/*_test.rb']
29
+ # t.warning = true
30
+ # t.verbose = true
31
+ end
32
+ Rake::Task[:test].prerequisites << :compile
33
+
34
+ task :c_coverage do
35
+ out_dir = "tmp/#{RUBY_PLATFORM}/wankel/#{RUBY_VERSION}"
36
+ src_dir = 'ext/wankel'
37
+ src_files = FileList["#{src_dir}/*.c"]
38
+ FileUtils.cp(src_files, out_dir)
39
+ src_files.map! { |f| File.basename(f) }
40
+ `cd "#{out_dir}" && gcov #{src_files.join(" ")}`
41
+ raise 'gcov error' if $? != 0
42
+
43
+ data = SimpleCov::ResultMerger.resultset
44
+
45
+ src_files.each do |f|
46
+ file_data = File.read("#{out_dir}/#{f}.gcov").split("\n").map{|l| l.gsub(/\s+/,' ').split(' ') }
47
+ file_data = file_data.select{|l| l[1].sub(/:.*$/,'').to_i != 0 }
48
+ file_data.map! do |l|
49
+ case l[0]
50
+ when '-:'
51
+ nil
52
+ when '#####:'
53
+ 0
54
+ else
55
+ l[0].sub(/:.*$/,'').to_i
56
+ end
57
+ end
58
+
59
+ data["Unit Tests"]["coverage"]["#{File.dirname(__FILE__)}/#{src_dir}/#{f}"] = file_data
60
+
61
+ SimpleCov::ResultMerger.store_result(data)
62
+ end
63
+ end
@@ -0,0 +1 @@
1
+ {"item": {"name": "generated", "cached_tag_list": "", "updated_at": "2009-03-24T05:25:09Z", "updated_by_id": null, "price": 1.99, "delta": false, "cost": 0.597, "account_id": 16, "unit": null, "import_tag": null, "taxable": true, "id": 1, "created_by_id": null, "description": null, "company_id": 0, "sku": "06317-0306", "created_at": "2009-03-24T05:25:09Z", "active": true}}