Class: Runner::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/logpoop/runner/context.rb

Class Method Summary collapse

Class Method Details

.logsObject



25
26
27
28
# File 'lib/logpoop/runner/context.rb', line 25

def self.logs
  dir = @@options[:log_dir] || "/var/log"
  `ls -S #{dir}/*.log`.split(/\n/)
end

.run(options = {}) ⇒ Object



30
31
32
33
# File 'lib/logpoop/runner/context.rb', line 30

def self.run(options={})
  @@options = options
  runner(@@options[:type]).new.run
end

.runner(opt) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/logpoop/runner/context.rb', line 39

def self.runner(opt)
  {
    :tail => MultiTail,
    :test => TestRun,
    :poop => Poop
  }[opt.to_sym]
end

.simulatorsObject

A list of the currently-running simulators



21
22
23
# File 'lib/logpoop/runner/context.rb', line 21

def self.simulators
  @@simulators ||= []
end

.stopObject



35
36
37
# File 'lib/logpoop/runner/context.rb', line 35

def self.stop 
  simulators.each(&:stop)
end

.ttys(nums = []) ⇒ Object

Get an array of open IO objects attached to existing terminal sessions. The current terminal (the one executing this program) will always be first.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/logpoop/runner/context.rb', line 5

def self.ttys(nums=[])
  this_tty=`tty`.strip
  # macos
  if(this_tty =~ /ttys[0-9]{3}/)
    other_ttys=Dir['/dev/ttys00*']

  # linux
  elsif(this_tty =~ /\/dev\/pts\/[0-9]{1}/)
    other_ttys=Dir["/dev/pts/*"].find_all{|t| t=~/[0-9]{1}$/ }
  end

  other_ttys.reject!{|t| t == this_tty}
  [this_tty].concat(other_ttys).map{|f| IO.sysopen(f, 'w')}.map{|n| IO.new(n, 'w')}
end