yajl-ffi 0.1.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6de3c945368d22be36236e10320d4f352eb30d92
4
- data.tar.gz: fb7fb82310439d20429da612ac5e134bfeb1e733
2
+ SHA256:
3
+ metadata.gz: fffd8c833d69c6f4f8d4789c0ce9280424382e54f9cf88c01692b4e391f89da1
4
+ data.tar.gz: 2f7b4c56052718cc19ed6ec12ade7919f316bb03fd7bbf9b4a46ce951b5602d9
5
5
  SHA512:
6
- metadata.gz: 42d060dadaf9bc2e0eea2e5ce7e218180b7bd6c483ae449ec4e8329d1da61bac9c85fd7c96a9ea374f49eca828fc967663f7caa0f43300bf458c4fe4a9567a4d
7
- data.tar.gz: e0b43c9e8427a05d72f76e69e468baf69483e69fd0290571173b023a283c8f5ae7791b99fb36c6457ecd35a1be4346e5281063790a99bbe2cd6a17a539c7b8d6
6
+ metadata.gz: 25b94db497125d03576caf1cd50096672a6d5de266c608887b056ce68ec685a5f0557c13cecb9a64e398a3e0a1f832ce16173bdb3f8871243701ef1d6d7d5c96
7
+ data.tar.gz: 756be42ebd98bbaa2548853869b93d1b6ba00e6c12277df6ef57284eb1a8089bc3ede827c6a1f8b13a78d440371ba470ac01756329d6e76a7d6036e3725cd7d5
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ group :benchmark do
5
+ gem 'json'
6
+ gem 'json-stream'
7
+ gem 'yajl-ruby'
8
+ end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 David Graham
1
+ Copyright (c) 2014-2024 David Graham
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -56,8 +56,8 @@ def post_init
56
56
  @parser.end_object { puts "end object" }
57
57
  @parser.start_array { puts "start array" }
58
58
  @parser.end_array { puts "end array" }
59
- @parser.key {|k| puts "key: #{k}" }
60
- @parser.value {|v| puts "value: #{v}" }
59
+ @parser.key { |k| puts "key: #{k}" }
60
+ @parser.value { |v| puts "value: #{v}" }
61
61
  end
62
62
 
63
63
  def receive_data(data)
@@ -83,8 +83,6 @@ processed in constant memory space this way.
83
83
  ## Dependencies
84
84
 
