oga 1.3.0-java → 1.3.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b02ebf4182fe4de0d8b0fe875352a7f87300c19c
4
- data.tar.gz: b190fec4be054b8acb23ba2b4e8b3d212a066ad7
3
+ metadata.gz: 3608b688e55076f115741bdb807801c071e30e60
4
+ data.tar.gz: 11f53bdfb9476c8f4fc1bb34d87492a735558924
5
5
  SHA512:
6
- metadata.gz: 096867f90ece07e4e6aa55d92074a3f5bcfe6626fb652b0f43f5955b0712dd27a7636630b3c003336222f61a5105b3e49a2538ec403be4f23927593895d96d0f
7
- data.tar.gz: 939678d51de4fe44eda8dada5d8b6e48a6cddb5b5f76b796501eb0c3dc643bae8a664b8cfe5a85c16194517cde982f22160995e79532f59a5a96ee92e7ae4d66
6
+ metadata.gz: ce3a13a06251539d4d9d16ea8095529606fb6d7a727c49ff8487c15bd62ee4233343e4ef8da5fd11323057607ad18421f8327830d36703b7575311217156625e
7
+ data.tar.gz: 6156e9bd4ec21b89974cf1e40406938164028c95aeac63207dffe48edbd3689bf3411cd3877e385fb7b38c790676b105c838db6e9eac8b614ae7cc1837b77561
data/README.md CHANGED
@@ -177,13 +177,17 @@ process and bundled inside the Gem itself.
177
177
 
178
178
  ## Thread Safety
179
179
 
180
- Documents parsed using Oga are thread-safe as long as they are not modified by
181
- multiple threads at the same time. Querying documents using XPath can be done by
182
- multiple threads just fine. Write operations, such as removing attributes, are
183
- _not_ thread-safe and should not be done by multiple threads at once.
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
- It is advised that you do not share parsed documents between threads unless you
186
- _really_ have to.
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/liboga.jar CHANGED
Binary file
data/lib/oga.rb CHANGED
@@ -55,6 +55,7 @@ require 'oga/ruby/generator'
55
55
 
56
56
  require 'oga/xpath/lexer'
57
57
  require 'oga/xpath/parser'
58
+ require 'oga/xpath/context'
58
59
  require 'oga/xpath/compiler'
59
60
  require 'oga/xpath/conversion'
60
61
 
data/lib/oga/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Oga
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end # Oga
@@ -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
- eval(source)
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.0
4
+ version: 1.3.1
5
5
  platform: java
6
6
  authors:
7
7
  - Yorick Peterse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-06 00:00:00.000000000 Z
11
+ date: 2015-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -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