Class: Retest::Program
- Inherits:
-
Object
- Object
- Retest::Program
- Extended by:
- Forwardable
- Includes:
- ForcedSelection, Pausable
- Defined in:
- lib/retest/program.rb
Instance Attribute Summary collapse
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#runner ⇒ Object
Returns the value of attribute runner.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Attributes included from ForcedSelection
Instance Method Summary collapse
- #clear_terminal ⇒ Object
- #diff(branch) ⇒ Object
-
#initialize(runner: nil, repository: nil, stdout: $stdout) ⇒ Program
constructor
A new instance of Program.
- #run(file, force_run: false) ⇒ Object
- #run_all ⇒ Object
- #run_selected(test_files) ⇒ Object
Methods included from ForcedSelection
#force_selection, #forced_selection?, #initialize_forced_selection, #reset_selection
Methods included from Pausable
#initialize_pause, #pause, #paused?, #resume, #running_state
Constructor Details
#initialize(runner: nil, repository: nil, stdout: $stdout) ⇒ Program
Returns a new instance of Program.
15 16 17 18 19 20 21 |
# File 'lib/retest/program.rb', line 15 def initialize(runner: nil, repository: nil, stdout: $stdout) @runner = runner @repository = repository @stdout = stdout initialize_pause(false) initialize_forced_selection([]) end |
Instance Attribute Details
#repository ⇒ Object
Returns the value of attribute repository.
10 11 12 |
# File 'lib/retest/program.rb', line 10 def repository @repository end |
#runner ⇒ Object
Returns the value of attribute runner.
10 11 12 |
# File 'lib/retest/program.rb', line 10 def runner @runner end |
#stdout ⇒ Object
Returns the value of attribute stdout.
10 11 12 |
# File 'lib/retest/program.rb', line 10 def stdout @stdout end |
Instance Method Details
#clear_terminal ⇒ Object
62 63 64 |
# File 'lib/retest/program.rb', line 62 def clear_terminal system('clear 2>/dev/null') || system('cls 2>/dev/null') end |
#diff(branch) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/retest/program.rb', line 47 def diff(branch) raise "Git not installed" unless VersionControl::Git.installed? test_files = repository.find_tests VersionControl::Git.diff_files(branch) run_selected(test_files) end |
#run(file, force_run: false) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/retest/program.rb', line 23 def run(file, force_run: false) if paused? && !force_run @stdout.puts "Main program paused. Please resume program first." return end if forced_selection? @stdout.puts <<~HINT Forced selection enabled. Reset to default settings by typing 'r' in the interactive console. HINT runner.run(test_files: selected_test_files) return end test_file = if runner.has_test? repository.find_test(file) end runner.run changed_files: [file], test_files: [test_file] end |
#run_all ⇒ Object
54 55 56 |
# File 'lib/retest/program.rb', line 54 def run_all runner.run_all end |
#run_selected(test_files) ⇒ Object
58 59 60 |
# File 'lib/retest/program.rb', line 58 def run_selected(test_files) runner.run(test_files: test_files) end |