Class: Timmy::Runner
- Inherits:
-
Object
- Object
- Timmy::Runner
- Defined in:
- lib/timmy/runner.rb
Class Method Summary collapse
Instance Method Summary collapse
- #consume_stdin ⇒ Object
-
#initialize(replay_speed:) ⇒ Runner
constructor
A new instance of Runner.
- #stream_command(command) ⇒ Object
Constructor Details
#initialize(replay_speed:) ⇒ Runner
Returns a new instance of Runner.
27 28 29 30 |
# File 'lib/timmy/runner.rb', line 27 def initialize(replay_speed:) @replay_speed = replay_speed @last_replay_time = 0 end |
Class Method Details
.run ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/timmy/runner.rb', line 8 def run ConfigLoader.load = OptionParser.parse replay_speed = [:replay_speed] || @replay_speed Logger.set_quiet([:quiet]) if .key?(:quiet) Logger.set_precision([:precision]) if .key?(:precision) Logger.set_profile([:profile]) if .key?(:profile) instance = self.new(replay_speed: replay_speed) if command = [:command] instance.stream_command(command) else instance.consume_stdin() end end |
.set_replay_speed(speed) ⇒ Object
4 5 6 |
# File 'lib/timmy/runner.rb', line 4 def set_replay_speed(speed) @replay_speed = speed end |
Instance Method Details
#consume_stdin ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/timmy/runner.rb', line 40 def consume_stdin around_run_lines do STDIN.each_line do |line| next if init_replay_mode(line) if @replay_mode replay_line(line) else run_line(line.rstrip) end end end end |
#stream_command(command) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/timmy/runner.rb', line 32 def stream_command(command) around_run_lines do CommandStreamer.stream(command) do |type, line| run_line(line.rstrip, type) end end end |