Module: Mirah::Env

Defined in:
lib/mirah/env.rb

Class Method Summary collapse

Class Method Details

.decode_paths(paths, dest = nil) ⇒ Object

Takes a single string value “paths” and returns an array of strings containing the original string separated using the path_separator. An option second parameter is an array that will have the strings appended to it. If the optional array parameter is supplied it is returned as the result



38
39
40
41
42
43
44
# File 'lib/mirah/env.rb', line 38

def self.decode_paths(paths, dest = nil)
  result = dest ? dest : []
  paths.split(path_separator).each do |path|
    result << path
  end
  result
end

.encode_paths(paths) ⇒ Object

Takes an array of strings and joins them using the path_separator returning a single string value



30
31
32
# File 'lib/mirah/env.rb', line 30

def self.encode_paths(paths)
  paths.join(path_separator)
end

.make_urls(classpath) ⇒ Object



46
47
48
49
50
# File 'lib/mirah/env.rb', line 46

def self.make_urls classpath
  decode_paths(classpath).map do |filename|
    java.io.File.new(filename).to_uri.to_url
  end.to_java(java.net.URL)
end

.path_separatorObject

Returns the system PATH_SEPARATOR environment variable value. This is used when separating multiple paths in one string. If none is defined then a : (colon) is returned



24
25
26
# File 'lib/mirah/env.rb', line 24

def self.path_separator
  File::PATH_SEPARATOR
end