Class: Githug::Repository
- Inherits:
-
Object
- Object
- Githug::Repository
show all
- Defined in:
- lib/githug/repository.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(location = ".") ⇒ Repository
6
7
8
9
10
|
# File 'lib/githug/repository.rb', line 6
def initialize(location = ".")
@grit = Grit::Repo.new(location)
rescue Grit::InvalidGitRepositoryError
@grit = nil
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
39
40
41
42
43
44
|
# File 'lib/githug/repository.rb', line 39
def method_missing(method, *args, &block)
if @grit && @grit.respond_to?(method)
return @grit.send(method, *args, &block)
end
super
end
|
Instance Attribute Details
#grit ⇒ Object
Returns the value of attribute grit.
4
5
6
|
# File 'lib/githug/repository.rb', line 4
def grit
@grit
end
|
Instance Method Details
#create_gitignore ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/githug/repository.rb', line 22
def create_gitignore
Dir.chdir("git_hug") if File.exists?("./git_hug")
File.open(".gitignore", "w") do |file|
file.puts(".profile.yml")
file.puts(".gitignore")
end
end
|
#init(location = ".") ⇒ Object
Initialize a Git repo. If the repo already exists, do nothing.
35
36
37
|
# File 'lib/githug/repository.rb', line 35
def init(location = ".")
@grit = Grit::Repo.init(location)
end
|
#reset ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/githug/repository.rb', line 12
def reset
dont_delete = ["..", ".", ".profile.yml"]
if File.basename(Dir.pwd) == "git_hug"
Dir.entries(Dir.pwd).each do |file|
FileUtils.rm_rf(file) unless dont_delete.include?(file)
end
end
create_gitignore
end
|
#valid? ⇒ Boolean
30
31
32
|
# File 'lib/githug/repository.rb', line 30
def valid?
!@grit.nil?
end
|