Module: Metior
- Defined in:
- lib/metior.rb,
lib/metior/vcs.rb,
lib/metior/actor.rb,
lib/metior/errors.rb,
lib/metior/report.rb,
lib/metior/commit.rb,
lib/metior/version.rb,
lib/metior/repository.rb,
lib/metior/auto_include_adapter.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-2012, Sebastian Staudt
Defined Under Namespace
Modules: Adapter, AutoIncludeAdapter, Registerable, Report, VCS Classes: Actor, ActorCollection, Collection, Commit, CommitCollection, FileNotFoundError, Repository, UnknownAdapterError, UnknownVCSError, UnsupportedError
Constant Summary
- VERSION =
'0.2.0'- @@reports =
This holds all available reports, i.e. their names and the corresponding class
{}
- @@vcs_adapters =
This hash will be dynamically filled with all available VCS adapters and the corresponding modules
{}
- @@vcs_types =
This hash will be dynamically filled with all available VCS types and the corresponding modules
{}
Class Method Summary (collapse)
-
+ (Module) find_adapter(name)
Returns the adapter
Modulefor a given symbolic adapter name. -
+ (Class) find_report(name)
Find the base class of the report with the given name.
-
+ (Module) find_vcs(name)
Returns the VCS
Modulefor a given symbolic VCS name. -
+ (Object) register(name, mod)
Registers a VCS or adapter
Moduleusing the given symbolic name. -
+ (Object) report(type, repo_options, target_dir, range = nil, report = 'default')
Generates a report for the given repository.
-
+ (Repository) repository(name, *options)
Creates a new repository for the given VCS or adapter name and repository path.
-
+ (Hash<Symbol, Object>) simple_stats(type, repo_options, range = nil)
Calculates simplistic stats for the given repository and branch.
Class Method Details
+ (Module) find_adapter(name)
Returns the adapter Module for a given symbolic adapter name
87 88 89 90 91 |
# File 'lib/metior.rb', line 87 def self.find_adapter(name) name = name.to_sym raise UnknownAdapterError.new(name) unless @@vcs_adapters.key? name @@vcs_adapters[name] end |
+ (Class) find_report(name)
Find the base class of the report with the given name
97 98 99 100 101 |
# File 'lib/metior.rb', line 97 def self.find_report(name) name = name.to_sym raise UnknownReportError.new(name) unless @@reports.key? name @@reports[name] end |
+ (Module) find_vcs(name)
Returns the VCS Module for a given symbolic VCS name
121 122 123 124 125 |
# File 'lib/metior.rb', line 121 def self.find_vcs(name) name = name.to_sym raise UnknownVCSError.new(name) unless @@vcs_types.key? name @@vcs_types[name] end |
+ (Object) register(name, mod)
Registers a VCS or adapter Module using the given symbolic name
107 108 109 110 111 112 113 114 115 |
# File 'lib/metior.rb', line 107 def self.register(name, mod) if mod.include? VCS @@vcs_types[name] = mod elsif mod.include? Adapter @@vcs_adapters[name] = mod elsif mod.include? Report @@reports[name] = mod end end |
+ (Object) report(type, repo_options, target_dir, range = nil, report = 'default')
Generates a report for the given repository
54 55 56 57 58 |
# File 'lib/metior.rb', line 54 def self.report(type, , target_dir, range = nil, report = 'default') repo = repository type, * range ||= repo.current_branch Report.create(report, repo, range).generate target_dir end |
+ (Repository) repository(name, *options)
Creates a new repository for the given VCS or adapter name and repository path
37 38 39 40 41 42 43 44 |
# File 'lib/metior.rb', line 37 def self.repository(name, *) begin adapter = find_adapter name rescue UnknownAdapterError adapter = find_vcs(name).default_adapter end adapter::Repository.new * end |
+ (Hash<Symbol, Object>) simple_stats(type, repo_options, range = nil)
Calculates simplistic stats for the given repository and branch
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/metior.rb', line 72 def self.simple_stats(type, , range = nil) repo = repository type, * range ||= repo.current_branch commits = repo.commits(range) { :commit_count => commits.size, :top_contributors => repo.top_contributors(range, 5) }.merge commits.activity end |