Class: Tracelogger::App
- Inherits:
-
Object
- Object
- Tracelogger::App
- Defined in:
- lib/tracelogger.rb
Overview
Application run scenario.
Instance Method Summary collapse
-
#initialize ⇒ App
constructor
Initializes the app’s settings and parses the CLI options.
-
#log(message) ⇒ Object
Logs the message.
-
#run ⇒ Object
Runs the app scenario.
-
#start ⇒ Object
Executed right after the start.
-
#trace ⇒ Object
Logs the underlying traceroute’s result.
-
#wrapup ⇒ Object
Executed right before the end.
Constructor Details
#initialize ⇒ App
Initializes the app’s settings and parses the CLI options.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tracelogger.rb', line 54 def initialize @config = Configuration.new = {} OptionParser.new do |opts| opts. = "Usage: dumb_tracer [options] host\n" + " Traces the route to destination host and sends\n" + " the traceroute result to SYSLOG's 'daemon' facility" opts.separator "" opts.separator "Optional parameters:" opts.on_tail "-h", "--help", "Show this message" do puts opts.help end end.parse! @config. = @config.host = ARGV.first @log = Log.new end |
Instance Method Details
#log(message) ⇒ Object
Logs the message.
78 79 80 |
# File 'lib/tracelogger.rb', line 78 def log # :nodoc: @log.info end |
#run ⇒ Object
Runs the app scenario.
98 99 100 101 102 |
# File 'lib/tracelogger.rb', line 98 def run start trace wrapup end |
#start ⇒ Object
Executed right after the start.
83 84 85 |
# File 'lib/tracelogger.rb', line 83 def start # :nodoc: log "Starting" end |
#trace ⇒ Object
Logs the underlying traceroute’s result.
93 94 95 |
# File 'lib/tracelogger.rb', line 93 def trace # :nodoc: log Traceroute.new.trace @config.host end |
#wrapup ⇒ Object
Executed right before the end.
88 89 90 |
# File 'lib/tracelogger.rb', line 88 def wrapup # :nodoc: log "Finishing" end |