Module: YAMLScript::LibYAMLScript
- Extended by:
- Fiddle::Importer
- Defined in:
- lib/yamlscript.rb
Overview
A low-level interface to the native library
Class Method Summary collapse
- .extension ⇒ Object
-
.find_libyamlscript_path ⇒ Object
Find the libyamlscript shared library file path.
-
.ld_library_paths ⇒ Object
Returns an array of library paths extracted from the LD_LIBRARY_PATH environment variable.
- .libyamlscript_name ⇒ Object
Class Method Details
.extension ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/yamlscript.rb', line 25 def self.extension case RUBY_PLATFORM when /darwin/ 'dylib' when /linux/ 'so' else raise Error, "Unsupported platform #{RUBY_PLATFORM} for yamlscript." end end |
.find_libyamlscript_path ⇒ Object
Find the libyamlscript shared library file path
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/yamlscript.rb', line 52 def self.find_libyamlscript_path name = libyamlscript_name path = ld_library_paths.map { |dir| File.join(dir, name) }.detect { |file| File.exist?(file) } vers = YAMLSCRIPT_VERSION raise Error, <<-ERROR unless path Shared library file `#{name}` not found Try: curl https://yamlscript.org/install | VERSION=#{vers} LIB=1 bash See: https://github.com/yaml/yamlscript/wiki/Installing-YAMLScript ERROR path end |
.ld_library_paths ⇒ Object
Returns an array of library paths extracted from the LD_LIBRARY_PATH environment variable. If the environment variable is not set will return an array with ‘/usr/local/lib` only.
44 45 46 47 48 49 |
# File 'lib/yamlscript.rb', line 44 def self.ld_library_paths env_value = ENV.fetch('LD_LIBRARY_PATH', '') paths = env_value.split(':') paths << '/usr/local/lib' paths << ENV.fetch('HOME', '') + '/.local/lib' end |
.libyamlscript_name ⇒ Object
36 37 38 |
# File 'lib/yamlscript.rb', line 36 def self.libyamlscript_name "libyamlscript.#{extension}.#{YAMLSCRIPT_VERSION}" end |