summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2014-08-07 18:26:46 -0500
committerLamont Granquist <lamont@scriptkiddie.org>2014-08-07 18:26:46 -0500
commitee34c3018a520bf1271fdbd85ada659900b17ba2 (patch)
tree79dee940f52453a303daef036bcb9337dd8c21e7
parenta21383e49ca307e140491524845fffac7a3df2e1 (diff)
downloadffi-yajl-ee34c3018a520bf1271fdbd85ada659900b17ba2.tar.gz
Revert "fix for chef pretty printing issues"
This reverts commit 5d260103d3f11897e7873fb3fa796966896ff946.
-rw-r--r--ext/ffi_yajl/ext/encoder/encoder.c6
-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
-rw-r--r--spec/ffi_yajl/json_gem_spec.rb11
5 files changed, 12 insertions, 27 deletions
diff --git a/ext/ffi_yajl/ext/encoder/encoder.c b/ext/ffi_yajl/ext/encoder/encoder.c
index 26ae368..5576881 100644
--- a/ext/ffi_yajl/ext/encoder/encoder.c
+++ b/ext/ffi_yajl/ext/encoder/encoder.c
@@ -9,7 +9,7 @@ static VALUE cYajl_Gen;
#define CHECK_STATUS(call) \
if ((status = (call)) != yajl_gen_status_ok) { rb_funcall(mEncoder2, rb_intern("raise_error_for_status"), 1, INT2FIX(status)); }
-static VALUE mEncoder_do_yajl_encode(VALUE self, VALUE obj, VALUE yajl_gen_opts, VALUE json_opts) {
+static VALUE mEncoder_do_yajl_encode(VALUE self, VALUE obj, VALUE yajl_gen_opts) {
ID sym_ffi_yajl = rb_intern("ffi_yajl");
VALUE sym_yajl_gen_beautify = ID2SYM(rb_intern("yajl_gen_beautify"));
VALUE sym_yajl_gen_validate_utf8 = ID2SYM(rb_intern("yajl_gen_validate_utf8"));
@@ -42,8 +42,6 @@ static VALUE mEncoder_do_yajl_encode(VALUE self, VALUE obj, VALUE yajl_gen_opts,
rb_hash_aset(state, rb_str_new2("processing_key"), Qfalse);
- rb_hash_aset(state, rb_str_new2("json_opts"), json_opts);
-
rb_yajl_gen = Data_Wrap_Struct(cYajl_Gen, NULL, NULL, yajl_gen);
rb_funcall(obj, sym_ffi_yajl, 2, rb_yajl_gen, state);
@@ -263,7 +261,7 @@ void Init_encoder() {
mExt = rb_define_module_under(mFFI_Yajl, "Ext");
mEncoder = rb_define_module_under(mExt, "Encoder");
cYajl_Gen = rb_define_class_under(mEncoder, "YajlGen", rb_cObject);
- rb_define_method(mEncoder, "do_yajl_encode", mEncoder_do_yajl_encode, 3);
+ rb_define_method(mEncoder, "do_yajl_encode", mEncoder_do_yajl_encode, 2);
rb_define_method(rb_cHash, "ffi_yajl", rb_cHash_ffi_yajl, 2);
rb_define_method(rb_cArray, "ffi_yajl", rb_cArray_ffi_yajl, 2);
diff --git a/lib/ffi_yajl/encoder.rb b/lib/ffi_yajl/encoder.rb
index bd3ff31..8b5bfcb 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, opts)
+ str = do_yajl_encode(obj, yajl_gen_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 8837e12..bbeba27 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 = {}, opts)
+ def do_yajl_encode(obj, yajl_gen_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 4773f7f..0e64d50 100644
--- a/lib/ffi_yajl/json_gem.rb
+++ b/lib/ffi_yajl/json_gem.rb
@@ -25,8 +25,6 @@ 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
@@ -57,49 +55,49 @@ end
class Array
def to_json(*opts, &block)
- FFI_Yajl::Encoder.encode(self, *opts)
+ FFI_Yajl::Encoder.encode(self)
end
end
class Hash
def to_json(*opts, &block)
- FFI_Yajl::Encoder.encode(self, *opts)
+ FFI_Yajl::Encoder.encode(self)
end
end
class Fixnum
def to_json(*opts, &block)
- FFI_Yajl::Encoder.encode(self, *opts)
+ FFI_Yajl::Encoder.encode(self)
end
end
class Float
def to_json(*opts, &block)
- FFI_Yajl::Encoder.encode(self, *opts)
+ FFI_Yajl::Encoder.encode(self)
end
end
class String
def to_json(*opts, &block)
- FFI_Yajl::Encoder.encode(self, *opts)
+ FFI_Yajl::Encoder.encode(self)
end
end
class TrueClass
def to_json(*opts, &block)
- FFI_Yajl::Encoder.encode(self, *opts)
+ FFI_Yajl::Encoder.encode(self)
end
end
class FalseClass
def to_json(*opts, &block)
- FFI_Yajl::Encoder.encode(self, *opts)
+ FFI_Yajl::Encoder.encode(self)
end
end
class NilClass
def to_json(*opts, &block)
- FFI_Yajl::Encoder.encode(self, *opts)
+ FFI_Yajl::Encoder.encode(self)
end
end
diff --git a/spec/ffi_yajl/json_gem_spec.rb b/spec/ffi_yajl/json_gem_spec.rb
index 36233eb..d342fd3 100644
--- a/spec/ffi_yajl/json_gem_spec.rb
+++ b/spec/ffi_yajl/json_gem_spec.rb
@@ -97,17 +97,6 @@ describe "JSON Gem Compat API" do
expect(JSON.pretty_generate({'foo' => 1234}, {})).to eql("{\n \"foo\": 1234\n}")
end
- class Foo
- def to_json(*a)
- {'foo' => 1234}.to_json(*a)
- end
- end
-
- it "JSON#pretty_generate should work with an Object that implements #to_json" do
- f = Foo.new
- expect(JSON.pretty_generate(f)).to eql("{\n \"foo\": 1234\n}\n")
- end
-
context "when setting symbolize_keys via JSON.default_options" do
after(:each) { JSON.default_options[:symbolize_keys] = false }