Class: Fyi

Inherits:
Object
  • Object
show all
Defined in:
lib/fyi.rb,
lib/fyi/config.rb,
lib/fyi/version.rb,
lib/fyi/notifiers/log.rb,
lib/fyi/notifiers/email.rb

Overview

See /bin/fyi for documentation.

Defined Under Namespace

Classes: Config, Notifier

Constant Summary collapse

VERSION =
'1.2.0'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Fyi

Returns a new instance of Fyi.



13
14
15
16
# File 'lib/fyi.rb', line 13

def initialize(command)
  @command = command
  @config = Config.new
end

Class Method Details

.run(command) ⇒ Object



9
10
11
# File 'lib/fyi.rb', line 9

def self.run(command)
  new(command).run
end

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/fyi.rb', line 18

def run
  start_stopwatch
  # Append ";" to command to force Ruby to invoke via shell.
  #
  # Open3.capture3 -> Open3.popen3 -> Process.spawn
  # Process.spawn is similar to Kernel.system
  # Kernel.system is similar to Kernel.exec.
  stdout, stderr, status = Open3.capture3 "#{@command};"
  stop_stopwatch
  status.success? ? run_succeeded(stdout, stderr) : run_failed(stdout, stderr)
rescue Object => e
  run_failed('', e.to_s)
end