Class: Bleetz

Inherits:
Object show all
Defined in:
lib/bleetz.rb

Constant Summary collapse

VERSION =
"2.0"
USAGE =
<<-EOF
Usage: bleetz [-c conf_file -h -l -s][[-t -v -c conf_file] action]

-c <conf_file>         - Specify a special bleetz configuration file.
-h                     - Help.
-l                     - List available action(s) defined in bleetz configuration file.
-s                     - Test ssh connection defined in bleetz conf.
-t <action_name>         - Test actions (just print command that will be executed.
-v                     - Verbose Mode.
-V                     - Print bleetz version.
EOF

Instance Method Summary collapse

Constructor Details

#initializeBleetz

Returns a new instance of Bleetz.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/bleetz.rb', line 24

def initialize
  arg_get
  @cmd_to_exec = []
  begin
    if @file.nil?
      cnf = YAML::load(File.open("#{Dir.pwd}/.bleetz"))
      @file = cnf['config']
    end
    load @file
  rescue TypeError
    abort "Didn't you make a mistake in .bleetz file ?"
  rescue BleetzException => e
    abort "Problem during configuration loading: #{e.message}"
  rescue ArgumentError
    abort "Did you configure attribute like this: 'attribute: <value>'"
  rescue Exception => e
    abort "Problem during configuration loading: #{e.message}"
  end
  list if @list
  test_ssh if @ssh_test
  abort "You need to specify an action." if @action.nil?
  format_cmds
  test if @test
  connect
end