Class: Git::DiffStats
- Inherits:
-
Object
- Object
- Git::DiffStats
- Defined in:
- lib/git/diff_stats.rb
Overview
Lazy diff statistics for a comparison between two trees
Supports comparing (1) two commits, (2) a commit against the working tree, or (3) the index against the working tree.
Instance Method Summary collapse
-
#deletions ⇒ Integer
Returns the total number of lines deleted.
-
#files ⇒ Hash{String=>Hash{Symbol=>Integer}}
Returns a hash of statistics for each file in the diff.
-
#initialize(base, from, to, path_limiter = nil) ⇒ DiffStats
constructor
A new instance of DiffStats.
-
#insertions ⇒ Integer
Returns the total number of lines inserted.
-
#lines ⇒ Integer
Returns the total number of lines changed (insertions + deletions).
-
#total ⇒ Hash{Symbol=>Integer}
Returns a hash of the total statistics for the diff.
Constructor Details
#initialize(base, from, to, path_limiter = nil) ⇒ DiffStats
Returns a new instance of DiffStats.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/git/diff_stats.rb', line 17 def initialize(base, from, to, path_limiter = nil) # Eagerly check for invalid arguments [from, to].compact.each do |arg| raise ArgumentError, "Invalid argument: '#{arg}'" if arg.start_with?('-') end @base = base @from = from @to = to @path_limiter = path_limiter @fetch_stats = nil end |
Instance Method Details
#deletions ⇒ Integer
Returns the total number of lines deleted
37 38 39 |
# File 'lib/git/diff_stats.rb', line 37 def deletions fetch_stats[:total][:deletions] end |
#files ⇒ Hash{String=>Hash{Symbol=>Integer}}
Returns a hash of statistics for each file in the diff
71 72 73 |
# File 'lib/git/diff_stats.rb', line 71 def files fetch_stats[:files] end |
#insertions ⇒ Integer
Returns the total number of lines inserted
48 49 50 |
# File 'lib/git/diff_stats.rb', line 48 def insertions fetch_stats[:total][:insertions] end |
#lines ⇒ Integer
Returns the total number of lines changed (insertions + deletions)
59 60 61 |
# File 'lib/git/diff_stats.rb', line 59 def lines fetch_stats[:total][:lines] end |
#total ⇒ Hash{Symbol=>Integer}
Returns a hash of the total statistics for the diff
83 84 85 |
# File 'lib/git/diff_stats.rb', line 83 def total fetch_stats[:total] end |