Class: Timmy::Runner

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

Class Method Summary collapse

Class Method Details

.consume_stdinObject



4
5
6
7
8
9
10
11
12
13
# File 'lib/timmy/runner.rb', line 4

def consume_stdin
  MasterTimer.start

  STDIN.each_line do |line|
    run_line(line.rstrip)
  end

  TargetedTimer.stop_all
  Logger.finalize
end

.replay_log(log) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/timmy/runner.rb', line 15

def replay_log(log)
  basename = File.basename(log)
  match = log.match(/timmy-(?<time>\d+)\+\d+.log/)
  time = match[:time].to_i

  MasterTimer.start(time)

  lines = File.readlines(log)
  lines.each do |line|
    if match = line.match(/^(?<m>\d+):(?<s>\d+(\.\d+)?) \| (?<content>.*)/)
      content = match[:content]
      time = match[:m].to_i * 60 + match[:s].to_f

      MasterTimer.set(time)
      run_line(content)
    end
  end

  TargetedTimer.stop_all
  Logger.finalize
end