Module: Julia::LibJulia::Finder
- Defined in:
- lib/julia/libjulia/finder.rb
Constant Summary collapse
- LIBPREFIX =
libprefix || 'lib'
- LIBSUFFIX =
libsuffix || 'so'
- DEFAULT_JULIA =
-'julia'
Class Method Summary collapse
- .find_libjulia(julia = nil) ⇒ Object
- .investigate_julia(julia = nil) ⇒ Object
- .julia_investigator_jl ⇒ Object
- .run_julia_investigator(julia_cmd) ⇒ Object
Class Method Details
.find_libjulia(julia = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/julia/libjulia/finder.rb', line 24 def find_libjulia(julia = nil) debug_report "find_libjulia(#{julia.inspect})" julia_cmd, julia_config = investigate_julia(julia) libpath = File.join(julia_config[:libdir], "libjulia.#{LIBSUFFIX}") if File.file? libpath begin return dlopen(libpath) rescue Fiddle::DLError debug_report "#{$!.class}: #{$!.}" else debug_report "Success to dlopen #{fullname}" end else debug_report "Unable to find #{fullname}" end raise Julia::JuliaNotFound end |
.investigate_julia(julia = nil) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/julia/libjulia/finder.rb', line 44 def investigate_julia(julia = nil) julia ||= DEFAULT_JULIA Array(julia).each do |julia_cmd| julia_config = run_julia_investigator(julia_cmd) return [julia_cmd, julia_config] unless julia_config.empty? end rescue debug_report "investigate_julia: (#{$!.class}) #{$!.}" raise Julia::JuliaNotFound else raise Julia::JuliaNotFound end |
.julia_investigator_jl ⇒ Object
76 77 78 |
# File 'lib/julia/libjulia/finder.rb', line 76 def julia_investigator_jl File.('../investigator.jl', __FILE__) end |
.run_julia_investigator(julia_cmd) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/julia/libjulia/finder.rb', line 57 def run_julia_investigator(julia_cmd) debug_report "run_julia_investigator(#{julia_cmd})" IO.popen({}, [julia_cmd, julia_investigator_jl], 'r') do |io| {}.tap do |config| io.each_line do |line| next unless line =~ /: / key, value = line.chomp.split(': ', 2) case value when 'true', 'false' value = (value == 'true') end config[key.to_sym] = value if value != 'nothing' end end end rescue Errno::ENOENT raise Julia::JuliaNotFound end |