summaryrefslogtreecommitdiff
path: root/maint/autocontrib
blob: f0eaf66fdf6fe8b8d95257b133f91e952ca92555 (plain)
1
2
3
4
5
6
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
#!/usr/bin/env ruby

begin
  require 'mustache'
rescue LoadError
  $stderr.puts <<-HERE
Error: This project requires the mustache Ruby gem in order to finish
the maintainer setup. Please install it and re-run autocontrib.

The mustache gem can be installed using gem:

    gem install mustache
  HERE
  exit 1
end

class ContributorView < Mustache
  def contributors
    @_contributors ||= raw_contributors
  end

  private

  def raw_contributors
    shortlog.map do |contributor_line|
      if contributor_line =~ /\d+\s+(.+)\s+<(.+)>/
        { :name => $1, :email => $2 }
      end
    end.compact
  end

  def shortlog
    `git shortlog -es`.split("\n")
  end
end


contributor_view = ContributorView.new

ARGV.each do |template_filename|
  output_filename = template_filename.sub(/\.mustache$/, '')
  contributor_view.template_file = template_filename
  output = contributor_view.render
  File.write(output_filename, output)
end