Method: Metior.simple_stats

Defined in:
lib/metior.rb

.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

[View source]

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