Class: Overcommit::GitHook::HookSpecificCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/overcommit/hook_specific_check.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ HookSpecificCheck

Returns a new instance of HookSpecificCheck.



37
38
39
# File 'lib/overcommit/hook_specific_check.rb', line 37

def initialize(*args)
  @arguments = args
end

Class Attribute Details

.filetypeObject

Returns the value of attribute filetype.



16
17
18
# File 'lib/overcommit/hook_specific_check.rb', line 16

def filetype
  @filetype
end

.requiredObject

Returns the value of attribute required.



16
17
18
# File 'lib/overcommit/hook_specific_check.rb', line 16

def required
  @required
end

.stealthObject

Returns the value of attribute stealth.



16
17
18
# File 'lib/overcommit/hook_specific_check.rb', line 16

def stealth
  @stealth
end

Class Method Details

.friendly_nameObject



32
33
34
# File 'lib/overcommit/hook_specific_check.rb', line 32

def friendly_name
  Overcommit::Utils.underscorize name.to_s.split('::').last
end

.required!Object



22
23
24
# File 'lib/overcommit/hook_specific_check.rb', line 22

def required!
  self.required = true
end

.skippable?Boolean

Can the check be skipped by environment variables? This can always be overriden with ‘–no-verify`.

Returns:

  • (Boolean)


28
29
30
# File 'lib/overcommit/hook_specific_check.rb', line 28

def skippable?
  !required
end

.stealth!Object



18
19
20
# File 'lib/overcommit/hook_specific_check.rb', line 18

def stealth!
  self.stealth = true
end

Instance Method Details

#nameObject



41
42
43
# File 'lib/overcommit/hook_specific_check.rb', line 41

def name
  self.class.friendly_name
end

#run_checkObject



61
62
63
# File 'lib/overcommit/hook_specific_check.rb', line 61

def run_check
  [:bad, 'No checks defined!']
end

#skip?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/overcommit/hook_specific_check.rb', line 45

def skip?
  false
end

#stagedObject



53
54
55
56
57
58
59
# File 'lib/overcommit/hook_specific_check.rb', line 53

def staged
  @staged ||= modified_files.map do |filename|
    if self.class.filetype.nil? || filename.end_with?(".#{self.class.filetype}")
      StagedFile.new(filename)
    end
  end.compact
end

#stealth?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/overcommit/hook_specific_check.rb', line 49

def stealth?
  self.class.stealth
end