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 # => {#<Grit::Actor "Jakub Stastny aka botanicus <stastny@101ideas.cz>"> => {:commits => 9, :LOC => 255}} # You can optionally specify project path thusly: contributors = Contributors.new(Dir.pwd) # The Contributors#result method takes an optional argument # determining by which field you want to sort the results: contributors.results(:LOC) # or :commits # By default it takes all the changes (as the second argument # defaults to :total), but if you want, you can limit changes # on :additions or :deletions only: contributors.results(:LOC, :additions)
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: Criterium for counting lines of code. Can be either # :additions, :deletions or :total (which is the default value). Task[:contributors].config[:criterium] = :total # 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] = -> { |author, data| "#{author.email}: #{data[:LOC]}" }