oga 2.10 → 2.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/ext/c/extconf.rb +1 -1
- data/ext/c/lexer.c +6 -6
- data/lib/oga/version.rb +1 -1
- data/lib/oga/xml/attribute.rb +5 -4
- data/lib/oga/xml/element.rb +5 -4
- data/lib/oga/xml/sax_parser.rb +18 -14
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b540a9f445ed303bc177df0a6207bfb07d84c7e
|
4
|
+
data.tar.gz: c74ab206a3728fa865751932c7f9e5e08b11e107
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3df865a3fee82becc0d8ab5d390b4faf55ff44791297d22bdd599de1ca68419a88a1677e7354683e006cedb8fa3badc106d1ff063aae981c0e23bc72e101a656
|
7
|
+
data.tar.gz: cb434d0175f1e158dcdb964af3949966d9b1a0a7a24029e9359232b4f741109de182c8b3d0a1ad1ccf6906945082acd0a0a8f61b19b8b3bae19d1ddc3ac1ba0f
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# Oga
|
2
2
|
|
3
|
+
**NOTE:** my spare time is limited which means I am unable to dedicate a lot of
|
4
|
+
time on Oga. If you're interested in contributing to FOSS, please take a look at
|
5
|
+
the open issues and submit a pull request to address them where possible.
|
6
|
+
|
3
7
|
Oga is an XML/HTML parser written in Ruby. It provides an easy to use API for
|
4
8
|
parsing, modifying and querying documents (using XPath expressions). Oga does
|
5
9
|
not require system libraries such as libxml, making it easier and faster to
|
@@ -287,7 +291,7 @@ Currently there are a few existing parser out there, the most famous one being
|
|
287
291
|
|
288
292
|
The sad truth is that these existing libraries are problematic in their own
|
289
293
|
ways. Nokogiri for example is extremely unstable on Rubinius. On MRI it works
|
290
|
-
because of the non
|
294
|
+
because of the non concurrent nature of MRI, on JRuby it works because it's
|
291
295
|
implemented as Java. Nokogiri also uses libxml2 which is a massive beast of a
|
292
296
|
library, is not thread-safe and problematic to install on certain platforms
|
293
297
|
(apparently). I don't want to compile libxml2 every time I install Nokogiri
|
data/ext/c/extconf.rb
CHANGED
data/ext/c/lexer.c
CHANGED
@@ -1097,7 +1097,7 @@ tr79:
|
|
1097
1097
|
{te = p+1;{
|
1098
1098
|
callback_simple(id_on_string_dquote);
|
1099
1099
|
|
1100
|
-
{( state->stack)[( state->top)++] = 55;
|
1100
|
+
{( state->stack)[( state->top)++] = 55;goto st51;}
|
1101
1101
|
}}
|
1102
1102
|
goto st55;
|
1103
1103
|
tr80:
|
@@ -1105,7 +1105,7 @@ tr80:
|
|
1105
1105
|
{te = p+1;{
|
1106
1106
|
callback_simple(id_on_string_squote);
|
1107
1107
|
|
1108
|
-
{( state->stack)[( state->top)++] = 55;
|
1108
|
+
{( state->stack)[( state->top)++] = 55;goto st49;}
|
1109
1109
|
}}
|
1110
1110
|
goto st55;
|
1111
1111
|
tr81:
|
@@ -1450,7 +1450,7 @@ tr99:
|
|
1450
1450
|
{te = p+1;{
|
1451
1451
|
callback_simple(id_on_string_dquote);
|
1452
1452
|
|
1453
|
-
{( state->stack)[( state->top)++] = 68;
|
1453
|
+
{( state->stack)[( state->top)++] = 68;goto st51;}
|
1454
1454
|
}}
|
1455
1455
|
#line 61 "ext/ragel/base_lexer.rl"
|
1456
1456
|
{
|
@@ -1462,7 +1462,7 @@ tr100:
|
|
1462
1462
|
{te = p+1;{
|
1463
1463
|
callback_simple(id_on_string_squote);
|
1464
1464
|
|
1465
|
-
{( state->stack)[( state->top)++] = 68;
|
1465
|
+
{( state->stack)[( state->top)++] = 68;goto st49;}
|
1466
1466
|
}}
|
1467
1467
|
#line 61 "ext/ragel/base_lexer.rl"
|
1468
1468
|
{
|
@@ -1914,7 +1914,7 @@ tr128:
|
|
1914
1914
|
tr131:
|
1915
1915
|
#line 525 "ext/ragel/base_lexer.rl"
|
1916
1916
|
{te = p+1;{
|
1917
|
-
{( state->stack)[( state->top)++] = 80;
|
1917
|
+
{( state->stack)[( state->top)++] = 80;goto st75;}
|
1918
1918
|
}}
|
1919
1919
|
goto st80;
|
1920
1920
|
tr132:
|
@@ -2033,7 +2033,7 @@ tr140:
|
|
2033
2033
|
tr143:
|
2034
2034
|
#line 525 "ext/ragel/base_lexer.rl"
|
2035
2035
|
{te = p+1;{
|
2036
|
-
{( state->stack)[( state->top)++] = 84;
|
2036
|
+
{( state->stack)[( state->top)++] = 84;goto st75;}
|
2037
2037
|
}}
|
2038
2038
|
goto st84;
|
2039
2039
|
tr144:
|
data/lib/oga/version.rb
CHANGED
data/lib/oga/xml/attribute.rb
CHANGED
@@ -34,10 +34,11 @@ module Oga
|
|
34
34
|
# @option options [String] :value
|
35
35
|
# @option options [Oga::XML::Element] :element
|
36
36
|
def initialize(options = {})
|
37
|
-
@name
|
38
|
-
@value
|
39
|
-
@element
|
40
|
-
|
37
|
+
@name = options[:name]
|
38
|
+
@value = options[:value]
|
39
|
+
@element = options[:element]
|
40
|
+
@decoded = false
|
41
|
+
@namespace = nil
|
41
42
|
@namespace_name = options[:namespace_name]
|
42
43
|
end
|
43
44
|
|
data/lib/oga/xml/element.rb
CHANGED
@@ -34,10 +34,11 @@ module Oga
|
|
34
34
|
def initialize(options = {})
|
35
35
|
super
|
36
36
|
|
37
|
-
@name
|
38
|
-
@namespace_name
|
39
|
-
@attributes
|
40
|
-
@namespaces
|
37
|
+
@name = options[:name]
|
38
|
+
@namespace_name = options[:namespace_name]
|
39
|
+
@attributes = options[:attributes] || []
|
40
|
+
@namespaces = options[:namespaces] || {}
|
41
|
+
@available_namespaces = nil
|
41
42
|
|
42
43
|
link_attributes
|
43
44
|
register_namespaces_from_attributes
|
data/lib/oga/xml/sax_parser.rb
CHANGED
@@ -74,18 +74,7 @@ module Oga
|
|
74
74
|
super(*args)
|
75
75
|
end
|
76
76
|
|
77
|
-
#
|
78
|
-
instance_methods.grep(/^(on_|after_)/).each do |method|
|
79
|
-
eval <<-EOF, nil, __FILE__, __LINE__ + 1
|
80
|
-
def #{method}(*args)
|
81
|
-
run_callback(:#{method}, *args)
|
82
|
-
|
83
|
-
return
|
84
|
-
end
|
85
|
-
EOF
|
86
|
-
end
|
87
|
-
|
88
|
-
# Manually overwrite `on_element` so we can ensure that `after_element`
|
77
|
+
# Manually define `on_element` so we can ensure that `after_element`
|
89
78
|
# always receives the namespace and name.
|
90
79
|
#
|
91
80
|
# @see [Oga::XML::Parser#on_element]
|
@@ -96,7 +85,7 @@ module Oga
|
|
96
85
|
[namespace, name]
|
97
86
|
end
|
98
87
|
|
99
|
-
# Manually
|
88
|
+
# Manually define `after_element` so it can take a namespace and name.
|
100
89
|
# This differs a bit from the regular `after_element` which only takes an
|
101
90
|
# {Oga::XML::Element} instance.
|
102
91
|
#
|
@@ -107,7 +96,7 @@ module Oga
|
|
107
96
|
return
|
108
97
|
end
|
109
98
|
|
110
|
-
# Manually
|
99
|
+
# Manually define this method since for this one we _do_ want the
|
111
100
|
# return value so it can be passed to `on_element`.
|
112
101
|
#
|
113
102
|
# @see [Oga::XML::Parser#on_attribute]
|
@@ -157,6 +146,21 @@ module Oga
|
|
157
146
|
return
|
158
147
|
end
|
159
148
|
|
149
|
+
# Delegate remaining callbacks to the handler object.
|
150
|
+
existing_methods = instance_methods(false)
|
151
|
+
|
152
|
+
instance_methods.grep(/^(on_|after_)/).each do |method|
|
153
|
+
next if existing_methods.include?(method)
|
154
|
+
|
155
|
+
eval <<-EOF, nil, __FILE__, __LINE__ + 1
|
156
|
+
def #{method}(*args)
|
157
|
+
run_callback(:#{method}, *args)
|
158
|
+
|
159
|
+
return
|
160
|
+
end
|
161
|
+
EOF
|
162
|
+
end
|
163
|
+
|
160
164
|
private
|
161
165
|
|
162
166
|
# @return [TrueClass|FalseClass]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '2.
|
4
|
+
version: '2.11'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yorick Peterse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|
@@ -226,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
226
|
version: '0'
|
227
227
|
requirements: []
|
228
228
|
rubyforge_project:
|
229
|
-
rubygems_version: 2.
|
229
|
+
rubygems_version: 2.6.13
|
230
230
|
signing_key:
|
231
231
|
specification_version: 4
|
232
232
|
summary: Oga is an XML/HTML parser written in Ruby.
|