Class: Grit::Status
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.
11 12 13 14 |
# File 'lib/grit/status.rb', line 11 def initialize(base) @base = base construct_status end |
Instance Attribute Details
#files ⇒ Object (readonly)
Returns the value of attribute files.
6 7 8 |
# File 'lib/grit/status.rb', line 6 def files @files end |
Instance Method Details
#[](file) ⇒ Object
enumerable method
49 50 51 |
# File 'lib/grit/status.rb', line 49 def [](file) @files[file] end |
#added ⇒ Object
20 21 22 |
# File 'lib/grit/status.rb', line 20 def added @files.select { |k, f| f.type == 'A' } end |
#changed ⇒ Object
16 17 18 |
# File 'lib/grit/status.rb', line 16 def changed @files.select { |k, f| f.type == 'M' } end |
#deleted ⇒ Object
24 25 26 |
# File 'lib/grit/status.rb', line 24 def deleted @files.select { |k, f| f.type == 'D' } end |
#each ⇒ Object
53 54 55 56 57 |
# File 'lib/grit/status.rb', line 53 def each @files.each do |k, file| yield file end end |
#pretty ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/grit/status.rb', line 32 def pretty out = '' self.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
28 29 30 |
# File 'lib/grit/status.rb', line 28 def untracked @files.select { |k, f| f.untracked } end |