[DRE-commits] [ruby-yajl] 01/05: Imported Upstream version 1.2.0
Cédric Boutillier
boutil at moszumanska.debian.org
Thu Dec 19 15:26:34 UTC 2013
This is an automated email from the git hooks/post-receive script.
boutil pushed a commit to annotated tag debian/1.2.0-1
in repository ruby-yajl.
commit 02363fbcf6b30f02be6adc972431920da4fc7f65
Author: Cédric Boutillier <boutil at debian.org>
Date: Thu Dec 19 15:41:13 2013 +0100
Imported Upstream version 1.2.0
---
.gitignore | 3 +-
.travis.yml | 10 +-
Gemfile | 4 +-
README.md | 9 +-
checksums.yaml.gz | Bin 0 -> 269 bytes
ext/yajl/api/yajl_common.h | 4 +-
ext/yajl/api/yajl_parse.h | 2 +-
ext/yajl/yajl_alloc.h | 1 +
ext/yajl/yajl_buf.h | 7 +
ext/yajl/yajl_encode.h | 3 +
ext/yajl/yajl_ext.c | 65 ++++++---
ext/yajl/yajl_ext.h | 18 +--
ext/yajl/yajl_lex.h | 11 ++
ext/yajl/yajl_parser.h | 2 +
lib/yajl.rb | 3 +-
lib/yajl/json_gem/encoding.rb | 19 ++-
lib/yajl/version.rb | 2 +-
metadata.yml | 164 +++++++++-------------
script/bootstrap | 5 +
spec/encoding/encoding_spec.rb | 43 +++++-
spec/json_gem_compatibility/compatibility_spec.rb | 4 +
21 files changed, 234 insertions(+), 145 deletions(-)
diff --git a/.gitignore b/.gitignore
index bc391c8..8f70952 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,4 +9,5 @@ tmp/*
pkg/*
vendor/gems
Gemfile.lock
-.rbx
\ No newline at end of file
+.rbx
+bin/
diff --git a/.travis.yml b/.travis.yml
index 23d7b94..5a693ea 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,14 @@
+language: ruby
rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- rbx
- - ree
\ No newline at end of file
+ - ree
+ - ruby-head
+ - rbx-18mode
+ - rbx-19mode
+matrix:
+ allow_failures:
+ - rvm: rbx-18mode
+ - rvm: rbx-19mode
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index f6a560f..fa75df1 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,3 +1,3 @@
-source :rubygems
+source 'https://rubygems.org'
-gemspec
\ No newline at end of file
+gemspec
diff --git a/README.md b/README.md
index 9eaed78..61f39a0 100644
--- a/README.md
+++ b/README.md
@@ -68,13 +68,13 @@ only had access to chunks of it at a time. No problem!
``` ruby
def post_init
- @parser = Yajl::Parser.new(:symbolize_keys => true)
+ @parser = Yajl::Parser.new(:symbolize_keys => true)
end
def object_parsed(obj)
- puts "Sometimes one pays most for the things one gets for nothing. - Albert Einstein"
- puts obj.inspect
- end
+ puts "Sometimes one pays most for the things one gets for nothing. - Albert Einstein"
+ puts obj.inspect
+end
def connection_completed
# once a full JSON object has been parsed from the stream
@@ -157,7 +157,6 @@ This allows you to encode JSON as a stream, writing directly to a socket
``` ruby
socket = TCPSocket.new('192.168.1.101', 9000)
hash = {:foo => 12425125, :bar => "some string", ... }
-encoder = Yajl::Encoder.new
Yajl::Encoder.encode(hash, socket)
```
diff --git a/checksums.yaml.gz b/checksums.yaml.gz
new file mode 100644
index 0000000..e3b70bc
Binary files /dev/null and b/checksums.yaml.gz differ
diff --git a/ext/yajl/api/yajl_common.h b/ext/yajl/api/yajl_common.h
index 0e75db1..dbd84e4 100644
--- a/ext/yajl/api/yajl_common.h
+++ b/ext/yajl/api/yajl_common.h
@@ -37,7 +37,7 @@
extern "C" {
#endif
-#define YAJL_MAX_DEPTH 128
+#define YAJL_MAX_DEPTH 256
/* msft dll export gunk. To build a DLL on windows, you
* must define WIN32, YAJL_SHARED, and YAJL_BUILD. To use a shared
@@ -50,7 +50,7 @@ extern "C" {
# endif
#else
# if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
-# define YAJL_API __attribute__ ((visibility("default")))
+# define YAJL_API __attribute__ ((visibility("hidden")))
# else
# define YAJL_API
# endif
diff --git a/ext/yajl/api/yajl_parse.h b/ext/yajl/api/yajl_parse.h
index 8c8b9b9..b65f54f 100644
--- a/ext/yajl/api/yajl_parse.h
+++ b/ext/yajl/api/yajl_parse.h
@@ -133,7 +133,7 @@ extern "C" {
void * ctx);
/** allow resetting of the lexer without the need to realloc a new parser */
- void yajl_reset_parser(yajl_handle hand);
+ YAJL_API void yajl_reset_parser(yajl_handle hand);
/** free a parser handle */
YAJL_API void yajl_free(yajl_handle handle);
diff --git a/ext/yajl/yajl_alloc.h b/ext/yajl/yajl_alloc.h
index 94e7de5..da73b40 100644
--- a/ext/yajl/yajl_alloc.h
+++ b/ext/yajl/yajl_alloc.h
@@ -45,6 +45,7 @@
#define YA_FREE(afs, ptr) (afs)->free((afs)->ctx, (ptr))
#define YA_REALLOC(afs, ptr, sz) (afs)->realloc((afs)->ctx, (ptr), (sz))
+YAJL_API
void yajl_set_default_alloc_funcs(yajl_alloc_funcs * yaf);
#endif
diff --git a/ext/yajl/yajl_buf.h b/ext/yajl/yajl_buf.h
index e330f33..f97355b 100644
--- a/ext/yajl/yajl_buf.h
+++ b/ext/yajl/yajl_buf.h
@@ -50,24 +50,31 @@
typedef struct yajl_buf_t * yajl_buf;
/* allocate a new buffer */
+YAJL_API
yajl_buf yajl_buf_alloc(yajl_alloc_funcs * alloc);
/* free the buffer */
+YAJL_API
void yajl_buf_free(yajl_buf buf);
/* append a number of bytes to the buffer */
+YAJL_API
void yajl_buf_append(yajl_buf buf, const void * data, unsigned int len);
/* empty the buffer */
+YAJL_API
void yajl_buf_clear(yajl_buf buf);
/* get a pointer to the beginning of the buffer */
+YAJL_API
const unsigned char * yajl_buf_data(yajl_buf buf);
/* get the length of the buffer */
+YAJL_API
unsigned int yajl_buf_len(yajl_buf buf);
/* truncate the buffer */
+YAJL_API
void yajl_buf_truncate(yajl_buf buf, unsigned int len);
#endif
diff --git a/ext/yajl/yajl_encode.h b/ext/yajl/yajl_encode.h
index 796c4e3..9f3a8d3 100644
--- a/ext/yajl/yajl_encode.h
+++ b/ext/yajl/yajl_encode.h
@@ -36,16 +36,19 @@
#include "yajl_buf.h"
#include "api/yajl_gen.h"
+YAJL_API
void yajl_string_encode2(const yajl_print_t printer,
void * ctx,
const unsigned char * str,
unsigned int length,
unsigned int htmlSafe);
+YAJL_API
void yajl_string_encode(yajl_buf buf, const unsigned char * str,
unsigned int length,
unsigned int htmlSafe);
+YAJL_API
void yajl_string_decode(yajl_buf buf, const unsigned char * str,
unsigned int length);
diff --git a/ext/yajl/yajl_ext.c b/ext/yajl/yajl_ext.c
index 172d76e..c2b1c89 100644
--- a/ext/yajl/yajl_ext.c
+++ b/ext/yajl/yajl_ext.c
@@ -54,6 +54,25 @@ static void yajl_check_and_fire_callback(void * ctx) {
}
}
+static char *yajl_raise_encode_error_for_status(yajl_gen_status status, VALUE obj) {
+ switch (status) {
+ case yajl_gen_keys_must_be_strings:
+ rb_raise(cEncodeError, "YAJL internal error: attempted use of non-string object as key");
+ case yajl_max_depth_exceeded:
+ rb_raise(cEncodeError, "Max nesting depth of %d exceeded", YAJL_MAX_DEPTH);
+ case yajl_gen_in_error_state:
+ rb_raise(cEncodeError, "YAJL internal error: a generator function (yajl_gen_XXX) was called while in an error state");
+ case yajl_gen_generation_complete:
+ rb_raise(cEncodeError, "YAJL internal error: attempted to encode to an already-complete document");
+ case yajl_gen_invalid_number:
+ rb_raise(cEncodeError, "Invalid number: cannot encode Infinity, -Infinity, or NaN");
+ case yajl_gen_no_buf:
+ rb_raise(cEncodeError, "YAJL internal error: yajl_gen_get_buf was called, but a print callback was specified, so no internal buffer is available");
+ default:
+ return NULL;
+ }
+}
+
static void yajl_set_static_value(void * ctx, VALUE val) {
yajl_parser_wrapper * wrapper;
VALUE lastEntry, hash;
@@ -96,10 +115,10 @@ static void yajl_encoder_wrapper_free(void * wrapper) {
yajl_encoder_wrapper * w = wrapper;
if (w) {
if (w->indentString) {
- free(w->indentString);
+ xfree(w->indentString);
}
yajl_gen_free(w->encoder);
- free(w);
+ xfree(w);
}
}
@@ -111,6 +130,9 @@ static void yajl_encoder_wrapper_mark(void * wrapper) {
}
}
+#define CHECK_STATUS(call) \
+ if ((status = (call)) != yajl_gen_status_ok) { break; }
+
void yajl_encode_part(void * wrapper, VALUE obj, VALUE io) {
VALUE str, outBuff, otherObj;
yajl_encoder_wrapper * w = wrapper;
@@ -123,6 +145,9 @@ void yajl_encode_part(void * wrapper, VALUE obj, VALUE io) {
if (io != Qnil || w->on_progress_callback != Qnil) {
status = yajl_gen_get_buf(w->encoder, &buffer, &len);
+ if (status != yajl_gen_status_ok) {
+ yajl_raise_encode_error_for_status(status, obj);
+ }
if (len >= WRITE_BUFSIZE) {
outBuff = rb_str_new((const char *)buffer, len);
if (io != Qnil) {
@@ -136,7 +161,7 @@ void yajl_encode_part(void * wrapper, VALUE obj, VALUE io) {
switch (TYPE(obj)) {
case T_HASH:
- status = yajl_gen_map_open(w->encoder);
+ CHECK_STATUS(yajl_gen_map_open(w->encoder));
/* TODO: itterate through keys in the hash */
keys = rb_funcall(obj, intern_keys, 0);
@@ -149,24 +174,24 @@ void yajl_encode_part(void * wrapper, VALUE obj, VALUE io) {
yajl_encode_part(w, rb_hash_aref(obj, entry), io);
}
- status = yajl_gen_map_close(w->encoder);
+ CHECK_STATUS(yajl_gen_map_close(w->encoder));
break;
case T_ARRAY:
- status = yajl_gen_array_open(w->encoder);
+ CHECK_STATUS(yajl_gen_array_open(w->encoder));
for(idx=0; idx<RARRAY_LEN(obj); idx++) {
otherObj = rb_ary_entry(obj, idx);
yajl_encode_part(w, otherObj, io);
}
- status = yajl_gen_array_close(w->encoder);
+ CHECK_STATUS(yajl_gen_array_close(w->encoder));
break;
case T_NIL:
- status = yajl_gen_null(w->encoder);
+ CHECK_STATUS(yajl_gen_null(w->encoder));
break;
case T_TRUE:
- status = yajl_gen_bool(w->encoder, 1);
+ CHECK_STATUS(yajl_gen_bool(w->encoder, 1));
break;
case T_FALSE:
- status = yajl_gen_bool(w->encoder, 0);
+ CHECK_STATUS(yajl_gen_bool(w->encoder, 0));
break;
case T_FIXNUM:
case T_FLOAT:
@@ -177,12 +202,12 @@ void yajl_encode_part(void * wrapper, VALUE obj, VALUE io) {
if (memcmp(cptr, "NaN", 3) == 0 || memcmp(cptr, "Infinity", 8) == 0 || memcmp(cptr, "-Infinity", 9) == 0) {
rb_raise(cEncodeError, "'%s' is an invalid number", cptr);
}
- status = yajl_gen_number(w->encoder, cptr, len);
+ CHECK_STATUS(yajl_gen_number(w->encoder, cptr, len));
break;
case T_STRING:
cptr = RSTRING_PTR(obj);
len = RSTRING_LEN(obj);
- status = yajl_gen_string(w->encoder, (const unsigned char *)cptr, len);
+ CHECK_STATUS(yajl_gen_string(w->encoder, (const unsigned char *)cptr, len));
break;
default:
if (rb_respond_to(obj, intern_to_json)) {
@@ -190,23 +215,28 @@ void yajl_encode_part(void * wrapper, VALUE obj, VALUE io) {
Check_Type(str, T_STRING);
cptr = RSTRING_PTR(str);
len = RSTRING_LEN(str);
- status = yajl_gen_number(w->encoder, cptr, len);
+ CHECK_STATUS(yajl_gen_number(w->encoder, cptr, len));
} else {
str = rb_funcall(obj, intern_to_s, 0);
Check_Type(str, T_STRING);
cptr = RSTRING_PTR(str);
len = RSTRING_LEN(str);
- status = yajl_gen_string(w->encoder, (const unsigned char *)cptr, len);
+ CHECK_STATUS(yajl_gen_string(w->encoder, (const unsigned char *)cptr, len));
}
break;
}
+
+ if (status != yajl_gen_status_ok) {
+ yajl_raise_encode_error_for_status(status, obj);
+ rb_raise(cEncodeError, "Encountered unknown YAJL status %d during JSON generation", status);
+ }
}
void yajl_parser_wrapper_free(void * wrapper) {
yajl_parser_wrapper * w = wrapper;
if (w) {
yajl_free(w->parser);
- free(w);
+ xfree(w);
}
}
@@ -384,7 +414,7 @@ static VALUE rb_yajl_parser_new(int argc, VALUE * argv, VALUE klass) {
if (rb_hash_aref(opts, sym_check_utf8) == Qfalse) {
checkUTF8 = 0;
}
- if (rb_hash_aref(opts, sym_symbolize_keys) == Qtrue) {
+ if (rb_hash_aref(opts, sym_symbolize_keys) == Qtrue || rb_hash_aref(opts, sym_symbolize_names) == Qtrue) {
symbolizeKeys = 1;
}
}
@@ -574,7 +604,7 @@ static VALUE rb_yajl_encoder_new(int argc, VALUE * argv, VALUE klass) {
indent = rb_str_export_to_enc(indent, utf8Encoding);
#endif
Check_Type(indent, T_STRING);
- indentString = (unsigned char*)malloc(RSTRING_LEN(indent)+1);
+ indentString = (unsigned char*)xmalloc(RSTRING_LEN(indent)+1);
memcpy(indentString, RSTRING_PTR(indent), RSTRING_LEN(indent));
indentString[RSTRING_LEN(indent)] = '\0';
actualIndent = indentString;
@@ -863,6 +893,8 @@ static VALUE rb_yajl_encoder_enable_json_gem_ext(VALUE klass) {
void Init_yajl() {
mYajl = rb_define_module("Yajl");
+ rb_define_const(mYajl, "MAX_DEPTH", INT2NUM(YAJL_MAX_DEPTH));
+
cParseError = rb_define_class_under(mYajl, "ParseError", rb_eStandardError);
cEncodeError = rb_define_class_under(mYajl, "EncodeError", rb_eStandardError);
@@ -898,6 +930,7 @@ void Init_yajl() {
sym_html_safe = ID2SYM(rb_intern("html_safe"));
sym_terminator = ID2SYM(rb_intern("terminator"));
sym_symbolize_keys = ID2SYM(rb_intern("symbolize_keys"));
+ sym_symbolize_names = ID2SYM(rb_intern("symbolize_names"));
#ifdef HAVE_RUBY_ENCODING_H
utf8Encoding = rb_utf8_encoding();
diff --git a/ext/yajl/yajl_ext.h b/ext/yajl/yajl_ext.h
index 28266f4..e0f5948 100644
--- a/ext/yajl/yajl_ext.h
+++ b/ext/yajl/yajl_ext.h
@@ -24,9 +24,9 @@
#include "api/yajl_parse.h"
#include "api/yajl_gen.h"
-// tell rbx not to use it's caching compat layer
-// by doing this we're making a promize to RBX that
-// we'll never modify the pointers we get back from RSTRING_PTR
+/* tell rbx not to use it's caching compat layer
+ by doing this we're making a promize to RBX that
+ we'll never modify the pointers we get back from RSTRING_PTR */
#define RSTRING_NOT_MODIFIED
#include <ruby.h>
@@ -56,15 +56,15 @@ static rb_encoding *utf8Encoding;
static VALUE cParseError, cEncodeError, mYajl, cParser, cEncoder;
static ID intern_io_read, intern_call, intern_keys, intern_to_s,
intern_to_json, intern_has_key, intern_to_sym, intern_as_json;
-static ID sym_allow_comments, sym_check_utf8, sym_pretty, sym_indent, sym_terminator, sym_symbolize_keys, sym_html_safe;
+static ID sym_allow_comments, sym_check_utf8, sym_pretty, sym_indent, sym_terminator, sym_symbolize_keys, sym_symbolize_names, sym_html_safe;
-#define GetParser(obj, sval) (sval = (yajl_parser_wrapper*)DATA_PTR(obj));
-#define GetEncoder(obj, sval) (sval = (yajl_encoder_wrapper*)DATA_PTR(obj));
+#define GetParser(obj, sval) Data_Get_Struct(obj, yajl_parser_wrapper, sval);
+#define GetEncoder(obj, sval) Data_Get_Struct(obj, yajl_encoder_wrapper, sval);
static void yajl_check_and_fire_callback(void * ctx);
static void yajl_set_static_value(void * ctx, VALUE val);
-void yajl_encode_part(void * wrapper, VALUE obj, VALUE io);
-void yajl_parse_chunk(const unsigned char * chunk, unsigned int len, yajl_handle parser);
+static void yajl_encode_part(void * wrapper, VALUE obj, VALUE io);
+static void yajl_parse_chunk(const unsigned char * chunk, unsigned int len, yajl_handle parser);
static int yajl_found_null(void * ctx);
static int yajl_found_boolean(void * ctx, int boolean);
@@ -132,4 +132,4 @@ static VALUE rb_yajl_json_ext_false_to_json(int argc, VALUE * argv, VALUE self);
static VALUE rb_yajl_json_ext_nil_to_json(int argc, VALUE * argv, VALUE self);
static VALUE rb_yajl_encoder_enable_json_gem_ext(VALUE klass);
-void Init_yajl();
\ No newline at end of file
+void Init_yajl();
diff --git a/ext/yajl/yajl_lex.h b/ext/yajl/yajl_lex.h
index a8defcf..3cdeef1 100644
--- a/ext/yajl/yajl_lex.h
+++ b/ext/yajl/yajl_lex.h
@@ -63,12 +63,16 @@ typedef enum {
typedef struct yajl_lexer_t * yajl_lexer;
+
+YAJL_API
yajl_lexer yajl_lex_alloc(yajl_alloc_funcs * alloc,
unsigned int allowComments,
unsigned int validateUTF8);
+YAJL_API
yajl_lexer yajl_lex_realloc(yajl_lexer orig);
+YAJL_API
void yajl_lex_free(yajl_lexer lexer);
/**
@@ -93,11 +97,13 @@ n * error messages.
* implications which require that the client choose a reasonable chunk
* size to get adequate performance.
*/
+YAJL_API
yajl_tok yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
unsigned int jsonTextLen, unsigned int * offset,
const unsigned char ** outBuf, unsigned int * outLen);
/** have a peek at the next token, but don't move the lexer forward */
+YAJL_API
yajl_tok yajl_lex_peek(yajl_lexer lexer, const unsigned char * jsonText,
unsigned int jsonTextLen, unsigned int offset);
@@ -116,20 +122,25 @@ typedef enum {
yajl_lex_unallowed_comment
} yajl_lex_error;
+YAJL_API
const char * yajl_lex_error_to_string(yajl_lex_error error);
/** allows access to more specific information about the lexical
* error when yajl_lex_lex returns yajl_tok_error. */
+YAJL_API
yajl_lex_error yajl_lex_get_error(yajl_lexer lexer);
/** get the current offset into the most recently lexed json string. */
+YAJL_API
unsigned int yajl_lex_current_offset(yajl_lexer lexer);
/** get the number of lines lexed by this lexer instance */
+YAJL_API
unsigned int yajl_lex_current_line(yajl_lexer lexer);
/** get the number of chars lexed by this lexer instance since the last
* \n or \r */
+YAJL_API
unsigned int yajl_lex_current_char(yajl_lexer lexer);
#endif
diff --git a/ext/yajl/yajl_parser.h b/ext/yajl/yajl_parser.h
index f72f3de..ee321e9 100644
--- a/ext/yajl/yajl_parser.h
+++ b/ext/yajl/yajl_parser.h
@@ -70,10 +70,12 @@ struct yajl_handle_t {
yajl_alloc_funcs alloc;
};
+YAJL_API
yajl_status
yajl_do_parse(yajl_handle handle, const unsigned char * jsonText,
unsigned int jsonTextLen);
+YAJL_API
unsigned char *
yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText,
unsigned int jsonTextLen, int verbose);
diff --git a/lib/yajl.rb b/lib/yajl.rb
index 539d083..a9bfb16 100644
--- a/lib/yajl.rb
+++ b/lib/yajl.rb
@@ -12,6 +12,7 @@ require 'yajl/yajl'
#
# Ruby bindings to the excellent Yajl (Yet Another JSON Parser) ANSI C library.
module Yajl
+
# For compatibility, has the same signature of Yajl::Parser.parse
def self.load(str_or_io, options={}, read_bufsize=nil, &block)
Parser.parse(str_or_io, options, read_bufsize, &block)
@@ -65,7 +66,7 @@ module Yajl
args.each do |arg|
if arg.is_a?(Hash)
options = arg
- elsif arg.respond_to?(:read)
+ elsif arg.respond_to?(:write)
io = arg
end
end if args.any?
diff --git a/lib/yajl/json_gem/encoding.rb b/lib/yajl/json_gem/encoding.rb
index 1c197df..0a3edac 100644
--- a/lib/yajl/json_gem/encoding.rb
+++ b/lib/yajl/json_gem/encoding.rb
@@ -17,17 +17,16 @@ module JSON
class JSONError < StandardError; end unless defined?(JSON::JSONError)
class GeneratorError < JSONError; end unless defined?(JSON::GeneratorError)
- def self.generate(obj, opts={})
- begin
- options_map = {}
- if opts.has_key?(:indent)
- options_map[:pretty] = true
- options_map[:indent] = opts[:indent]
- end
- Yajl::Encoder.encode(obj, options_map)
- rescue Yajl::EncodeError => e
- raise JSON::GeneratorError, e.message
+ def self.generate(obj, opts=nil)
+ opts ||= {}
+ options_map = {}
+ if opts.has_key?(:indent)
+ options_map[:pretty] = true
+ options_map[:indent] = opts[:indent]
end
+ Yajl::Encoder.encode(obj, options_map)
+ rescue Yajl::EncodeError => e
+ raise JSON::GeneratorError, e.message
end
def self.pretty_generate(obj, opts={})
diff --git a/lib/yajl/version.rb b/lib/yajl/version.rb
index 8082fd5..c944c9c 100644
--- a/lib/yajl/version.rb
+++ b/lib/yajl/version.rb
@@ -1,3 +1,3 @@
module Yajl
- VERSION = '1.1.0'
+ VERSION = '1.2.0'
end
diff --git a/metadata.yml b/metadata.yml
index 2cb52e9..bbf9d29 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -1,93 +1,79 @@
---- !ruby/object:Gem::Specification
+--- !ruby/object:Gem::Specification
name: yajl-ruby
-version: !ruby/object:Gem::Version
- hash: 19
- prerelease:
- segments:
- - 1
- - 1
- - 0
- version: 1.1.0
+version: !ruby/object:Gem::Version
+ version: 1.2.0
platform: ruby
-authors:
+authors:
- Brian Lopez
- Lloyd Hilaiel
autorequire:
bindir: bin
cert_chain: []
-
-date: 2011-11-09 00:00:00 -08:00
-default_executable:
-dependencies:
-- !ruby/object:Gem::Dependency
+date: 2013-12-17 00:00:00.000000000 Z
+dependencies:
+- !ruby/object:Gem::Dependency
name: rake-compiler
- prerelease: false
- requirement: &id001 !ruby/object:Gem::Requirement
- none: false
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- hash: 9
- segments:
- - 0
- - 7
- - 5
+ requirement: !ruby/object:Gem::Requirement
+ requirements:
+ - - '>='
+ - !ruby/object:Gem::Version
version: 0.7.5
type: :development
- version_requirements: *id001
-- !ruby/object:Gem::Dependency
- name: rspec
prerelease: false
- requirement: &id002 !ruby/object:Gem::Requirement
- none: false
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- hash: 15
- segments:
- - 2
- - 0
- - 0
+ version_requirements: !ruby/object:Gem::Requirement
+ requirements:
+ - - '>='
+ - !ruby/object:Gem::Version
+ version: 0.7.5
+- !ruby/object:Gem::Dependency
+ name: rspec
+ requirement: !ruby/object:Gem::Requirement
+ requirements:
+ - - '>='
+ - !ruby/object:Gem::Version
version: 2.0.0
type: :development
- version_requirements: *id002
-- !ruby/object:Gem::Dependency
- name: activesupport
prerelease: false
- requirement: &id003 !ruby/object:Gem::Requirement
- none: false
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- hash: 3
- segments:
- - 0
- version: "0"
+ version_requirements: !ruby/object:Gem::Requirement
+ requirements:
+ - - '>='
+ - !ruby/object:Gem::Version
+ version: 2.0.0
+- !ruby/object:Gem::Dependency
+ name: activesupport
+ requirement: !ruby/object:Gem::Requirement
+ requirements:
+ - - '>='
+ - !ruby/object:Gem::Version
+ version: '0'
type: :development
- version_requirements: *id003
-- !ruby/object:Gem::Dependency
- name: json
prerelease: false
- requirement: &id004 !ruby/object:Gem::Requirement
- none: false
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- hash: 3
- segments:
- - 0
- version: "0"
+ version_requirements: !ruby/object:Gem::Requirement
+ requirements:
+ - - '>='
+ - !ruby/object:Gem::Version
+ version: '0'
+- !ruby/object:Gem::Dependency
+ name: json
+ requirement: !ruby/object:Gem::Requirement
+ requirements:
+ - - '>='
+ - !ruby/object:Gem::Version
+ version: '0'
type: :development
- version_requirements: *id004
+ prerelease: false
+ version_requirements: !ruby/object:Gem::Requirement
+ requirements:
+ - - '>='
+ - !ruby/object:Gem::Version
+ version: '0'
description:
email: seniorlopez at gmail.com
executables: []
-
-extensions:
+extensions:
- ext/yajl/extconf.rb
extra_rdoc_files: []
-
-files:
+files:
- .gitignore
- .rspec
- .travis.yml
@@ -155,6 +141,7 @@ files:
- lib/yajl/json_gem/encoding.rb
- lib/yajl/json_gem/parsing.rb
- lib/yajl/version.rb
+- script/bootstrap
- spec/encoding/encoding_spec.rb
- spec/global/global_spec.rb
- spec/http/fixtures/http.bzip2.dump
@@ -237,43 +224,30 @@ files:
- tasks/compile.rake
- tasks/rspec.rake
- yajl-ruby.gemspec
-has_rdoc: true
homepage: http://github.com/brianmario/yajl-ruby
licenses: []
-
+metadata: {}
post_install_message:
rdoc_options: []
-
-require_paths:
+require_paths:
- lib
-required_ruby_version: !ruby/object:Gem::Requirement
- none: false
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- hash: 59
- segments:
- - 1
- - 8
- - 6
+required_ruby_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - '>='
+ - !ruby/object:Gem::Version
version: 1.8.6
-required_rubygems_version: !ruby/object:Gem::Requirement
- none: false
- requirements:
- - - ">="
- - !ruby/object:Gem::Version
- hash: 3
- segments:
- - 0
- version: "0"
+required_rubygems_version: !ruby/object:Gem::Requirement
+ requirements:
+ - - '>='
+ - !ruby/object:Gem::Version
+ version: '0'
requirements: []
-
rubyforge_project:
-rubygems_version: 1.6.2
+rubygems_version: 2.0.3
signing_key:
-specification_version: 3
+specification_version: 4
summary: Ruby C bindings to the excellent Yajl JSON stream-based parser library.
-test_files:
+test_files:
- examples/encoding/chunked_encoding.rb
- examples/encoding/one_shot.rb
- examples/encoding/to_an_io.rb
diff --git a/script/bootstrap b/script/bootstrap
new file mode 100755
index 0000000..500005c
--- /dev/null
+++ b/script/bootstrap
@@ -0,0 +1,5 @@
+#!/bin/sh
+set -e
+
+cd "$(dirname "$0")/.."
+exec bundle install --binstubs --path vendor/gems "$@"
diff --git a/spec/encoding/encoding_spec.rb b/spec/encoding/encoding_spec.rb
index b02c2e0..818f028 100644
--- a/spec/encoding/encoding_spec.rb
+++ b/spec/encoding/encoding_spec.rb
@@ -1,5 +1,7 @@
# encoding: UTF-8
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
+require 'tmpdir'
+require 'zlib'
class Dummy2
def to_json
@@ -23,7 +25,7 @@ describe "Yajl JSON encoder" do
FILES = Dir[File.dirname(__FILE__)+'/../../benchmark/subjects/*.json']
FILES.each do |file|
- it "should encode #{File.basename(file)} to an IO" do
+ it "should encode #{File.basename(file)} to an StringIO" do
# we don't care about testing the stream subject as it has multiple JSON strings in it
if File.basename(file) != 'twitter_stream.json'
input = File.new(File.expand_path(file), 'r')
@@ -41,6 +43,27 @@ describe "Yajl JSON encoder" do
end
FILES.each do |file|
+ it "should encode #{File.basename(file)} to a Zlib::GzipWriter" do
+ # we don't care about testing the stream subject as it has multiple JSON strings in it
+ if File.basename(file) != 'twitter_stream.json'
+ hash = File.open(File.expand_path(file), 'r') do |input|
+ Yajl::Parser.parse(input)
+ end
+ hash2 = Dir.mktmpdir do |tmp_dir|
+ output_filename = File.join(tmp_dir, 'output.json')
+ Zlib::GzipWriter.open(output_filename) do |writer|
+ Yajl::Encoder.encode(hash, writer)
+ end
+ Zlib::GzipReader.open(output_filename) do |reader|
+ Yajl::Parser.parse(reader.read)
+ end
+ end
+ hash.should == hash2
+ end
+ end
+ end
+
+ FILES.each do |file|
it "should encode #{File.basename(file)} and return a String" do
# we don't care about testing the stream subject as it has multiple JSON strings in it
if File.basename(file) != 'twitter_stream.json'
@@ -271,4 +294,22 @@ describe "Yajl JSON encoder" do
Yajl::Encoder.encode(TheMindKillerDuce.new)
}.should raise_error(TypeError)
end
+
+ it "should raise an exception for deeply nested arrays" do
+ root = []
+ a = root
+ (Yajl::MAX_DEPTH + 1).times { |_| a << []; a = a[0] }
+ lambda {
+ Yajl::Encoder.encode(root)
+ }.should raise_error(Yajl::EncodeError)
+ end
+
+ it "should raise an exception for deeply nested hashes" do
+ root = {}
+ a = root
+ (Yajl::MAX_DEPTH + 1).times { |_| a["a"] = {}; a = a["a"] }
+ lambda {
+ Yajl::Encoder.encode(root)
+ }.should raise_error(Yajl::EncodeError)
+ end
end
\ No newline at end of file
diff --git a/spec/json_gem_compatibility/compatibility_spec.rb b/spec/json_gem_compatibility/compatibility_spec.rb
index a1d96b8..b1d7701 100644
--- a/spec/json_gem_compatibility/compatibility_spec.rb
+++ b/spec/json_gem_compatibility/compatibility_spec.rb
@@ -51,6 +51,10 @@ describe "JSON Gem compatability API" do
JSON.default_options[:symbolize_keys] = default # ensure the rest of the test cases expect the default
end
+ it "should also allow the json gem's symbolize_names key" do
+ JSON.parse('{"foo": 1234}', :symbolize_names => true).should === {:foo => 1234}
+ end
+
it "should encode arbitrary classes via their default to_json method" do
d = Dummy.new
d.to_json.should == "\"#{d.to_s}\""
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-yajl.git
More information about the Pkg-ruby-extras-commits
mailing list