ox 1.4.5 → 1.4.6

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.

data/README.md CHANGED
@@ -26,9 +26,9 @@ A fast XML parser and Object marshaller as a Ruby gem.
26
26
 
27
27
  ## <a name="release">Release Notes</a>
28
28
 
29
- ### Release 1.4.5
29
+ ### Release 1.4.6
30
30
 
31
- - Fixed encoding issues with all parsers so that attribute and element names can now be encoded with something other than ASCII.
31
+ - Adopted the Exception message encoding hack to work for the latests ruby versions.
32
32
 
33
33
  ## <a name="description">Description</a>
34
34
 
@@ -72,6 +72,7 @@ typedef struct _Out {
72
72
  int indent;
73
73
  int depth; // used by dumpHash
74
74
  Options opts;
75
+ VALUE obj;
75
76
  } *Out;
76
77
 
77
78
  static void dump_obj_to_xml(VALUE obj, Options copts, Out out);
@@ -435,9 +436,11 @@ dump_first_obj(VALUE obj, Out out) {
435
436
  static void
436
437
  dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
437
438
  struct _Element e;
439
+ VALUE prev_obj = out->obj;
438
440
  char value_buf[64];
439
441
  int cnt;
440
442
 
443
+ out->obj = obj;
441
444
  if (0 == aid) {
442
445
  //e.attr.str = 0;
443
446
  e.attr.len = 0;
@@ -823,20 +826,20 @@ dump_obj(ID aid, VALUE obj, unsigned int depth, Out out) {
823
826
  }
824
827
  break;
825
828
  }
829
+ out->obj = prev_obj;
826
830
  }
827
831
 
828
832
  static int
829
833
  dump_var(ID key, VALUE value, Out out) {
830
- if (T_DATA == rb_type(value) && rb_cTime != rb_obj_class(value)) {
834
+ if (T_DATA == rb_type(value) && key == mesg_id) {
831
835
  /* There is a secret recipe that keeps Exception mesg attributes as a
832
- * T_DATA until it is needed. StringValue() or a safer method of
833
- * calling to_s() makes the value needed and it is converted to a
834
- * regular Ruby Object. It might seem reasonable to expect that this
835
- * would be done before calling the foreach callback but it isn't. A
836
- * slight hack fixes the inconsistency. If the var is not something
837
- * that can be represented as a String then this will fail.
836
+ * T_DATA until it is needed. The safe way around this hack is to call
837
+ * the message() method and use the returned string as the
838
+ * message. Not pretty but it solves the most common use of this
839
+ * hack. If there are others they will have to be handled one at a
840
+ * time.
838
841
  */
839
- rb_funcall(value, to_s_id, 0);
842
+ value = rb_funcall(out->obj, message_id, 0);
840
843
  }
841
844
  dump_obj(key, value, out->depth, out);
842
845
 
@@ -1026,6 +1029,7 @@ dump_obj_to_xml(VALUE obj, Options copts, Out out) {
1026
1029
  out->circ_cache = 0;
1027
1030
  out->circ_cnt = 0;
1028
1031
  out->opts = copts;
1032
+ out->obj = obj;
1029
1033
  if (Yes == copts->circular) {
1030
1034
  ox_cache8_new(&out->circ_cache);
1031
1035
  }
@@ -62,6 +62,8 @@ ID inspect_id;
62
62
  ID instruct_id;
63
63
  ID keys_id;
64
64
  ID local_id;
65
+ ID mesg_id;
66
+ ID message_id;
65
67
  ID nodes_id;
66
68
  ID num_id;
67
69
  ID parse_id;
@@ -653,6 +655,8 @@ void Init_ox() {
653
655
  instruct_id = rb_intern("instruct");
654
656
  keys_id = rb_intern("keys");
655
657
  local_id = rb_intern("local");
658
+ mesg_id = rb_intern("mesg");
659
+ message_id = rb_intern("message");
656
660
  nodes_id = rb_intern("@nodes");
657
661
  num_id = rb_intern("@num");
658
662
  parse_id = rb_intern("parse");
@@ -233,6 +233,8 @@ extern ID inspect_id;
233
233
  extern ID instruct_id;
234
234
  extern ID keys_id;
235
235
  extern ID local_id;
236
+ extern ID mesg_id;
237
+ extern ID message_id;
236
238
  extern ID nodes_id;
237
239
  extern ID num_id;
238
240
  extern ID parse_id;
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Ox
3
3
  # Current version of the module.
4
- VERSION = '1.4.5'
4
+ VERSION = '1.4.6'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.5
4
+ version: 1.4.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-19 00:00:00.000000000Z
12
+ date: 2012-02-09 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: ! "A fast XML parser and object serializer that uses only standard C
15
15
  lib.\n \nOptimized XML (Ox), as the name implies was written to provide