Class: AmusingGit::GitHook
- Inherits:
-
Object
- Object
- AmusingGit::GitHook
- Defined in:
- lib/amusing_git/git/git_hook.rb
Instance Method Summary collapse
- #amusing? ⇒ Boolean
- #configure_amusing_git! ⇒ Object
- #create! ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(hook_file) ⇒ GitHook
constructor
A new instance of GitHook.
- #remove_amusing_git! ⇒ Object
Constructor Details
#initialize(hook_file) ⇒ GitHook
Returns a new instance of GitHook.
3 4 5 |
# File 'lib/amusing_git/git/git_hook.rb', line 3 def initialize(hook_file) @hook_file = hook_file end |
Instance Method Details
#amusing? ⇒ Boolean
26 27 28 |
# File 'lib/amusing_git/git/git_hook.rb', line 26 def amusing? File.read(@hook_file).include? 'amusing_git amuse' end |
#configure_amusing_git! ⇒ Object
16 17 18 |
# File 'lib/amusing_git/git/git_hook.rb', line 16 def configure_amusing_git! `echo "amusing_git amuse" >> #{@hook_file}` end |
#create! ⇒ Object
11 12 13 14 |
# File 'lib/amusing_git/git/git_hook.rb', line 11 def create! `touch #{@hook_file}` `chmod 777 #{@hook_file}` end |
#exists? ⇒ Boolean
7 8 9 |
# File 'lib/amusing_git/git/git_hook.rb', line 7 def exists? File.file? @hook_file end |
#remove_amusing_git! ⇒ Object
20 21 22 23 24 |
# File 'lib/amusing_git/git/git_hook.rb', line 20 def remove_amusing_git! content = File.read(@hook_file) new_content = content.gsub('amusing_git amuse', '') File.open(@hook_file, 'w').write(new_content) end |