Class: Git::Blame::PorcelainEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/Git/Blame.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(porcelain_output, line_number = nil) ⇒ PorcelainEntry

Returns a new instance of PorcelainEntry.



42
43
44
45
# File 'lib/Git/Blame.rb', line 42

def initialize(porcelain_output, line_number = nil)
  @porcelain_output = porcelain_output
  @line_number = line_number
end

Instance Attribute Details

#line_numberObject (readonly)

class << self



40
41
42
# File 'lib/Git/Blame.rb', line 40

def line_number
  @line_number
end

Class Method Details

.parse(porcelain_output) ⇒ Object



34
35
36
# File 'lib/Git/Blame.rb', line 34

def parse(porcelain_output)
  new(porcelain_output).parse
end

Instance Method Details

#codeObject



65
66
67
# File 'lib/Git/Blame.rb', line 65

def code
  lines.last
end

#commit_hashObject



57
58
59
# File 'lib/Git/Blame.rb', line 57

def commit_hash
  lines.first.split.first
end

#parseObject



47
48
49
50
51
52
53
54
55
# File 'lib/Git/Blame.rb', line 47

def parse
  lines_with_keys.each do |line|
    variable_name = line.split.first.tr('-','_')
    value = line.split.all_but_first.join(' ')
    instance_variable_set("@#{variable_name}", value)
    self.class.class_eval("attr_reader :#{variable_name}")
  end
  self
end

#previous_commit_hashObject



61
62
63
# File 'lib/Git/Blame.rb', line 61

def previous_commit_hash
  @previous.split.first
end