oga 2.15-java → 3.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 23b316d99884b02f345750c4f2f68bd245891c67
4
- data.tar.gz: 62b7a2f7a2d73b548047dc79865f72b58ae5d806
2
+ SHA256:
3
+ metadata.gz: bfae6d81e50c59fe3b0cbf4a5f6028c749820b6d93bf30c7f5efb08419d0cbb3
4
+ data.tar.gz: 8f9ad335e6b387f247ddcde93d74c4c2c75a00ad09148b902628728a8ecdce97
5
5
  SHA512:
6
- metadata.gz: 954fe9a4397b7d6b274a12963df19c9206ae377b51879c83ae63e7e9ac51e0e00599686e2e63dfc919d3c75f4a8cfe11c81e12d3c84320196ec38f1c4d954975
7
- data.tar.gz: 27bb50ab795cde9b92fa2e84293379e0b68fc0df86a407f76c7765a4294f10274c1a1426fd86fbbddca5988b4743b27944b1bcba60e66787495b7755ad6e6275
6
+ metadata.gz: 298c8bd91c7fd954956e2757cde6fa1b832dc16d0896553dd4684b4bdcfa72c39b6128dc56b1a9dd2864057b0c964c82d810d49e32d276ebb19e68a27c110aeb
7
+ data.tar.gz: 2c46594d335c3b31260bce5125463caf7a83249034d438ee96daa001e441c8bf773fc99c529547d114d0734ea190083110809ece7260c06b684f1118500b49c9
data/README.md CHANGED
@@ -172,9 +172,9 @@ Querying a document using a namespace:
172
172
 
173
173
  | Ruby | Required | Recommended |
174
174
  |:---------|:--------------|:------------|
175
- | MRI | >= 1.9.3 | >= 2.1.2 |
176
- | Rubinius | >= 2.2 | >= 2.2.10 |
175
+ | MRI | >= 2.3.0 | >= 2.6.0 |
177
176
  | JRuby | >= 1.7 | >= 1.7.12 |
177
+ | Rubinius | Not supported | |
178
178
  | Maglev | Not supported | |
179
179
  | Topaz | Not supported | |
180
180
  | mruby | Not supported | |
data/lib/liboga.jar CHANGED
Binary file
data/lib/oga/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Oga
2
- VERSION = '2.15'
2
+ VERSION = '3.0'
3
3
  end # Oga
@@ -10,6 +10,7 @@ module Oga
10
10
  # document = Oga.parse_xml <<-EOF
11
11
  # <people>
12
12
  # <person age="25">Alice</person>
13
+ # <ns:person xmlns:ns="http://example.net">Bob</ns:person>
13
14
  # </people>
14
15
  # EOF
15
16
  #
@@ -25,15 +26,23 @@ module Oga
25
26
  #
26
27
  # document.xpath('people/person[@age = $age]', 'age' => 25)
27
28
  #
29
+ # Using namespace aliases:
30
+ #
31
+ # namespaces = {'example' => 'http://example.net'}
32
+ # document.xpath('people/example:person', namespaces: namespaces)
33
+ #
28
34
  # @param [String] expression The XPath expression to run.
29
35
  #
30
36
  # @param [Hash] variables Variables to bind. The keys of this Hash should
31
37
  # be String values.
32
38
  #
39
+ # @param [Hash] namespaces Namespace aliases. The keys of this Hash should
40
+ # be String values.
41
+ #
33
42
  # @return [Oga::XML::NodeSet]
34
- def xpath(expression, variables = {})
43
+ def xpath(expression, variables = {}, namespaces: nil)
35
44
  ast = XPath::Parser.parse_with_cache(expression)
36
- block = XPath::Compiler.compile_with_cache(ast)
45
+ block = XPath::Compiler.compile_with_cache(ast, namespaces: namespaces)
37
46
 
38
47
  block.call(self, variables)
39
48
  end
