Class: Gitscrub::Repository
- Inherits:
-
Object
- Object
- Gitscrub::Repository
show all
- Defined in:
- lib/gitscrub/repository.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(location = ".") ⇒ Repository
Returns a new instance of Repository.
6
7
8
9
10
|
# File 'lib/gitscrub/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
33
34
35
36
37
38
|
# File 'lib/gitscrub/repository.rb', line 33
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/gitscrub/repository.rb', line 4
def grit
@grit
end
|
Instance Method Details
#init(gitignore = true) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/gitscrub/repository.rb', line 25
def init(gitignore = true)
@grit = Grit::Repo.init(".")
if gitignore
@grit.add(".gitignore")
@grit.commit("added .gitignore")
end
end
|
#reset ⇒ Object
12
13
14
15
16
17
18
19
|
# File 'lib/gitscrub/repository.rb', line 12
def reset
dont_delete = ["..", ".", ".gitignore", ".profile.yml"]
if File.basename(Dir.pwd) == "git_scrub"
Dir.entries(Dir.pwd).each do |file|
FileUtils.rm_rf(file) unless dont_delete.include?(file)
end
end
end
|
#valid? ⇒ Boolean
21
22
23
|
# File 'lib/gitscrub/repository.rb', line 21
def valid?
!@grit.nil?
end
|