Class: FitCommit::Runner
- Inherits:
-
Object
- Object
- FitCommit::Runner
- Includes:
- HasErrors
- Defined in:
- lib/fit_commit/runner.rb
Constant Summary collapse
- EXIT_CODE_ALLOW_COMMIT =
0
- EXIT_CODE_REJECT_COMMIT =
1
Instance Attribute Summary collapse
-
#branch_name ⇒ Object
Returns the value of attribute branch_name.
-
#message_path ⇒ Object
Returns the value of attribute message_path.
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdin ⇒ Object
Returns the value of attribute stdin.
Instance Method Summary collapse
-
#initialize(message_path, branch_name, stderr = $stderr, stdin = $stdin) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
Methods included from HasErrors
#add_error, #add_warning, #clear_errors, #clear_warnings, #errors, #merge_errors, #merge_warnings, #warnings
Constructor Details
#initialize(message_path, branch_name, stderr = $stderr, stdin = $stdin) ⇒ Runner
Returns a new instance of Runner.
13 14 15 16 17 18 |
# File 'lib/fit_commit/runner.rb', line 13 def initialize(, branch_name, stderr = $stderr, stdin = $stdin) self. = self.branch_name = branch_name self.stderr = stderr self.stdin = stdin end |
Instance Attribute Details
#branch_name ⇒ Object
Returns the value of attribute branch_name.
12 13 14 |
# File 'lib/fit_commit/runner.rb', line 12 def branch_name @branch_name end |
#message_path ⇒ Object
Returns the value of attribute message_path.
12 13 14 |
# File 'lib/fit_commit/runner.rb', line 12 def @message_path end |
#stderr ⇒ Object
Returns the value of attribute stderr.
12 13 14 |
# File 'lib/fit_commit/runner.rb', line 12 def stderr @stderr end |
#stdin ⇒ Object
Returns the value of attribute stdin.
12 13 14 |
# File 'lib/fit_commit/runner.rb', line 12 def stdin @stdin end |
Instance Method Details
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fit_commit/runner.rb', line 20 def run allow_commit = retry_on_user_edit do return EXIT_CODE_ALLOW_COMMIT if empty_commit? run_validators return EXIT_CODE_ALLOW_COMMIT if [errors, warnings].all?(&:empty?) print_results errors.empty? || ask_force_commit end if allow_commit stderr.print "\n" EXIT_CODE_ALLOW_COMMIT else EXIT_CODE_REJECT_COMMIT end rescue Interrupt # Ctrl-c EXIT_CODE_REJECT_COMMIT end |