ox 1.2.9 → 1.2.10

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

Potentially problematic release.


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

Files changed (5) hide show
  1. data/ext/ox/dump.c +15 -5
  2. data/lib/ox/version.rb +1 -1
  3. data/test/bug3.rb +11 -13
  4. metadata +4 -13
  5. data/test/big.rb +0 -24
@@ -447,7 +447,7 @@ dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
447
447
  }
448
448
  e.id = 0;
449
449
  e.clas.len = 0;
450
- e.clas.str = 0;
450
+ e.clas.str = 0;
451
451
  switch (rb_type(obj)) {
452
452
  case RUBY_T_NIL:
453
453
  e.type = NilClassCode;
@@ -598,8 +598,7 @@ dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
598
598
  out->w_end(out, &e);
599
599
  } else {
600
600
  if (StrictEffort == out->opts->effort) {
601
- rb_raise(rb_eNotImpError, "Failed to dump RUBY_T_DATA %s Object (%02x)\n",
602
- rb_class2name(clas), rb_type(obj));
601
+ rb_raise(rb_eNotImpError, "Failed to dump RUBY_T_DATA %s\n", rb_class2name(clas));
603
602
  } else {
604
603
  e.type = NilClassCode;
605
604
  e.closed = 1;
@@ -673,7 +672,7 @@ dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
673
672
  out->w_start(out, &e);
674
673
  if (0 < cnt) {
675
674
  unsigned int od = out->depth;
676
-
675
+
677
676
  out->depth = depth + 1;
678
677
  rb_ivar_foreach(obj, dump_var, (VALUE)out);
679
678
  out->depth = od;
@@ -781,8 +780,19 @@ dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
781
780
 
782
781
  static int
783
782
  dump_var(ID key, VALUE value, Out out) {
783
+ if (RUBY_T_DATA == rb_type(value) && rb_cTime != rb_obj_class(value)) {
784
+ /* There is a secret recipe that keeps Exception mesg attributes as a
785
+ * T_DATA until it is needed. StringValue() makes the value needed and
786
+ * it is converted to a regular Ruby Object. It might seem reasonable
787
+ * to expect that this would be done before calling the foreach
788
+ * callback but it isn't. A slight hack fixes the inconsistency. If
789
+ * the var is not something that can be represented as a String then
790
+ * this will fail.
791
+ */
792
+ StringValue(value);
793
+ }
784
794
  dump_obj(key, value, out->depth, out);
785
-
795
+
786
796
  return ST_CONTINUE;
787
797
  }
788
798
 
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '1.2.9'
4
+ VERSION = '1.2.10'
5
5
  end
@@ -3,21 +3,19 @@
3
3
  $: << '../lib'
4
4
  $: << '../ext'
5
5
 
6
- if __FILE__ == $0
7
- if (i = ARGV.index('-I'))
8
- x,path = ARGV.slice!(i, 2)
9
- $: << path
10
- end
11
- end
12
-
13
6
  require 'ox'
14
7
 
15
- def dump(cnt = 100000)
16
- cnt.times do |i|
17
- xml = Ox.dump([:inc, 1])
18
- #puts xml
19
-
8
+ def name_it()
9
+ begin
10
+ "x".foo
11
+ rescue Exception => e
12
+ #puts e.message
13
+ xml = Ox.dump(e, effort: :tolerant)
14
+ puts xml
15
+ o = Ox.load(xml, mode: :object)
16
+ puts o.message
17
+ puts Ox.dump(e)
20
18
  end
21
19
  end
22
20
 
23
- dump()
21
+ name_it()
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ox
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 2
8
- - 9
9
- version: 1.2.9
4
+ prerelease:
5
+ version: 1.2.10
10
6
  platform: ruby
11
7
  authors:
12
8
  - Peter Ohler
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-08-25 00:00:00 +09:00
13
+ date: 2011-08-29 00:00:00 +09:00
18
14
  default_executable:
19
15
  dependencies: []
20
16
 
@@ -51,7 +47,6 @@ files:
51
47
  - ext/ox/obj_load.c
52
48
  - ext/ox/ox.c
53
49
  - ext/ox/parse.c
54
- - test/big.rb
55
50
  - test/bug1.rb
56
51
  - test/bug2.rb
57
52
  - test/bug3.rb
@@ -100,21 +95,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
95
  requirements:
101
96
  - - ">="
102
97
  - !ruby/object:Gem::Version
103
- segments:
104
- - 0
105
98
  version: "0"
106
99
  required_rubygems_version: !ruby/object:Gem::Requirement
107
100
  none: false
108
101
  requirements:
109
102
  - - ">="
110
103
  - !ruby/object:Gem::Version
111
- segments:
112
- - 0
113
104
  version: "0"
114
105
  requirements: []
115
106
 
116
107
  rubyforge_project: ox
117
- rubygems_version: 1.3.7
108
+ rubygems_version: 1.6.2
118
109
  signing_key:
119
110
  specification_version: 3
120
111
  summary: A fast XML parser and object serializer.
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby -wW1
2
-
3
- $: << '../lib'
4
- $: << '../ext'
5
-
6
- if __FILE__ == $0
7
- while (i = ARGV.index('-I'))
8
- x,path = ARGV.slice!(i, 2)
9
- $: << path
10
- end
11
- end
12
-
13
- require 'ox'
14
-
15
- def dump(cnt = 10000)
16
- h = { }
17
- cnt.times do |i|
18
- h[i] = [i * 2, "this is #{i}"]
19
- end
20
- xml = Ox.dump(h)
21
- puts "size: #{xml.size}"
22
- end
23
-
24
- dump(200000)