Class: GitPm::LinesByAuthor

Inherits:
Object
  • Object
show all
Defined in:
lib/git_pm/lines_by_author.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ LinesByAuthor

Returns a new instance of LinesByAuthor.



3
4
5
# File 'lib/git_pm/lines_by_author.rb', line 3

def initialize(options)
  @branch = options.shift || "master"
end

Instance Method Details

#run!Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/git_pm/lines_by_author.rb', line 7

def run!
  exclude = []

  if File.directory?("vendor")
    exclude << "vendor"
  end

  if File.directory?("3rdparty")
    exclude << "3rdparty"
  end

  data = GitData.blame(@branch, exclude)

  fields = []
  lines_by_author = []
  authors = 0
  data.sort_by { |k, v| v[:lines] }.each { |value|
    author = value.first
    d = value.last
    fields << author
    lines_by_author << d[:lines]

    authors += 1
  }

  graph = SVG::Graph::BarHorizontal.new({
    :height => 40*authors,
    :width  => 640+20*authors,
    :fields => fields,
    :rotate_y_labels => false
  })

  graph.add_data({
    :data => lines_by_author,
    :title => 'Lines by author',
  })

  graph.burn()
end