diff options
author | Tim Smith <tsmith@chef.io> | 2017-06-20 15:37:38 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2017-06-20 15:37:38 -0700 |
commit | 672fce3aed2d68e7362dc5cfeb72df78f30eb3a2 (patch) | |
tree | 76598d0c31493ca6fa8a8353402136cf8003b997 /lib/ffi_yajl | |
parent | f3f92275f804f4c6cf93ee054af7d4ba3e50030a (diff) | |
download | ffi-yajl-672fce3aed2d68e7362dc5cfeb72df78f30eb3a2.tar.gz |
Switch from reek/rubocop to chefstyle
Reek doesn't work with modern Rake
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib/ffi_yajl')
-rw-r--r-- | lib/ffi_yajl/benchmark.rb | 10 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/encode.rb | 16 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/encode_json_and_marshal.rb | 18 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/encode_json_and_yaml.rb | 22 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/encode_profile.rb | 10 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/http.rb | 24 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/parse.rb | 16 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/parse_json_and_marshal.rb | 20 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/parse_json_and_yaml.rb | 22 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/parse_profile.rb | 10 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb | 8 | ||||
-rw-r--r-- | lib/ffi_yajl/benchmark/parse_stream.rb | 18 | ||||
-rw-r--r-- | lib/ffi_yajl/encoder.rb | 4 | ||||
-rw-r--r-- | lib/ffi_yajl/ext.rb | 18 | ||||
-rw-r--r-- | lib/ffi_yajl/ffi.rb | 16 | ||||
-rw-r--r-- | lib/ffi_yajl/ffi/encoder.rb | 18 | ||||
-rw-r--r-- | lib/ffi_yajl/ffi/parser.rb | 10 | ||||
-rw-r--r-- | lib/ffi_yajl/map_library_name.rb | 6 | ||||
-rw-r--r-- | lib/ffi_yajl/parser.rb | 4 |
19 files changed, 135 insertions, 135 deletions
diff --git a/lib/ffi_yajl/benchmark.rb b/lib/ffi_yajl/benchmark.rb index e8944ca..1372133 100644 --- a/lib/ffi_yajl/benchmark.rb +++ b/lib/ffi_yajl/benchmark.rb @@ -20,8 +20,8 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -require 'ffi_yajl/benchmark/encode.rb' -require 'ffi_yajl/benchmark/encode_profile.rb' -require 'ffi_yajl/benchmark/parse.rb' -require 'ffi_yajl/benchmark/parse_profile.rb' -require 'ffi_yajl/benchmark/parse_profile_ruby_prof.rb' +require "ffi_yajl/benchmark/encode.rb" +require "ffi_yajl/benchmark/encode_profile.rb" +require "ffi_yajl/benchmark/parse.rb" +require "ffi_yajl/benchmark/parse_profile.rb" +require "ffi_yajl/benchmark/parse_profile_ruby_prof.rb" diff --git a/lib/ffi_yajl/benchmark/encode.rb b/lib/ffi_yajl/benchmark/encode.rb index fc03c06..17e12cc 100644 --- a/lib/ffi_yajl/benchmark/encode.rb +++ b/lib/ffi_yajl/benchmark/encode.rb @@ -1,26 +1,26 @@ # Portions Originally Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario # See MIT-LICENSE -require 'rubygems' -require 'benchmark' -require 'stringio' +require "rubygems" +require "benchmark" +require "stringio" if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/ begin - require 'yajl' + require "yajl" rescue LoadError puts "INFO: yajl-ruby not installed" end else puts "INFO: skipping yajl-ruby on jruby" end -require 'ffi_yajl' +require "ffi_yajl" begin - require 'json' + require "json" rescue LoadError puts "INFO: json gem not installed" end begin - require 'oj' + require "oj" rescue LoadError puts "INFO: oj gem not installed" end @@ -31,7 +31,7 @@ module FFI_Yajl def run # filename = ARGV[0] || 'benchmark/subjects/ohai.json' filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json")) - hash = File.open(filename, 'rb') { |f| FFI_Yajl::Parser.parse(f.read) } + hash = File.open(filename, "rb") { |f| FFI_Yajl::Parser.parse(f.read) } times = ARGV[1] ? ARGV[1].to_i : 1000 puts "Starting benchmark encoding #{filename} #{times} times\n\n" diff --git a/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb b/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb index e9d19bc..4269056 100644 --- a/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb +++ b/lib/ffi_yajl/benchmark/encode_json_and_marshal.rb @@ -1,18 +1,18 @@ -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..') -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..") +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib") -require 'rubygems' -require 'benchmark' -require 'yajl' -require 'stringio' +require "rubygems" +require "benchmark" +require "yajl" +require "stringio" begin - require 'json' + require "json" rescue LoadError end times = ARGV[0] ? ARGV[0].to_i : 1000 -filename = 'benchmark/subjects/ohai.json' -json = File.new(filename, 'r') +filename = "benchmark/subjects/ohai.json" +json = File.new(filename, "r") hash = Yajl::Parser.new.parse(json) json.close diff --git a/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb b/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb index 33dbbb2..72310c1 100644 --- a/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb +++ b/lib/ffi_yajl/benchmark/encode_json_and_yaml.rb @@ -1,18 +1,18 @@ -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..') -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..") +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib") -require 'rubygems' -require 'benchmark' -require 'yajl' +require "rubygems" +require "benchmark" +require "yajl" begin - require 'json' + require "json" rescue LoadError end -require 'yaml' +require "yaml" # JSON Section -filename = 'benchmark/subjects/ohai.json' -json = File.new(filename, 'r') +filename = "benchmark/subjects/ohai.json" +json = File.new(filename, "r") hash = Yajl::Parser.new.parse(json) json.close @@ -33,8 +33,8 @@ Benchmark.bmbm do |x| end # YAML Section -filename = 'benchmark/subjects/ohai.yml' -yml = File.new(filename, 'r') +filename = "benchmark/subjects/ohai.yml" +yml = File.new(filename, "r") data = YAML.load_stream(yml) yml.close diff --git a/lib/ffi_yajl/benchmark/encode_profile.rb b/lib/ffi_yajl/benchmark/encode_profile.rb index 36b92c7..468f88b 100644 --- a/lib/ffi_yajl/benchmark/encode_profile.rb +++ b/lib/ffi_yajl/benchmark/encode_profile.rb @@ -1,15 +1,15 @@ # Portions Originally Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario # See MIT-LICENSE -require 'rubygems' -require 'ffi_yajl' +require "rubygems" +require "ffi_yajl" begin - require 'perftools' + require "perftools" rescue LoadError puts "INFO: perftools.rb gem not installed" end -ENV['CPUPROFILE_FREQUENCY'] = "4000" +ENV["CPUPROFILE_FREQUENCY"] = "4000" module FFI_Yajl class Benchmark @@ -18,7 +18,7 @@ module FFI_Yajl return unless defined?(PerfTools) filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json")) - hash = File.open(filename, 'rb') { |f| FFI_Yajl::Parser.parse(f.read) } + hash = File.open(filename, "rb") { |f| FFI_Yajl::Parser.parse(f.read) } times = 1000 puts "Starting profiling encoding #{filename} #{times} times\n\n" diff --git a/lib/ffi_yajl/benchmark/http.rb b/lib/ffi_yajl/benchmark/http.rb index b94a46c..0b19387 100644 --- a/lib/ffi_yajl/benchmark/http.rb +++ b/lib/ffi_yajl/benchmark/http.rb @@ -1,17 +1,17 @@ -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..') -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..") +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib") -require 'rubygems' -require 'benchmark' -require 'yajl/http_stream' -require 'yajl/gzip' -require 'yajl/deflate' -require 'yajl/bzip2' unless defined?(Bzip2) -require 'json' -require 'uri' -require 'net/http' +require "rubygems" +require "benchmark" +require "yajl/http_stream" +require "yajl/gzip" +require "yajl/deflate" +require "yajl/bzip2" unless defined?(Bzip2) +require "json" +require "uri" +require "net/http" -uri = URI.parse('http://search.twitter.com/search.json?q=github') +uri = URI.parse("http://search.twitter.com/search.json?q=github") # uri = URI.parse('http://localhost/yajl-ruby.git/benchmark/subjects/contacts.json') times = ARGV[0] ? ARGV[0].to_i : 1 diff --git a/lib/ffi_yajl/benchmark/parse.rb b/lib/ffi_yajl/benchmark/parse.rb index 6aacc94..ad0091c 100644 --- a/lib/ffi_yajl/benchmark/parse.rb +++ b/lib/ffi_yajl/benchmark/parse.rb @@ -1,10 +1,10 @@ -require 'rubygems' -require 'benchmark' -require 'yajl' -require 'ffi_yajl' +require "rubygems" +require "benchmark" +require "yajl" +require "ffi_yajl" if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/ begin - require 'yajl' + require "yajl" rescue LoadError puts "INFO: yajl-ruby not installed" end @@ -12,11 +12,11 @@ else puts "INFO: skipping yajl-ruby on jruby" end begin - require 'json' + require "json" rescue LoadError end begin - require 'oj' + require "oj" rescue LoadError end @@ -25,7 +25,7 @@ module FFI_Yajl class Parse def run filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "item.json")) - json = File.new(filename, 'r') + json = File.new(filename, "r") json_str = json.read times = ARGV[1] ? ARGV[1].to_i : 10_000 diff --git a/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb b/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb index cd07d46..1148ebc 100644 --- a/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb +++ b/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb @@ -1,19 +1,19 @@ -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..') -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..") +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib") -require 'rubygems' -require 'benchmark' -require 'yajl' +require "rubygems" +require "benchmark" +require "yajl" begin - require 'json' + require "json" rescue LoadError end # JSON section -filename = 'benchmark/subjects/ohai.json' -marshal_filename = 'benchmark/subjects/ohai.marshal_dump' -json = File.new(filename, 'r') -marshal_file = File.new(marshal_filename, 'r') +filename = "benchmark/subjects/ohai.json" +marshal_filename = "benchmark/subjects/ohai.marshal_dump" +json = File.new(filename, "r") +marshal_file = File.new(marshal_filename, "r") hash = {} diff --git a/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb b/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb index 6e479ce..b55d916 100644 --- a/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb +++ b/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb @@ -1,18 +1,18 @@ -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..') -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..") +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib") -require 'rubygems' -require 'benchmark' -require 'yajl' +require "rubygems" +require "benchmark" +require "yajl" begin - require 'json' + require "json" rescue LoadError end -require 'yaml' +require "yaml" # JSON section -filename = 'benchmark/subjects/ohai.json' -json = File.new(filename, 'r') +filename = "benchmark/subjects/ohai.json" +json = File.new(filename, "r") times = ARGV[0] ? ARGV[0].to_i : 1000 puts "Starting benchmark parsing #{File.size(filename)} bytes of JSON data #{times} times\n\n" @@ -39,8 +39,8 @@ end json.close # YAML section -filename = 'benchmark/subjects/ohai.yml' -yaml = File.new(filename, 'r') +filename = "benchmark/subjects/ohai.yml" +yaml = File.new(filename, "r") puts "Starting benchmark parsing #{File.size(filename)} bytes of YAML data #{times} times\n\n" Benchmark.bmbm do |x| diff --git a/lib/ffi_yajl/benchmark/parse_profile.rb b/lib/ffi_yajl/benchmark/parse_profile.rb index 6ef00ac..4b396b4 100644 --- a/lib/ffi_yajl/benchmark/parse_profile.rb +++ b/lib/ffi_yajl/benchmark/parse_profile.rb @@ -1,15 +1,15 @@ # Portions Originally Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario # See MIT-LICENSE -require 'rubygems' -require 'ffi_yajl' +require "rubygems" +require "ffi_yajl" begin - require 'perftools' + require "perftools" rescue LoadError puts "INFO: perftools.rb gem not installed" end -ENV['CPUPROFILE_FREQUENCY'] = "4000" +ENV["CPUPROFILE_FREQUENCY"] = "4000" module FFI_Yajl class Benchmark @@ -18,7 +18,7 @@ module FFI_Yajl return if defined?(PerfTools) filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json")) - json = File.new(filename, 'r').read + json = File.new(filename, "r").read times = 1000 puts "Starting profiling encoding #{filename} #{times} times\n\n" diff --git a/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb b/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb index 51696c5..2c4021a 100644 --- a/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb +++ b/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb @@ -1,15 +1,15 @@ # Portions Originally Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario # See MIT-LICENSE -require 'rubygems' -require 'ffi_yajl' +require "rubygems" +require "ffi_yajl" module FFI_Yajl class Benchmark class ParseProfileRubyProf def run begin - require 'ruby-prof' + require "ruby-prof" rescue LoadError puts "INFO: perftools.rb gem not installed" end @@ -17,7 +17,7 @@ module FFI_Yajl return if defined?(RubyProf) filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json")) - json = File.new(filename, 'r').read + json = File.new(filename, "r").read times = 1000 puts "Starting profiling encoding #{filename} #{times} times\n\n" diff --git a/lib/ffi_yajl/benchmark/parse_stream.rb b/lib/ffi_yajl/benchmark/parse_stream.rb index 679eb92..9ca0050 100644 --- a/lib/ffi_yajl/benchmark/parse_stream.rb +++ b/lib/ffi_yajl/benchmark/parse_stream.rb @@ -1,20 +1,20 @@ -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/..') -$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/..") +$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib") -require 'rubygems' -require 'benchmark' -require 'yajl' +require "rubygems" +require "benchmark" +require "yajl" begin - require 'json' + require "json" rescue LoadError end begin - require 'active_support' + require "active_support" rescue LoadError end -filename = 'benchmark/subjects/twitter_stream.json' -json = File.new(filename, 'r') +filename = "benchmark/subjects/twitter_stream.json" +json = File.new(filename, "r") times = ARGV[0] ? ARGV[0].to_i : 100 puts "Starting benchmark parsing JSON stream (#{File.size(filename)} bytes of JSON data with 430 JSON separate strings) #{times} times\n\n" diff --git a/lib/ffi_yajl/encoder.rb b/lib/ffi_yajl/encoder.rb index 3b07e95..97f3e66 100644 --- a/lib/ffi_yajl/encoder.rb +++ b/lib/ffi_yajl/encoder.rb @@ -47,7 +47,7 @@ module FFI_Yajl if str.respond_to?(:scrub) str.scrub! else - str.encode!("UTF-16le", undef: :replace, invalid: :replace).encode!('UTF-8') + str.encode!("UTF-16le", undef: :replace, invalid: :replace).encode!("UTF-8") end end str @@ -68,7 +68,7 @@ module FFI_Yajl if token.respond_to?(:scrub) token.scrub! else - token.encode!("UTF-16le", undef: :replace, invalid: :replace).encode!('UTF-8') + token.encode!("UTF-16le", undef: :replace, invalid: :replace).encode!("UTF-8") end case status when 1 # yajl_gen_keys_must_be_strings diff --git a/lib/ffi_yajl/ext.rb b/lib/ffi_yajl/ext.rb index ed17e59..f7bbcfd 100644 --- a/lib/ffi_yajl/ext.rb +++ b/lib/ffi_yajl/ext.rb @@ -20,16 +20,16 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -require 'rubygems' +require "rubygems" -require 'ffi_yajl/encoder' -require 'ffi_yajl/parser' -require 'ffi_yajl/ext/dlopen' -require 'ffi_yajl/map_library_name' +require "ffi_yajl/encoder" +require "ffi_yajl/parser" +require "ffi_yajl/ext/dlopen" +require "ffi_yajl/map_library_name" # needed so the encoder c-code can find these symbols -require 'stringio' -require 'date' +require "stringio" +require "date" module FFI_Yajl extend FFI_Yajl::MapLibraryName @@ -38,12 +38,12 @@ module FFI_Yajl dlopen_yajl_library class Parser - require 'ffi_yajl/ext/parser' + require "ffi_yajl/ext/parser" include FFI_Yajl::Ext::Parser end class Encoder - require 'ffi_yajl/ext/encoder' + require "ffi_yajl/ext/encoder" include FFI_Yajl::Ext::Encoder end end diff --git a/lib/ffi_yajl/ffi.rb b/lib/ffi_yajl/ffi.rb index 3b83bae..7211c79 100644 --- a/lib/ffi_yajl/ffi.rb +++ b/lib/ffi_yajl/ffi.rb @@ -20,18 +20,18 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -require 'rubygems' +require "rubygems" -require 'libyajl2' +require "libyajl2" begin - require 'ffi' + require "ffi" rescue LoadError $stderr.puts "FATAL: to use the ffi extension instead of the compiled C extension, the ffi gem must be installed" $stderr.puts " (it is optional, so you must include it in your bundle manually)" exit 1 end -require 'ffi_yajl/map_library_name' +require "ffi_yajl/map_library_name" module FFI_Yajl extend ::FFI::Library @@ -137,17 +137,17 @@ module FFI_Yajl attach_function :yajl_gen_clear, [:yajl_gen], :void end -require 'ffi_yajl/encoder' -require 'ffi_yajl/parser' +require "ffi_yajl/encoder" +require "ffi_yajl/parser" module FFI_Yajl class Parser - require 'ffi_yajl/ffi/parser' + require "ffi_yajl/ffi/parser" include FFI_Yajl::FFI::Parser end class Encoder - require 'ffi_yajl/ffi/encoder' + require "ffi_yajl/ffi/encoder" include FFI_Yajl::FFI::Encoder end end diff --git a/lib/ffi_yajl/ffi/encoder.rb b/lib/ffi_yajl/ffi/encoder.rb index 304c85f..f35f3c4 100644 --- a/lib/ffi_yajl/ffi/encoder.rb +++ b/lib/ffi_yajl/ffi/encoder.rb @@ -20,8 +20,8 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -require 'date' -require 'stringio' +require "date" +require "stringio" module FFI_Yajl module FFI @@ -73,7 +73,7 @@ class Hash end else if ( status = FFI_Yajl.yajl_gen_map_open(yajl_gen) ) != 0 - FFI_Yajl::Encoder.raise_error_for_status(status, '{') + FFI_Yajl::Encoder.raise_error_for_status(status, "{") end each do |key, value| # Perf Fix: mutate state hash rather than creating new copy @@ -83,7 +83,7 @@ class Hash value.ffi_yajl(yajl_gen, state) end if ( status = FFI_Yajl.yajl_gen_map_close(yajl_gen) ) != 0 - FFI_Yajl::Encoder.raise_error_for_status(status, '}') + FFI_Yajl::Encoder.raise_error_for_status(status, "}") end end end @@ -98,13 +98,13 @@ class Array end else if ( status = FFI_Yajl.yajl_gen_array_open(yajl_gen) ) != 0 - FFI_Yajl::Encoder.raise_error_for_status(status, '[') + FFI_Yajl::Encoder.raise_error_for_status(status, "[") end each do |value| value.ffi_yajl(yajl_gen, state) end if ( status = FFI_Yajl.yajl_gen_array_close(yajl_gen) ) != 0 - FFI_Yajl::Encoder.raise_error_for_status(status, ']') + FFI_Yajl::Encoder.raise_error_for_status(status, "]") end end end @@ -155,7 +155,7 @@ class FalseClass end end -class Fixnum +class Integer def ffi_yajl(yajl_gen, state) str = to_s if str == "NaN" || str == "Infinity" || str == "-Infinity" @@ -173,7 +173,7 @@ class Fixnum end end -class Bignum +class Integer def ffi_yajl(yajl_gen, state) str = to_s if str == "NaN" || str == "Infinity" || str == "-Infinity" @@ -265,7 +265,7 @@ end # I feel dirty class Object def ffi_yajl(yajl_gen, state) - if !state[:processing_key] && self.respond_to?(:to_json) + if !state[:processing_key] && respond_to?(:to_json) str = to_json(state[:json_opts]) # #yajl_gen_number outputs a string without quotes around it status = FFI_Yajl.yajl_gen_number(yajl_gen, str, str.bytesize) diff --git a/lib/ffi_yajl/ffi/parser.rb b/lib/ffi_yajl/ffi/parser.rb index 67df934..7c98d59 100644 --- a/lib/ffi_yajl/ffi/parser.rb +++ b/lib/ffi_yajl/ffi/parser.rb @@ -65,7 +65,7 @@ module FFI_Yajl end @number_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t ]) do |ctx, stringval, stringlen| s = stringval.slice(0, stringlen) - s.force_encoding('UTF-8') if defined? Encoding + s.force_encoding("UTF-8") if defined? Encoding # XXX: I can't think of a better way to do this right now. need to call to_f if and only if its a float. v = ( s =~ /[\.eE]/ ) ? s.to_f : s.to_i set_value(v) @@ -77,7 +77,7 @@ module FFI_Yajl end @string_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t]) do |ctx, stringval, stringlen| s = stringval.slice(0, stringlen) - s.force_encoding('UTF-8') if defined? Encoding + s.force_encoding("UTF-8") if defined? Encoding set_value(s) 1 end @@ -88,7 +88,7 @@ module FFI_Yajl end @map_key_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t]) do |ctx, key, keylen| s = key.slice(0, keylen) - s.force_encoding('UTF-8') if defined? Encoding + s.force_encoding("UTF-8") if defined? Encoding self.key = @opts[:symbolize_keys] ? s.to_sym : s 1 end @@ -143,12 +143,12 @@ module FFI_Yajl ::FFI_Yajl.yajl_config(yajl_handle, :yajl_allow_partial_values, :int, 1) end - if ( ::FFI_Yajl.yajl_parse(yajl_handle, str, str.bytesize) != :yajl_status_ok ) + if ::FFI_Yajl.yajl_parse(yajl_handle, str, str.bytesize) != :yajl_status_ok # FIXME: dup the error and call yajl_free_error? error = ::FFI_Yajl.yajl_get_error(yajl_handle, 1, str, str.bytesize) raise ::FFI_Yajl::ParseError, error end - if ( ::FFI_Yajl.yajl_complete_parse(yajl_handle) != :yajl_status_ok ) + if ::FFI_Yajl.yajl_complete_parse(yajl_handle) != :yajl_status_ok # FIXME: dup the error and call yajl_free_error? error = ::FFI_Yajl.yajl_get_error(yajl_handle, 1, str, str.bytesize) raise ::FFI_Yajl::ParseError, error diff --git a/lib/ffi_yajl/map_library_name.rb b/lib/ffi_yajl/map_library_name.rb index 249116e..6ec3c0c 100644 --- a/lib/ffi_yajl/map_library_name.rb +++ b/lib/ffi_yajl/map_library_name.rb @@ -20,7 +20,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -require 'libyajl2' +require "libyajl2" # Mixin for use in finding the right yajl library on the system. The 'caller' # needs to also mixin either the FFI module or the DLopen module. Those are @@ -36,7 +36,7 @@ module FFI_Yajl # @api private # @return Array<String> lower case ruby host_os string def host_os - RbConfig::CONFIG['host_os'].downcase + RbConfig::CONFIG["host_os"].downcase end # Array of yajl library names on the platform. Some platforms like Windows @@ -103,7 +103,7 @@ module FFI_Yajl rescue LoadError end end - ffi_lib 'yajl' unless found + ffi_lib "yajl" unless found end end end diff --git a/lib/ffi_yajl/parser.rb b/lib/ffi_yajl/parser.rb index 6029691..2f1dbf7 100644 --- a/lib/ffi_yajl/parser.rb +++ b/lib/ffi_yajl/parser.rb @@ -65,10 +65,10 @@ module FFI_Yajl raise ArgumentError, "options check_utf8 and dont_validate_strings are both true which conflict" end - yajl_opts[:yajl_allow_comments] = true + yajl_opts[:yajl_allow_comments] = true if @opts.key?(:allow_comments) - yajl_opts[:yajl_allow_comments] = @opts[:allow_comments] + yajl_opts[:yajl_allow_comments] = @opts[:allow_comments] end yajl_opts[:yajl_dont_validate_strings] = (@opts[:check_utf8] == false || @opts[:dont_validate_strings]) |