json 1.2.3 → 1.2.4

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

Potentially problematic release.


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

data/CHANGES CHANGED
@@ -1,3 +1,5 @@
1
+ 2010-04-07 (1.2.4)
2
+ * Triger const_missing callback to make Rails' dynamic class loading work.
1
3
  2010-03-11 (1.2.3)
2
4
  * Added a State#[] method which returns an attribute's value in order to
3
5
  increase duck type compatibility to Hash.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.3
1
+ 1.2.4
@@ -26,7 +26,7 @@ static VALUE CNaN, CInfinity, CMinusInfinity;
26
26
 
27
27
  static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
28
28
  i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_object_class,
29
- i_array_class, i_key_p;
29
+ i_array_class, i_key_p, i_deep_const_get;
30
30
 
31
31
  #define MinusInfinity "-Infinity"
32
32
 
@@ -415,7 +415,7 @@ case 26:
415
415
  if (RTEST(json->create_id)) {
416
416
  VALUE klassname = rb_hash_aref(*result, json->create_id);
417
417
  if (!NIL_P(klassname)) {
418
- VALUE klass = rb_path2class(StringValueCStr(klassname));
418
+ VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, klassname);
419
419
  if RTEST(rb_funcall(klass, i_json_creatable_p, 0)) {
420
420
  *result = rb_funcall(klass, i_json_create, 1, *result);
421
421
  }
@@ -1875,6 +1875,7 @@ void Init_parser()
1875
1875
  i_object_class = rb_intern("object_class");
1876
1876
  i_array_class = rb_intern("array_class");
1877
1877
  i_key_p = rb_intern("key?");
1878
+ i_deep_const_get = rb_intern("deep_const_get");
1878
1879
  #ifdef HAVE_RUBY_ENCODING_H
1879
1880
  mEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
1880
1881
  mEncoding_UTF_16BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16be"));
@@ -24,7 +24,7 @@ static VALUE CNaN, CInfinity, CMinusInfinity;
24
24
 
25
25
  static ID i_json_creatable_p, i_json_create, i_create_id, i_create_additions,
26
26
  i_chr, i_max_nesting, i_allow_nan, i_symbolize_names, i_object_class,
27
- i_array_class, i_key_p;
27
+ i_array_class, i_key_p, i_deep_const_get;
28
28
 
29
29
  #define MinusInfinity "-Infinity"
30
30
 
@@ -136,7 +136,7 @@ static char *JSON_parse_object(JSON_Parser *json, char *p, char *pe, VALUE *resu
136
136
  if (RTEST(json->create_id)) {
137
137
  VALUE klassname = rb_hash_aref(*result, json->create_id);
138
138
  if (!NIL_P(klassname)) {
139
- VALUE klass = rb_path2class(StringValueCStr(klassname));
139
+ VALUE klass = rb_funcall(mJSON, i_deep_const_get, 1, klassname);
140
140
  if RTEST(rb_funcall(klass, i_json_creatable_p, 0)) {
141
141
  *result = rb_funcall(klass, i_json_create, 1, *result);
142
142
  }
@@ -732,6 +732,7 @@ void Init_parser()
732
732
  i_object_class = rb_intern("object_class");
733
733
  i_array_class = rb_intern("array_class");
734
734
  i_key_p = rb_intern("key?");
735
+ i_deep_const_get = rb_intern("deep_const_get");
735
736
  #ifdef HAVE_RUBY_ENCODING_H
736
737
  mEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
737
738
  mEncoding_UTF_16BE = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-16be"));
@@ -33,12 +33,16 @@ module JSON
33
33
  # level (absolute namespace path?). If there doesn't exist a constant at
34
34
  # the given path, an ArgumentError is raised.
35
35
  def deep_const_get(path) # :nodoc:
36
- path = path.to_s
37
- path.split(/::/).inject(Object) do |p, c|
36
+ path.to_s.split(/::/).inject(Object) do |p, c|
38
37
  case
39
38
  when c.empty? then p
40
39
  when p.const_defined?(c) then p.const_get(c)
41
- else raise ArgumentError, "can't find const #{path}"
40
+ else
41
+ begin
42
+ p.const_missing(c)
43
+ rescue NameError
44
+ raise ArgumentError, "can't find const #{path}"
45
+ end
42
46
  end
43
47
  end
44
48
  end
@@ -1,6 +1,6 @@
1
1
  module JSON
2
2
  # JSON version
3
- VERSION = '1.2.3'
3
+ VERSION = '1.2.4'
4
4
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-11 00:00:00 +01:00
12
+ date: 2010-04-08 00:00:00 +02:00
13
13
  default_executable: edit_json.rb
14
14
  dependencies: []
15
15