ffi-yajl 2.2.3 → 2.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d781f4b2a16bfdf584c9e5e18aacc4acead4e2d1
4
- data.tar.gz: b983d62ab1c69061965c697c28d4a2f3eb903fff
3
+ metadata.gz: 34f8ead0d7b0acd7c0b717d91620c434a6664e77
4
+ data.tar.gz: 35178ecea062849647eb0ebcdb174e70b31c3c12
5
5
  SHA512:
6
- metadata.gz: 3ff1a41b3526497a2c8b76ddba312121973aa1191d968e284ca084c96db7c243dc38f01443de87c0673565f09a68604586e0a036732fbda6a18dda24d590f524
7
- data.tar.gz: ab3ac6089aa276b4937ec8c51cffc76800e1595d17b40c6449df7cd30edeeba27959c87a34ed1fea658c6b8a1fbbbc4198591748630a4c6c8e7123de2f182f5d
6
+ metadata.gz: fc7c2f379e5a565a278ff16723197b994c354f560364774d90c17ee491f26ba28a91bbce7655e51e2f9bce43f6ce2e4f2c17b1bb4068f17518bf4fb389b3bb78
7
+ data.tar.gz: 9b4137b8cd49ff37b49b474f442c350bd0ca2c4d767ae45cb39163a6c5b6a5ee59e5909d43d7e556a860ed253503ee882a21551ca46e97b18d7d65052820434f
data/README.md CHANGED
@@ -1,13 +1,8 @@
1
-
2
- [![Build Status](https://travis-ci.org/chef/ffi-yajl.png)](https://travis-ci.org/chef/ffi-yajl) [![Code Climate](https://codeclimate.com/github/chef/ffi-yajl.png)](https://codeclimate.com/github/chef/ffi-yajl)
3
-
4
1
  # FFI YAJL
5
2
 
6
- ffi-yajl is a Ruby adapter for the [yajl](http://lloyd.github.io/yajl/)
7
- JSON parser/generator library. ffi-yajl supports multiple Ruby C
8
- extension mechanisms, including both MRI native extensions and FFI in
9
- order to be compatible with as many Ruby implementations as possible
10
- while providing good performance where possible.
3
+ [![Build Status](https://travis-ci.org/chef/ffi-yajl.svg?branch=master)](https://travis-ci.org/chef/ffi-yajl) [![Gem Version](https://badge.fury.io/rb/ffi-yajl.svg)](https://badge.fury.io/rb/ffi-yajl)
4
+
5
+ ffi-yajl is a Ruby adapter for the [yajl](http://lloyd.github.io/yajl/) JSON parser/generator library. ffi-yajl supports multiple Ruby C extension mechanisms, including both MRI native extensions and FFI in order to be compatible with as many Ruby implementations as possible while providing good performance where possible.
11
6
 
12
7
  ## How to Install
13
8
 
@@ -25,20 +20,20 @@ gem 'ffi-yajl'
25
20
 
26
21
  ## Supported Ruby VMs:
27
22
 
28
- * Ruby MRI 1.9.3/2.0.0/2.1.x/2.2.x
29
- * rbx 2.2.x (possibly earlier)
30
- * Jruby 1.7.x (possibly earlier)
23
+ - Ruby MRI 1.9.3/2.0.0/2.1.x/2.2.x
24
+ - rbx 2.2.x (possibly earlier)
25
+ - Jruby 1.7.x (possibly earlier)
31
26
 
32
27
  Ruby 1.8.7 support was dropped in 2.2.0
33
28
 
34
29
  ## Supported Distros:
35
30
 
36
- * Ubuntu 10.04 through 14.10
37
- * Debian 7.x
38
- * RHEL/CentOS/Oracle 5.x/6.x/7.x
39
- * Solaris 9/10/11 (gcc, sun compiler untested)
40
- * AIX 6.x/7.x (gcc or xlc)
41
- * Windows 2008r2/2012 (and Win2k/2k3 and consumer versions should work)
31
+ - Ubuntu 10.04 through 14.10
32
+ - Debian 7.x
33
+ - RHEL/CentOS/Oracle 5.x/6.x/7.x
34
+ - Solaris 9/10/11 (gcc, sun compiler untested)
35
+ - AIX 6.x/7.x (gcc or xlc)
36
+ - Windows 2008r2/2012 (and Win2k/2k3 and consumer versions should work)
42
37
 
43
38
  ## Basic Usage
44
39
 
@@ -68,81 +63,44 @@ hash = parser.parse( json )
68
63
 
69
64
  ## Parser Options
70
65
 
71
- * `:check_utf8`
72
- * `:dont_validate_strings`
73
- * `:symbolize_keys` (default = false): JSON keys are parsed into symbols instead of strings.
74
- * `:symbolize_names` (default = false): Alias for `:symbolize_keys`.
75
- * `:allow_trailing_garbage`
76
- * `:allow_multiple_values`
77
- * `:allow_partial_values`
78
- * `:unique_key_checking` (default = false): Will raise an exception if keys
79
- are repeated in hashes in the input JSON. Without this, repeated keys will
80
- silently replace the previous key.
66
+ - `:check_utf8`
67
+ - `:dont_validate_strings`
68
+ - `:symbolize_keys` (default = false): JSON keys are parsed into symbols instead of strings.
69
+ - `:symbolize_names` (default = false): Alias for `:symbolize_keys`.
70
+ - `:allow_trailing_garbage`
71
+ - `:allow_multiple_values`
72
+ - `:allow_partial_values`
73
+ - `:unique_key_checking` (default = false): Will raise an exception if keys are repeated in hashes in the input JSON. Without this, repeated keys will silently replace the previous key.
81
74
 
82
75
  ## Encoder Options
83
76
 
84
- * `:pretty` (default = false): Produces more human readable 'pretty' output.
85
- * `:validate_utf8` (default = true): Will raise an exception when trying to
86
- encode strings that are invalid UTF-8. When set to false this still will
87
- produce valid UTF-8 JSON but will replace invalid characters.
77
+ - `:pretty` (default = false): Produces more human readable 'pretty' output.
78
+ - `:validate_utf8` (default = true): Will raise an exception when trying to encode strings that are invalid UTF-8\. When set to false this still will produce valid UTF-8 JSON but will replace invalid characters.
88
79
 
89
80
  ## Forcing FFI or C Extension
90
81
 
91
- You can set the environment variable `FORCE_FFI_YAJL` to `ext` or `ffi` to
92
- control if the C extension or FFI bindings are used.
82
+ You can set the environment variable `FORCE_FFI_YAJL` to `ext` or `ffi` to control if the C extension or FFI bindings are used.
93
83
 
94
84
  ## Yajl Library Packaging
95
85
 
96
- This library prefers to use the embedded yajl 2.x C library packaged in the
97
- libyajl2 gem. In order to use the operating system yajl library (which must be
98
- yajl 2.x) the environment variable `USE_SYSTEM_LIBYAJL2` can be set before
99
- installing or bundling libyajl2. This will force the libyajl2 gem to skip
100
- compiling its embedded library and the ffi-yajl gem will fallback to using the
101
- system yajl library.
86
+ This library prefers to use the embedded yajl 2.x C library packaged in the libyajl2 gem. In order to use the operating system yajl library (which must be yajl 2.x) the environment variable `USE_SYSTEM_LIBYAJL2` can be set before installing or bundling libyajl2\. This will force the libyajl2 gem to skip compiling its embedded library and the ffi-yajl gem will fallback to using the system yajl library.
102
87
 
103
88
  ## No JSON Gem Compatiblity layer
104
89
 
105
- This library does not offer a feature to patch `#to_json` methods into all
106
- the ruby classes similarly to the JSON gem or yajl-ruby's `yajl/json_gem`
107
- compatibility API. The differences in encoding between the JSON gem and the
108
- Yajl C library can produce different output on different systems and makes
109
- testing brittle. Such a feature will not be included. It was removed in
110
- this pull request and could be easily extracted to its own gem (we have
111
- no interest in maintaining that gem):
90
+ This library does not offer a feature to patch `#to_json` methods into all the ruby classes similarly to the JSON gem or yajl-ruby's `yajl/json_gem` compatibility API. The differences in encoding between the JSON gem and the Yajl C library can produce different output on different systems and makes testing brittle. Such a feature will not be included. It was removed in this pull request and could be easily extracted to its own gem (we have no interest in maintaining that gem):
112
91
 
113
- https://github.com/chef/ffi-yajl/pull/47/files
92
+ <https://github.com/chef/ffi-yajl/pull/47/files>
114
93
 
115
94
  ## Why This Instead of X?
116
95
 
117
- yajl is the only JSON library we've found that has error messages that
118
- meet our requirements. The stdlib json gem and oj (at the time we
119
- started this project) have error messages like "invalid token at byte
120
- 1234," which are probably fine for server use, but in
121
- [chef](https://github.com/chef/chef) we frequently deal with
122
- user-written JSON documents, which means we need a good user experience
123
- when encountering malformed JSON.
124
-
125
- We previously used brianmario's
126
- [yajl-ruby](https://github.com/brianmario/yajl-ruby) project, but we
127
- wanted to be able to fallback to using FFI bindings to the C code (so we
128
- could support non-MRI rubies) and we also needed some bug fixes in
129
- yajl2, but the maintainer wasn't able to devote enough time to the
130
- project to make these updates in a timeframe that worked for us.
96
+ yajl is the only JSON library we've found that has error messages that meet our requirements. The stdlib json gem and oj (at the time we started this project) have error messages like "invalid token at byte 1234," which are probably fine for server use, but in [chef](https://github.com/chef/chef) we frequently deal with user-written JSON documents, which means we need a good user experience when encountering malformed JSON.
97
+
98
+ We previously used brianmario's [yajl-ruby](https://github.com/brianmario/yajl-ruby) project, but we wanted to be able to fallback to using FFI bindings to the C code (so we could support non-MRI rubies) and we also needed some bug fixes in yajl2, but the maintainer wasn't able to devote enough time to the project to make these updates in a timeframe that worked for us.
131
99
 
132
100
  ## Thanks
133
101
 
134
- This was initially going to be a clean rewrite of an ffi ruby wrapper around
135
- yajl2, but as it progressed more and more code was pulled in from brianmario's
136
- existing yajl-ruby gem, particularly all the c extension code, lots of specs
137
- and the benchmarks. And the process of writing this would have been much more
138
- difficult without being able to draw heavily from already solved problems in
139
- yajl-ruby.
102
+ This was initially going to be a clean rewrite of an ffi ruby wrapper around yajl2, but as it progressed more and more code was pulled in from brianmario's existing yajl-ruby gem, particularly all the c extension code, lots of specs and the benchmarks. And the process of writing this would have been much more difficult without being able to draw heavily from already solved problems in yajl-ruby.
140
103
 
141
104
  ## License
142
105
 
143
- Given that this draws heavily from the yajl-ruby sources, and could be
144
- considered a derivative work, the MIT License from that project has been
145
- preserved and this source code has deliberately not been dual licensed under
146
- Chef's typical Apache License. See the
147
- [LICENSE](https://github.com/chef/ffi-yajl/blob/master/LICENSE) file in this
148
- project.
106
+ Given that this draws heavily from the yajl-ruby sources, and could be considered a derivative work, the MIT License from that project has been preserved and this source code has deliberately not been dual licensed under Chef's typical Apache License. See the [LICENSE](https://github.com/chef/ffi-yajl/blob/master/LICENSE) file in this project.
data/Rakefile CHANGED
@@ -1,19 +1,24 @@
1
1
  $LOAD_PATH << File.expand_path(File.join(File.dirname( __FILE__ ), "lib"))
2
2
 
3
- require 'rspec/core/rake_task'
4
- require 'rubygems/package_task'
5
- require 'rake/extensiontask'
6
- require 'ffi_yajl/version'
7
- require 'github_changelog_generator/task'
3
+ require "rspec/core/rake_task"
4
+ require "rubygems/package_task"
5
+ require "rake/extensiontask"
6
+ require "ffi_yajl/version"
8
7
 
9
8
  Dir[File.expand_path("../*gemspec", __FILE__)].reverse_each do |gemspec_path|
10
9
  gemspec = eval(IO.read(gemspec_path))
11
10
  Gem::PackageTask.new(gemspec).define
12
11
  end
13
12
 
14
- GitHubChangelogGenerator::RakeTask.new :changelog do |config|
15
- config.since_tag = '1.0.1'
16
- config.exclude_labels = %w{duplicate question invalid wontfix changelog_skip}
13
+ begin
14
+ require "github_changelog_generator/task"
15
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
16
+ config.issues = false
17
+ config.since_tag = "1.0.1"
18
+ config.exclude_labels = %w{duplicate question invalid wontfix changelog_skip}
19
+ end
20
+ rescue LoadError
21
+ puts "no github-changelog-generator"
17
22
  end
18
23
 
19
24
  desc "Build it and ship it"
@@ -41,26 +46,26 @@ task install: [:package] do
41
46
  end
42
47
  end
43
48
 
44
- spec = Gem::Specification.load('ffi-yajl.gemspec')
49
+ spec = Gem::Specification.load("ffi-yajl.gemspec")
45
50
 
46
51
  Rake::ExtensionTask.new do |ext|
47
- ext.name = 'encoder'
48
- ext.lib_dir = 'lib/ffi_yajl/ext'
49
- ext.ext_dir = 'ext/ffi_yajl/ext/encoder'
52
+ ext.name = "encoder"
53
+ ext.lib_dir = "lib/ffi_yajl/ext"
54
+ ext.ext_dir = "ext/ffi_yajl/ext/encoder"
50
55
  ext.gem_spec = spec
51
56
  end
52
57
 
53
58
  Rake::ExtensionTask.new do |ext|
54
- ext.name = 'parser'
55
- ext.lib_dir = 'lib/ffi_yajl/ext'
56
- ext.ext_dir = 'ext/ffi_yajl/ext/parser'
59
+ ext.name = "parser"
60
+ ext.lib_dir = "lib/ffi_yajl/ext"
61
+ ext.ext_dir = "ext/ffi_yajl/ext/parser"
57
62
  ext.gem_spec = spec
58
63
  end
59
64
 
60
65
  Rake::ExtensionTask.new do |ext|
61
- ext.name = 'dlopen'
62
- ext.lib_dir = 'lib/ffi_yajl/ext'
63
- ext.ext_dir = 'ext/ffi_yajl/ext/dlopen'
66
+ ext.name = "dlopen"
67
+ ext.lib_dir = "lib/ffi_yajl/ext"
68
+ ext.ext_dir = "ext/ffi_yajl/ext/dlopen"
64
69
  ext.gem_spec = spec
65
70
  end
66
71
 
@@ -79,101 +84,56 @@ end
79
84
  namespace :spec do
80
85
  desc "Run all specs against ffi extension"
81
86
  RSpec::Core::RakeTask.new(:ffi) do |t|
82
- ENV['FORCE_FFI_YAJL'] = "ffi"
83
- t.pattern = FileList['spec/**/*_spec.rb']
87
+ ENV["FORCE_FFI_YAJL"] = "ffi"
88
+ t.pattern = FileList["spec/**/*_spec.rb"]
84
89
  end
85
90
  if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/
86
91
  desc "Run all specs again c extension"
87
92
  RSpec::Core::RakeTask.new(:ext) do |t|
88
- ENV['FORCE_FFI_YAJL'] = "ext"
89
- t.pattern = FileList['spec/**/*_spec.rb']
93
+ ENV["FORCE_FFI_YAJL"] = "ext"
94
+ t.pattern = FileList["spec/**/*_spec.rb"]
90
95
  end
91
96
  end
92
97
  end
93
98
 
94
- if RUBY_VERSION.to_f >= 1.9
95
- namespace :integration do
96
- begin
97
- require 'kitchen'
98
- rescue LoadError
99
- task :vagrant do
100
- puts "test-kitchen gem is not installed"
101
- end
102
- task :cloud do
103
- puts "test-kitchen gem is not installed"
104
- end
105
- else
106
- desc 'Run Test Kitchen with Vagrant'
107
- task :vagrant do
108
- Kitchen.logger = Kitchen.default_file_logger
109
- Kitchen::Config.new.instances.each do |instance|
110
- instance.test(:always)
111
- end
112
- end
113
-
114
- desc 'Run Test Kitchen with cloud plugins'
115
- task :cloud do
116
- if ENV['TRAVIS_PULL_REQUEST'] != 'true'
117
- ENV['KITCHEN_YAML'] = '.kitchen.cloud.yml'
118
- sh "kitchen test --concurrency 4"
119
- end
120
- end
121
- end
122
- end
123
- namespace :style do
124
- desc 'Run Ruby style checks'
125
- begin
126
- require 'rubocop/rake_task'
127
- rescue LoadError
128
- task :rubocop do
129
- puts "rubocop gem is not installed"
130
- end
131
- else
132
- RuboCop::RakeTask.new(:rubocop) do |t|
133
- t.fail_on_error = false
134
- end
135
- end
136
-
137
- desc 'Run Ruby smell checks'
138
- begin
139
- require 'reek/rake/task'
140
- rescue LoadError
141
- task :reek do
142
- puts "reek gem is not installed"
143
- end
144
- else
145
- Reek::Rake::Task.new(:reek) do |t|
146
- t.fail_on_error = false
147
- # t.config_files = '.reek.yml'
148
- end
149
- end
150
- end
151
- else
152
- namespace :integration do
99
+ namespace :integration do
100
+ begin
101
+ require "kitchen"
102
+ rescue LoadError
153
103
  task :vagrant do
154
- puts "test-kitchen unsupported on ruby 1.8"
104
+ puts "test-kitchen gem is not installed"
155
105
  end
156
- task :cloud do
157
- puts "test-kitchen unsupported on ruby 1.8"
106
+ else
107
+ desc "Run Test Kitchen with Vagrant"
108
+ task :vagrant do
109
+ Kitchen.logger = Kitchen.default_file_logger
110
+ Kitchen::Config.new.instances.each do |instance|
111
+ instance.test(:always)
112
+ end
158
113
  end
159
114
  end
160
- namespace :style do
115
+ end
116
+ namespace :style do
117
+ desc "Run Ruby style checks"
118
+ begin
119
+ require "chefstyle"
120
+ require "rubocop/rake_task"
121
+ rescue LoadError
161
122
  task :rubocop do
162
- puts "rubocop unsupported on ruby 1.8"
123
+ puts "chefstyle gem is not installed"
163
124
  end
164
- task :reek do
165
- puts "reek unsupported on ruby 1.8"
125
+ else
126
+ RuboCop::RakeTask.new(:rubocop) do |t|
127
+ t.fail_on_error = false
166
128
  end
167
129
  end
168
130
  end
169
131
 
170
- desc 'Run all style checks'
171
- task style: ['style:rubocop', 'style:reek']
132
+ desc "Run all style checks"
133
+ task style: ["style:rubocop"]
172
134
 
173
- desc 'Run style + spec tests by default on travis'
135
+ desc "Run style + spec tests by default on travis"
174
136
  task travis: %w{style spec}
175
137
 
176
- desc 'Run style, spec and test kichen on travis'
177
- task travis_all: ['style', 'spec', 'integration:cloud']
178
-
179
- task default: ['style', 'spec', 'integration:vagrant']
138
+ desc "Run style + spec tests by default"
139
+ task default: %w{compile style spec}
data/bin/ffi-yajl-bench CHANGED
@@ -2,31 +2,31 @@
2
2
 
3
3
  $LOAD_PATH << File.expand_path(File.join(File.dirname( File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__ ), "../lib"))
4
4
 
5
- require 'optparse'
6
- require 'ffi_yajl/benchmark'
5
+ require "optparse"
6
+ require "ffi_yajl/benchmark"
7
7
 
8
8
  opts = {}
9
9
  optparse = OptionParser.new do |o|
10
10
  o.banner = "Usage: ffi-yajl-bench"
11
11
 
12
12
  opts[:profile] = false
13
- o.on( '-p', '--profile', 'Run perftools.rb profiling' ) do
13
+ o.on( "-p", "--profile", "Run perftools.rb profiling" ) do
14
14
  opts[:profile] = true
15
15
  end
16
16
 
17
- o.on( '-F', '--ffi', 'Force using FFI' ) do
17
+ o.on( "-F", "--ffi", "Force using FFI" ) do
18
18
  opts[:ffi] = true
19
19
  end
20
20
 
21
- o.on( '-E', '--ext', 'Force using C ext' ) do
21
+ o.on( "-E", "--ext", "Force using C ext" ) do
22
22
  opts[:ext] = true
23
23
  end
24
24
  end
25
25
 
26
26
  optparse.parse!
27
27
 
28
- ENV['FORCE_FFI_YAJL'] = 'ffi' if opts[:ffi]
29
- ENV['FORCE_FFI_YAJL'] = 'ext' if opts[:ext]
28
+ ENV["FORCE_FFI_YAJL"] = "ffi" if opts[:ffi]
29
+ ENV["FORCE_FFI_YAJL"] = "ext" if opts[:ext]
30
30
 
31
31
  if opts[:profile]
32
32
  FFI_Yajl::Benchmark::ParseProfileRubyProf.new.run
@@ -1,8 +1,8 @@
1
1
  # rubocop:disable Style/GlobalVars
2
- require 'mkmf'
3
- require 'rubygems'
2
+ require "mkmf"
3
+ require "rubygems"
4
4
 
5
- RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
5
+ RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
6
6
 
7
7
  puts $CFLAGS
8
8
  puts $LDFLAGS
@@ -11,6 +11,6 @@ have_header("dlfcn.h")
11
11
 
12
12
  have_library("dl", "dlopen")
13
13
 
14
- dir_config 'dlopen'
14
+ dir_config "dlopen"
15
15
 
16
- create_makefile 'ffi_yajl/ext/dlopen'
16
+ create_makefile "ffi_yajl/ext/dlopen"
@@ -377,8 +377,12 @@ void Init_encoder() {
377
377
  rb_define_method(rb_cNilClass, "ffi_yajl", rb_cNilClass_ffi_yajl, 2);
378
378
  rb_define_method(rb_cTrueClass, "ffi_yajl", rb_cTrueClass_ffi_yajl, 2);
379
379
  rb_define_method(rb_cFalseClass, "ffi_yajl", rb_cFalseClass_ffi_yajl, 2);
380
+ #ifdef rb_cFixnum /* ruby < 2.4 */
380
381
  rb_define_method(rb_cFixnum, "ffi_yajl", rb_cFixnum_ffi_yajl, 2);
381
382
  rb_define_method(rb_cBignum, "ffi_yajl", rb_cBignum_ffi_yajl, 2);
383
+ #else
384
+ rb_define_method(rb_cInteger, "ffi_yajl", rb_cFixnum_ffi_yajl, 2);
385
+ #endif
382
386
  rb_define_method(rb_cFloat, "ffi_yajl", rb_cFloat_ffi_yajl, 2);
383
387
  rb_define_method(rb_cString, "ffi_yajl", rb_cString_ffi_yajl, 2);
384
388
  rb_define_method(rb_cSymbol, "ffi_yajl", rb_cSymbol_ffi_yajl, 2);
@@ -1,9 +1,9 @@
1
1
  # rubocop:disable Style/GlobalVars
2
- require 'mkmf'
3
- require 'rubygems'
4
- require 'libyajl2'
2
+ require "mkmf"
3
+ require "rubygems"
4
+ require "libyajl2"
5
5
 
6
- RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
6
+ RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
7
7
 
8
8
  # pick up the vendored libyajl2 out of the libyajl2 gem
9
9
  $CFLAGS = " -I#{Libyajl2.include_path} #{$CFLAGS}"
@@ -16,7 +16,7 @@ puts $CFLAGS
16
16
  puts $LDFLAGS
17
17
 
18
18
  # except if you're doing an unoptimized gcc install we're going to help you out a bit
19
- if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc|clang/
19
+ if RbConfig::MAKEFILE_CONFIG["CC"] =~ /gcc|clang/
20
20
  $CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
21
21
  # how many people realize that -Wall is a compiler-specific flag???
22
22
  # apparently not many based on reading lots of shitty extconf.rb's out there
@@ -34,32 +34,32 @@ end
34
34
 
35
35
  # NOTE: find_library has the side effect of adding -lyajl to the flags which we are deliberately
36
36
  # avoiding doing with the libyajl2-gem (allowing it to be lazily loaded with dlopen)
37
- if !windows? && !find_header('yajl/yajl_tree.h')
37
+ if !windows? && !find_header("yajl/yajl_tree.h")
38
38
  puts "libyajl2 headers not found in libyajl2-gem, searching for system libraries..."
39
39
 
40
40
  HEADER_DIRS = [
41
41
  "/opt/local/include", # MacPorts
42
42
  "/usr/local/include", # /usr/local
43
- RbConfig::CONFIG['includedir'], # Ruby
43
+ RbConfig::CONFIG["includedir"], # Ruby
44
44
  "/usr/include", # (default)
45
45
  ]
46
46
 
47
47
  LIB_DIRS = [
48
48
  "/opt/local/lib", # MacPorts
49
49
  "/usr/local/lib", # /usr/local + Homebrew
50
- RbConfig::CONFIG['libdir'], # Ruby
50
+ RbConfig::CONFIG["libdir"], # Ruby
51
51
  "/usr/lib", # (default)
52
52
  ]
53
53
 
54
54
  # add --with-yajl-dir, --with-yajl-include, --with-yajl-lib
55
- dir_config('yajl', HEADER_DIRS, LIB_DIRS)
55
+ dir_config("yajl", HEADER_DIRS, LIB_DIRS)
56
56
 
57
57
  # here we use find_library in order to deliberately link with -lyajl as a useful side-effect
58
- unless find_header('yajl/yajl_tree.h') && find_library('yajl', 'yajl_complete_parse')
58
+ unless find_header("yajl/yajl_tree.h") && find_library("yajl", "yajl_complete_parse")
59
59
  abort "libyajl2 is missing. please install libyajl2"
60
60
  end
61
61
  end
62
62
 
63
- dir_config 'encoder'
63
+ dir_config "encoder"
64
64
 
65
- create_makefile 'ffi_yajl/ext/encoder'
65
+ create_makefile "ffi_yajl/ext/encoder"
@@ -1,9 +1,9 @@
1
1
  # rubocop:disable Style/GlobalVars
2
- require 'mkmf'
3
- require 'rubygems'
4
- require 'libyajl2'
2
+ require "mkmf"
3
+ require "rubygems"
4
+ require "libyajl2"
5
5
 
6
- RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
6
+ RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
7
7
 
8
8
  # pick up the vendored libyajl2 out of the libyajl2 gem
9
9
  $CFLAGS = "-I#{Libyajl2.include_path} #{$CFLAGS}"
@@ -16,7 +16,7 @@ puts $CFLAGS
16
16
  puts $LDFLAGS
17
17
 
18
18
  # except if you're doing an unoptimized gcc install we're going to help you out a bit
19
- if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc|clang/
19
+ if RbConfig::MAKEFILE_CONFIG["CC"] =~ /gcc|clang/
20
20
  $CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
21
21
  # how many people realize that -Wall is a compiler-specific flag???
22
22
  # apparently not many based on reading lots of shitty extconf.rb's out there
@@ -34,32 +34,32 @@ end
34
34
 
35
35
  # NOTE: find_library has the side effect of adding -lyajl to the flags which we are deliberately
36
36
  # avoiding doing with the libyajl2-gem (allowing it to be lazily loaded with dlopen)
37
- if !windows? && !find_header('yajl/yajl_tree.h')
37
+ if !windows? && !find_header("yajl/yajl_tree.h")
38
38
  puts "libyajl2 headers not found in libyajl2-gem, searching for system libraries..."
39
39
 
40
40
  HEADER_DIRS = [
41
41
  "/opt/local/include", # MacPorts
42
42
  "/usr/local/include", # /usr/local
43
- RbConfig::CONFIG['includedir'], # Ruby
43
+ RbConfig::CONFIG["includedir"], # Ruby
44
44
  "/usr/include", # (default)
45
45
  ]
46
46
 
47
47
  LIB_DIRS = [
48
48
  "/opt/local/lib", # MacPorts
49
49
  "/usr/local/lib", # /usr/local + Homebrew
50
- RbConfig::CONFIG['libdir'], # Ruby
50
+ RbConfig::CONFIG["libdir"], # Ruby
51
51
  "/usr/lib", # (default)
52
52
  ]
53
53
 
54
54
  # add --with-yajl-dir, --with-yajl-include, --with-yajl-lib
55
- dir_config('yajl', HEADER_DIRS, LIB_DIRS)
55
+ dir_config("yajl", HEADER_DIRS, LIB_DIRS)
56
56
 
57
57
  # here we use find_library in order to deliberately link with -lyajl as a useful side-effect
58
- unless find_header('yajl/yajl_tree.h') && find_library('yajl', 'yajl_complete_parse')
58
+ unless find_header("yajl/yajl_tree.h") && find_library("yajl", "yajl_complete_parse")
59
59
  abort "libyajl2 is missing. please install libyajl2"
60
60
  end
61
61
  end
62
62
 
63
- dir_config 'parser'
63
+ dir_config "parser"
64
64
 
65
- create_makefile 'ffi_yajl/ext/parser'
65
+ create_makefile "ffi_yajl/ext/parser"
@@ -1,26 +1,26 @@
1
1
  # Portions Originally Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario
2
2
  # See MIT-LICENSE
3
3
 
4
- require 'rubygems'
5
- require 'benchmark'
6
- require 'stringio'
4
+ require "rubygems"
5
+ require "benchmark"
6
+ require "stringio"
7
7
  if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/
8
8
  begin
9
- require 'yajl'
9
+ require "yajl"
10
10
  rescue LoadError
11
11
  puts "INFO: yajl-ruby not installed"
12
12
  end
13
13
  else
14
14
  puts "INFO: skipping yajl-ruby on jruby"
15
15
  end
16
- require 'ffi_yajl'
16
+ require "ffi_yajl"
17
17
  begin
18
- require 'json'
18
+ require "json"
19
19
  rescue LoadError
20
20
  puts "INFO: json gem not installed"
21
21
  end
22
22
  begin
23
- require 'oj'
23
+ require "oj"
24
24
  rescue LoadError
25
25
  puts "INFO: oj gem not installed"
26
26
  end
@@ -31,7 +31,7 @@ module FFI_Yajl
31
31
  def run
32
32
  # filename = ARGV[0] || 'benchmark/subjects/ohai.json'
33
33
  filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json"))
34
- hash = File.open(filename, 'rb') { |f| FFI_Yajl::Parser.parse(f.read) }
34
+ hash = File.open(filename, "rb") { |f| FFI_Yajl::Parser.parse(f.read) }
35
35
 
36
36
  times = ARGV[1] ? ARGV[1].to_i : 1000
37
37
  puts "Starting benchmark encoding #{filename} #{times} times\n\n"
@@ -1,18 +1,18 @@
1
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..')
2
- $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
1
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..")
2
+ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
3
3
 
4
- require 'rubygems'
5
- require 'benchmark'
6
- require 'yajl'
7
- require 'stringio'
4
+ require "rubygems"
5
+ require "benchmark"
6
+ require "yajl"
7
+ require "stringio"
8
8
  begin
9
- require 'json'
9
+ require "json"
10
10
  rescue LoadError
11
11
  end
12
12
 
13
13
  times = ARGV[0] ? ARGV[0].to_i : 1000
14
- filename = 'benchmark/subjects/ohai.json'
15
- json = File.new(filename, 'r')
14
+ filename = "benchmark/subjects/ohai.json"
15
+ json = File.new(filename, "r")
16
16
  hash = Yajl::Parser.new.parse(json)
17
17
  json.close
18
18