Class: StatusChecker
- Inherits:
-
Object
- Object
- StatusChecker
- Defined in:
- lib/status_checker.rb
Instance Attribute Summary collapse
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#shell ⇒ Object
readonly
Returns the value of attribute shell.
-
#untested_files ⇒ Object
readonly
Returns the value of attribute untested_files.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(env, confirm_exit_status) ⇒ StatusChecker
constructor
A new instance of StatusChecker.
- #report ⇒ Object
Constructor Details
#initialize(env, confirm_exit_status) ⇒ StatusChecker
Returns a new instance of StatusChecker.
7 8 9 10 11 12 |
# File 'lib/status_checker.rb', line 7 def initialize(env, confirm_exit_status) @repo = env[:repo] @shell = env[:shell] @untested_files = [] @confirm_exit_status = confirm_exit_status end |
Instance Attribute Details
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
6 7 8 |
# File 'lib/status_checker.rb', line 6 def repo @repo end |
#shell ⇒ Object (readonly)
Returns the value of attribute shell.
6 7 8 |
# File 'lib/status_checker.rb', line 6 def shell @shell end |
#untested_files ⇒ Object (readonly)
Returns the value of attribute untested_files.
6 7 8 |
# File 'lib/status_checker.rb', line 6 def untested_files @untested_files end |
Class Method Details
.report(env, confirm_exit_status) ⇒ Object
2 3 4 |
# File 'lib/status_checker.rb', line 2 def self.report(env, confirm_exit_status) new(env, confirm_exit_status).report end |
Instance Method Details
#report ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/status_checker.rb', line 14 def report non_test_files.each do |file| if ! test_files.include? "#{file}_test" untested_files << full_path_by_basename(file) end end if untested_files.empty? shell.notify "All ruby files are tested!" exit 0 else shell.warn "The following files have changed without being tested:\n\n#{untested_files.join("\n")}" STDIN.reopen('/dev/tty') if confirm_exit_status? && shell.confirm?("\nDo you still wish to commit?") exit 0 else exit 1 end end end |