Class: GitSemverCop::Generator
- Inherits:
-
Thor
- Object
- Thor
- GitSemverCop::Generator
- Includes:
- Thor::Actions
- Defined in:
- lib/git-semver-cop/generator.rb
Overview
Our generator that creates the commit hook
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.destination ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/git-semver-cop/generator.rb', line 12 def self.destination # For submodules which have a .git file that points to the module hooks_dir = "/hooks/pre-commit" if File.file?(".git") File.(submodule_git + hooks_dir, Dir.pwd) else File.(".git" + hooks_dir, Dir.pwd) end end |
.source_root ⇒ Object
8 9 10 |
# File 'lib/git-semver-cop/generator.rb', line 8 def self.source_root File.("../../hooks", __FILE__) end |
.submodule_git ⇒ Object
23 24 25 |
# File 'lib/git-semver-cop/generator.rb', line 23 def self.submodule_git File.read(".git").strip[/^(gitdir: )(.+)$/, 2] end |
Instance Method Details
#destroy ⇒ Object
34 35 36 |
# File 'lib/git-semver-cop/generator.rb', line 34 def destroy remove_file self.class.destination end |
#init ⇒ Object
28 29 30 31 |
# File 'lib/git-semver-cop/generator.rb', line 28 def init copy_file "pre-commit", self.class.destination chmod self.class.destination, 0744 end |