summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-09-22 15:56:09 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-09-22 15:56:09 -0700
commit54789f3bfce4f1167d0ebaf9897345d47649a368 (patch)
tree85183d0a656ec154d466e0f26dcea7713cd03b82
parente5294ab56f26ccb35338032f656ac2e7362b61f1 (diff)
downloadffi-yajl-lcg/finstyle.tar.gz
Convert from rubocop to finstylelcg/finstyle
-rw-r--r--.rubocop.yml66
-rw-r--r--Gemfile18
-rw-r--r--Rakefile77
-rwxr-xr-xbin/ffi-yajl-bench16
-rw-r--r--ext/ffi_yajl/ext/dlopen/extconf.rb10
-rw-r--r--ext/ffi_yajl/ext/encoder/extconf.rb24
-rw-r--r--ext/ffi_yajl/ext/parser/extconf.rb24
-rw-r--r--ffi-yajl.gemspec2
-rw-r--r--lib/ffi_yajl.rb14
-rw-r--r--lib/ffi_yajl/benchmark.rb10
-rw-r--r--lib/ffi_yajl/benchmark/encode.rb16
-rw-r--r--lib/ffi_yajl/benchmark/encode_json_and_marshal.rb18
-rw-r--r--lib/ffi_yajl/benchmark/encode_json_and_yaml.rb22
-rw-r--r--lib/ffi_yajl/benchmark/encode_profile.rb10
-rw-r--r--lib/ffi_yajl/benchmark/http.rb24
-rw-r--r--lib/ffi_yajl/benchmark/parse.rb20
-rw-r--r--lib/ffi_yajl/benchmark/parse_json_and_marshal.rb22
-rw-r--r--lib/ffi_yajl/benchmark/parse_json_and_yaml.rb24
-rw-r--r--lib/ffi_yajl/benchmark/parse_profile.rb10
-rw-r--r--lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb8
-rw-r--r--lib/ffi_yajl/benchmark/parse_stream.rb20
-rw-r--r--lib/ffi_yajl/ext.rb18
-rw-r--r--lib/ffi_yajl/ffi.rb40
-rw-r--r--lib/ffi_yajl/ffi/encoder.rb78
-rw-r--r--lib/ffi_yajl/ffi/parser.rb36
-rw-r--r--lib/ffi_yajl/map_library_name.rb16
-rw-r--r--spec/ffi_yajl/encoder_spec.rb40
-rw-r--r--spec/ffi_yajl/map_library_name_spec.rb26
-rw-r--r--spec/ffi_yajl/parser_spec.rb46
-rw-r--r--spec/spec_helper.rb10
30 files changed, 363 insertions, 402 deletions
diff --git a/.rubocop.yml b/.rubocop.yml
index e843ff7..8a7d03f 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -1,67 +1,27 @@
-AbcSize:
+Lint/HandleExceptions:
Enabled: false
-AndOr:
+Lint/Eval:
Enabled: false
-Lint/AssignmentInCondition:
+Metrics/AbcSize:
Enabled: false
-ClassAndModuleCamelCase:
+Metrics/ClassLength:
Enabled: false
-ClassLength:
+Metrics/CyclomaticComplexity:
Enabled: false
-CommentAnnotation:
+Metrics/LineLength:
Enabled: false
-CyclomaticComplexity:
+Metrics/MethodLength:
Enabled: false
-Documentation:
+Metrics/ModuleLength:
Enabled: false
-DoubleNegation:
+Metrics/PerceivedComplexity:
Enabled: false
-Encoding:
+Style/ClassAndModuleCamelCase:
Enabled: false
-Eval:
+Style/DoubleNegation:
Enabled: false
Style/FileName:
Exclude:
- bin/ffi-yajl-bench
-FormatString:
- Enabled: false
-Style/GuardClause:
- Enabled: false
-Lint/HandleExceptions:
- Enabled: false
-LineLength:
- Enabled: false
-MethodLength:
- Enabled: false
-ModuleLength:
- Enabled: false
-PerceivedComplexity:
- Enabled: false
-PercentLiteralDelimiters:
- PreferredDelimiters:
- '%': '{}'
- '%q': '{}'
- '%Q': '{}'
- '%w': '{}'
- '%W': '{}'
- '%x': '{}'
-RegexpLiteral:
- Enabled: false
-Style/Semicolon:
- Enabled: false
-SignalException:
- Enabled: false
-SingleSpaceBeforeFirstArg:
- Enabled: false
-SpaceInsideBrackets:
- Enabled: false
-SpaceInsideParens:
- Enabled: false
-StringLiterals:
- Enabled: false
-TrailingComma:
- EnforcedStyleForMultiline: comma
-UnusedMethodArgument:
- Enabled: false
-UnusedBlockArgument:
- Enabled: false
+Style/HashSyntax:
+ EnforcedStyle: 'ruby19'
diff --git a/Gemfile b/Gemfile
index 330a01b..d014f5f 100644
--- a/Gemfile
+++ b/Gemfile
@@ -3,20 +3,20 @@ source "https://rubygems.org"
gemspec name: "ffi-yajl"
platforms :rbx do
- gem 'rubysl', '~> 2.0'
+ gem "rubysl", "~> 2.0"
end
group :development do
# for testing loading concurrently with yajl-ruby, not on jruby
- gem 'yajl-ruby', platforms: [ :ruby, :mswin, :mingw ]
- gem 'github_changelog_generator'
+ gem "yajl-ruby", platforms: [:ruby, :mswin, :mingw]
+ gem "github_changelog_generator"
end
group :development_extras do
- gem 'rubocop', '= 0.32.1'
- gem 'reek', '= 1.3.7'
- gem 'test-kitchen', '~> 1.2'
- gem 'kitchen-digitalocean'
- gem 'kitchen-ec2'
- gem 'kitchen-vagrant'
+ gem "finstyle", "= 1.5.0"
+ gem "reek", "= 1.3.7"
+ gem "test-kitchen", "~> 1.2"
+ gem "kitchen-digitalocean"
+ gem "kitchen-ec2"
+ gem "kitchen-vagrant"
end
diff --git a/Rakefile b/Rakefile
index e9746fb..547e8c8 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,10 +1,11 @@
-$LOAD_PATH << File.expand_path(File.join(File.dirname( __FILE__ ), "lib"))
+$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "lib"))
-require 'rspec/core/rake_task'
-require 'rubygems/package_task'
-require 'rake/extensiontask'
-require 'ffi_yajl/version'
-require 'github_changelog_generator/task'
+require "finstyle"
+require "rspec/core/rake_task"
+require "rubygems/package_task"
+require "rake/extensiontask"
+require "ffi_yajl/version"
+require "github_changelog_generator/task"
Dir[File.expand_path("../*gemspec", __FILE__)].reverse_each do |gemspec_path|
gemspec = eval(IO.read(gemspec_path))
@@ -12,8 +13,8 @@ Dir[File.expand_path("../*gemspec", __FILE__)].reverse_each do |gemspec_path|
end
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
- config.since_tag = '1.0.1'
- config.exclude_labels = %w{duplicate question invalid wontfix changelog_skip}
+ config.since_tag = "1.0.1"
+ config.exclude_labels = %w[duplicate question invalid wontfix changelog_skip]
end
desc "Build it and ship it"
@@ -41,26 +42,26 @@ task install: [:package] do
end
end
-spec = Gem::Specification.load('ffi-yajl.gemspec')
+spec = Gem::Specification.load("ffi-yajl.gemspec")
Rake::ExtensionTask.new do |ext|
- ext.name = 'encoder'
- ext.lib_dir = 'lib/ffi_yajl/ext'
- ext.ext_dir = 'ext/ffi_yajl/ext/encoder'
+ ext.name = "encoder"
+ ext.lib_dir = "lib/ffi_yajl/ext"
+ ext.ext_dir = "ext/ffi_yajl/ext/encoder"
ext.gem_spec = spec
end
Rake::ExtensionTask.new do |ext|
- ext.name = 'parser'
- ext.lib_dir = 'lib/ffi_yajl/ext'
- ext.ext_dir = 'ext/ffi_yajl/ext/parser'
+ ext.name = "parser"
+ ext.lib_dir = "lib/ffi_yajl/ext"
+ ext.ext_dir = "ext/ffi_yajl/ext/parser"
ext.gem_spec = spec
end
Rake::ExtensionTask.new do |ext|
- ext.name = 'dlopen'
- ext.lib_dir = 'lib/ffi_yajl/ext'
- ext.ext_dir = 'ext/ffi_yajl/ext/dlopen'
+ ext.name = "dlopen"
+ ext.lib_dir = "lib/ffi_yajl/ext"
+ ext.ext_dir = "ext/ffi_yajl/ext/dlopen"
ext.gem_spec = spec
end
@@ -79,14 +80,14 @@ end
namespace :spec do
desc "Run all specs against ffi extension"
RSpec::Core::RakeTask.new(:ffi) do |t|
- ENV['FORCE_FFI_YAJL'] = "ffi"
- t.pattern = FileList['spec/**/*_spec.rb']
+ ENV["FORCE_FFI_YAJL"] = "ffi"
+ t.pattern = FileList["spec/**/*_spec.rb"]
end
if !defined?(RUBY_ENGINE) || RUBY_ENGINE !~ /jruby/
desc "Run all specs again c extension"
RSpec::Core::RakeTask.new(:ext) do |t|
- ENV['FORCE_FFI_YAJL'] = "ext"
- t.pattern = FileList['spec/**/*_spec.rb']
+ ENV["FORCE_FFI_YAJL"] = "ext"
+ t.pattern = FileList["spec/**/*_spec.rb"]
end
end
end
@@ -94,7 +95,7 @@ end
if RUBY_VERSION.to_f >= 1.9
namespace :integration do
begin
- require 'kitchen'
+ require "kitchen"
rescue LoadError
task :vagrant do
puts "test-kitchen gem is not installed"
@@ -103,7 +104,7 @@ if RUBY_VERSION.to_f >= 1.9
puts "test-kitchen gem is not installed"
end
else
- desc 'Run Test Kitchen with Vagrant'
+ desc "Run Test Kitchen with Vagrant"
task :vagrant do
Kitchen.logger = Kitchen.default_file_logger
Kitchen::Config.new.instances.each do |instance|
@@ -111,19 +112,19 @@ if RUBY_VERSION.to_f >= 1.9
end
end
- desc 'Run Test Kitchen with cloud plugins'
+ desc "Run Test Kitchen with cloud plugins"
task :cloud do
- if ENV['TRAVIS_PULL_REQUEST'] != 'true'
- ENV['KITCHEN_YAML'] = '.kitchen.cloud.yml'
+ if ENV["TRAVIS_PULL_REQUEST"] != "true"
+ ENV["KITCHEN_YAML"] = ".kitchen.cloud.yml"
sh "kitchen test --concurrency 4"
end
end
end
end
namespace :style do
- desc 'Run Ruby style checks'
+ desc "Run Ruby style checks"
begin
- require 'rubocop/rake_task'
+ require "rubocop/rake_task"
rescue LoadError
task :rubocop do
puts "rubocop gem is not installed"
@@ -134,9 +135,9 @@ if RUBY_VERSION.to_f >= 1.9
end
end
- desc 'Run Ruby smell checks'
+ desc "Run Ruby smell checks"
begin
- require 'reek/rake/task'
+ require "reek/rake/task"
rescue LoadError
task :reek do
puts "reek gem is not installed"
@@ -167,13 +168,13 @@ else
end
end
-desc 'Run all style checks'
-task style: ['style:rubocop', 'style:reek']
+desc "Run all style checks"
+task style: ["style:rubocop", "style:reek"]
-desc 'Run style + spec tests by default on travis'
-task travis: %w{style spec}
+desc "Run style + spec tests by default on travis"
+task travis: %w[style spec]
-desc 'Run style, spec and test kichen on travis'
-task travis_all: ['style', 'spec', 'integration:cloud']
+desc "Run style, spec and test kichen on travis"
+task travis_all: ["style", "spec", "integration:cloud"]
-task default: ['style', 'spec', 'integration:vagrant']
+task default: ["style", "spec", "integration:vagrant"]
diff --git a/bin/ffi-yajl-bench b/bin/ffi-yajl-bench
index ceff62b..fadbcbc 100755
--- a/bin/ffi-yajl-bench
+++ b/bin/ffi-yajl-bench
@@ -1,32 +1,32 @@
#!/usr/bin/env ruby
-$LOAD_PATH << File.expand_path(File.join(File.dirname( File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__ ), "../lib"))
+$LOAD_PATH << File.expand_path(File.join(File.dirname(File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__), "../lib"))
-require 'optparse'
-require 'ffi_yajl/benchmark'
+require "optparse"
+require "ffi_yajl/benchmark"
opts = {}
optparse = OptionParser.new do |o|
o.banner = "Usage: ffi-yajl-bench"
opts[:profile] = false
- o.on( '-p', '--profile', 'Run perftools.rb profiling' ) do
+ o.on("-p", "--profile", "Run perftools.rb profiling") do
opts[:profile] = true
end
- o.on( '-F', '--ffi', 'Force using FFI' ) do
+ o.on("-F", "--ffi", "Force using FFI") do
opts[:ffi] = true
end
- o.on( '-E', '--ext', 'Force using C ext' ) do
+ o.on("-E", "--ext", "Force using C ext") do
opts[:ext] = true
end
end
optparse.parse!
-ENV['FORCE_FFI_YAJL'] = 'ffi' if opts[:ffi]
-ENV['FORCE_FFI_YAJL'] = 'ext' if opts[:ext]
+ENV["FORCE_FFI_YAJL"] = "ffi" if opts[:ffi]
+ENV["FORCE_FFI_YAJL"] = "ext" if opts[:ext]
if opts[:profile]
FFI_Yajl::Benchmark::ParseProfileRubyProf.new.run
diff --git a/ext/ffi_yajl/ext/dlopen/extconf.rb b/ext/ffi_yajl/ext/dlopen/extconf.rb
index f35d0cb..803d326 100644
--- a/ext/ffi_yajl/ext/dlopen/extconf.rb
+++ b/ext/ffi_yajl/ext/dlopen/extconf.rb
@@ -1,8 +1,8 @@
# rubocop:disable Style/GlobalVars
-require 'mkmf'
-require 'rubygems'
+require "mkmf"
+require "rubygems"
-RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
+RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
puts $CFLAGS
puts $LDFLAGS
@@ -11,6 +11,6 @@ have_header("dlfcn.h")
have_library("dl", "dlopen")
-dir_config 'dlopen'
+dir_config "dlopen"
-create_makefile 'ffi_yajl/ext/dlopen'
+create_makefile "ffi_yajl/ext/dlopen"
diff --git a/ext/ffi_yajl/ext/encoder/extconf.rb b/ext/ffi_yajl/ext/encoder/extconf.rb
index e46080a..e13c0a1 100644
--- a/ext/ffi_yajl/ext/encoder/extconf.rb
+++ b/ext/ffi_yajl/ext/encoder/extconf.rb
@@ -1,9 +1,9 @@
# rubocop:disable Style/GlobalVars
-require 'mkmf'
-require 'rubygems'
-require 'libyajl2'
+require "mkmf"
+require "rubygems"
+require "libyajl2"
-RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
+RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
# pick up the vendored libyajl2 out of the libyajl2 gem
$CFLAGS = " -I#{Libyajl2.include_path} #{$CFLAGS}"
@@ -16,7 +16,7 @@ puts $CFLAGS
puts $LDFLAGS
# except if you're doing an unoptimized gcc install we're going to help you out a bit
-if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc|clang/
+if RbConfig::MAKEFILE_CONFIG["CC"] =~ /gcc|clang/
$CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
# how many people realize that -Wall is a compiler-specific flag???
# apparently not many based on reading lots of shitty extconf.rb's out there
@@ -34,32 +34,32 @@ end
# NOTE: find_library has the side effect of adding -lyajl to the flags which we are deliberately
# avoiding doing with the libyajl2-gem (allowing it to be lazily loaded with dlopen)
-if !windows? && !find_header('yajl/yajl_tree.h')
+if !windows? && !find_header("yajl/yajl_tree.h")
puts "libyajl2 headers not found in libyajl2-gem, searching for system libraries..."
HEADER_DIRS = [
"/opt/local/include", # MacPorts
"/usr/local/include", # /usr/local
- RbConfig::CONFIG['includedir'], # Ruby
+ RbConfig::CONFIG["includedir"], # Ruby
"/usr/include", # (default)
]
LIB_DIRS = [
"/opt/local/lib", # MacPorts
"/usr/local/lib", # /usr/local + Homebrew
- RbConfig::CONFIG['libdir'], # Ruby
+ RbConfig::CONFIG["libdir"], # Ruby
"/usr/lib", # (default)
]
# add --with-yajl-dir, --with-yajl-include, --with-yajl-lib
- dir_config('yajl', HEADER_DIRS, LIB_DIRS)
+ dir_config("yajl", HEADER_DIRS, LIB_DIRS)
# here we use find_library in order to deliberately link with -lyajl as a useful side-effect
- unless find_header('yajl/yajl_tree.h') && find_library('yajl', 'yajl_complete_parse')
+ unless find_header("yajl/yajl_tree.h") && find_library("yajl", "yajl_complete_parse")
abort "libyajl2 is missing. please install libyajl2"
end
end
-dir_config 'encoder'
+dir_config "encoder"
-create_makefile 'ffi_yajl/ext/encoder'
+create_makefile "ffi_yajl/ext/encoder"
diff --git a/ext/ffi_yajl/ext/parser/extconf.rb b/ext/ffi_yajl/ext/parser/extconf.rb
index 6f8526e..86ee50f 100644
--- a/ext/ffi_yajl/ext/parser/extconf.rb
+++ b/ext/ffi_yajl/ext/parser/extconf.rb
@@ -1,9 +1,9 @@
# rubocop:disable Style/GlobalVars
-require 'mkmf'
-require 'rubygems'
-require 'libyajl2'
+require "mkmf"
+require "rubygems"
+require "libyajl2"
-RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
+RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
# pick up the vendored libyajl2 out of the libyajl2 gem
$CFLAGS = "-I#{Libyajl2.include_path} #{$CFLAGS}"
@@ -16,7 +16,7 @@ puts $CFLAGS
puts $LDFLAGS
# except if you're doing an unoptimized gcc install we're going to help you out a bit
-if RbConfig::MAKEFILE_CONFIG['CC'] =~ /gcc|clang/
+if RbConfig::MAKEFILE_CONFIG["CC"] =~ /gcc|clang/
$CFLAGS << " -O3" unless $CFLAGS[/-O\d/]
# how many people realize that -Wall is a compiler-specific flag???
# apparently not many based on reading lots of shitty extconf.rb's out there
@@ -34,32 +34,32 @@ end
# NOTE: find_library has the side effect of adding -lyajl to the flags which we are deliberately
# avoiding doing with the libyajl2-gem (allowing it to be lazily loaded with dlopen)
-if !windows? && !find_header('yajl/yajl_tree.h')
+if !windows? && !find_header("yajl/yajl_tree.h")
puts "libyajl2 headers not found in libyajl2-gem, searching for system libraries..."
HEADER_DIRS = [
"/opt/local/include", # MacPorts
"/usr/local/include", # /usr/local
- RbConfig::CONFIG['includedir'], # Ruby
+ RbConfig::CONFIG["includedir"], # Ruby
"/usr/include", # (default)
]
LIB_DIRS = [
"/opt/local/lib", # MacPorts
"/usr/local/lib", # /usr/local + Homebrew
- RbConfig::CONFIG['libdir'], # Ruby
+ RbConfig::CONFIG["libdir"], # Ruby
"/usr/lib", # (default)
]
# add --with-yajl-dir, --with-yajl-include, --with-yajl-lib
- dir_config('yajl', HEADER_DIRS, LIB_DIRS)
+ dir_config("yajl", HEADER_DIRS, LIB_DIRS)
# here we use find_library in order to deliberately link with -lyajl as a useful side-effect
- unless find_header('yajl/yajl_tree.h') && find_library('yajl', 'yajl_complete_parse')
+ unless find_header("yajl/yajl_tree.h") && find_library("yajl", "yajl_complete_parse")
abort "libyajl2 is missing. please install libyajl2"
end
end
-dir_config 'parser'
+dir_config "parser"
-create_makefile 'ffi_yajl/ext/parser'
+create_makefile "ffi_yajl/ext/parser"
diff --git a/ffi-yajl.gemspec b/ffi-yajl.gemspec
index 83af1f6..399fea0 100644
--- a/ffi-yajl.gemspec
+++ b/ffi-yajl.gemspec
@@ -1,7 +1,7 @@
gemspec = eval(IO.read(File.expand_path(File.join(File.dirname(__FILE__), "ffi-yajl.gemspec.shared"))))
gemspec.platform = Gem::Platform::RUBY
-gemspec.extensions = %w{ext/ffi_yajl/ext/encoder/extconf.rb ext/ffi_yajl/ext/parser/extconf.rb ext/ffi_yajl/ext/dlopen/extconf.rb}
+gemspec.extensions = %w[ext/ffi_yajl/ext/encoder/extconf.rb ext/ffi_yajl/ext/parser/extconf.rb ext/ffi_yajl/ext/dlopen/extconf.rb]
gemspec.add_development_dependency "ffi", "~> 1.5"
diff --git a/lib/ffi_yajl.rb b/lib/ffi_yajl.rb
index 49cf97f..1111775 100644
--- a/lib/ffi_yajl.rb
+++ b/lib/ffi_yajl.rb
@@ -34,17 +34,17 @@
# dropped, so don't bother asking for that.
# - Then we try the c-ext and rescue into ffi that fails
#
-if ENV['FORCE_FFI_YAJL'] == "ext"
- require 'ffi_yajl/ext'
-elsif ENV['FORCE_FFI_YAJL'] == "ffi"
- require 'ffi_yajl/ffi'
+if ENV["FORCE_FFI_YAJL"] == "ext"
+ require "ffi_yajl/ext"
+elsif ENV["FORCE_FFI_YAJL"] == "ffi"
+ require "ffi_yajl/ffi"
elsif RUBY_PLATFORM == "java"
- require 'ffi_yajl/ffi'
+ require "ffi_yajl/ffi"
else
begin
- require 'ffi_yajl/ext'
+ require "ffi_yajl/ext"
rescue LoadError
warn "failed to load the ffi-yajl c-extension, falling back to ffi interface"
- require 'ffi_yajl/ffi'
+ require "ffi_yajl/ffi"
end
end
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..f7ab8b1 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
@@ -49,7 +49,7 @@ module FFI_Yajl
times.times { Yajl::Parser.parse(json_str) }
end
io_parser = Yajl::Parser.new
- io_parser.on_parse_complete = ->(obj) {} if times > 1
+ io_parser.on_parse_complete = ->(_obj) {} if times > 1
x.report do
puts "Yajl::Parser#parse (from an IO)"
times.times do
@@ -58,7 +58,7 @@ module FFI_Yajl
end
end
string_parser = Yajl::Parser.new
- string_parser.on_parse_complete = ->(obj) {} if times > 1
+ string_parser.on_parse_complete = ->(_obj) {} if times > 1
x.report do
puts "Yajl::Parser#parse (from a String)"
times.times do
diff --git a/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb b/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
index cd07d46..194c18b 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 = {}
@@ -23,7 +23,7 @@ Benchmark.bmbm do |x|
x.report do
puts "Yajl::Parser#parse"
yajl = Yajl::Parser.new
- yajl.on_parse_complete = ->(obj) {} if times > 1
+ yajl.on_parse_complete = ->(_obj) {} if times > 1
times.times do
json.rewind
hash = yajl.parse(json)
diff --git a/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb b/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb
index 6e479ce..d73d0bd 100644
--- a/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb
+++ b/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb
@@ -1,24 +1,24 @@
-$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"
Benchmark.bmbm do |x|
parser = Yajl::Parser.new
- parser.on_parse_complete = ->(obj) {} if times > 1
+ parser.on_parse_complete = ->(_obj) {} if times > 1
x.report do
puts "Yajl::Parser#parse"
times.times do
@@ -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..d689a3d 100644
--- a/lib/ffi_yajl/benchmark/parse_stream.rb
+++ b/lib/ffi_yajl/benchmark/parse_stream.rb
@@ -1,26 +1,26 @@
-$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"
Benchmark.bmbm do |x|
parser = Yajl::Parser.new
- parser.on_parse_complete = ->(obj) {}
+ parser.on_parse_complete = ->(_obj) {}
x.report do
puts "Yajl::Parser#parse"
times.times do
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..fc6f99f 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
@@ -42,23 +42,23 @@ module FFI_Yajl
class YajlCallbacks < ::FFI::Struct
layout :yajl_null, :pointer,
- :yajl_boolean, :pointer,
- :yajl_integer, :pointer,
- :yajl_double, :pointer,
- :yajl_number, :pointer,
- :yajl_string, :pointer,
- :yajl_start_map, :pointer,
- :yajl_map_key, :pointer,
- :yajl_end_map, :pointer,
- :yajl_start_array, :pointer,
- :yajl_end_array, :pointer
+ :yajl_boolean, :pointer,
+ :yajl_integer, :pointer,
+ :yajl_double, :pointer,
+ :yajl_number, :pointer,
+ :yajl_string, :pointer,
+ :yajl_start_map, :pointer,
+ :yajl_map_key, :pointer,
+ :yajl_end_map, :pointer,
+ :yajl_start_array, :pointer,
+ :yajl_end_array, :pointer
end
enum :yajl_status, [
:yajl_status_ok,
:yajl_status_client_canceled,
:yajl_status_insufficient_data,
- :yajl_status_error,
+ :yajl_status_error
]
# FFI::Enums are slow, should remove the rest
@@ -95,7 +95,7 @@ module FFI_Yajl
typedef :string, :ustring
# const char *yajl_status_to_string (yajl_status code)
- attach_function :yajl_status_to_string, [ :yajl_status ], :string
+ attach_function :yajl_status_to_string, [:yajl_status], :string
# yajl_handle yajl_alloc(const yajl_callbacks * callbacks, yajl_alloc_funcs * afs, void * ctx)
attach_function :yajl_alloc, [:pointer, :pointer, :pointer], :yajl_handle
# void yajl_free (yajl_handle handle)
@@ -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..a46cb96 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
@@ -42,7 +42,7 @@ module FFI_Yajl
# setup our own state
state = {
json_opts: opts,
- processing_key: false,
+ processing_key: false
}
# do the encoding
@@ -51,7 +51,7 @@ module FFI_Yajl
# get back our encoded JSON
string_ptr = ::FFI::MemoryPointer.new(:string)
length_ptr = ::FFI::MemoryPointer.new(:int)
- if ( status = FFI_Yajl.yajl_gen_get_buf(yajl_gen, string_ptr, length_ptr) ) != 0
+ if (status = FFI_Yajl.yajl_gen_get_buf(yajl_gen, string_ptr, length_ptr)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status)
end
string = string_ptr.get_pointer(0).read_string
@@ -68,12 +68,12 @@ class Hash
def ffi_yajl(yajl_gen, state)
if state[:processing_key]
str = to_s
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
else
- if ( status = FFI_Yajl.yajl_gen_map_open(yajl_gen) ) != 0
- FFI_Yajl::Encoder.raise_error_for_status(status, '{')
+ if (status = FFI_Yajl.yajl_gen_map_open(yajl_gen)) != 0
+ FFI_Yajl::Encoder.raise_error_for_status(status, "{")
end
each do |key, value|
# Perf Fix: mutate state hash rather than creating new copy
@@ -82,8 +82,8 @@ class Hash
state[:processing_key] = false
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, '}')
+ if (status = FFI_Yajl.yajl_gen_map_close(yajl_gen)) != 0
+ FFI_Yajl::Encoder.raise_error_for_status(status, "}")
end
end
end
@@ -93,18 +93,18 @@ class Array
def ffi_yajl(yajl_gen, state)
if state[:processing_key]
str = to_s
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
else
- if ( status = FFI_Yajl.yajl_gen_array_open(yajl_gen) ) != 0
- FFI_Yajl::Encoder.raise_error_for_status(status, '[')
+ if (status = FFI_Yajl.yajl_gen_array_open(yajl_gen)) != 0
+ 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, ']')
+ if (status = FFI_Yajl.yajl_gen_array_close(yajl_gen)) != 0
+ FFI_Yajl::Encoder.raise_error_for_status(status, "]")
end
end
end
@@ -114,11 +114,11 @@ class NilClass
def ffi_yajl(yajl_gen, state)
str = to_s
if state[:processing_key]
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
else
- if ( status = FFI_Yajl.yajl_gen_null(yajl_gen) ) != 0
+ if (status = FFI_Yajl.yajl_gen_null(yajl_gen)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
end
@@ -129,11 +129,11 @@ class TrueClass
def ffi_yajl(yajl_gen, state)
str = to_s
if state[:processing_key]
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
else
- if ( status = FFI_Yajl.yajl_gen_bool(yajl_gen, 1) ) != 0
+ if (status = FFI_Yajl.yajl_gen_bool(yajl_gen, 1)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
end
@@ -144,11 +144,11 @@ class FalseClass
def ffi_yajl(yajl_gen, state)
str = to_s
if state[:processing_key]
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
else
- if ( status = FFI_Yajl.yajl_gen_bool(yajl_gen, 0) ) != 0
+ if (status = FFI_Yajl.yajl_gen_bool(yajl_gen, 0)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
end
@@ -162,11 +162,11 @@ class Fixnum
raise ::FFI_Yajl::EncodeError, "'#{str}' is an invalid number"
end
if state[:processing_key]
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
else
- if ( status = FFI_Yajl.yajl_gen_integer(yajl_gen, self) ) != 0
+ if (status = FFI_Yajl.yajl_gen_integer(yajl_gen, self)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
end
@@ -180,11 +180,11 @@ class Bignum
raise ::FFI_Yajl::EncodeError, "'#{str}' is an invalid number"
end
if state[:processing_key]
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
else
- if ( status = FFI_Yajl.yajl_gen_number(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_number(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
end
@@ -198,11 +198,11 @@ class Float
raise ::FFI_Yajl::EncodeError, "'#{str}' is an invalid number"
end
if state[:processing_key]
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
else
- if ( status = FFI_Yajl.yajl_gen_number(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_number(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
end
@@ -210,53 +210,53 @@ class Float
end
class Symbol
- def ffi_yajl(yajl_gen, state)
+ def ffi_yajl(yajl_gen, _state)
str = to_s
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
end
end
class String
- def ffi_yajl(yajl_gen, state)
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, self, bytesize) ) != 0
+ def ffi_yajl(yajl_gen, _state)
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, self, bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, self)
end
end
end
class StringIO
- def ffi_yajl(yajl_gen, state)
+ def ffi_yajl(yajl_gen, _state)
str = read
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
end
end
class Date
- def ffi_yajl(yajl_gen, state)
+ def ffi_yajl(yajl_gen, _state)
str = to_s
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
end
end
class Time
- def ffi_yajl(yajl_gen, state)
+ def ffi_yajl(yajl_gen, _state)
str = strftime "%Y-%m-%d %H:%M:%S %z"
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
end
end
class DateTime
- def ffi_yajl(yajl_gen, state)
+ def ffi_yajl(yajl_gen, _state)
str = to_s
- if ( status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize) ) != 0
+ if (status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)) != 0
FFI_Yajl::Encoder.raise_error_for_status(status, str)
end
end
@@ -273,6 +273,6 @@ class Object
str = to_s
status = FFI_Yajl.yajl_gen_string(yajl_gen, str, str.bytesize)
end
- FFI_Yajl::Encoder.raise_error_for_status(status, str) if ( status ) != 0
+ FFI_Yajl::Encoder.raise_error_for_status(status, str) if (status) != 0
end
end
diff --git a/lib/ffi_yajl/ffi/parser.rb b/lib/ffi_yajl/ffi/parser.rb
index 67df934..4f39179 100644
--- a/lib/ffi_yajl/ffi/parser.rb
+++ b/lib/ffi_yajl/ffi/parser.rb
@@ -39,7 +39,7 @@ module FFI_Yajl
end
def stack_pop
- set_value( stack.pop ) if stack.length > 1
+ set_value(stack.pop) if stack.length > 1
end
def key_push
@@ -51,58 +51,58 @@ module FFI_Yajl
end
def setup_callbacks
- @null_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
+ @null_callback = ::FFI::Function.new(:int, [:pointer]) do |_ctx|
set_value(nil)
1
end
- @boolean_callback = ::FFI::Function.new(:int, [:pointer, :int]) do |ctx, boolval|
+ @boolean_callback = ::FFI::Function.new(:int, [:pointer, :int]) do |_ctx, boolval|
set_value(boolval == 1 ? true : false)
1
end
- @integer_callback = ::FFI::Function.new(:int, [:pointer, :long_long]) do |ctx, intval|
+ @integer_callback = ::FFI::Function.new(:int, [:pointer, :long_long]) do |_ctx, intval|
set_value(intval)
1
end
- @number_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t ]) do |ctx, stringval, stringlen|
+ @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
+ v = (s =~ /[\.eE]/) ? s.to_f : s.to_i
set_value(v)
1
end
- @double_callback = ::FFI::Function.new(:int, [:pointer, :double]) do |ctx, doubleval|
+ @double_callback = ::FFI::Function.new(:int, [:pointer, :double]) do |_ctx, doubleval|
set_value(doubleval)
1
end
- @string_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t]) do |ctx, stringval, stringlen|
+ @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
- @start_map_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
+ @start_map_callback = ::FFI::Function.new(:int, [:pointer]) do |_ctx|
key_push # for key => { } case, save the key
stack.push({})
1
end
- @map_key_callback = ::FFI::Function.new(:int, [:pointer, :string, :size_t]) do |ctx, key, keylen|
+ @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
- @end_map_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
+ @end_map_callback = ::FFI::Function.new(:int, [:pointer]) do |_ctx|
key_pop
stack_pop
1
end
- @start_array_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
+ @start_array_callback = ::FFI::Function.new(:int, [:pointer]) do |_ctx|
key_push # for key => [ ] case, save the key
stack.push([])
1
end
- @end_array_callback = ::FFI::Function.new(:int, [:pointer]) do |ctx|
+ @end_array_callback = ::FFI::Function.new(:int, [:pointer]) do |_ctx|
key_pop
stack_pop
1
@@ -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..83d9e0e 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
@@ -47,13 +47,13 @@ module FFI_Yajl
def library_names
case host_os
when /mingw|mswin/
- [ "libyajl.so", "yajl.dll" ]
+ ["libyajl.so", "yajl.dll"]
when /cygwin/
- [ "libyajl.so", "cygyajl.dll" ]
+ ["libyajl.so", "cygyajl.dll"]
when /darwin/
- [ "libyajl.bundle", "libyajl.dylib" ]
+ ["libyajl.bundle", "libyajl.dylib"]
else
- [ "libyajl.so" ]
+ ["libyajl.so"]
end
end
@@ -78,7 +78,7 @@ module FFI_Yajl
# @api private
def dlopen_yajl_library
found = false
- ( expanded_library_names + library_names ).each do |libname|
+ (expanded_library_names + library_names).each do |libname|
begin
dlopen(libname)
found = true
@@ -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/spec/ffi_yajl/encoder_spec.rb b/spec/ffi_yajl/encoder_spec.rb
index 91009f4..3e7f410 100644
--- a/spec/ffi_yajl/encoder_spec.rb
+++ b/spec/ffi_yajl/encoder_spec.rb
@@ -21,8 +21,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 'spec_helper'
-require 'date'
+require "spec_helper"
+require "date"
describe "FFI_Yajl::Encoder" do
let(:options) { {} }
@@ -30,7 +30,7 @@ describe "FFI_Yajl::Encoder" do
let(:encoder) { FFI_Yajl::Encoder.new(options) }
it "encodes hashes in keys as strings", ruby_gte_193: true do
- ruby = { { 'a' => 'b' } => 2 }
+ ruby = { { "a" => "b" } => 2 }
expect(encoder.encode(ruby)).to eq('{"{\"a\"=>\"b\"}":2}')
end
@@ -77,7 +77,7 @@ describe "FFI_Yajl::Encoder" do
it "encodes an object in a key which has a #to_json method as strings" do
class Thing
- def to_json(*a)
+ def to_json(*_a)
"{}"
end
end
@@ -126,40 +126,40 @@ describe "FFI_Yajl::Encoder" do
end
it "can encode Date objects" do
- ruby = Date.parse('2001-02-03')
- expect(encoder.encode(ruby)).to eq( '"2001-02-03"' )
+ ruby = Date.parse("2001-02-03")
+ expect(encoder.encode(ruby)).to eq('"2001-02-03"')
end
it "can encode StringIOs" do
- ruby = { "foo" => StringIO.new('THING') }
+ ruby = { "foo" => StringIO.new("THING") }
expect(encoder.encode(ruby)).to eq("{\"foo\":\"THING\"}")
end
context "when encoding Time objects in UTC timezone" do
before do
- @saved_tz = ENV['TZ']
- ENV['TZ'] = 'UTC'
+ @saved_tz = ENV["TZ"]
+ ENV["TZ"] = "UTC"
end
after do
- ENV['TZ'] = @saved_tz
+ ENV["TZ"] = @saved_tz
end
it "encodes them correctly" do
ruby = Time.local(2001, 02, 02, 21, 05, 06)
- expect(encoder.encode(ruby)).to eq( '"2001-02-02 21:05:06 +0000"' )
+ expect(encoder.encode(ruby)).to eq('"2001-02-02 21:05:06 +0000"')
end
end
it "can encode DateTime objects" do
- ruby = DateTime.parse('2001-02-03T04:05:06.1+07:00')
- expect(encoder.encode(ruby)).to eq( '"2001-02-03T04:05:06+07:00"' )
+ ruby = DateTime.parse("2001-02-03T04:05:06.1+07:00")
+ expect(encoder.encode(ruby)).to eq('"2001-02-03T04:05:06+07:00"')
end
describe "testing .to_json for Objects" do
class NoToJson; end
class HasToJson
- def to_json(*args)
+ def to_json(*_args)
"{}"
end
end
@@ -179,10 +179,10 @@ describe "FFI_Yajl::Encoder" do
"etc" => {
"passwd" => {
"root" => { "dir" => "/root", "gid" => 0, "uid" => 0, "shell" => "/bin/sh", "gecos" => "Elan Ruusam\xc3\xa4e" },
- "glen" => { "dir" => "/home/glen", "gid" => 500, "uid" => 500, "shell" => "/bin/bash", "gecos" => "Elan Ruusam\xE4e" },
- },
- },
- },
+ "glen" => { "dir" => "/home/glen", "gid" => 500, "uid" => 500, "shell" => "/bin/bash", "gecos" => "Elan Ruusam\xE4e" }
+ }
+ }
+ }
}
it "raises an error on invalid json" do
@@ -197,11 +197,11 @@ describe "FFI_Yajl::Encoder" do
end
it "returns utf8" do
- expect( encoder.encode(ruby).encoding ).to eq(Encoding::UTF_8)
+ expect(encoder.encode(ruby).encoding).to eq(Encoding::UTF_8)
end
it "returns valid utf8" do
- expect( encoder.encode(ruby).valid_encoding? ).to be true
+ expect(encoder.encode(ruby).valid_encoding?).to be true
end
end
end
diff --git a/spec/ffi_yajl/map_library_name_spec.rb b/spec/ffi_yajl/map_library_name_spec.rb
index 0b5e9cb..b9e9bfe 100644
--- a/spec/ffi_yajl/map_library_name_spec.rb
+++ b/spec/ffi_yajl/map_library_name_spec.rb
@@ -20,24 +20,24 @@
# 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 'spec_helper'
+require "spec_helper"
class Test
extend FFI_Yajl::MapLibraryName
end
host_os_library_name_mapping = {
- "mingw" => [ "libyajl.so", "yajl.dll" ],
- "mswin" => [ "libyajl.so", "yajl.dll" ],
- "cygwin" => [ "libyajl.so", "cygyajl.dll" ],
- "darwin" => [ "libyajl.bundle", "libyajl.dylib" ],
- "solaris2" => [ "libyajl.so" ],
- "linux" => [ "libyajl.so" ],
- "aix" => [ "libyajl.so" ],
- "hpux" => [ "libyajl.so" ],
- "netbsd" => [ "libyajl.so" ],
- "openbsd" => [ "libyajl.so" ],
- "freebsd" => [ "libyajl.so" ],
+ "mingw" => ["libyajl.so", "yajl.dll"],
+ "mswin" => ["libyajl.so", "yajl.dll"],
+ "cygwin" => ["libyajl.so", "cygyajl.dll"],
+ "darwin" => ["libyajl.bundle", "libyajl.dylib"],
+ "solaris2" => ["libyajl.so"],
+ "linux" => ["libyajl.so"],
+ "aix" => ["libyajl.so"],
+ "hpux" => ["libyajl.so"],
+ "netbsd" => ["libyajl.so"],
+ "openbsd" => ["libyajl.so"],
+ "freebsd" => ["libyajl.so"]
}
describe "FFI_Yajl::MapLibraryName" do
@@ -107,7 +107,7 @@ describe "FFI_Yajl::MapLibraryName" do
allow(File).to receive(:file?).with(path).and_return(true)
allow(Test).to receive(:ffi_lib).with(path).and_raise(LoadError)
end
- allow(Test).to receive(:ffi_lib).with('yajl').and_return(nil)
+ allow(Test).to receive(:ffi_lib).with("yajl").and_return(nil)
Test.send(:ffi_open_yajl_library)
end
end
diff --git a/spec/ffi_yajl/parser_spec.rb b/spec/ffi_yajl/parser_spec.rb
index 750567f..f40307e 100644
--- a/spec/ffi_yajl/parser_spec.rb
+++ b/spec/ffi_yajl/parser_spec.rb
@@ -21,7 +21,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 'spec_helper'
+require "spec_helper"
describe "FFI_Yajl::Parser" do
shared_examples_for "correct json parsing" do
@@ -44,42 +44,42 @@ describe "FFI_Yajl::Parser" do
context "when parsing bare int" do
let(:json) { "1" }
it "should parse to the int value" do
- expect( parser ).to eq(1)
+ expect(parser).to eq(1)
end
end
context "when parsing bare string" do
let(:json) { '"a"' }
it "should parse to the string value" do
- expect( parser ).to eq("a")
+ expect(parser).to eq("a")
end
end
context "when parsing bare true" do
let(:json) { "true" }
it "should parse to the true value" do
- expect( parser ).to eq(true)
+ expect(parser).to eq(true)
end
end
context "when parsing bare false" do
let(:json) { "false" }
it "should parse to the false value" do
- expect( parser ).to eq(false)
+ expect(parser).to eq(false)
end
end
context "when parsing bare null" do
let(:json) { "null" }
it "should parse to the nil value" do
- expect( parser ).to eq(nil)
+ expect(parser).to eq(nil)
end
end
context "when parsing bare float" do
let(:json) { "1.1" }
it "should parse to the a float" do
- expect( parser ).to eq(1.1)
+ expect(parser).to eq(1.1)
end
end
@@ -271,14 +271,14 @@ describe "FFI_Yajl::Parser" do
Encoding.default_internal = @saved_encoding
end
it "encodes keys to UTF-8" do
- expect(parser.keys.first.encoding).to eql(Encoding.find('utf-8'))
+ expect(parser.keys.first.encoding).to eql(Encoding.find("utf-8"))
end
it "encodes values to UTF-8" do
- expect(parser.values.first.encoding).to eql(Encoding.find('utf-8'))
+ expect(parser.values.first.encoding).to eql(Encoding.find("utf-8"))
end
end
- %w{utf-8 us-ascii}.each do |encoding|
+ %w[utf-8 us-ascii].each do |encoding|
context "when Encoding.default_internal is #{encoding}" do
before do
@saved_encoding = Encoding.default_internal
@@ -349,7 +349,7 @@ describe "FFI_Yajl::Parser" do
# NOTE: we are choosing to be compatible with yajl-ruby here vs. JSON
# gem and libyajl C behavior (which is to throw an exception in this case)
context "when the JSON is empty string" do
- let(:json) { '' }
+ let(:json) { "" }
it "returns nil" do
expect(parser).to be_nil
@@ -402,7 +402,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { '{"München": "Bayern"}' }
it "correctly parses" do
- expect(parser).to eql( "München" => "Bayern" )
+ expect(parser).to eql("München" => "Bayern")
end
end
@@ -411,7 +411,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { '{"foo": 3.14159265358979}' }
it "correctly parses" do
- expect(parser).to eql( "foo" => 3.14159265358979 )
+ expect(parser).to eql("foo" => 3.14159265358979)
end
end
@@ -419,7 +419,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { '{"foo":-2.00231930436153}' }
it "correctly parses" do
- expect(parser).to eql( "foo" => -2.00231930436153 )
+ expect(parser).to eql("foo" => -2.00231930436153)
end
end
@@ -427,7 +427,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { '{"foo": 1.602176565E-19}' }
it "correctly parses" do
- expect(parser).to eql( "foo" => 1.602176565e-19 )
+ expect(parser).to eql("foo" => 1.602176565e-19)
end
end
@@ -435,7 +435,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { '{"foo": 6.6260689633e-34 }' }
it "correctly parses" do
- expect(parser).to eql( "foo" => 6.6260689633e-34 )
+ expect(parser).to eql("foo" => 6.6260689633e-34)
end
end
@@ -443,7 +443,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { '{"foo": 6.0221413E+23}' }
it "correctly parses" do
- expect(parser).to eql( "foo" => 6.0221413e+23 )
+ expect(parser).to eql("foo" => 6.0221413e+23)
end
end
@@ -451,7 +451,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { '{"foo": 8.9875517873681764e+9 }' }
it "correctly parses" do
- expect(parser).to eql( "foo" => 8.9875517873681764e+9 )
+ expect(parser).to eql("foo" => 8.9875517873681764e+9)
end
end
@@ -459,7 +459,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { '{"foo": 2.99792458E8 }' }
it "correctly parses" do
- expect(parser).to eql( "foo" => 2.99792458e+8 )
+ expect(parser).to eql("foo" => 2.99792458e+8)
end
end
@@ -467,7 +467,7 @@ describe "FFI_Yajl::Parser" do
let(:json) { '{"foo": 1.0973731568539e7 }' }
it "correctly parses" do
- expect(parser).to eql( "foo" => 1.0973731568539e+7 )
+ expect(parser).to eql("foo" => 1.0973731568539e+7)
end
end
end
@@ -475,7 +475,7 @@ describe "FFI_Yajl::Parser" do
# NOTE: parsing floats with 8 million digits on windows has some kind of huge
# perf issues likely in ruby and/or the underlying windows libs
context "when parsing big floats", ruby_gte_193: true, unix_only: true do
- let(:json) { '[0.' + '1' * 2**23 + ']' }
+ let(:json) { "[0." + "1" * 2**23 + "]" }
it "parses" do
expect { parser }.not_to raise_error
@@ -483,7 +483,7 @@ describe "FFI_Yajl::Parser" do
end
context "when parsing long hash keys with symbolize_keys option", ruby_gte_193: true do
- let(:json) { '{"' + 'a' * 2**23 + '": 0}' }
+ let(:json) { '{"' + "a" * 2**23 + '": 0}' }
let(:options) { { symbolize_keys: true } }
it "parses" do
@@ -494,7 +494,7 @@ describe "FFI_Yajl::Parser" do
context "should ignore repeated keys by default" do
let(:json) { '{"foo":"bar","foo":"baz"}' }
it "should replace the first hash key with the second" do
- expect(parser).to eql( "foo" => "baz" )
+ expect(parser).to eql("foo" => "baz")
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 9ec853d..1858417 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -20,24 +20,24 @@
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-$LOAD_PATH << File.expand_path(File.join(File.dirname( __FILE__ ), "../lib"))
+$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), "../lib"))
# load yajl-ruby into the same process (tests that both c-libs can be
# linked in the same process). this should work, see:
# http://stackoverflow.com/questions/3232822/linking-with-multiple-versions-of-a-library
begin
- require 'yajl'
+ require "yajl"
rescue LoadError
- puts 'WARN: yajl cannot be loaded, expected if this is jruby'
+ puts "WARN: yajl cannot be loaded, expected if this is jruby"
end
-require 'ffi_yajl'
+require "ffi_yajl"
RSpec.configure do |conf|
conf.filter_run_excluding unix_only: true unless RUBY_PLATFORM !~ /mswin|mingw|windows/
conf.filter_run_excluding ruby_gte_193: true unless RUBY_VERSION.to_f >= 2.0 || RUBY_VERSION =~ /^1\.9\.3/
- conf.order = 'random'
+ conf.order = "random"
conf.expect_with :rspec do |rspec|
rspec.syntax = :expect