ox 1.0.0 → 1.0.1

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.

@@ -2,6 +2,8 @@
2
2
 
3
3
  *GitHub* *repo*: https://github.com/ohler55/ox
4
4
 
5
+ *RubyGems* *repo*: https://rubygems.org/gems/ox
6
+
5
7
  === Description:
6
8
 
7
9
  Optimized XML (Ox), as the name implies was written to provide speed optimized
data/ext/ox/dump.c CHANGED
@@ -702,8 +702,8 @@ dump_hash(VALUE key, VALUE value, Out out) {
702
702
 
703
703
  static void
704
704
  dump_gen_doc(VALUE obj, unsigned int depth, Out out) {
705
- VALUE attrs = rb_ivar_get(obj, attributes_id);
706
- VALUE nodes = rb_ivar_get(obj, nodes_id);
705
+ VALUE attrs = rb_attr_get(obj, attributes_id);
706
+ VALUE nodes = rb_attr_get(obj, nodes_id);
707
707
 
708
708
  dump_value(out, "<?xml", 5);
709
709
  if (Qnil != attrs) {
@@ -717,9 +717,9 @@ dump_gen_doc(VALUE obj, unsigned int depth, Out out) {
717
717
 
718
718
  static void
719
719
  dump_gen_element(VALUE obj, unsigned int depth, Out out) {
720
- VALUE rname = rb_ivar_get(obj, value_id);
721
- VALUE attrs = rb_ivar_get(obj, attributes_id);
722
- VALUE nodes = rb_ivar_get(obj, nodes_id);
720
+ VALUE rname = rb_attr_get(obj, value_id);
721
+ VALUE attrs = rb_attr_get(obj, attributes_id);
722
+ VALUE nodes = rb_attr_get(obj, nodes_id);
723
723
  const char *name = StringValuePtr(rname);
724
724
  long nlen = RSTRING_LEN(rname);
725
725
  size_t size;
@@ -817,7 +817,7 @@ static void
817
817
  dump_gen_val_node(VALUE obj, unsigned int depth,
818
818
  const char *pre, size_t plen,
819
819
  const char *suf, size_t slen, Out out) {
820
- VALUE v = rb_ivar_get(obj, value_id);
820
+ VALUE v = rb_attr_get(obj, value_id);
821
821
  const char *val;
822
822
  size_t vlen;
823
823
  size_t size;
data/ext/ox/ox.c CHANGED
@@ -228,7 +228,6 @@ load_str(int argc, VALUE *argv, VALUE self) {
228
228
  * or Object depending on the options. Raises an exception if the XML is
229
229
  * malformed or the classes specified are not valid.
230
230
  * [file_path] file path to read the XML document from
231
- * [xml] XML String
232
231
  * [options] load options
233
232
  * [:mode] format expected
234
233
  * [:object] object format
data/lib/ox/element.rb CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Ox
3
- # An Element represents a element of an EML document. It has a name,
3
+ # An Element represents a element of an XML document. It has a name,
4
4
  # attributes, and sub-nodes.
5
5
  class Element < Node
6
6
 
@@ -17,28 +17,28 @@ module Ox
17
17
  # Returns the Element's nodes array. These are the sub-elements of this
18
18
  # Element.
19
19
  def nodes
20
- @nodes = [] if @nodes.nil?
20
+ @nodes = [] if !instance_variable_defined?(:@nodes) or @nodes.nil?
21
21
  @nodes
22
22
  end
23
23
 
24
24
  # Appends a Node to the Element's nodes array.
25
25
  # [node] Node to append to the nodes array
26
26
  def <<(node)
27
- @nodes = [] if @nodes.nil?
27
+ @nodes = [] if !instance_variable_defined?(:@nodes) or @nodes.nil?
28
28
  raise "argument to << must be a String or Ox::Node." unless node.is_a?(String) or node.is_a?(Node)
29
29
  @nodes << node
30
30
  end
31
31
 
32
32
  # Returns all the attributes of the Element as a Hash.
33
33
  def attributes
34
- @attributes = { } if @attributes.nil?
34
+ @attributes = { } if !instance_variable_defined?(:@attributes) or @attributes.nil?
35
35
  @attributes
36
36
  end
37
37
 
38
38
  # Returns the value of an attribute.
39
39
  # [attr] attribute name or key to return the value for
40
40
  def [](attr)
41
- return nil unless @attributes.is_a?(Hash)
41
+ return nil unless instance_variable_defined?(:@attributes) and @attributes.is_a?(Hash)
42
42
  @attributes[attr] or (attr.is_a?(String) ? @attributes[attr.to_sym] : @attributes[attr.to_s])
43
43
  end
44
44
 
@@ -47,7 +47,7 @@ module Ox
47
47
  # [value] value for the attribute
48
48
  def []=(attr, value)
49
49
  raise "argument to [] must be a Symbol or a String." unless attr.is_a?(Symbol) or attr.is_a?(String)
50
- @attributes = { } if @attributes.nil?
50
+ @attributes = { } if !instance_variable_defined?(:@attributes) or @attributes.nil?
51
51
  @attributes[attr] = value.to_s
52
52
  end
53
53
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ox
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.0
5
+ version: 1.0.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Peter Ohler
@@ -20,7 +20,7 @@ executables: []
20
20
  extensions:
21
21
  - ext/ox/extconf.rb
22
22
  extra_rdoc_files:
23
- - README
23
+ - README.rdoc
24
24
  files:
25
25
  - lib/ox/cdata.rb
26
26
  - lib/ox/comment.rb
@@ -72,14 +72,14 @@ files:
72
72
  - test/test.rb
73
73
  - test/Sample.graffle
74
74
  - LICENSE
75
- - README
75
+ - README.rdoc
76
76
  homepage: http://www.ohler.com/ox
77
77
  licenses: []
78
78
 
79
79
  post_install_message:
80
80
  rdoc_options:
81
81
  - --main
82
- - README
82
+ - README.rdoc
83
83
  require_paths:
84
84
  - lib
85
85
  - ext