Class: AmusingGit::GitRepository
- Inherits:
-
Object
- Object
- AmusingGit::GitRepository
- Defined in:
- lib/amusing_git/git/git_repository.rb
Class Method Summary collapse
Instance Method Summary collapse
- #configure_amusing_git! ⇒ Object
- #create_hooks! ⇒ Object
- #has_hooks? ⇒ Boolean
-
#initialize(dir, config) ⇒ GitRepository
constructor
A new instance of GitRepository.
- #remove_amusing_git! ⇒ Object
Constructor Details
#initialize(dir, config) ⇒ GitRepository
Returns a new instance of GitRepository.
5 6 7 8 |
# File 'lib/amusing_git/git/git_repository.rb', line 5 def initialize(dir, config) @dir = dir @hooks = config.hooks end |
Class Method Details
.git_repo?(dir) ⇒ Boolean
31 32 33 |
# File 'lib/amusing_git/git/git_repository.rb', line 31 def self.git_repo? dir File.exists? "#{dir}/.git" end |
Instance Method Details
#configure_amusing_git! ⇒ Object
18 19 20 21 22 23 |
# File 'lib/amusing_git/git/git_repository.rb', line 18 def configure_amusing_git! hooks.each do |hook| hook.create! unless hook.exists? hook.configure_amusing_git! unless hook.amusing? end end |
#create_hooks! ⇒ Object
14 15 16 |
# File 'lib/amusing_git/git/git_repository.rb', line 14 def create_hooks! `mkdir -p .git/hooks` end |
#has_hooks? ⇒ Boolean
10 11 12 |
# File 'lib/amusing_git/git/git_repository.rb', line 10 def has_hooks? File.exists? "#{@dir}/.git/hooks" end |
#remove_amusing_git! ⇒ Object
25 26 27 28 29 |
# File 'lib/amusing_git/git/git_repository.rb', line 25 def remove_amusing_git! hooks.each do |hook| hook.remove_amusing_git! if hook.amusing? end end |