oj 2.0.11 → 2.0.12

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of oj might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 451501e86625385b0362d776ad531e20f8be0aa5
4
- data.tar.gz: fc691b28aba6381bec1aebe7acfe25f0483f0b82
3
+ metadata.gz: c6d89419541ffeaab83eaea37802686aae4fab16
4
+ data.tar.gz: 0d6fd040e9438dbee988ee0ef7b5f35ea31e3b7e
5
5
  SHA512:
6
- metadata.gz: 6f779275172ff00267a5c7d9398b831253c0582abc2eb93f1e9b1f74d7863bf0e16156a9926d5008006329bb5d78549f799e8f54bf9d4b6effa422849171d767
7
- data.tar.gz: 0d971692dce841116f198fc6c190c906ce613784b647908e706d8a8e76d965b4e9d7fc16a960e776da5dbb5426a8f53dd4d5b0744aafe36a0831532f1cf97490
6
+ metadata.gz: 01a5f4dbfc93069e199591710d4bf98df329b48f58bb29eb5a54df896a5fa217a79685a63cedf2a88af86a32519083f32d608a93059104255fdffa7da6d58650
7
+ data.tar.gz: d16b98eedefb8e483df1f8ea14c6ed4a8036943501864334f19b8bfc7221498059343313c7aa722f592fc210b4c8eb0ce0cfefd532ba7017c82a389856a319ed
data/README.md CHANGED
@@ -32,6 +32,14 @@ A fast JSON parser and Object marshaller as a Ruby gem.
32
32
 
33
33
  ## <a name="release">Release Notes</a>
34
34
 
35
+ ### Release 2.0.12
36
+
37
+ - Another fix for mimic.
38
+
39
+ - mimic_JSON now can now be called after loading the json gem. This will
40
+ replace the json gem methods after loading. This may be more compatible in
41
+ many cases.
42
+
35
43
  ### Release 2.0.11
36
44
 
37
45
  - Fixed mimic issue with Debian
@@ -979,15 +979,25 @@ define_mimic_json(int argc, VALUE *argv, VALUE self) {
979
979
  if (Qnil == mimic) {
980
980
  VALUE ext;
981
981
  VALUE dummy;
982
-
982
+
983
+ // Either set the paths to indicate JSON has been loaded or replaces the
984
+ // methods if it has been loaded.
983
985
  if (rb_const_defined_at(rb_cObject, rb_intern("JSON"))) {
984
- rb_raise(rb_const_get_at(Oj, rb_intern("MimicError")),
985
- "JSON module already exists. Can not mimic. Do not require 'json' before calling mimic_JSON.");
986
+ mimic = rb_const_get_at(rb_cObject, rb_intern("JSON"));
987
+ } else {
988
+ mimic = rb_define_module("JSON");
989
+ }
990
+ if (rb_const_defined_at(mimic, rb_intern("Ext"))) {
991
+ ext = rb_const_get_at(mimic, rb_intern("Ext"));
992
+ } else {
993
+ ext = rb_define_module_under(mimic, "Ext");
994
+ }
995
+ if (!rb_const_defined_at(ext, rb_intern("Parser"))) {
996
+ dummy = rb_define_class_under(ext, "Parser", rb_cObject);
997
+ }
998
+ if (!rb_const_defined_at(ext, rb_intern("Generator"))) {
999
+ dummy = rb_define_class_under(ext, "Generator", rb_cObject);
986
1000
  }
987
- mimic = rb_define_module("JSON");
988
- ext = rb_define_module_under(mimic, "Ext");
989
- dummy = rb_define_class_under(ext, "Parser", rb_cObject);
990
- dummy = rb_define_class_under(ext, "Generator", rb_cObject);
991
1001
  // convince Ruby that the json gem has already been loaded
992
1002
  dummy = rb_gv_get("$LOADED_FEATURES");
993
1003
  if (rb_type(dummy) == T_ARRAY) {
@@ -1001,7 +1011,8 @@ define_mimic_json(int argc, VALUE *argv, VALUE self) {
1001
1011
  rb_funcall2(Oj, rb_intern("mimic_loaded"), 0, 0);
1002
1012
  }
1003
1013
  }
1004
-
1014
+ dummy = rb_gv_get("$VERBOSE");
1015
+ rb_gv_set("$VERBOSE", Qfalse);
1005
1016
  rb_define_module_function(mimic, "parser=", no_op1, 1);
1006
1017
  rb_define_module_function(mimic, "generator=", no_op1, 1);
1007
1018
  rb_define_module_function(mimic, "create_id=", mimic_create_id, 1);
@@ -1022,6 +1033,7 @@ define_mimic_json(int argc, VALUE *argv, VALUE self) {
1022
1033
 
1023
1034
  rb_define_module_function(mimic, "parse", mimic_parse, -1);
1024
1035
  rb_define_module_function(mimic, "parse!", mimic_parse, -1);
1036
+ rb_gv_set("$VERBOSE", dummy);
1025
1037
 
1026
1038
  array_nl_sym = ID2SYM(rb_intern("array_nl")); rb_gc_register_address(&array_nl_sym);
1027
1039
  create_additions_sym = ID2SYM(rb_intern("create_additions")); rb_gc_register_address(&create_additions_sym);
@@ -4,15 +4,15 @@ module Oj
4
4
  def self.mimic_loaded(mimic_paths=[])
5
5
  gems_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__))))
