diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2014-08-07 14:24:20 -0500 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2014-08-07 16:38:18 -0500 |
commit | 5d260103d3f11897e7873fb3fa796966896ff946 (patch) | |
tree | 405786d255997ddf66c49e569bd7a08b9766d97d /lib | |
parent | 199bcc2304bc032559ca0b9f82978b4ebb64fe41 (diff) | |
download | ffi-yajl-5d260103d3f11897e7873fb3fa796966896ff946.tar.gz |
fix for chef pretty printing issues
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ffi_yajl/encoder.rb | 2 | ||||
-rw-r--r-- | lib/ffi_yajl/ffi/encoder.rb | 2 | ||||
-rw-r--r-- | lib/ffi_yajl/json_gem.rb | 18 |
3 files changed, 12 insertions, 10 deletions
diff --git a/lib/ffi_yajl/encoder.rb b/lib/ffi_yajl/encoder.rb index 8b5bfcb..bd3ff31 100644 --- a/lib/ffi_yajl/encoder.rb +++ b/lib/ffi_yajl/encoder.rb @@ -18,7 +18,7 @@ module FFI_Yajl end # call either the ext or ffi hook - str = do_yajl_encode(obj, yajl_gen_opts) + str = do_yajl_encode(obj, yajl_gen_opts, opts) str.force_encoding('UTF-8') if defined? Encoding str end diff --git a/lib/ffi_yajl/ffi/encoder.rb b/lib/ffi_yajl/ffi/encoder.rb index bbeba27..8837e12 100644 --- a/lib/ffi_yajl/ffi/encoder.rb +++ b/lib/ffi_yajl/ffi/encoder.rb @@ -4,7 +4,7 @@ require 'ffi_yajl/ffi' module FFI_Yajl module FFI module Encoder - def do_yajl_encode(obj, yajl_gen_opts = {}) + def do_yajl_encode(obj, yajl_gen_opts = {}, opts) yajl_gen = FFI_Yajl.yajl_gen_alloc(nil); diff --git a/lib/ffi_yajl/json_gem.rb b/lib/ffi_yajl/json_gem.rb index 0e64d50..4773f7f 100644 --- a/lib/ffi_yajl/json_gem.rb +++ b/lib/ffi_yajl/json_gem.rb @@ -25,6 +25,8 @@ module JSON options_map = {} options_map[:pretty] = true options_map[:indent] = opts[:indent] if opts.has_key?(:indent) + require 'pp' + pp options_map FFI_Yajl::Encoder.encode(obj, options_map).chomp rescue FFI_Yajl::EncodeError => e raise JSON::GeneratorError, e.message @@ -55,49 +57,49 @@ end class Array def to_json(*opts, &block) - FFI_Yajl::Encoder.encode(self) + FFI_Yajl::Encoder.encode(self, *opts) end end class Hash def to_json(*opts, &block) - FFI_Yajl::Encoder.encode(self) + FFI_Yajl::Encoder.encode(self, *opts) end end class Fixnum def to_json(*opts, &block) - FFI_Yajl::Encoder.encode(self) + FFI_Yajl::Encoder.encode(self, *opts) end end class Float def to_json(*opts, &block) - FFI_Yajl::Encoder.encode(self) + FFI_Yajl::Encoder.encode(self, *opts) end end class String def to_json(*opts, &block) - FFI_Yajl::Encoder.encode(self) + FFI_Yajl::Encoder.encode(self, *opts) end end class TrueClass def to_json(*opts, &block) - FFI_Yajl::Encoder.encode(self) + FFI_Yajl::Encoder.encode(self, *opts) end end class FalseClass def to_json(*opts, &block) - FFI_Yajl::Encoder.encode(self) + FFI_Yajl::Encoder.encode(self, *opts) end end class NilClass def to_json(*opts, &block) - FFI_Yajl::Encoder.encode(self) + FFI_Yajl::Encoder.encode(self, *opts) end end |