Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: brianmario/yajl-ruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 89efc57e4c91235a8caf9609bb2fef20d77d94ac
Choose a base ref
..
head repository: brianmario/yajl-ruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 57a833be9c7a34a64c3d06d2d4b59d419a18c916
Choose a head ref
9 changes: 4 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -3,12 +3,11 @@ rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- rbx
- 2.0.0
- 2.1
- rbx-2
- ree
- ruby-head
- rbx-18mode
- rbx-19mode
matrix:
allow_failures:
- rvm: rbx-18mode
- rvm: rbx-19mode
- rvm: rbx-2
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -25,6 +25,12 @@ Go ahead and install it as usual:
gem install yajl
```

Or use your Gemfile:

``` ruby
gem 'yajl-ruby', require: 'yajl'
```

## Example of use

NOTE: I'm building up a collection of small examples in the examples (http://github.com/brianmario/yajl-ruby/tree/master/examples) folder.
2 changes: 1 addition & 1 deletion examples/encoding/chunked_encoding.rb
Original file line number Diff line number Diff line change
@@ -24,4 +24,4 @@
STDOUT << chunk
end

puts "\n\nEncoder generated #{total_size} bytes of data, in #{chunks} chunks"
puts "\n\nEncoder generated #{total_size} bytes of data, in #{chunks} chunks"
2 changes: 1 addition & 1 deletion examples/encoding/one_shot.rb
Original file line number Diff line number Diff line change
@@ -10,4 +10,4 @@
}

str = Yajl::Encoder.encode(obj)
puts str
puts str
2 changes: 1 addition & 1 deletion examples/encoding/to_an_io.rb
Original file line number Diff line number Diff line change
@@ -9,4 +9,4 @@
:as_easy_as => 123
}

Yajl::Encoder.encode(obj, STDOUT)
Yajl::Encoder.encode(obj, STDOUT)
2 changes: 1 addition & 1 deletion examples/http/twitter_search_api.rb
Original file line number Diff line number Diff line change
@@ -9,4 +9,4 @@
exit(0)
end

puts Yajl::HttpStream.get("http://search.twitter.com/search.json?q=#{keywords}").inspect
puts Yajl::HttpStream.get("http://search.twitter.com/search.json?q=#{keywords}").inspect
2 changes: 1 addition & 1 deletion examples/http/twitter_stream_api.rb
Original file line number Diff line number Diff line change
@@ -23,4 +23,4 @@
STDOUT.putc '.'
STDOUT.flush
captured += 1
end
end
2 changes: 1 addition & 1 deletion examples/parsing/from_file.rb
Original file line number Diff line number Diff line change
@@ -11,4 +11,4 @@
json = File.new(file, 'r')

hash = Yajl::Parser.parse(json)
puts hash.inspect
puts hash.inspect
2 changes: 1 addition & 1 deletion examples/parsing/from_stdin.rb
Original file line number Diff line number Diff line change
@@ -6,4 +6,4 @@
# Usage: cat benchmark/subjects/item.json | ruby examples/from_stdin.rb

hash = Yajl::Parser.parse(STDIN)
puts hash.inspect
puts hash.inspect
2 changes: 1 addition & 1 deletion examples/parsing/from_string.rb
Original file line number Diff line number Diff line change
@@ -10,4 +10,4 @@
end

hash = Yajl::Parser.parse(string)
puts hash.inspect
puts hash.inspect
2 changes: 1 addition & 1 deletion ext/yajl/extconf.rb
Original file line number Diff line number Diff line change
@@ -2,6 +2,6 @@
require 'rbconfig'

$CFLAGS << ' -Wall -funroll-loops'
$CFLAGS << ' -Wextra -O0 -ggdb3' if ENV['DEBUG']
$CFLAGS << ' -Werror-implicit-function-declaration -Wextra -O0 -ggdb3' if ENV['DEBUG']

create_makefile('yajl/yajl')
17 changes: 8 additions & 9 deletions ext/yajl/yajl_ext.c
Original file line number Diff line number Diff line change
@@ -275,7 +275,7 @@ static int yajl_found_boolean(void * ctx, int boolean) {
}

static int yajl_found_number(void * ctx, const char * numberVal, unsigned int numberLen) {
char buf[numberLen+1];
char* buf = (char*)malloc(numberLen + 1);
buf[numberLen] = 0;
memcpy(buf, numberVal, numberLen);

@@ -286,6 +286,7 @@ static int yajl_found_number(void * ctx, const char * numberVal, unsigned int nu
} else {
yajl_set_static_value(ctx, rb_cstr2inum(buf, 10));
}
free(buf);
return 1;
}

@@ -315,15 +316,13 @@ static int yajl_found_hash_key(void * ctx, const unsigned char * stringVal, unsi
#endif

if (wrapper->symbolizeKeys) {
char buf[stringLen+1];
memcpy(buf, stringVal, stringLen);
buf[stringLen] = 0;
VALUE stringEncoded = rb_str_new2(buf);
#ifdef HAVE_RUBY_ENCODING_H
rb_enc_associate(stringEncoded, rb_utf8_encoding());
ID id = rb_intern3((const char *)stringVal, stringLen, utf8Encoding);
keyStr = ID2SYM(id);
#else
VALUE str = rb_str_new((const char *)stringVal, stringLen);
keyStr = rb_str_intern(str);
#endif

yajl_set_static_value(ctx, ID2SYM(rb_to_id(stringEncoded)));
} else {
keyStr = rb_str_new((const char *)stringVal, stringLen);
#ifdef HAVE_RUBY_ENCODING_H
@@ -332,8 +331,8 @@ static int yajl_found_hash_key(void * ctx, const unsigned char * stringVal, unsi
keyStr = rb_str_export_to_enc(keyStr, default_internal_enc);
}
#endif
yajl_set_static_value(ctx, keyStr);
}
yajl_set_static_value(ctx, keyStr);
yajl_check_and_fire_callback(ctx);
return 1;
}
2 changes: 1 addition & 1 deletion lib/yajl/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Yajl
VERSION = '1.2.0'
VERSION = '1.2.1'
end
Loading