Class: LLenv::Declare

Inherits:
Object
  • Object
show all
Defined in:
lib/llenv/declare.rb

Instance Method Summary collapse

Constructor Details

#initialize(dir, env) ⇒ Declare

Returns a new instance of Declare.



5
6
7
8
9
10
11
12
# File 'lib/llenv/declare.rb', line 5

def initialize(dir, env)
  @root_dir = dir
  @env = {}
  env.split(',').each do |str|
    k, v = str.split(/=|\\=/)
    @env[k] = v
  end
end

Instance Method Details

#listObject



21
22
23
24
25
26
27
# File 'lib/llenv/declare.rb', line 21

def list
  Dir.entries(@root_dir).each do |f|
    next if f =~ /^\./
    next unless File.directory?(File.join(@root_dir, f))
    print f + "\n"
  end
end

#run(llenv, command, argv = []) ⇒ Object



14
15
16
17
18
19
# File 'lib/llenv/declare.rb', line 14

def run(llenv, command, argv = [])
  set_env(llenv)
  script = File.join(@declare_dir, "run")
  argv.unshift(command)
  exec(script, *argv)
end