Class: Space::Model::Repo::Git
- Inherits:
-
Object
- Object
- Space::Model::Repo::Git
show all
- Includes:
- Source
- Defined in:
- lib/space/model/repo/git.rb
Instance Attribute Summary collapse
Attributes included from Source
#results
#path
Instance Method Summary
collapse
Methods included from Source
#commands, included, #refresh, #result, #update
Methods included from Events
events, flush, #notify, notify, sources, subscribe, subscriptions
#watched_paths
Constructor Details
#initialize(repo) ⇒ Git
Returns a new instance of Git.
15
16
17
18
|
# File 'lib/space/model/repo/git.rb', line 15
def initialize(repo)
@repo = repo
super(repo.path)
end
|
Instance Attribute Details
#repo ⇒ Object
Returns the value of attribute repo.
13
14
15
|
# File 'lib/space/model/repo/git.rb', line 13
def repo
@repo
end
|
Instance Method Details
#ahead ⇒ Object
36
37
38
|
# File 'lib/space/model/repo/git.rb', line 36
def ahead
result(:status) =~ /Your branch is ahead of .* by (\d+) commits?\./ ? $1.to_i : 0
end
|
#ahead? ⇒ Boolean
28
29
30
|
# File 'lib/space/model/repo/git.rb', line 28
def ahead?
ahead > 0
end
|
#branch ⇒ Object
40
41
42
|
# File 'lib/space/model/repo/git.rb', line 40
def branch
result(:branch) =~ /^\* (.+)/ && $1.strip
end
|
#clean? ⇒ Boolean
32
33
34
|
# File 'lib/space/model/repo/git.rb', line 32
def clean?
result(:status) =~ /nothing to commit (working directory clean)/
end
|
#commit ⇒ Object
44
45
46
|
# File 'lib/space/model/repo/git.rb', line 44
def commit
result(:commit) =~ /^commit (\S{7})/ && $1
end
|
#dirty? ⇒ Boolean
24
25
26
|
# File 'lib/space/model/repo/git.rb', line 24
def dirty?
!clean?
end
|
#status ⇒ Object
20
21
22
|
# File 'lib/space/model/repo/git.rb', line 20
def status
dirty? ? :dirty : (ahead? ? :ahead : :clean)
end
|