Module: Dolt::View::Blame

Defined in:
lib/libdolt/view/blame.rb

Instance Method Summary collapse

Instance Method Details

#blame_annotation_cell(annotation) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/libdolt/view/blame.rb', line 39

def blame_annotation_cell(annotation)
  class_name = "gts-blame-annotation" + (annotation.nil? ? "" : " gts-annotated")
  return "<td class=\"#{class_name}\"></td>" if annotation.nil?

  <<-HTML
    <td class="#{class_name}">
      <span class="gts-commit-oid" data-gts-commit-oid="#{annotation[:oid]}" title="#{annotation[:summary]}">#{annotation[:oid][0..6]}</span>
      #{annotation[:committer][:time].strftime("%Y-%m-%d")}
      #{annotation[:committer][:name]}
    </td>
  HTML
end

#blame_annotations(blame) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/libdolt/view/blame.rb', line 22

def blame_annotations(blame)
  blame.chunks.inject([]) do |blames, chunk|
    blames << chunk
    (chunk[:lines].length - 1).times { blames << nil }
    blames
  end
end

#blame_code_cell(line) ⇒ Object



52
53
54
# File 'lib/libdolt/view/blame.rb', line 52

def blame_code_cell(line)
  "<td class=\"gts-code\"><code>#{line}</code></td>"
end

#blame_lines(path, blame) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/libdolt/view/blame.rb', line 30

def blame_lines(path, blame)
  lines = blame.chunks.inject([]) do |lines, chunk|
    lines.concat(chunk[:lines])
  end

  return lines unless respond_to?(:highlight)
  highlight(path, lines.join("\n")).split("\n")
end