6
6
  Dir.foreach(gems_dir) do |gem|
7
- next unless (gem.start_with?('json-') || gem.start_with?('json_pure'))
7
+ next unless (gem.start_with?('json') || gem.start_with?('json_pure'))
8
8
  $LOADED_FEATURES << File.join(gems_dir, gem, 'lib', 'json.rb')
9
9
  end
10
10
  # and another approach in case the first did not get all
11
11
  $LOAD_PATH.each do |d|
12
12
  next unless File.exist?(d)
13
- Dir.entries(d) do |file|
14
- next unless file.ends_with?('jsob.rb')
15
- $LOADED_FEATURES << file unless $LOADED_FEATURES.include?(file)
13
+ Dir.foreach(d) do |file|
14
+ next unless file.end_with?('json.rb')
15
+ $LOADED_FEATURES << File.join(d, file) unless $LOADED_FEATURES.include?(file)
16
16
  end
17
17
  end
18
18
  mimic_paths.each { |p| $LOADED_FEATURES << p }
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '2.0.11'
4
+ VERSION = '2.0.12'
5
5
  end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ # Ubuntu does not accept arguments to ruby when called using env. To get warnings to show up the -w options is
5
+ # required. That can be set in the RUBYOPT environment variable.
6
+ # export RUBYOPT=-w
7
+
8
+ $VERBOSE = true
9
+
10
+ $: << File.join(File.dirname(__FILE__), "../lib")
11
+ $: << File.join(File.dirname(__FILE__), "../ext")
12
+
13
+ require 'test/unit'
14
+ require 'stringio'
15
+ require 'oj'
16
+ require 'json'
17
+
18
+ class MimicAfter < ::Test::Unit::TestCase
19
+
20
+ def test0_mimic_json
21
+ assert(!defined?(JSON).nil?)
22
+ Oj.mimic_JSON
23
+ end
24
+
25
+ # dump
26
+ def test_dump_string
27
+ Oj.default_options= {:indent => 2} # JSON this will not change anything
28
+ json = JSON.dump([1, true, nil])
29
+ assert_equal(%{[
30
+ 1,
31
+ true,
32
+ null]}, json)
33
+ end
34
+
35
+ end # MimicAfter
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.11
4
+ version: 2.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-23 00:00:00.000000000 Z
11
+ date: 2013-04-28 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'The fastest JSON parser and object serializer. '
14
14
  email: peter@ohler.com
@@ -65,6 +65,7 @@ files:
65
65
  - test/sample_json.rb
66
66
  - test/test_fast.rb
67
67
  - test/test_mimic.rb
68
+ - test/test_mimic_after.rb
68
69
  - test/test_saj.rb
69
70
  - test/tests.rb
70
71
  - LICENSE