Class: AmusingGit::Amuser
- Inherits:
-
Object
- Object
- AmusingGit::Amuser
show all
- Includes:
- PrettyPrinter
- Defined in:
- lib/amusing_git/amuser.rb
Instance Method Summary
collapse
#colorize, #green, #print_error, #print_info, #print_success, #red, #yellow
Constructor Details
#initialize ⇒ Amuser
Returns a new instance of Amuser.
9
10
11
|
# File 'lib/amusing_git/amuser.rb', line 9
def initialize
@config = AmusingGit::Config.new
end
|
Instance Method Details
#amuse ⇒ Object
13
14
15
16
17
|
# File 'lib/amusing_git/amuser.rb', line 13
def amuse
msgs = @config.messages
return if msgs.empty?
print_info(msgs[rand(0..msgs.size-1)] + "\n")
end
|
#start_amusing(dir) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/amusing_git/amuser.rb', line 19
def start_amusing(dir)
unless AmusingGit::GitRepository.git_repo? dir
print_error "#{dir} is not a git repository, halting...\n"
return
end
git_repository = AmusingGit::GitRepository.new dir, @config
git_repository.create_hooks! unless git_repository.has_hooks?
git_repository.configure_amusing_git!
print_success "Done :)\n"
end
|
#stop_amusing(dir) ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/amusing_git/amuser.rb', line 32
def stop_amusing(dir)
unless AmusingGit::GitRepository.git_repo? dir
print_error "#{dir} is not a git repository, halting...\n"
return
end
git_repository = AmusingGit::GitRepository.new dir, @config
return unless git_repository.has_hooks?
git_repository.remove_amusing_git!
print_success "Done :)\n"
end
|