diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-06-21 12:26:09 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-06-21 12:26:09 -0700 |
commit | aa80a0441ef24dc9b6278a6ae1bb44a42d7d19de (patch) | |
tree | 7bc26f1ebb9eefecfd39cbf0b0a97058138ad156 | |
parent | f703608a13bf85a22eb39020a0fcb3dbc10a8a0b (diff) | |
download | ffi-yajl-aa80a0441ef24dc9b6278a6ae1bb44a42d7d19de.tar.gz |
remove duplicated code
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Gemfile | 6 | ||||
-rw-r--r-- | lib/ffi_yajl/ffi/encoder.rb | 20 |
3 files changed, 8 insertions, 19 deletions
@@ -19,6 +19,7 @@ .rvmrc .yardoc Gemfile.lock +Gemfile.local InstalledFiles _yardoc bin/json_reformat @@ -15,3 +15,9 @@ end group :development_extras do gem "chefstyle" end + +instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"] + +# If you want to load debugging tools into the bundle exec sandbox, +# add these additional dependencies into Gemfile.local +eval_gemfile(__FILE__ + ".local") if File.exist?(__FILE__ + ".local") diff --git a/lib/ffi_yajl/ffi/encoder.rb b/lib/ffi_yajl/ffi/encoder.rb index f35f3c4..62b2c96 100644 --- a/lib/ffi_yajl/ffi/encoder.rb +++ b/lib/ffi_yajl/ffi/encoder.rb @@ -1,5 +1,5 @@ # Copyright (c) 2015 Lamont Granquist -# Copyright (c) 2015 Chef Software, Inc. +# Copyright (c) 2015-2017, Chef Software Inc. # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -166,24 +166,6 @@ class Integer FFI_Yajl::Encoder.raise_error_for_status(status, str) end else - if ( status = FFI_Yajl.yajl_gen_integer(yajl_gen, self) ) != 0 - FFI_Yajl::Encoder.raise_error_for_status(status, str) - end - end - end -end - -class Integer - def ffi_yajl(yajl_gen, state) - str = to_s - if str == "NaN" || str == "Infinity" || str == "-Infinity" - 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 - FFI_Yajl::Encoder.raise_error_for_status(status, str) - end - else if ( status = FFI_Yajl.yajl_gen_number(yajl_gen, str, str.bytesize) ) != 0 FFI_Yajl::Encoder.raise_error_for_status(status, str) end |