class Gitrob::CLI::Commands::Analyze

Public Class Methods

new(targets, options) click to toggle source
# File lib/gitrob/cli/commands/analyze.rb, line 11
def initialize(targets, options)
  Thread.abort_on_exception = true
  @options = options
  @targets = targets.split(",").map(&:strip).uniq
  load_signatures!
  create_database_assessment
  gather_owners
  gather_repositories
  analyze_repositories
  @db_assessment.finished = true
  @db_assessment.save
  start_web_server
end

Public Instance Methods

blobs_for_repository(repo) click to toggle source
# File lib/gitrob/cli/commands/analyze/analysis.rb, line 65
def blobs_for_repository(repo)
  github_data_manager.blobs_for_repository(repo)
end
repo_progress_bar() { |progress| ... } click to toggle source
# File lib/gitrob/cli/commands/analyze/analysis.rb, line 52
def repo_progress_bar
  progress_bar(
    "Analyzing repositories...",
    :total => repository_count) do |progress|
    yield progress
  end
  sleep 0.1
end
repositories_for_owner(owner) click to toggle source
# File lib/gitrob/cli/commands/analyze/analysis.rb, line 61
def repositories_for_owner(owner)
  github_data_manager.repositories_for_owner(owner)
end
repository_count() click to toggle source
# File lib/gitrob/cli/commands/analyze/analysis.rb, line 69
def repository_count
  @github_data_manager.repositories.count
end

Private Instance Methods

create_database_assessment() click to toggle source
# File lib/gitrob/cli/commands/analyze.rb, line 27
def create_database_assessment
  @db_assessment = Gitrob::Models::Assessment.create(
    :endpoint   => @options[:endpoint],
    :site       => @options[:site],
    :verify_ssl => @options[:verify_ssl],
    :finished   => false
  )
  github_access_tokens.each do |access_token|
    @db_assessment.save_github_access_token(access_token)
  end
end
load_signatures!() click to toggle source
# File lib/gitrob/cli/commands/analyze.rb, line 39
def load_signatures!
  task("Loading signatures...", true) do
    Gitrob::BlobObserver.load_signatures!
  end

  if Gitrob::BlobObserver.custom_signatures?
    task("Loading custom signatures...", true) do
      Gitrob::BlobObserver.load_custom_signatures!
    end
    info("Please consider contributing your custom signatures to the " \
         "Gitrob project.")
  end
  info("Loaded #{Gitrob::BlobObserver.signatures.count} signatures")
end
start_web_server() click to toggle source
# File lib/gitrob/cli/commands/analyze.rb, line 54
def start_web_server
  return unless options[:server]
  info "Starting web application on port #{options[:port]}..."
  info "Browse to http://#{options[:bind_address]}:" \
       "#{options[:port]}/ to see results!"

  if debugging_enabled?
    Sequel::Model.db.logger = QueryLogger.new(STDOUT)
  end

  Gitrob::WebApp.run!(
    :port => options[:port].to_i,
    :bind => options[:bind_address]
  )
end