Class: Grit::Status
- Inherits:
-
Object
- Object
- Grit::Status
- Includes:
- Enumerable
- Defined in:
- lib/grit_ext/status.rb
Defined Under Namespace
Classes: StatusFile
Instance Attribute Summary collapse
-
#files ⇒ Object
readonly
Returns the value of attribute files.
Instance Method Summary collapse
-
#[](file) ⇒ Object
enumerable method.
- #added ⇒ Object
- #changed ⇒ Object
- #deleted ⇒ Object
- #each ⇒ Object
-
#initialize(base) ⇒ Status
constructor
A new instance of Status.
- #pretty ⇒ Object
- #untracked ⇒ Object
Constructor Details
#initialize(base) ⇒ Status
Returns a new instance of Status.
10 11 12 13 |
# File 'lib/grit_ext/status.rb', line 10 def initialize(base) @base = base construct_status end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
5 6 7 |
# File 'lib/grit_ext/status.rb', line 5 def files @files end |
Instance Method Details
#[](file) ⇒ Object
enumerable method
48 49 50 |
# File 'lib/grit_ext/status.rb', line 48 def [](file) @files[file] end |
#added ⇒ Object
19 20 21 |
# File 'lib/grit_ext/status.rb', line 19 def added @files.select{|k, f| f.type == 'A'} end |
#changed ⇒ Object
15 16 17 |
# File 'lib/grit_ext/status.rb', line 15 def changed @files.select{|k, f| f.type == 'M'} end |
#deleted ⇒ Object
23 24 25 |
# File 'lib/grit_ext/status.rb', line 23 def deleted @files.select{|k, f| f.type == 'D'} end |
#each ⇒ Object
52 53 54 55 56 |
# File 'lib/grit_ext/status.rb', line 52 def each @files.each do |k, file| yield file end end |
#pretty ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/grit_ext/status.rb', line 31 def pretty out = '' each do |file| out << file.path out << "\n\tsha(r) " + file.sha_repo.to_s + ' ' + file.mode_repo.to_s out << "\n\tsha(i) " + file.sha_index.to_s + ' ' + file.mode_index.to_s out << "\n\ttype " + file.type.to_s out << "\n\tstage " + file.stage.to_s out << "\n\tuntrac " + file.untracked.to_s out << "\n" end out << "\n" out end |
#untracked ⇒ Object
27 28 29 |
# File 'lib/grit_ext/status.rb', line 27 def untracked @files.select{|k, f| f.untracked && !f.ignored} end |