class Ramper

Constants

VERSION

Public Class Methods

author_summary() click to toggle source
# File lib/ramper.rb, line 60
def self.author_summary
  # http://stackoverflow.com/questions/1265040/how-to-count-total-lines-changed-by-a-specific-author-in-a-git-repository
  `git shortlog -sne --no-merges`
end
author_summary_help() click to toggle source
# File lib/ramper.rb, line 56
def self.author_summary_help
  "Gives authorship summary. To figure out who to talk to."
end
batch_from_most_list(options, most_function, most_param) click to toggle source
# File lib/ramper.rb, line 120
def self.batch_from_most_list(options, most_function, most_param)
  file_metric_calc = RamperFileMetrics.new(options)
  puts file_metric_calc.process_file_format
  pull_files_from_stats_list(most_function.call(most_param)).each do |line|
    puts file_metric_calc.process_file(line)
  end
  exit
end
batch_metrics(options) click to toggle source
# File lib/ramper.rb, line 111
def self.batch_metrics(options)
  file_metric_calc = RamperFileMetrics.new(options)
  puts file_metric_calc.process_file_format
  while (line=STDIN.gets)
    puts file_metric_calc.process_file(line.chomp)
  end
  exit
end
batch_metrics_help() click to toggle source
# File lib/ramper.rb, line 107
def self.batch_metrics_help
  "Batch file metrics for input stream."
end
dependency_in(n) click to toggle source
# File lib/ramper.rb, line 85
def self.dependency_in(n)
  DependencyAnalyzer.new.get_in_stats n
end
dependency_in_help() click to toggle source
# File lib/ramper.rb, line 81
def self.dependency_in_help
  "Displays classes that depend on the most other classes."
end
dependency_out(n) click to toggle source
# File lib/ramper.rb, line 93
def self.dependency_out(n)
  DependencyAnalyzer.new.get_out_stats n
end
dependency_out_help() click to toggle source
# File lib/ramper.rb, line 89
def self.dependency_out_help
  "Displays classes that are depended on by the most other classes."
end
file_metrics(file, options) click to toggle source
# File lib/ramper.rb, line 101
def self.file_metrics(file, options)
  file_metric_calc = RamperFileMetrics.new(options)
  puts file_metric_calc.process_file_format
  puts file_metric_calc.process_file(file)
end
file_metrics_help() click to toggle source
# File lib/ramper.rb, line 97
def self.file_metrics_help
  "Computes metrics for a given file based on the flags given. Defaults to computing everything"
end
files_most_recent(n) click to toggle source
# File lib/ramper.rb, line 37
def self.files_most_recent(n)
  require 'time'
  # http://serverfault.com/questions/401437/how-to-retrieve-the-last-modification-date-of-all-files-in-a-git-repository
  `git ls-tree -r --name-only HEAD | while read filename; do
    echo "$(git log -1 --format="%at" -- $filename) $filename"
    done | sort -rg | head -#{n}`.gsub(/^(\d+) /) { |_| "#{Time.at($1.to_i).iso8601} " }
end
files_most_recent_help() click to toggle source
# File lib/ramper.rb, line 33
def self.files_most_recent_help
  "Returns the top n recently changed files"
end
files_with_most_changes(n) click to toggle source
# File lib/ramper.rb, line 15
def self.files_with_most_changes(n)
  # http://stackoverflow.com/questions/7686582/finding-most-changed-files-in-git
  `git log --pretty=format: --name-only | sed '/^$/d' | sort | uniq -c | sort -rg | head -#{n}`
end
files_with_most_changes_help() click to toggle source
# File lib/ramper.rb, line 11
def self.files_with_most_changes_help
  "Files with most changes"
end
files_with_most_commit(n) click to toggle source
# File lib/ramper.rb, line 24
def self.files_with_most_commit(n)
  # http://stackoverflow.com/questions/5669621/git-find-out-which-files-have-had-the-most-commits
  `git rev-list --objects --all | awk '$2' | sort -k2 | uniq -cf1 | sort -rn |
    while read frequency sample path
    do
       [ "blob" == "$(git cat-file -t $sample)" ] && echo -e "$frequency\t$path";
    done | head -#{n}`.gsub(/^-e /, '') #there's a bug with bash adds -e to each line
end
files_with_most_commit_help() click to toggle source
# File lib/ramper.rb, line 20
def self.files_with_most_commit_help
  "Returns top n files with most commit"
end
flay(file) click to toggle source
# File lib/ramper.rb, line 77
def self.flay(file)
  `flay #{file}`
end
flay_help() click to toggle source
# File lib/ramper.rb, line 73
def self.flay_help
  "Runs the flay tool on a file/dir. Reports similar blocks of code."
end
flog(file) click to toggle source
# File lib/ramper.rb, line 69
def self.flog(file)
  `flog #{file}`
end
flog_help() click to toggle source
# File lib/ramper.rb, line 65
def self.flog_help
  "Runs the flog metric on a file/dir. Higher numbers = more complex or painful code."
end
stats() click to toggle source
# File lib/ramper.rb, line 49
def self.stats
  require 'rake'
  require 'code_statistics'
  
  Rake::Task[:stats].execute
end
stats_help() click to toggle source
# File lib/ramper.rb, line 45
def self.stats_help
  "Executes rake stats"
end
version() click to toggle source
# File lib/ramper.rb, line 7
def self.version
  puts VERSION
end

Private Class Methods

pull_files_from_stats_list(list) click to toggle source
# File lib/ramper.rb, line 131
def self.pull_files_from_stats_list(list)
  list.split("\n").map { |l| /\s(\S*?)$/.match(l) { |_| $1 } }
end
tips() click to toggle source
# File lib/ramper.rb, line 139
  def self.tips
'######### Tips ########
# Talk to developer to understand overall architecture, block diagram, dependencies.
# Use pen and paper (or IDE) and draw UML diagrams like Class Diagram, Sequence Diagrams to understand structure.
# Follow Top Down Approach. Start from Top View. Then drill down to Mid View and then Low level view features.
# Build code, Run tests, Run Interface, Change something and see tests fail.
# Run code in a debugger to see the stack trace/code flow.
# Use "git grep" to search about git code base. More "git help grep".
# Jumping around definition and references in an IDE helps a lot.
# Write a glossary. It can cover class names, function names, datatype names, common prefixes
#   and file names conventions. This can be contributed back to the project as documentation.
# Read the test suite. This will give you a better idea of what the library does.
# Use "git blame" to see when things have been changed.
########################'
  end
tips_help() click to toggle source
# File lib/ramper.rb, line 135
def self.tips_help
  "Gives some tips on how to ramp up faster"
end