Class: Reviewer::Runner::Strategies::Passthrough

Inherits:
Object
  • Object
show all
Defined in:
lib/reviewer/runner/strategies/passthrough.rb

Overview

Execution strategy for a runner to run a command transparently-displaying the command’s

output in realtime as it runs (as opposed to capturing and suppressing the output unless
the command fails)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner) ⇒ self

Create an instance of the passthrough strategy for a command runner. This strategy ensures that when a command is run, the output isn’t suppressed. Essentially, it’s a transparent wrapper for running a command and displaying the results realtime.

Parameters:

  • runner (Runner)

    the instance of the runner to apply the strategy to

[View source]

19
20
21
# File 'lib/reviewer/runner/strategies/passthrough.rb', line 19

def initialize(runner)
  @runner = runner
end

Instance Attribute Details

#runnerRunner (readonly)

the instance of the runner that will be executed with this strategy

Returns:

  • (Runner)

    the current value of runner


10
11
12
# File 'lib/reviewer/runner/strategies/passthrough.rb', line 10

def runner
  @runner
end

Instance Method Details

#preparevoid

This method returns an undefined value.

The prepare command strategy when running a command transparently

[View source]

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/reviewer/runner/strategies/passthrough.rb', line 26

def prepare
  # Running the prepare command, so make sure the timestamp is updated
  runner.update_last_prepared_at

  # Display the exact command syntax that's being run. This can come in handy if there's an
  # issue and the command can be copied/pasted or if the generated command somehow has some
  # incorrect syntax or options that need to be corrected.
  runner.output.current_command(runner.prepare_command)

  # Add a divider to visually delineate the results
  runner.output.divider

  # Run the command through the shell directly so no output is suppressed
  runner.shell.direct(runner.prepare_command)
end

#runvoid

This method returns an undefined value.

The run command strategy when running a command transparently

[View source]

45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/reviewer/runner/strategies/passthrough.rb', line 45

def run
  # Display the exact command syntax that's being run. This can come in handy if there's an
  # issue and the command can be copied/pasted or if the generated command somehow has some
  # incorrect syntax or options that need to be corrected.
  runner.output.current_command(runner.command)

  # Add a divider to visually delineate the results
  runner.output.divider

  # Run the command through the shell directly so no output is suppressed
  runner.shell.direct(runner.command)

  # Add a final divider to visually delineate the results
  runner.output.divider
end