Class: Git::Diff
Overview
object that holds the last X commits on given branch
Defined Under Namespace
Classes: DiffFile
Instance Method Summary collapse
-
#[](key) ⇒ Object
enumerable methods.
- #deletions ⇒ Object
- #each ⇒ Object
-
#initialize(base, from = nil, to = nil) ⇒ Diff
constructor
A new instance of Diff.
- #insertions ⇒ Object
- #lines ⇒ Object
-
#patch(file = nil) ⇒ Object
(also: #to_s)
if file is provided and is writable, it will write the patch into the file.
- #path(path) ⇒ Object
- #size ⇒ Object
- #stats ⇒ Object
Constructor Details
#initialize(base, from = nil, to = nil) ⇒ Diff
Returns a new instance of Diff.
16 17 18 19 20 |
# File 'lib/git/diff.rb', line 16 def initialize(base, from = nil, to = nil) @base = base @from = from.to_s @to = to.to_s end |
Instance Method Details
#[](key) ⇒ Object
enumerable methods
61 62 63 64 |
# File 'lib/git/diff.rb', line 61 def [](key) process_full @full_diff_files.assoc(key)[1] end |
#deletions ⇒ Object
37 38 39 40 |
# File 'lib/git/diff.rb', line 37 def deletions cache_stats @stats[:total][:deletions] end |
#each ⇒ Object
66 67 68 69 70 71 |
# File 'lib/git/diff.rb', line 66 def each process_full @full_diff_files.each do |file| yield file[1] end end |
#insertions ⇒ Object
42 43 44 45 |
# File 'lib/git/diff.rb', line 42 def insertions cache_stats @stats[:total][:insertions] end |
#lines ⇒ Object
32 33 34 35 |
# File 'lib/git/diff.rb', line 32 def lines cache_stats @stats[:total][:lines] end |
#patch(file = nil) ⇒ Object Also known as: to_s
if file is provided and is writable, it will write the patch into the file
53 54 55 56 |
# File 'lib/git/diff.rb', line 53 def patch(file = nil) cache_full @full_diff end |
#path(path) ⇒ Object
22 23 24 25 |
# File 'lib/git/diff.rb', line 22 def path(path) @path = path return self end |
#size ⇒ Object
27 28 29 30 |
# File 'lib/git/diff.rb', line 27 def size cache_stats @stats[:total][:files] end |
#stats ⇒ Object
47 48 49 50 |
# File 'lib/git/diff.rb', line 47 def stats cache_stats @stats end |