Class: GitHooksHelper::Result
- Inherits:
-
Object
- Object
- GitHooksHelper::Result
- Defined in:
- lib/git-hooks-helper/result.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#never_stop ⇒ Object
Returns the value of attribute never_stop.
-
#stop_on_warnings ⇒ Object
Returns the value of attribute stop_on_warnings.
-
#warnings ⇒ Object
Returns the value of attribute warnings.
Instance Method Summary collapse
- #continue? ⇒ Boolean
- #errors? ⇒ Boolean
-
#initialize(stop_on_warnings) ⇒ Result
constructor
A new instance of Result.
- #pass? ⇒ Boolean
- #perfect_commit? ⇒ Boolean
- #warn(msg) ⇒ Object
- #warnings? ⇒ Boolean
Constructor Details
#initialize(stop_on_warnings) ⇒ Result
Returns a new instance of Result.
6 7 8 9 10 11 |
# File 'lib/git-hooks-helper/result.rb', line 6 def initialize(stop_on_warnings) @errors = [] @warnings = [] @stop_on_warnings = stop_on_warnings @never_stop = false end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
4 5 6 |
# File 'lib/git-hooks-helper/result.rb', line 4 def errors @errors end |
#never_stop ⇒ Object
Returns the value of attribute never_stop.
4 5 6 |
# File 'lib/git-hooks-helper/result.rb', line 4 def never_stop @never_stop end |
#stop_on_warnings ⇒ Object
Returns the value of attribute stop_on_warnings.
4 5 6 |
# File 'lib/git-hooks-helper/result.rb', line 4 def stop_on_warnings @stop_on_warnings end |
#warnings ⇒ Object
Returns the value of attribute warnings.
4 5 6 |
# File 'lib/git-hooks-helper/result.rb', line 4 def warnings @warnings end |
Instance Method Details
#continue? ⇒ Boolean
21 22 23 |
# File 'lib/git-hooks-helper/result.rb', line 21 def continue? @never_stop || (!(errors? || (warnings? && @stop_on_warnings))) end |
#errors? ⇒ Boolean
29 30 31 |
# File 'lib/git-hooks-helper/result.rb', line 29 def errors? @errors.size > 0 end |
#pass? ⇒ Boolean
33 34 35 |
# File 'lib/git-hooks-helper/result.rb', line 33 def pass? @never_stop || errors? end |
#perfect_commit? ⇒ Boolean
37 38 39 |
# File 'lib/git-hooks-helper/result.rb', line 37 def perfect_commit? !(errors? || warnings?) end |
#warn(msg) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/git-hooks-helper/result.rb', line 13 def warn(msg) if msg.class == Array @warnings.concat msg else @warnings << msg end end |
#warnings? ⇒ Boolean
25 26 27 |
# File 'lib/git-hooks-helper/result.rb', line 25 def warnings? @warnings.size > 0 end |