module GitSurvey

Generates a report on a git project's history

Constants

VERSION

Public Class Methods

main(_argv) click to toggle source
# File lib/git_survey.rb, line 37
def self.main(_argv)
  options = Parser.parse(ARGV)

  # Google JSON Style Guide (camel case for keys)
  # https://google.github.io/styleguide/jsoncstyleguide.xml

  result = {
    EXECUTABLE_NAME => executable_hash(options),
    'repo' => repo_hash(options),
    'hotFiles' => ShellAdapter.hot_files(options.anonymize,
                                         options.input_directory,
                                         options.number_of_hotfiles),
    'authors' => ShellAdapter.authors(options.anonymize,
                                      options.input_directory)
  }

  puts JSON.pretty_generate(result)

  exit 0
end

Private Class Methods

executable_hash(options) click to toggle source
# File lib/git_survey.rb, line 13
def self.executable_hash(options)
  {
    'date' => options.scan_date,
    'anonymized' => options.anonymize,
    'branch' => options.git_branch,
    'hotFiles' => options.number_of_hotfiles
  }
end
repo_hash(options) click to toggle source
# File lib/git_survey.rb, line 23
def self.repo_hash(options)
  {
    'name' => ShellAdapter.repo_name(options.anonymize, options.input_directory),
    'dateOfInit' => ShellAdapter.init_date(options.input_directory),
    'dateOfLastCommit' => ShellAdapter.latest_activity_date(options.input_directory),
    'yearsWorkedOn' => ShellAdapter.activity_interval(options.input_directory),
    'numberOfFiles' => ShellAdapter.number_of_files(options.input_directory),
    'numberOfCommits' => ShellAdapter.number_of_commits(options.input_directory,
                                                        options.git_branch),
    'numberOfBranches' => ShellAdapter.number_of_branches(options.input_directory)
  }
end