Class: RubyGit::Status::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_git/status/report.rb

Overview

Represents a full git status report

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(branch, stash, entries) ⇒ Report

Initialize a new status report

Examples:

Report.new(
  branch = Branch.new,
  stash = Stash.new,
  entries = [Ordinary.new, Renamed.new]
)


58
59
60
61
62
# File 'lib/ruby_git/status/report.rb', line 58

def initialize(branch, stash, entries)
  @branch = branch
  @stash = stash
  @entries = entries
end

Instance Attribute Details

#branchRubyGit::Status::BranchInfo? (readonly)

Information about the current git branch

Examples:

report.branch #=> #<RubyGit::Status::BranchInfo:0x00000001046bd488 ...>


19
20
21
# File 'lib/ruby_git/status/report.rb', line 19

def branch
  @branch
end

#entriesArray<RubyGit::Status::Entry> (readonly)

All entries in the git status

Examples:

report.entries #=> [#<RubyGit::Status::Ordinary:0x00000001046bd488 ...>, ...]


43
44
45
# File 'lib/ruby_git/status/report.rb', line 43

def entries
  @entries
end

#stashRubyGit::Status::Stash? (readonly)

Information about git stash if available

Examples:

report.stash #=> #<RubyGit::Status::Stash:0x00000001046bd488 ...>


31
32
33
# File 'lib/ruby_git/status/report.rb', line 31

def stash
  @stash
end

Instance Method Details

#fully_stagedArray<UntrackedEntry, OrdinaryEntry, RenamedEntry>

The entries that have staged changes and no unstaged changes

Examples:

report.fully_staged #=> [#<RubyGit::Status::OrdinaryEntry ...>, ...]


115
116
117
# File 'lib/ruby_git/status/report.rb', line 115

def fully_staged
  entries.select(&:fully_staged?)
end

#ignoredArray<IgnoredEntry>

The entries that are ignored

Examples:

report.ignored #=> [#<RubyGit::Status::IgnoredEntry ...>, ...]


71
72
73
# File 'lib/ruby_git/status/report.rb', line 71

def ignored
  entries.select(&:ignored?)
end

#merge_conflict?Boolean

Are there any unmerged entries?

Examples:

report.merge_conflicts? #=> true


138
139
140
# File 'lib/ruby_git/status/report.rb', line 138

def merge_conflict?
  unmerged.any?
end

#stagedArray<UntrackedEntry, OrdinaryEntry, RenamedEntry>

The entries that have staged changes

Examples:

report.staged #=> [#<RubyGit::Status::OrdinaryEntry ...>, ...]


104
105
106
# File 'lib/ruby_git/status/report.rb', line 104

def staged
  entries.select(&:staged?)
end

#unmergedArray<UnmergedEntry>

The entries that represent merge conflicts

Examples:

report.unmerged #=> [#<RubyGit::Status::UnmergedEntry ...>, ...]
report.merge_conflicts? #=> true


127
128
129
# File 'lib/ruby_git/status/report.rb', line 127

def unmerged
  entries.select(&:unmerged?)
end

#unstagedArray<UntrackedEntry, OrdinaryEntry, RenamedEntry>

The entries that have unstaged changes

Examples:

report.unstaged #=> [#<RubyGit::Status::OrdinaryEntry ...>, ...]


93
94
95
# File 'lib/ruby_git/status/report.rb', line 93

def unstaged
  entries.select(&:unstaged?)
end

#untrackedArray<UntrackedEntry>

The entries that are untracked

Examples:

report.untracked #=> [#<RubyGit::Status::UntrackedEntry ...>, ...]


82
83
84
# File 'lib/ruby_git/status/report.rb', line 82

def untracked
  entries.select(&:untracked?)
end