@@ -42,12 +42,16 @@ module Oga
42
42
  # Compiles and caches an AST.
43
43
  #
44
44
  # @see [#compile]
45
- def self.compile_with_cache(ast)
46
- CACHE.get_or_set(ast) { new.compile(ast) }
45
+ def self.compile_with_cache(ast, namespaces: nil)
46
+ cache_key = namespaces ? [ast, namespaces] : ast
47
+ CACHE.get_or_set(cache_key) { new(namespaces: namespaces).compile(ast) }
47
48
  end
48
49
 
49
- def initialize
50
+ # @param [Hash] namespaces
51
+ def initialize(namespaces: nil)
50
52
  reset
53
+
54
+ @namespaces = namespaces
51
55
  end
52
56
 
53
57
  # Resets the internal state.
@@ -1385,7 +1389,23 @@ module Oga
1385
1389
  end
1386
1390
 
1387
1391
  if ns and ns != STAR
1388
- ns_match = input.namespace_name.eq(string(ns))
1392
+ if @namespaces
1393
+ ns_uri = @namespaces[ns]
1394
+ ns_match =
1395
+ if ns_uri
1396
+ input.namespace.and(input.namespace.uri.eq(string(ns_uri)))
1397
+ else
1398
+ self.false
1399
+ end
1400
+ else
1401
+ ns_match =
1402
+ if ns == XML::Element::XMLNS_PREFIX
1403
+ input
1404
+ else
1405
+ input.namespace_name.eq(string(ns))
1406
+ end
1407
+ end
1408
+
1389
1409
  condition = condition ? condition.and(ns_match) : ns_match
1390
1410
  end
1391
1411
 
data/oga.gemspec CHANGED
@@ -29,8 +29,7 @@ Gem::Specification.new do |s|
29
29
  s.extensions = ['ext/c/extconf.rb']
30
30
  end
31
31
 
32
- s.has_rdoc = 'yard'
33
- s.required_ruby_version = '>= 1.9.3'
32
+ s.required_ruby_version = '>= 2.3.0'
34
33
 
35
34
  s.add_dependency 'ast'
36
35
  s.add_dependency 'ruby-ll', '~> 2.1'
metadata CHANGED
@@ -1,141 +1,141 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oga
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.15'
4
+ version: '3.0'
5
5
  platform: java
6
6
  authors:
7
7
  - Yorick Peterse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-11 00:00:00.000000000 Z
11
+ date: 2019-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ast
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
18
  version: '0'
19
+ name: ast
20
+ prerelease: false
21
+ type: :runtime
20
22
  version_requirements: !ruby/object:Gem::Requirement
21
23
  requirements:
22
24
  - - ">="
23
25
  - !ruby/object:Gem::Version
24
26
  version: '0'
25
- prerelease: false
26
- type: :runtime
27
27
  - !ruby/object:Gem::Dependency
28
- name: ruby-ll
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
32
  version: '2.1'
33
+ name: ruby-ll
34
+ prerelease: false
35
+ type: :runtime
34
36
  version_requirements: !ruby/object:Gem::Requirement
35
37
  requirements:
36
38
  - - "~>"
37
39
  - !ruby/object:Gem::Version
38
40
  version: '2.1'
39
- prerelease: false
40
- type: :runtime
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - ">="
46
45
  - !ruby/object:Gem::Version
47
46
  version: '0'
47
+ name: rake
48
+ prerelease: false
49
+ type: :development
48
50
  version_requirements: !ruby/object:Gem::Requirement
49
51
  requirements:
50
52
  - - ">="
51
53
  - !ruby/object:Gem::Version
52
54
  version: '0'
53
- prerelease: false
54
- type: :development
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - "~>"
60
59
  - !ruby/object:Gem::Version
61
60
  version: '3.0'
61
+ name: rspec
62
+ prerelease: false
63
+ type: :development
62
64
  version_requirements: !ruby/object:Gem::Requirement
