Class: Git::Catch::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/git/catch.rb

Instance Method Summary collapse

Constructor Details

#initializeRunner

Returns a new instance of Runner.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/git/catch.rb', line 9

def initialize
  @logger = Logger.new(STDOUT)
  @logger.formatter = proc do |type, time, name, message|
    "[#{time}]  #{type.ljust(5)}  #{message}\n"
  end
  @config = YAML.load_file("./.git-catch.yaml")
  @dir    = @config.fetch("dir", nil)
  @hooks  = [
    "applypatch-msg",
    "commit-msg",
    "post-update",
    "pre-applypatch",
    "pre-commit",
    "pre-push",
    "pre-rebase",
    "prepare-commit-msg",
    "update",
  ]
end

Instance Method Details

#initObject



29
30
31
32
33
34
35
36
37
# File 'lib/git/catch.rb', line 29

def init
  @config.fetch("hooks", {}).each do |name, _|
    if !@hooks.include? name
      @logger.error "Hook #{name} is not known."
      next
    end
    build name, files(name)
  end
end

#listObject



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/git/catch.rb', line 39

def list
  data = {}
  @config.fetch("hooks", {}).each do |name, _|
    if !@hooks.include? name
      @logger.error "Hook #{name} is not known."
      next
    end

    data[name] = files(name)
  end

  data
end