Class: Kamaze::Project::Tools::Git::Status::Decorator
- Defined in:
- lib/kamaze/project/tools/git/status/decorator.rb
Overview
Provide decoration for status
Result of to_s
, SHOULD be similar to result obtained with:
git status -z | sed "s/\x0/\n/g"
Instance Attribute Summary collapse
- #status ⇒ Kamaze::Project::Tools::Git::Status readonly protected
Instance Method Summary collapse
- #files ⇒ Object
-
#initialize(status) ⇒ Decorator
constructor
A new instance of Decorator.
- #to_s ⇒ Object
Constructor Details
#initialize(status) ⇒ Decorator
Returns a new instance of Decorator.
20 21 22 |
# File 'lib/kamaze/project/tools/git/status/decorator.rb', line 20 def initialize(status) @status = status end |
Instance Attribute Details
#status ⇒ Kamaze::Project::Tools::Git::Status (readonly, protected)
38 39 40 |
# File 'lib/kamaze/project/tools/git/status/decorator.rb', line 38 def status @status end |
Instance Method Details
#files ⇒ Object
24 25 26 27 28 29 |
# File 'lib/kamaze/project/tools/git/status/decorator.rb', line 24 def files files = [status.index.to_a, status.worktree.to_a].flatten.sort_by(&:to_s) files.reject(&:untracked?) .concat(files.keep_if(&:untracked?)) end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/kamaze/project/tools/git/status/decorator.rb', line 31 def to_s files.map { |file| "#{file.status} #{file}" }.uniq.join("\n") end |