Module: Saxon::Loader
- Defined in:
- lib/saxon/loader.rb
Overview
The mechanism for adding the JARs for either the bundled Saxon HE, or an external Saxon HE/PE/EE version, into the CLASSPATH and requiring them.
Defined Under Namespace
Classes: MissingJarError, NoJarsError
Class Method Summary collapse
-
.jars_not_on_classpath? ⇒ Boolean
Are the Saxon jars missing from the Classpath?.
-
.jars_on_classpath? ⇒ Boolean
Are the Saxon JARs on the Classpath?.
-
.load!(saxon_home = nil) ⇒ true, false
Returns true if Saxon had not been loaded and is now, and false if Saxon was already loaded.
Class Method Details
.jars_not_on_classpath? ⇒ Boolean
Are the Saxon jars missing from the Classpath?
44 45 46 47 48 49 50 51 |
# File 'lib/saxon/loader.rb', line 44 def jars_not_on_classpath? begin Java::net.sf.saxon.s9api.Processor false rescue true end end |
.jars_on_classpath? ⇒ Boolean
Are the Saxon JARs on the Classpath?
55 56 57 |
# File 'lib/saxon/loader.rb', line 55 def jars_on_classpath? !jars_not_on_classpath? end |
.load!(saxon_home = nil) ⇒ true, false
Returns true if Saxon had not been loaded and is now, and false if Saxon was already loaded
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/saxon/loader.rb', line 63 def load!(saxon_home = nil) return false if instance_variable_defined?(:@saxon_loaded) && @saxon_loaded LOAD_SEMAPHORE.synchronize do if Saxon::S9API.const_defined?(:Processor) false else if jars_not_on_classpath? if saxon_home.nil? require 'saxon-rb_jars' else saxon_home = Pathname.new(saxon_home) raise NoJarsError, saxon_home unless saxon_home.directory? jars = [main_jar(saxon_home)].compact raise MissingJarError if jars.empty? jars += extra_jars(saxon_home) add_jars_to_classpath!(saxon_home, jars) end end require_relative 'jruby_bug_6197_workaround' @saxon_loaded = true true end end end |