Class: GitHooksHelper::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/git-hooks-helper/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#errorsObject

Returns the value of attribute errors.



4
5
6
# File 'lib/git-hooks-helper/result.rb', line 4

def errors
  @errors
end

#never_stopObject

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_warningsObject

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

#warningsObject

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

Returns:

  • (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

Returns:

  • (Boolean)


29
30
31
# File 'lib/git-hooks-helper/result.rb', line 29

def errors?
  @errors.size > 0
end

#pass?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/git-hooks-helper/result.rb', line 33

def pass?
  @never_stop || errors?
end

#perfect_commit?Boolean

Returns:

  • (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

Returns:

  • (Boolean)


25
26
27
# File 'lib/git-hooks-helper/result.rb', line 25

def warnings?
  @warnings.size > 0
end