ox 2.14.0 → 2.14.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -1
- data/README.md +2 -7
- data/ext/ox/builder.c +7 -3
- data/ext/ox/dump.c +1 -1
- data/ext/ox/gen_load.c +2 -2
- data/ext/ox/obj_load.c +21 -18
- data/lib/ox/hasattrs.rb +9 -2
- data/lib/ox/version.rb +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3288687ada02ee5a8c19fbde18da50329577718b7db9650a3cf544e423d3c20
|
4
|
+
data.tar.gz: 711f74754b5e417028c8b6c1956eda6c6483ca7a1ce906bbdb64a60c36169de4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ed4c311f6e5100b36db59aa46eaf5870479bee44ac733bd844591b87205da49437f715c504f0e048a73e7c0f82c953e74e5fe08772a723561c7b2c5ec30ef20
|
7
|
+
data.tar.gz: 2149589a87c214dbbc5b999c4ae3123a106813d453b1f0e9c9b387d2356668d6b84de964b0e82a47f695810a776cb5e9960490ca6d391a4c77cbb1b6c8a39204
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,36 @@
|
|
2
2
|
|
3
3
|
All changes to the Ox gem are documented here. Releases follow semantic versioning.
|
4
4
|
|
5
|
-
## [
|
5
|
+
## [2.14.5] - 2021-06-04
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
|
9
|
+
- Fixed RDoc for for Ox::Builder.
|
10
|
+
|
11
|
+
## [2.14.4] - 2021-03-19
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
|
15
|
+
- Really fixed code issue around HAVE_RB_ENC_ASSOCIATE.
|
16
|
+
|
17
|
+
## [2.14.3] - 2021-03-12
|
18
|
+
|
19
|
+
### Fixed
|
20
|
+
|
21
|
+
- Code issue around HAVE_RB_ENC_ASSOCIATE fixed.
|
22
|
+
|
23
|
+
## [2.14.2] - 2021-03-07
|
24
|
+
|
25
|
+
### Fixed
|
26
|
+
|
27
|
+
- Attribute keys for setting attributes no longer create seemily
|
28
|
+
duplicates if symbol and string keys are mixed.
|
29
|
+
|
30
|
+
## [2.14.1] - 2021-01-11
|
31
|
+
|
32
|
+
### Fixed
|
33
|
+
|
34
|
+
- In Ruby 3.0 Range objects are frozen. This version allows Ranges to be created on load.
|
6
35
|
|
7
36
|
## [2.14.0] - 2020-12-15
|
8
37
|
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# Ox gem
|
2
2
|
A fast XML parser and Object marshaller as a Ruby gem.
|
3
3
|
|
4
|
-
[![Build
|
5
|
-
[![Financial Contributors on Open Collective](https://opencollective.com/ohler/all/badge.svg?label=financial+contributors)](https://opencollective.com/ohler)
|
4
|
+
[![Build status](https://ci.appveyor.com/api/projects/status/pg2w4wspbrflbi8c?svg=true)](https://ci.appveyor.com/project/ohler55/ox)
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
gem install ox
|
@@ -17,10 +16,6 @@ A fast XML parser and Object marshaller as a Ruby gem.
|
|
17
16
|
|
18
17
|
*RubyGems* *repo*: https://rubygems.org/gems/ox
|
19
18
|
|
20
|
-
## Follow @oxgem on Twitter
|
21
|
-
|
22
|
-
[Follow @peterohler on Twitter](http://twitter.com/#!/peterohler) for announcements and news about the Ox gem.
|
23
|
-
|
24
19
|
## Support
|
25
20
|
|
26
21
|
[Get supported Ox with a Tidelift Subscription.](https://tidelift.com/subscription/pkg/rubygems-ox?utm_source=rubygems-ox&utm_medium=referral&utm_campaign=readme) Security updates are [supported](https://tidelift.com/security).
|
@@ -79,7 +74,7 @@ callbacks. Unlike Nokogiri and LibXML, Ox can be tuned to use only the SAX
|
|
79
74
|
callbacks that are of interest to the caller. (See the perf_sax.rb file for an
|
80
75
|
example.)
|
81
76
|
|
82
|
-
Ox is compatible with Ruby
|
77
|
+
Ox is compatible with Ruby 2.3, 2.4, 2.5, 2.6, 2.7, 3.0.
|
83
78
|
|
84
79
|
### Object Dump Sample:
|
85
80
|
|
data/ext/ox/builder.c
CHANGED
@@ -898,8 +898,7 @@ builder_pos(VALUE self) {
|
|
898
898
|
*
|
899
899
|
* Closes the current element.
|
900
900
|
*/
|
901
|
-
static VALUE
|
902
|
-
builder_pop(VALUE self) {
|
901
|
+
static VALUE builder_pop(VALUE self) {
|
903
902
|
pop((Builder)DATA_PTR(self));
|
904
903
|
|
905
904
|
return Qnil;
|
@@ -921,7 +920,12 @@ builder_close(VALUE self) {
|
|
921
920
|
*
|
922
921
|
* An XML builder.
|
923
922
|
*/
|
924
|
-
void
|
923
|
+
void
|
924
|
+
ox_init_builder(VALUE ox) {
|
925
|
+
#if 0
|
926
|
+
// Just for rdoc.
|
927
|
+
ox = rb_define_module("Ox");
|
928
|
+
#endif
|
925
929
|
builder_class = rb_define_class_under(ox, "Builder", rb_cObject);
|
926
930
|
rb_define_module_function(builder_class, "new", builder_new, -1);
|
927
931
|
rb_define_module_function(builder_class, "file", builder_file, -1);
|
data/ext/ox/dump.c
CHANGED
@@ -838,7 +838,7 @@ dump_obj(ID aid, VALUE obj, int depth, Out out) {
|
|
838
838
|
out->w_start(out, &e);
|
839
839
|
|
840
840
|
for (i = 0; i < cnt; i++) {
|
841
|
-
VALUE v = RSTRUCT_GET(obj, i);
|
841
|
+
VALUE v = RSTRUCT_GET(obj, (int)(i));
|
842
842
|
dump_obj(rb_intern(ulong2str(i, num_buf + sizeof(num_buf) - 1)), v, d2, out);
|
843
843
|
}
|
844
844
|
out->w_end(out, &e);
|
data/ext/ox/gen_load.c
CHANGED
@@ -116,18 +116,18 @@ create_prolog_doc(PInfo pi, const char *target, Attr attrs) {
|
|
116
116
|
#endif
|
117
117
|
rb_hash_aset(ah, sym, rb_str_new2(attrs->value));
|
118
118
|
} else {
|
119
|
+
#if HAVE_RB_ENC_ASSOCIATE
|
119
120
|
volatile VALUE rstr = rb_str_new2(attrs->name);
|
120
121
|
|
121
|
-
#if HAVE_RB_ENC_ASSOCIATE
|
122
122
|
if (0 != pi->options->rb_enc) {
|
123
123
|
rb_enc_associate(rstr, pi->options->rb_enc);
|
124
124
|
}
|
125
125
|
rb_hash_aset(ah, rstr, rb_str_new2(attrs->value));
|
126
|
+
#endif
|
126
127
|
}
|
127
128
|
if (0 == strcmp("encoding", attrs->name)) {
|
128
129
|
pi->options->rb_enc = rb_enc_find(attrs->value);
|
129
130
|
}
|
130
|
-
#endif
|
131
131
|
}
|
132
132
|
nodes = rb_ary_new();
|
133
133
|
rb_ivar_set(doc, ox_attributes_id, ah);
|
data/ext/ox/obj_load.c
CHANGED
@@ -42,10 +42,10 @@ static void fill_indent(PInfo pi, char *buf, size_t size);
|
|
42
42
|
|
43
43
|
|
44
44
|
struct _parseCallbacks _ox_obj_callbacks = {
|
45
|
-
instruct,
|
46
|
-
0,
|
47
|
-
0,
|
48
|
-
0,
|
45
|
+
instruct, // instruct,
|
46
|
+
0, // add_doctype,
|
47
|
+
0, // add_comment,
|
48
|
+
0, // add_cdata,
|
49
49
|
add_text,
|
50
50
|
add_element,
|
51
51
|
end_element,
|
@@ -128,7 +128,7 @@ resolve_classname(VALUE mod, const char *class_name, Effort effort, VALUE base_c
|
|
128
128
|
break;
|
129
129
|
case StrictEffort:
|
130
130
|
default:
|
131
|
-
|
131
|
+
// raise an error if name is not defined
|
132
132
|
clas = rb_const_get_at(mod, ci);
|
133
133
|
break;
|
134
134
|
}
|
@@ -183,7 +183,7 @@ parse_ulong(const char *s, PInfo pi) {
|
|
183
183
|
return ULONG2NUM(n);
|
184
184
|
}
|
185
185
|
|
186
|
-
|
186
|
+
// 2010-07-09T10:47:45.895826162+09:00
|
187
187
|
inline static VALUE
|
188
188
|
parse_time(const char *text, VALUE clas) {
|
189
189
|
VALUE t;
|
@@ -559,7 +559,7 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
|
|
559
559
|
printf("%s%s\n", indent, buf);
|
560
560
|
}
|
561
561
|
}
|
562
|
-
if (helper_stack_empty(&pi->helpers)) {
|
562
|
+
if (helper_stack_empty(&pi->helpers)) { // top level object
|
563
563
|
if (0 != (id = get_id_from_attrs(pi, attrs))) {
|
564
564
|
pi->circ_array = circ_array_new();
|
565
565
|
}
|
@@ -580,7 +580,7 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
|
|
580
580
|
h->obj = Qfalse;
|
581
581
|
break;
|
582
582
|
case StringCode:
|
583
|
-
|
583
|
+
// h->obj will be replaced by add_text if it is called
|
584
584
|
h->obj = ox_empty_string;
|
585
585
|
if (0 != pi->circ_array) {
|
586
586
|
pi->id = get_id_from_attrs(pi, attrs);
|
@@ -597,8 +597,8 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
|
|
597
597
|
case ComplexCode:
|
598
598
|
case DateCode:
|
599
599
|
case TimeCode:
|
600
|
-
case RationalCode:
|
601
|
-
|
600
|
+
case RationalCode: // sub elements read next
|
601
|
+
// value will be read in the following add_text
|
602
602
|
h->obj = Qundef;
|
603
603
|
break;
|
604
604
|
case String64Code:
|
@@ -620,7 +620,7 @@ add_element(PInfo pi, const char *ename, Attr attrs, int hasChildren) {
|
|
620
620
|
}
|
621
621
|
break;
|
622
622
|
case RangeCode:
|
623
|
-
h->obj =
|
623
|
+
h->obj = rb_ary_new_from_args(3, Qnil, Qnil, Qfalse);
|
624
624
|
break;
|
625
625
|
case RawCode:
|
626
626
|
if (hasChildren) {
|
@@ -700,12 +700,15 @@ end_element(PInfo pi, const char *ename) {
|
|
700
700
|
Helper ph = helper_stack_peek(&pi->helpers);
|
701
701
|
|
702
702
|
if (ox_empty_string == h->obj) {
|
703
|
-
|
703
|
+
// special catch for empty strings
|
704
704
|
h->obj = rb_str_new2("");
|
705
|
-
}
|
706
|
-
if (Qundef == h->obj) {
|
705
|
+
} else if (Qundef == h->obj) {
|
707
706
|
set_error(&pi->err, "Invalid element for object mode", pi->str, pi->s);
|
708
707
|
return;
|
708
|
+
} else if (RangeCode == h->type) { // Expect an array of 3 elements.
|
709
|
+
const VALUE *ap = RARRAY_PTR(h->obj);
|
710
|
+
|
711
|
+
h->obj = rb_range_new(*ap, *(ap + 1), Qtrue == *(ap + 2));
|
709
712
|
}
|
710
713
|
pi->obj = h->obj;
|
711
714
|
if (0 != ph) {
|
@@ -740,11 +743,11 @@ end_element(PInfo pi, const char *ename) {
|
|
740
743
|
break;
|
741
744
|
case RangeCode:
|
742
745
|
if (ox_beg_id == h->var) {
|
743
|
-
|
746
|
+
rb_ary_store(ph->obj, 0, h->obj);
|
744
747
|
} else if (ox_end_id == h->var) {
|
745
|
-
|
748
|
+
rb_ary_store(ph->obj, 1, h->obj);
|
746
749
|
} else if (ox_excl_id == h->var) {
|
747
|
-
|
750
|
+
rb_ary_store(ph->obj, 2, h->obj);
|
748
751
|
} else {
|
749
752
|
set_error(&pi->err, "Invalid range attribute", pi->str, pi->s);
|
750
753
|
return;
|
@@ -903,7 +906,7 @@ parse_xsd_time(const char *text, VALUE clas) {
|
|
903
906
|
#endif
|
904
907
|
}
|
905
908
|
|
906
|
-
|
909
|
+
// debug functions
|
907
910
|
static void
|
908
911
|
fill_indent(PInfo pi, char *buf, size_t size) {
|
909
912
|
size_t cnt;
|
data/lib/ox/hasattrs.rb
CHANGED
@@ -13,7 +13,7 @@ module Ox
|
|
13
13
|
@attributes = { } if !instance_variable_defined?(:@attributes) or @attributes.nil?
|
14
14
|
@attributes
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
# Returns the value of an attribute.
|
18
18
|
# - +attr+ [Symbol|String] attribute name or key to return the value for
|
19
19
|
def [](attr)
|
@@ -27,9 +27,16 @@ module Ox
|
|
27
27
|
def []=(attr, value)
|
28
28
|
raise "argument to [] must be a Symbol or a String." unless attr.is_a?(Symbol) or attr.is_a?(String)
|
29
29
|
@attributes = { } if !instance_variable_defined?(:@attributes) or @attributes.nil?
|
30
|
+
a_str = attr.to_s
|
31
|
+
a_sym = attr.to_sym
|
32
|
+
if @attributes.has_key?(a_str)
|
33
|
+
attr = a_str
|
34
|
+
elsif @attributes.has_key?(a_sym)
|
35
|
+
attr = a_sym
|
36
|
+
end
|
30
37
|
@attributes[attr] = value.to_s
|
31
38
|
end
|
32
|
-
|
39
|
+
|
33
40
|
# Handles the 'easy' API that allows navigating a simple XML by
|
34
41
|
# referencing attributes by name.
|
35
42
|
# - +id+ [Symbol] element or attribute name
|
data/lib/ox/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.14.
|
4
|
+
version: 2.14.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "A fast XML parser and object serializer that uses only standard C lib.\n\nOptimized
|
14
14
|
XML (Ox), as the name implies was written to provide speed optimized\nXML handling.
|
@@ -81,9 +81,12 @@ rdoc_options:
|
|
81
81
|
- "--main"
|
82
82
|
- README.md
|
83
83
|
- "--title"
|
84
|
-
- Ox
|
84
|
+
- Ox
|
85
85
|
- "--exclude"
|
86
86
|
- extconf.rb
|
87
|
+
- lib
|
88
|
+
- ext/ox
|
89
|
+
- README.md
|
87
90
|
require_paths:
|
88
91
|
- lib
|
89
92
|
- ext
|
@@ -98,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
101
|
- !ruby/object:Gem::Version
|
99
102
|
version: '0'
|
100
103
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
104
|
+
rubygems_version: 3.2.3
|
102
105
|
signing_key:
|
103
106
|
specification_version: 4
|
104
107
|
summary: A fast XML parser and object serializer.
|