oga 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -6
- data/lib/oga.rb +1 -0
- data/lib/oga/version.rb +1 -1
- data/lib/oga/xpath/compiler.rb +6 -1
- data/lib/oga/xpath/context.rb +17 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0230f47af567902efa1575a8447774e4a35fb50c
|
4
|
+
data.tar.gz: 5cae5f489883d8c8e9f76309e8c1e9d9e8e7c9cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 092aca9cb1b728a572e397efde33e2a4a9897e11938aa34638bbcb0d361ebc7af9d85962920c898ecfe09b531d7a78667471a7f6aa7e776b4a650ddadbf72bf0
|
7
|
+
data.tar.gz: ba98f9c6d4b9bcbdc7356678b00543e31ecdb4fd0657c61efd998a015a9f7e3e9564d577f5950237ecd9a173121cc3349a310431cc126f34797659b03b73c535
|
data/README.md
CHANGED
@@ -177,13 +177,17 @@ process and bundled inside the Gem itself.
|
|
177
177
|
|
178
178
|
## Thread Safety
|
179
179
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
180
|
+
Oga does not use a unsynchronized global mutable state. As a result of this you
|
181
|
+
can parse/create documents concurrently without any problems. Modifying
|
182
|
+
documents concurrently can lead to bugs as these operations are not
|
183
|
+
synchronized.
|
184
184
|
|
185
|
-
|
186
|
-
|
185
|
+
Some querying operations will cache data in instance variables, without
|
186
|
+
synchronization. An example is `Oga::XML::Element#namespace` which will cache an
|
187
|
+
element's namespace after the first call.
|
188
|
+
|
189
|
+
In general it's recommended to _not_ use the same document in multiple threads
|
190
|
+
at the same time.
|
187
191
|
|
188
192
|
## Namespace Support
|
189
193
|
|
data/lib/oga.rb
CHANGED
data/lib/oga/version.rb
CHANGED
data/lib/oga/xpath/compiler.rb
CHANGED
@@ -12,6 +12,11 @@ module Oga
|
|
12
12
|
# @return [Oga::LRU]
|
13
13
|
CACHE = LRU.new
|
14
14
|
|
15
|
+
# Context for compiled Procs. As compiled Procs do not mutate the
|
16
|
+
# enclosing environment we can just re-use the same instance without
|
17
|
+
# synchronization.
|
18
|
+
CONTEXT = Context.new
|
19
|
+
|
15
20
|
# Wildcard for node names/namespace prefixes.
|
16
21
|
STAR = '*'
|
17
22
|
|
@@ -86,7 +91,7 @@ module Oga
|
|
86
91
|
generator = Ruby::Generator.new
|
87
92
|
source = generator.process(proc_ast)
|
88
93
|
|
89
|
-
|
94
|
+
CONTEXT.evaluate(source)
|
90
95
|
ensure
|
91
96
|
reset
|
92
97
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Oga
|
2
|
+
module XPath
|
3
|
+
# Class used as the context for compiled XPath Procs.
|
4
|
+
#
|
5
|
+
# The binding of this class is used for the binding of Procs compiled by
|
6
|
+
# {Compiler}. Not using a specific binding would result in the procs
|
7
|
+
# using the binding of {Compiler#compile}, which could lead to race
|
8
|
+
# conditions.
|
9
|
+
class Context
|
10
|
+
# @param [String] string
|
11
|
+
# @return [Proc]
|
12
|
+
def evaluate(string)
|
13
|
+
binding.eval(string)
|
14
|
+
end
|
15
|
+
end # Context
|
16
|
+
end # XPath
|
17
|
+
end # Oga
|
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: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yorick Peterse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ast
|
@@ -199,6 +199,7 @@ files:
|
|
199
199
|
- lib/oga/xml/traversal.rb
|
200
200
|
- lib/oga/xml/xml_declaration.rb
|
201
201
|
- lib/oga/xpath/compiler.rb
|
202
|
+
- lib/oga/xpath/context.rb
|
202
203
|
- lib/oga/xpath/conversion.rb
|
203
204
|
- lib/oga/xpath/lexer.rb
|
204
205
|
- lib/oga/xpath/parser.rb
|