85
85
  * [libyajl2](https://github.com/lloyd/yajl)
86
- * ruby >= 1.9.3
87
- * jruby >= 1.7
88
86
 
89
87
  ## Library loading
90
88
 
@@ -146,25 +144,21 @@ $ ./configure
146
144
  $ make && make install
147
145
  ```
148
146
 
149
- ## Alternatives
150
-
151
- * [json](https://github.com/flori/json)
152
- * [yajl-ruby](https://github.com/brianmario/yajl-ruby)
153
- * [json-stream](https://github.com/dgraham/json-stream)
147
+ ## Performance
154
148
 
155
149
  This gem provides a benchmark script to test the relative performance of
156
150
  several parsers. Here's a sample run.
157
151
 
158
152
  ```
159
- $ rake benchmark
153
+ $ bin/rake benchmark
160
154
  user system total real
161
- json 0.120000 0.010000 0.130000 ( 0.130072)
162
- yajl-ruby 0.130000 0.000000 0.130000 ( 0.129388)
163
- yajl-ffi 0.790000 0.010000 0.800000 ( 0.805279)
164
- json-stream 7.500000 0.030000 7.530000 ( 7.524760)
155
+ json 0.037963 0.002951 0.040914 ( 0.041196)
156
+ yajl-ruby 0.043128 0.001845 0.044973 ( 0.045292)
157
+ yajl-ffi 0.181198 0.004324 0.185522 ( 0.186301)
158
+ json-stream 2.169778 0.010984 2.180762 ( 2.196817)
165
159
  ```
166
160
 
167
- Yajl::FFI is about 6x slower than the pure native parsers. JSON::Stream is a
161
+ Yajl::FFI is about 4x slower than the pure native parsers. JSON::Stream is a
168
162
  pure Ruby parser, and it performs accordingly. But it's useful in cases where
169
163
  you're unable to use native bindings or when the limiting factor is the
170
164
  network, rather than processor speed.
@@ -174,6 +168,20 @@ are the best options. If you need to stream, and incrementally parse, pieces of
174
168
  large document in constant memory space, yajl-ffi and json-stream are good
175
169
  choices.
176
170
 
171
+ ## Alternatives
172
+
173
+ * [json](https://github.com/flori/json)
174
+ * [yajl-ruby](https://github.com/brianmario/yajl-ruby)
175
+ * [json-stream](https://github.com/dgraham/json-stream)
176
+ * [application/json-seq](http://www.rfc-editor.org/rfc/rfc7464.txt)
177
+
178
+ ## Development
179
+
180
+ ```
181
+ $ bin/setup
182
+ $ bin/rake test
183
+ ```
184
+
177
185
  ## License
178
186
 
179
187
  Yajl::FFI is released under the MIT license. Check the LICENSE file for details.
@@ -8,8 +8,8 @@ module Yajl
8
8
  # Examples
9
9
  #
10
10
  # parser = Yajl::FFI::Parser.new
11
- # parser.key {|key| puts key }
12
- # parser.value {|value| puts value }
11
+ # parser.key { |key| puts key }
12
+ # parser.value { |value| puts value }
13
13
  # parser << '{"answer":'
14
14
  # parser << ' 42}'
15
15
  class Parser
@@ -56,8 +56,8 @@ module Yajl
56
56
  # end_object { puts "end object" }
57
57
  # start_array { puts "start array" }
58
58
  # end_array { puts "end array" }
59
- # key {|k| puts "key: #{k}" }
60
- # value {|v| puts "value: #{v}" }
59
+ # key { |k| puts "key: #{k}" }
60
+ # value { |v| puts "value: #{v}" }
61
61
  # end
62
62
  def initialize(&block)
63
63
  @listeners = {
@@ -176,9 +176,9 @@ module Yajl
176
176
  #
177
177
  # Examples
178
178
  #
179
- # # broadcast events for {"answer": 42}
179
+ # # Broadcast events for {"answer": 42}
180
180
  # notify(:start_object)
181
- # notify(:key, "answer")
181
+ # notify(:key, 'answer')
182
182
  # notify(:value, 42)
183
183
  # notify(:end_object)
184
184
  #
@@ -1,6 +1,5 @@
1
1
  desc 'Compare parser performance'
2
2
  task :benchmark do
3
- $: << './lib'
4
3
  require 'benchmark'
5
4
  require 'json'
6
5
  require 'json/stream'
@@ -1,5 +1,5 @@
1
1
  module Yajl
2
2
  module FFI
3
- VERSION = '0.1.2'
3
+ VERSION = '1.0.0'
4
4
  end
5
5
  end
data/yajl-ffi.gemspec CHANGED
@@ -11,12 +11,13 @@ Gem::Specification.new do |s|
11
11
  s.homepage = 'https://github.com/dgraham/yajl-ffi'
12
12
  s.license = 'MIT'
13
13
 
14
- s.files = Dir['[A-Z]*', 'yajl-ffi.gemspec', '{lib}/**/*']
15
- s.test_files = Dir['spec/**/*']
14
+ s.files = Dir['[A-Z]*', 'yajl-ffi.gemspec', '{lib}/**/*'] - ['Gemfile.lock']
16
15
  s.require_path = 'lib'
17
16
 
18
- s.add_dependency 'ffi', '~> 1.9'
19
- s.add_development_dependency 'rake', '~> 10.3'
17
+ s.add_dependency 'ffi', '~> 1.16'
18
+ s.add_development_dependency 'bundler', '~> 2.2'
19
+ s.add_development_dependency 'minitest', '~> 5.22'
20
+ s.add_development_dependency 'rake', '~> 13.2'
20
21
 
21
- s.required_ruby_version = '>= 1.9.3'
22
+ s.required_ruby_version = '>= 2.6.0'
22
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yajl-ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Graham
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-08 00:00:00.000000000 Z
11
+ date: 2024-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -16,28 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.9'
19
+ version: '1.16'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.9'
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.22'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.22'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: rake
29
57
  requirement: !ruby/object:Gem::Requirement
30
58
  requirements:
31
59
  - - "~>"
32
60
  - !ruby/object:Gem::Version
33
- version: '10.3'
61
+ version: '13.2'
34
62
  type: :development
35
63
  prerelease: false
36
64
  version_requirements: !ruby/object:Gem::Requirement
37
65
  requirements:
38
66
  - - "~>"
39
67
  - !ruby/object:Gem::Version
40
- version: '10.3'
68
+ version: '13.2'
41
69
  description: Ruby FFI bindings to the native YAJL streaming JSON parser.
42
70
  email:
43
71
  - david.malcom.graham@gmail.com
@@ -45,6 +73,7 @@ executables: []
45
73
  extensions: []
46
74
  extra_rdoc_files: []
47
75
  files:
76
+ - Gemfile
48
77
  - LICENSE
49
78
  - README.md
50
79
  - Rakefile
@@ -53,15 +82,12 @@ files:
53
82
  - lib/yajl/ffi/parser.rb
54
83
  - lib/yajl/ffi/tasks/benchmark.rake
55
84
  - lib/yajl/ffi/version.rb
56
- - spec/builder_spec.rb
57
- - spec/fixtures/repository.json
58
- - spec/parser_spec.rb
59
85
  - yajl-ffi.gemspec
60
86
  homepage: https://github.com/dgraham/yajl-ffi
61
87
  licenses:
62
88
  - MIT
63
89
  metadata: {}
64
- post_install_message:
90
+ post_install_message:
65
91
  rdoc_options: []
66
92
  require_paths:
67
93
  - lib
@@ -69,19 +95,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
95
  requirements:
70
96
  - - ">="
71
97
  - !ruby/object:Gem::Version
72
- version: 1.9.3
98
+ version: 2.6.0
73
99
  required_rubygems_version: !ruby/object:Gem::Requirement
74
100
  requirements:
75
101
  - - ">="
76
102
  - !ruby/object:Gem::Version
77
103
  version: '0'
78
104
  requirements: []
79
- rubyforge_project:
80
- rubygems_version: 2.2.2
81
- signing_key:
105
+ rubygems_version: 3.5.4
106
+ signing_key:
82
107
  specification_version: 4
83
108
  summary: A streaming JSON parser that generates SAX-like events.
84
- test_files:
85
- - spec/builder_spec.rb
86
- - spec/fixtures/repository.json
87
- - spec/parser_spec.rb
109
+ test_files: []
data/spec/builder_spec.rb DELETED
@@ -1,155 +0,0 @@
1
- require 'yajl/ffi'
2
- require 'minitest/autorun'
3
-
4
- describe Yajl::FFI::Builder do
5
- let(:parser) { Yajl::FFI::Parser.new }
6
- subject { Yajl::FFI::Builder.new(parser) }
7
-
8
- it 'builds a false value' do
9
- assert_nil subject.result
10
- subject.start_document
11
- subject.value(false)
12
- assert_nil subject.result
13
- subject.end_document
14
- assert_equal false, subject.result
15
- end
16
-
17
- it 'builds a string value' do
18
- assert_nil subject.result
19
- subject.start_document
20
- subject.value("test")
21
- assert_nil subject.result
22
- subject.end_document
23
- assert_equal "test", subject.result
24
- end
25
-
26
- it 'builds an empty array' do
27
- assert_nil subject.result
28
- subject.start_document
29
- subject.start_array
30
- subject.end_array
31
- assert_nil subject.result
32
- subject.end_document
33
- assert_equal [], subject.result
34
- end
35
-
36
- it 'builds an array of numbers' do
37
- subject.start_document
38
- subject.start_array
39
- subject.value(1)
40
- subject.value(2)
41
- subject.value(3)
42
- subject.end_array
43
- subject.end_document
44
- assert_equal [1, 2, 3], subject.result
45
- end
46
-
47
- it 'builds nested empty arrays' do
48
- subject.start_document
49
- subject.start_array
50
- subject.start_array
51
- subject.end_array
52
- subject.end_array
53
- subject.end_document
54
- assert_equal [[]], subject.result
55
- end
56
-
57
- it 'builds nested arrays of numbers' do
58
- subject.start_document
59
- subject.start_array
60
- subject.value(1)
61
- subject.start_array
62
- subject.value(2)
63
- subject.end_array
64
- subject.value(3)
65
- subject.end_array
66
- subject.end_document
67
- assert_equal [1, [2], 3], subject.result
68
- end
69
-
70
- it 'builds an empty object' do
71
- subject.start_document
72
- subject.start_object
73
- subject.end_object
74
- subject.end_document
75
- assert_equal({}, subject.result)
76
- end
77
-
78
- it 'builds a complex object' do
79
- subject.start_document
80
- subject.start_object
81
- subject.key("k1")
82
- subject.value(1)
83
- subject.key("k2")
84
- subject.value(nil)
85
- subject.key("k3")
86
- subject.value(true)
87
- subject.key("k4")
88
- subject.value(false)
89
- subject.key("k5")
90
- subject.value("string value")
91
- subject.end_object
92
- subject.end_document
93
- expected = {
94
- "k1" => 1,
95
- "k2" => nil,
96
- "k3" => true,
97
- "k4" => false,
98
- "k5" => "string value"
99
- }
100
- assert_equal expected, subject.result
101
- end
102
-
103
- it 'builds a nested object' do
104
- subject.start_document
105
- subject.start_object
106
- subject.key("k1")
107
- subject.value(1)
108
-
109
- subject.key("k2")
110
- subject.start_object
111
- subject.end_object
112
-
113
- subject.key("k3")
114
- subject.start_object
115
- subject.key("sub1")
116
- subject.start_array
117
- subject.value(12)
118
- subject.end_array
119
- subject.end_object
120
-
121
- subject.key("k4")
122
- subject.start_array
123
- subject.value(1)
124
- subject.start_object
125
- subject.key("sub2")
126
- subject.start_array
127
- subject.value(nil)
128
- subject.end_array
129
- subject.end_object
130
- subject.end_array
131
-
132
- subject.key("k5")
133
- subject.value("string value")
134
- subject.end_object
135
- subject.end_document
136
- expected = {
137
- "k1" => 1,
138
- "k2" => {},
139
- "k3" => {"sub1" => [12]},
140
- "k4" => [1, {"sub2" => [nil]}],
141
- "k5" => "string value"
142
- }
143
- assert_equal expected, subject.result
144
- end
145
-
146
- it 'builds a real document' do
147
- refute_nil subject
148
- parser << File.read('spec/fixtures/repository.json')
149
- refute_nil subject.result
150
- assert_equal 'rails', subject.result['name']
151
- assert_equal 4223, subject.result['owner']['id']
152
- assert_equal false, subject.result['fork']
153
- assert_equal nil, subject.result['mirror_url']
154
- end
155
- end
@@ -1,107 +0,0 @@
1
- {
2
- "id": 8514,
3
- "name": "rails",
4
- "full_name": "rails/rails",
5
- "owner": {
6
- "login": "rails",
7
- "id": 4223,
8
- "avatar_url": "https://avatars.githubusercontent.com/u/4223?",
9
- "gravatar_id": "30f39a09e233e8369dddf6feb4be0308",
10
- "url": "https://api.github.com/users/rails",
11
- "html_url": "https://github.com/rails",
12
- "followers_url": "https://api.github.com/users/rails/followers",
13
- "following_url": "https://api.github.com/users/rails/following{/other_user}",
14
- "gists_url": "https://api.github.com/users/rails/gists{/gist_id}",
15
- "starred_url": "https://api.github.com/users/rails/starred{/owner}{/repo}",
16
- "subscriptions_url": "https://api.github.com/users/rails/subscriptions",
17
- "organizations_url": "https://api.github.com/users/rails/orgs",
18
- "repos_url": "https://api.github.com/users/rails/repos",
19
- "events_url": "https://api.github.com/users/rails/events{/privacy}",
20
- "received_events_url": "https://api.github.com/users/rails/received_events",
21
- "type": "Organization",
22
- "site_admin": false
23
- },
24
- "private": false,
25
- "html_url": "https://github.com/rails/rails",
26
- "description": "Ruby on Rails",
27
- "fork": false,
28
- "url": "https://api.github.com/repos/rails/rails",
29
- "forks_url": "https://api.github.com/repos/rails/rails/forks",
30
- "keys_url": "https://api.github.com/repos/rails/rails/keys{/key_id}",
31
- "collaborators_url": "https://api.github.com/repos/rails/rails/collaborators{/collaborator}",
32
- "teams_url": "https://api.github.com/repos/rails/rails/teams",
33
- "hooks_url": "https://api.github.com/repos/rails/rails/hooks",
34
- "issue_events_url": "https://api.github.com/repos/rails/rails/issues/events{/number}",
35
- "events_url": "https://api.github.com/repos/rails/rails/events",
36
- "assignees_url": "https://api.github.com/repos/rails/rails/assignees{/user}",
37
- "branches_url": "https://api.github.com/repos/rails/rails/branches{/branch}",
38
- "tags_url": "https://api.github.com/repos/rails/rails/tags",
39
- "blobs_url": "https://api.github.com/repos/rails/rails/git/blobs{/sha}",
40
- "git_tags_url": "https://api.github.com/repos/rails/rails/git/tags{/sha}",
41
- "git_refs_url": "https://api.github.com/repos/rails/rails/git/refs{/sha}",
42
- "trees_url": "https://api.github.com/repos/rails/rails/git/trees{/sha}",
43
- "statuses_url": "https://api.github.com/repos/rails/rails/statuses/{sha}",
44
- "languages_url": "https://api.github.com/repos/rails/rails/languages",
45
- "stargazers_url": "https://api.github.com/repos/rails/rails/stargazers",
46
- "contributors_url": "https://api.github.com/repos/rails/rails/contributors",
47
- "subscribers_url": "https://api.github.com/repos/rails/rails/subscribers",
48
- "subscription_url": "https://api.github.com/repos/rails/rails/subscription",
49
- "commits_url": "https://api.github.com/repos/rails/rails/commits{/sha}",
50
- "git_commits_url": "https://api.github.com/repos/rails/rails/git/commits{/sha}",
51
- "comments_url": "https://api.github.com/repos/rails/rails/comments{/number}",
52
- "issue_comment_url": "https://api.github.com/repos/rails/rails/issues/comments/{number}",
53
- "contents_url": "https://api.github.com/repos/rails/rails/contents/{+path}",
54
- "compare_url": "https://api.github.com/repos/rails/rails/compare/{base}...{head}",
55
- "merges_url": "https://api.github.com/repos/rails/rails/merges",
56
- "archive_url": "https://api.github.com/repos/rails/rails/{archive_format}{/ref}",
57
- "downloads_url": "https://api.github.com/repos/rails/rails/downloads",
58
- "issues_url": "https://api.github.com/repos/rails/rails/issues{/number}",
59
- "pulls_url": "https://api.github.com/repos/rails/rails/pulls{/number}",
60
- "milestones_url": "https://api.github.com/repos/rails/rails/milestones{/number}",
61
- "notifications_url": "https://api.github.com/repos/rails/rails/notifications{?since,all,participating}",
62
- "labels_url": "https://api.github.com/repos/rails/rails/labels{/name}",
63
- "releases_url": "https://api.github.com/repos/rails/rails/releases{/id}",
64
- "created_at": "2008-04-11T02:19:47Z",
65
- "updated_at": "2014-06-25T21:08:45Z",
66
- "pushed_at": "2014-06-25T17:47:52Z",
67
- "git_url": "git://github.com/rails/rails.git",
68
- "ssh_url": "git@github.com:rails/rails.git",
69
- "clone_url": "https://github.com/rails/rails.git",
70
- "svn_url": "https://github.com/rails/rails",
71
- "homepage": "http://rubyonrails.org",
72
- "size": 331047,
73
- "stargazers_count": 22248,
74
- "watchers_count": 22248,
75
- "language": "Ruby",
76
- "has_issues": true,
77
- "has_downloads": true,
78
- "has_wiki": false,
79
- "forks_count": 8278,
80
- "mirror_url": null,
81
- "open_issues_count": 625,
82
- "forks": 8278,
83
- "open_issues": 625,
84
- "watchers": 22248,
85
- "default_branch": "master",
86
- "organization": {
87
- "login": "rails",
88
- "id": 4223,
89
- "avatar_url": "https://avatars.githubusercontent.com/u/4223?",
90
- "gravatar_id": "30f39a09e233e8369dddf6feb4be0308",
91
- "url": "https://api.github.com/users/rails",
92
- "html_url": "https://github.com/rails",
93
- "followers_url": "https://api.github.com/users/rails/followers",
94
- "following_url": "https://api.github.com/users/rails/following{/other_user}",
95
- "gists_url": "https://api.github.com/users/rails/gists{/gist_id}",
96
- "starred_url": "https://api.github.com/users/rails/starred{/owner}{/repo}",
97
- "subscriptions_url": "https://api.github.com/users/rails/subscriptions",
98
- "organizations_url": "https://api.github.com/users/rails/orgs",
99
- "repos_url": "https://api.github.com/users/rails/repos",
100
- "events_url": "https://api.github.com/users/rails/events{/privacy}",
101
- "received_events_url": "https://api.github.com/users/rails/received_events",
102
- "type": "Organization",
103
- "site_admin": false
104
- },
105
- "network_count": 8278,
106
- "subscribers_count": 1521
107
- }