Class: Git::Diff
Overview
object that holds the last X commits on given branch
Defined Under Namespace
Classes: DiffFile
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
-
#[](key) ⇒ Object
enumerable methods.
- #deletions ⇒ Object
-
#each(&block) ⇒ Object
:yields: each Git::DiffFile in turn.
-
#initialize(base, from = nil, to = nil) ⇒ Diff
constructor
A new instance of Diff.
- #insertions ⇒ Object
- #lines ⇒ Object
- #name_status ⇒ 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.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/git/diff.rb', line 7 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
#from ⇒ Object (readonly)
Returns the value of attribute from.
17 18 19 |
# File 'lib/git/diff.rb', line 17 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
17 18 19 |
# File 'lib/git/diff.rb', line 17 def to @to end |
Instance Method Details
#[](key) ⇒ Object
enumerable methods
62 63 64 65 |
# File 'lib/git/diff.rb', line 62 def [](key) process_full @full_diff_files.assoc(key)[1] end |
#deletions ⇒ Object
38 39 40 41 |
# File 'lib/git/diff.rb', line 38 def deletions cache_stats @stats[:total][:deletions] end |
#each(&block) ⇒ Object
:yields: each Git::DiffFile in turn
67 68 69 70 |
# File 'lib/git/diff.rb', line 67 def each(&block) # :yields: each Git::DiffFile in turn process_full @full_diff_files.map { |file| file[1] }.each(&block) end |
#insertions ⇒ Object
43 44 45 46 |
# File 'lib/git/diff.rb', line 43 def insertions cache_stats @stats[:total][:insertions] end |
#lines ⇒ Object
33 34 35 36 |
# File 'lib/git/diff.rb', line 33 def lines cache_stats @stats[:total][:lines] end |
#name_status ⇒ Object
19 20 21 |
# File 'lib/git/diff.rb', line 19 def name_status cache_name_status 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
54 55 56 57 |
# File 'lib/git/diff.rb', line 54 def patch(file = nil) cache_full @full_diff end |
#path(path) ⇒ Object
23 24 25 26 |
# File 'lib/git/diff.rb', line 23 def path(path) @path = path return self end |
#size ⇒ Object
28 29 30 31 |
# File 'lib/git/diff.rb', line 28 def size cache_stats @stats[:total][:files] end |
#stats ⇒ Object
48 49 50 51 |
# File 'lib/git/diff.rb', line 48 def stats cache_stats @stats end |