Class: Depends::Commands::Base

Inherits:
Object
  • Object
show all
Includes:
Mixlib::CLI
Defined in:
lib/depends/commands/base.rb

Direct Known Subclasses

Install, List, Upload

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/depends/commands/base.rb', line 7

def initialize
  super

  trap("TERM") do
    Depends::Commands::Base.fatal!("SIGTERM received, stopping", 1)
  end

  trap("INT") do
    Depends::Commands::Base.fatal!("SIGINT received, stopping", 2)
  end

  processor, platform, *rest = RUBY_PLATFORM.split("-")

  unless RUBY_PLATFORM =~ /mingw32|mswin32/
    trap("QUIT") do
      Depends::Log.info("SIGQUIT received, call stack:\n  " + caller.join("\n  "))
    end

    trap("HUP") do
      Depends::Log.info("SIGHUP received, reconfiguring")
      reconfigure
    end
  end

end

Class Method Details

.exit!(msg, err = -1)) ⇒ Object



80
81
82
83
# File 'lib/depends/commands/base.rb', line 80

def exit!(msg, err = -1)
  Depends::Log.debug(msg)
  Process.exit err
end

.fatal!(msg, err = -1)) ⇒ Object

Log a fatal error message to both STDERR and the Logger, exit the application



75
76
77
78
# File 'lib/depends/commands/base.rb', line 75

def fatal!(msg, err = -1)
  Depends::Log.fatal(msg)
  Process.exit err
end

Instance Method Details

#reconfigureObject



33
34
35
36
37
# File 'lib/depends/commands/base.rb', line 33

def reconfigure
  parse_options
  configure_depends
  configure_logging
end

#runObject



39
40
41
42
43
# File 'lib/depends/commands/base.rb', line 39

def run
  reconfigure
  setup_application
  run_application
end