Class: Git::Diff
Overview
object that holds the last X commits on given branch
Defined Under Namespace
Classes: DiffFile
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#[](key)
enumerable methods.
- #deletions
-
#each(&block)
:yields: each Git::DiffFile in turn.
-
#initialize(base, from = nil, to = nil) ⇒ Diff
constructor
A new instance of Diff.
- #insertions
- #lines
- #name_status
-
#patch(file = nil)
(also: #to_s)
if file is provided and is writable, it will write the patch into the file.
- #path(path)
- #size
- #stats
Constructor Details
permalink #initialize(base, from = nil, to = nil) ⇒ Diff
Returns a new instance of Diff.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/git/diff.rb', line 9 def initialize(base, from = nil, to = nil) @base = base @from = from && from.to_s @to = to && to.to_s @path = nil @full_diff = nil @full_diff_files = nil @stats = nil end |
Instance Attribute Details
permalink #from (readonly)
Returns the value of attribute from.
19 20 21 |
# File 'lib/git/diff.rb', line 19 def from @from end |
permalink #to (readonly)
Returns the value of attribute to.
19 20 21 |
# File 'lib/git/diff.rb', line 19 def to @to end |
Instance Method Details
permalink #[](key)
enumerable methods
64 65 66 67 |
# File 'lib/git/diff.rb', line 64 def [](key) process_full @full_diff_files.assoc(key)[1] end |
permalink #deletions
[View source]
40 41 42 43 |
# File 'lib/git/diff.rb', line 40 def deletions cache_stats @stats[:total][:deletions] end |
permalink #each(&block)
:yields: each Git::DiffFile in turn
69 70 71 72 |
# File 'lib/git/diff.rb', line 69 def each(&block) # :yields: each Git::DiffFile in turn process_full @full_diff_files.map { |file| file[1] }.each(&block) end |
permalink #insertions
[View source]
45 46 47 48 |
# File 'lib/git/diff.rb', line 45 def insertions cache_stats @stats[:total][:insertions] end |
permalink #lines
[View source]
35 36 37 38 |
# File 'lib/git/diff.rb', line 35 def lines cache_stats @stats[:total][:lines] end |
permalink #name_status
[View source]
21 22 23 |
# File 'lib/git/diff.rb', line 21 def name_status cache_name_status end |
permalink #patch(file = nil) Also known as: to_s
if file is provided and is writable, it will write the patch into the file
56 57 58 59 |
# File 'lib/git/diff.rb', line 56 def patch(file = nil) cache_full @full_diff end |
permalink #path(path)
[View source]
25 26 27 28 |
# File 'lib/git/diff.rb', line 25 def path(path) @path = path return self end |
permalink #size
[View source]
30 31 32 33 |
# File 'lib/git/diff.rb', line 30 def size cache_stats @stats[:total][:files] end |
permalink #stats
[View source]
50 51 52 53 |
# File 'lib/git/diff.rb', line 50 def stats cache_stats @stats end |