Module: Metior

Defined in:
lib/metior.rb,
lib/metior/git.rb,
lib/metior/vcs.rb,
lib/metior/actor.rb,
lib/metior/commit.rb,
lib/metior/errors.rb,
lib/metior/github.rb,
lib/metior/report.rb,
lib/metior/version.rb,
lib/metior/git/actor.rb,
lib/metior/git/commit.rb,
lib/metior/repository.rb,
lib/metior/github/actor.rb,
lib/metior/github/commit.rb,
lib/metior/git/repository.rb,
lib/metior/auto_include_vcs.rb,
lib/metior/github/repository.rb,
lib/metior/collections/collection.rb,
lib/metior/collections/actor_collection.rb,
lib/metior/collections/commit_collection.rb

Overview

This code is free software; you can redistribute it and/or modify it under the terms of the new BSD License.

Copyright (c) 2011, Sebastian Staudt

Defined Under Namespace

Modules: AutoIncludeVCS, Git, GitHub, VCS Classes: Actor, ActorCollection, Collection, Commit, CommitCollection, Report, Repository, UnsupportedError

Constant Summary collapse

VERSION =

The current version of the Metior gem

'0.2.0'
@@vcs_types =

This hash will be dynamically filled with all available VCS types and the corresponding implementation modules

{}

Class Method Summary collapse

Class Method Details

.report(type, repo_options, target_dir, range = nil, report = 'default') ⇒ Object

Generates a report for the given repository

Parameters:

  • type (Symbol)

    The type of the repository, e.g. :git

  • options (Array<Object>)

    The options to use for creating the new repository, e.g. a file system path

  • target_dir (String)

    The target directory to save the report to

  • range (String, Range) (defaults to: nil)

    The commit range to analyze for the report

  • report (String) (defaults to: 'default')

    The name of the report template to use



36
37
38
39
40
# File 'lib/metior.rb', line 36

def self.report(type, repo_options, target_dir, range = nil, report = 'default')
  repo = repository type, *repo_options
  range ||= repo.vcs::DEFAULT_BRANCH
  Report.create(report, repo, range).generate target_dir
end

.repository(type, *options) ⇒ Repository

Creates a new repository for the given repository type and path

Parameters:

  • type (Symbol)

    The type of the repository, e.g. :git

  • options (Array<Object>)

    The options to use for creating the new repository, e.g. a file system path

Returns:

  • (Repository)

    A VCS specific Repository instance



24
25
26
# File 'lib/metior.rb', line 24

def self.repository(type, *options)
  vcs(type)::Repository.new(*options)
end

.simple_stats(type, repo_options, range = nil) ⇒ Hash<Symbol, Object>

Calculates simplistic stats for the given repository and branch

Parameters:

  • type (Symbol)

    The type of the repository, e.g. :git

  • repo_options (Object, Array<Object>)

    The options to supply to the repository

  • range (String, Range) (defaults to: nil)

    The range of commits for which the commits should be loaded. This may be given as a string ('master..development'), a range ('master'..'development') or as a single ref ('master'). A single ref name means all commits reachable from that ref.

Returns:

  • (Hash<Symbol, Object>)

    The calculated stats for the given repository and branch



54
55
56
57
58
59
60
61
62
63
# File 'lib/metior.rb', line 54

def self.simple_stats(type, repo_options, range = nil)
  range = vcs(type)::DEFAULT_BRANCH if range.nil?
  repo  = repository type, *repo_options

  commits = repo.commits(range)
  {
    :commit_count     => commits.size,
    :top_contributors => repo.top_contributors(range, 5),
  }.merge commits.activity
end

.vcs(type) ⇒ VCS

Returns the VCS implementation Module for a given symbolic VCS name

Parameters:

  • type (Symbol)

    The symbolic type name of the VCS

Returns:

  • (VCS)

    The VCS for the given name



18
19
20
21
22
23
24
# File 'lib/metior/vcs.rb', line 18

def self.vcs(type)
  type = type.to_sym
  unless @@vcs_types.key? type
    raise 'No VCS registered for :%s' % type
  end
  @@vcs_types[type].init
end

.vcs_typesHash<Symbol, VCS>

Returns a Hash with all available VCS types as keys and the implementation modules as values

Returns:

  • (Hash<Symbol, VCS>)

    All available VCS implementations and their corresponding names



31
32
33
# File 'lib/metior/vcs.rb', line 31

def self.vcs_types
  @@vcs_types
end