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

.filetypesObject

Returns the value of attribute filetypes.



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

def filetypes
  @filetypes
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

.file_type(*types) ⇒ Object Also known as: file_types



103
104
105
# File 'lib/overcommit/hook_specific_check.rb', line 103

def file_type(*types)
  self.filetypes = types
end

.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



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

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
60
# File 'lib/overcommit/hook_specific_check.rb', line 53

def staged
  @staged ||= modified_files.map do |filename|
    filetypes = Array(self.class.filetypes).map { |type| ".#{type}" }
    if filetypes.empty? || filename.end_with?(*filetypes)
      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