Class: Runner::Context

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

Class Method Summary collapse

Class Method Details

.logsObject



28
29
30
31
# File 'lib/logpoop/runner/context.rb', line 28

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

.run(options = {}) ⇒ Object



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

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

.runner(opt) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/logpoop/runner/context.rb', line 42

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

.simulatorsObject

A list of the currently-running simulators



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

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

.stopObject



38
39
40
# File 'lib/logpoop/runner/context.rb', line 38

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

.ttys(nums = []) ⇒ Object

Get a hash of tty names / 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
19
20
21
# 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}
  ios = [this_tty].concat(other_ttys).map do |f| 
    [f, IO.new(IO.sysopen(f, 'w'), 'w')]
  end
  Hash[*ios.flatten]
end