class Repokeeper::RepoAnalyzer

provides infrastructure for running commits analyzers

Public Class Methods

new(repo_proxy, formatter, analyzers, config) click to toggle source
# File lib/repokeeper/repo_analyzer.rb, line 4
def initialize(repo_proxy, formatter, analyzers, config)
  @analyzers = analyzers
  @formatter = formatter
  @repo = repo_proxy
  @config = config
end

Public Instance Methods

analyze(rev_range = nil) click to toggle source
# File lib/repokeeper/repo_analyzer.rb, line 11
def analyze(rev_range = nil)
  @rev_range = rev_range

  @formatter.started
  run_commits_analyzers
  run_branches_analyzers
  @formatter.finished
end

Private Instance Methods

branch_analyzers() click to toggle source
# File lib/repokeeper/repo_analyzer.rb, line 26
def branch_analyzers
  @analyzers.branch_analyzers
end
commits() click to toggle source
# File lib/repokeeper/repo_analyzer.rb, line 64
def commits
  @commits ||= @repo.commits(@rev_range)
end
commits_analyzers() click to toggle source
# File lib/repokeeper/repo_analyzer.rb, line 22
def commits_analyzers
  @analyzers.commits_analyzers
end
enabled_analyzers(collection) click to toggle source
# File lib/repokeeper/repo_analyzer.rb, line 30
def enabled_analyzers(collection)
  collection
    .map { |analyzer_class| instantiate_analyzer(analyzer_class) }
    .select(&:enabled?)
end
enabled_branches_analyzers() click to toggle source
# File lib/repokeeper/repo_analyzer.rb, line 40
def enabled_branches_analyzers
  @enabled_branches_analyzers ||= enabled_analyzers(branch_analyzers)
end
enabled_commits_analyzers() click to toggle source
# File lib/repokeeper/repo_analyzer.rb, line 36
def enabled_commits_analyzers
  @enabled_commits_analyzers ||= enabled_analyzers(commits_analyzers)
end
instantiate_analyzer(analyzer_class) click to toggle source
# File lib/repokeeper/repo_analyzer.rb, line 60
def instantiate_analyzer(analyzer_class)
  analyzer_class.new(@config.for(analyzer_class))
end
run_branches_analyzers() click to toggle source
# File lib/repokeeper/repo_analyzer.rb, line 53
def run_branches_analyzers
  enabled_branches_analyzers.each do |analyzer|
    result = analyzer.analyze(@repo)
    @formatter.branches_analyzer_results(analyzer.name, result)
  end
end
run_commits_analyzers() click to toggle source
# File lib/repokeeper/repo_analyzer.rb, line 44
def run_commits_analyzers
  commits.each do |commit|
    enabled_commits_analyzers.each do |analyzer|
      result = analyzer.process_commit(commit)
      @formatter.commits_analyzer_results(analyzer.name, result)
    end
  end
end