Class: Git::Blame
- Inherits:
-
Object
- Object
- Git::Blame
- Defined in:
- lib/Git/Blame.rb
Defined Under Namespace
Classes: PorcelainEntry
Instance Method Summary collapse
- #blame_output ⇒ Object
- #command_string ⇒ Object
- #entries ⇒ Object
- #find(line_number) ⇒ Object
-
#initialize(filename, line_number = nil) ⇒ Blame
constructor
class PorcelainEntry.
Constructor Details
#initialize(filename, line_number = nil) ⇒ Blame
class PorcelainEntry
81 82 83 84 |
# File 'lib/Git/Blame.rb', line 81 def initialize(filename, line_number = nil) @filename = filename @line_number = line_number end |
Instance Method Details
#blame_output ⇒ Object
94 95 96 |
# File 'lib/Git/Blame.rb', line 94 def blame_output `#{command_string}` end |
#command_string ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/Git/Blame.rb', line 86 def command_string if @line_number "git --no-pager blame -L #{@line_number},#{@line_number} #{@filename} --line-porcelain" else "git --no-pager blame #{@filename} --line-porcelain" end end |
#entries ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/Git/Blame.rb', line 98 def entries line_count = 0 porcelain_entry_string = '' entries = [] blame_array = blame_output.split("\n") line_number = 0 i = -1 until i >= blame_array.size - 1 until blame_array[i].split.first == 'filename' porcelain_entry_string << blame_array[i += 1] porcelain_entry_string << "\n" end porcelain_entry_string << blame_array[i += 1] porcelain_entry_string << "\n" entries << PorcelainEntry.new(porcelain_entry_string, line_number += 1).parse line_count = 0 porcelain_entry_string = '' end entries end |
#find(line_number) ⇒ Object
119 120 121 |
# File 'lib/Git/Blame.rb', line 119 def find(line_number) entries.detect{|entry| entry.line_number == line_number} end |