Class: GitHook::CLI
- Inherits:
-
Thor
- Object
- Thor
- GitHook::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/git_hook/cli.rb
Class Method Summary collapse
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(*args) ⇒ CLI
constructor
A new instance of CLI.
- #install ⇒ Object
- #list ⇒ Object
- #test(timing, hook) ⇒ Object
- #version ⇒ Object
Constructor Details
Class Method Details
.source_root ⇒ Object
25 26 27 |
# File 'lib/git_hook/cli.rb', line 25 def self.source_root Pathname.new(File.dirname(__FILE__)).join('template').to_s end |
Instance Method Details
#apply ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/git_hook/cli.rb', line 42 def apply opts = { with_bundler: File.exist?('Gemfile') } config.hooks.keys.each do | timing | opts[:timing] = timing template('hook.tt', ".git/hooks/#{timing}", opts) chmod(".git/hooks/#{timing}", 0755) end end |
#install ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/git_hook/cli.rb', line 30 def install opts = { with_bundler: File.exist?('Gemfile') } unless File.exist?('.githooks') template('githooks.tt', '.githooks', opts) end invoke(:apply) end |
#list ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/git_hook/cli.rb', line 54 def list config.hooks.each_pair do | timing, hooks | say(timing, :blue) hooks.each do | hook | say(" #{hook[:class]}", :green, true) hook[:options].each_pair do | key, value | say(" " * 4 + key.to_s, :yellow, false) say(" : #{value}", nil, true) end end end end |