module YAMLScript::LibYS
def self.extension
def self.extension case RUBY_PLATFORM when /darwin/ 'dylib' when /linux/ 'so' else raise Error, "Unsupported platform #{RUBY_PLATFORM} for yamlscript." end end
def self.find_libys_path
def self.find_libys_path name = libys_name path = ld_library_paths.map { |dir| File.join(dir, name) }.detect { |file| File.exist?(file) } vers = YAMLSCRIPT_VERSION raise Error, <<-ERROR unless path ed library file `#{name}` not found curl https://yamlscript.org/install | VERSION=#{vers} LIB=1 bash https://github.com/yaml/yamlscript/wiki/Installing-YAMLScript R path end
def self.ld_library_paths
If the environment variable is not set will return an array with
environment variable.
Returns an array of library paths extracted from the LD_LIBRARY_PATH
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
def self.libys_name
def self.libys_name "libys.#{extension}.#{YAMLSCRIPT_VERSION}" end