About

The contributors gem is useful for getting informations about project contributors. It assumes that Git is used. In particular it can be used for generating CONTRIBUTORS file.

Usage

Just install it through RubyGems:


gem install contributors

Use the API:


require "contributors"

contributors = Contributors.new
contributors.results
# => {"[email protected]" => {:name => "Jakub Stastny aka botanicus", :commits = >3, :LOC = >219}}

# You can optionally specify project path and list of ignored patterns thusly:
contributors = Contributors.new(Dir.pwd, [/^(vendor|gems)\//, /.+\.gem$/])

# The Contributors#result method takes an optional argument determining by which field you want to sort the results:
contributors.resuls(:LOC) # or :commits

Use the Nake tasks:


load "contributors.nake"

# OPTIONAL: Where the project is located. Defaults to Dir.pwd.
Task[:contributors].config[:path] = Dir.pwd

# OPTIONAL: Where the CONTRIBUTORS file is located.
# It can be either a string or a callable object. Defaults to:
# Proc.new { File.join(task.config[:path], "CONTRIBUTORS") }
Task[:contributors].config[:output_path] = Proc.new { File.join(task.config[:path], "CONTRIBUTORS") }

# OPTIONAL: How to sort results, options are :commits or :LOC, :LOC is default.
Task[:contributors].config[:sort_by] = :LOC

# OPTIONAL: An array of regular expressions which should be ignored.
# Defaults to Contributors::IGNORED_PATTERNS, which is [/^vendor\//, /^gems\//, /.+\.gem$/].
Task[:contributors].config[:ignore] = Contributors::IGNORED_PATTERNS

# OPTIONAL: How to format each line. E-mail is author's e-mail and in data
there are keys :name, :commits and :LOC. Commits and LOC are both integers.
Task[:contributors].config[:format] = -> { |email, data| "#{email}: #{data[:LOC]}" }