63
65
  requirements:
64
66
  - - "~>"
65
67
  - !ruby/object:Gem::Version
66
68
  version: '3.0'
67
- prerelease: false
68
- type: :development
69
69
  - !ruby/object:Gem::Dependency
70
- name: yard
71
70
  requirement: !ruby/object:Gem::Requirement
72
71
  requirements:
73
72
  - - ">="
74
73
  - !ruby/object:Gem::Version
75
74
  version: '0'
75
+ name: yard
76
+ prerelease: false
77
+ type: :development
76
78
  version_requirements: !ruby/object:Gem::Requirement
77
79
  requirements:
78
80
  - - ">="
79
81
  - !ruby/object:Gem::Version
80
82
  version: '0'
81
- prerelease: false
82
- type: :development
83
83
  - !ruby/object:Gem::Dependency
84
- name: simplecov
85
84
  requirement: !ruby/object:Gem::Requirement
86
85
  requirements:
87
86
  - - ">="
88
87
  - !ruby/object:Gem::Version
89
88
  version: '0'
89
+ name: simplecov
90
+ prerelease: false
91
+ type: :development
90
92
  version_requirements: !ruby/object:Gem::Requirement
91
93
  requirements:
92
94
  - - ">="
93
95
  - !ruby/object:Gem::Version
94
96
  version: '0'
95
- prerelease: false
96
- type: :development
97
97
  - !ruby/object:Gem::Dependency
98
- name: kramdown
99
98
  requirement: !ruby/object:Gem::Requirement
100
99
  requirements:
101
100
  - - ">="
102
101
  - !ruby/object:Gem::Version
103
102
  version: '0'
103
+ name: kramdown
104
+ prerelease: false
105
+ type: :development
104
106
  version_requirements: !ruby/object:Gem::Requirement
105
107
  requirements:
106
108
  - - ">="
107
109
  - !ruby/object:Gem::Version
108
110
  version: '0'
109
- prerelease: false
110
- type: :development
111
111
  - !ruby/object:Gem::Dependency
112
- name: benchmark-ips
113
112
  requirement: !ruby/object:Gem::Requirement
114
113
  requirements:
115
114
  - - "~>"
116
115
  - !ruby/object:Gem::Version
117
116
  version: '2.0'
117
+ name: benchmark-ips
118
+ prerelease: false
119
+ type: :development
118
120
  version_requirements: !ruby/object:Gem::Requirement
119
121
  requirements:
120
122
  - - "~>"
121
123
  - !ruby/object:Gem::Version
122
124
  version: '2.0'
123
- prerelease: false
124
- type: :development
125
125
  - !ruby/object:Gem::Dependency
126
- name: rake-compiler
127
126
  requirement: !ruby/object:Gem::Requirement
128
127
  requirements:
129
128
  - - ">="
130
129
  - !ruby/object:Gem::Version
131
130
  version: '0'
131
+ name: rake-compiler
132
+ prerelease: false
133
+ type: :development
132
134
  version_requirements: !ruby/object:Gem::Requirement
133
135
  requirements:
134
136
  - - ">="
135
137
  - !ruby/object:Gem::Version
136
138
  version: '0'
137
- prerelease: false
138
- type: :development
139
139
  description: Oga is an XML/HTML parser written in Ruby.
140
140
  email: yorickpeterse@gmail.com
141
141
  executables: []
@@ -218,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
218
218
  requirements:
219
219
  - - ">="
220
220
  - !ruby/object:Gem::Version
221
- version: 1.9.3
221
+ version: 2.3.0
222
222
  required_rubygems_version: !ruby/object:Gem::Requirement
223
223
  requirements:
224
224
  - - ">="
@@ -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.6.14
229
+ rubygems_version: 2.7.10
230
230
  signing_key:
231
231
  specification_version: 4
232
232
  summary: Oga is an XML/HTML parser written in Ruby.