summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-08-07 14:24:20 -0500
committerLamont Granquist <lamont@scriptkiddie.org>2014-08-07 18:30:02 -0500
commit18ac44d520d40ec8981b4266b8bb040607377f1e (patch)
tree924204fc1e962216143884c2c33297a9c542e18d /lib
parent46239c54700ad1e06a6ac86eaf0fbcb141ce3eb1 (diff)
downloadffi-yajl-18ac44d520d40ec8981b4266b8bb040607377f1e.tar.gz
fix for chef pretty printing issues
Diffstat (limited to 'lib')
-rw-r--r--lib/ffi_yajl/encoder.rb2
-rw-r--r--lib/ffi_yajl/ffi/encoder.rb2
-rw-r--r--lib/ffi_yajl/json_gem.rb18
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