Module: Flaun

Extended by:
Flaun
Included in:
Flaun
Defined in:
lib/flaun.rb,
lib/flaun/dsl.rb,
lib/flaun/config.rb,
lib/flaun/version.rb

Defined Under Namespace

Classes: Config, DSL, DSLTarget, TargetConfig

Constant Summary collapse

VERSION =
"0.0.3"

Instance Method Summary collapse

Instance Method Details

#config_load(text, filename) ⇒ Object



22
23
24
25
26
# File 'lib/flaun.rb', line 22

def config_load(text, filename)
  dsl = Flaun::DSL.new
  dsl.instance_eval text, filename
  dsl.config
end

#run(*argv) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/flaun.rb', line 9

def run(*argv)
  Thread.abort_on_exception = true
  thread = Thread.new do
    start *argv
  end

  loop do
    puts 'quit? (y/N)'
    break if $stdin.gets.chomp == 'y'
  end
  thread.kill
end

#start(target_name = nil, config_file = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/flaun.rb', line 28

def start(target_name = nil, config_file = nil)
  config_file ||= default_config_file
  unless File.exist? config_file
    not_found_config_file
    exit 1
  end
  config = config_load(open(config_file).read, config_file)

  if target_name.nil?
    not_target_name config
    exit 1
  end

  target = config[target_name.to_sym]

  ssh_forward_and_launch target
end