Class: Ramper
- Inherits:
-
Object
- Object
- Ramper
- Defined in:
- lib/ramper.rb
Constant Summary collapse
- VERSION =
"0.0.3"
Class Method Summary collapse
- .author_summary ⇒ Object
- .author_summary_help ⇒ Object
- .batch_from_most_list(options, most_function, most_param) ⇒ Object
- .batch_metrics(options) ⇒ Object
- .batch_metrics_help ⇒ Object
- .dependency_in(n) ⇒ Object
- .dependency_in_help ⇒ Object
- .dependency_out(n) ⇒ Object
- .dependency_out_help ⇒ Object
- .file_metrics(file, options) ⇒ Object
- .file_metrics_help ⇒ Object
- .files_most_recent(n) ⇒ Object
- .files_most_recent_help ⇒ Object
- .files_with_most_changes(n) ⇒ Object
- .files_with_most_changes_help ⇒ Object
- .files_with_most_commit(n) ⇒ Object
- .files_with_most_commit_help ⇒ Object
- .flay(file) ⇒ Object
- .flay_help ⇒ Object
- .flog(file) ⇒ Object
- .flog_help ⇒ Object
- .stats ⇒ Object
- .stats_help ⇒ Object
- .version ⇒ Object
Class Method Details
.author_summary ⇒ Object
60 61 62 63 |
# File 'lib/ramper.rb', line 60 def self. # 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 ⇒ Object
56 57 58 |
# File 'lib/ramper.rb', line 56 def self. "Gives authorship summary. To figure out who to talk to." end |
.batch_from_most_list(options, most_function, most_param) ⇒ Object
120 121 122 123 124 125 126 127 |
# File 'lib/ramper.rb', line 120 def self.batch_from_most_list(, most_function, most_param) file_metric_calc = RamperFileMetrics.new() 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) ⇒ Object
111 112 113 114 115 116 117 118 |
# File 'lib/ramper.rb', line 111 def self.batch_metrics() file_metric_calc = RamperFileMetrics.new() 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 ⇒ Object
107 108 109 |
# File 'lib/ramper.rb', line 107 def self.batch_metrics_help "Batch file metrics for input stream." end |
.dependency_in(n) ⇒ Object
85 86 87 |
# File 'lib/ramper.rb', line 85 def self.dependency_in(n) DependencyAnalyzer.new.get_in_stats n end |
.dependency_in_help ⇒ Object
81 82 83 |
# File 'lib/ramper.rb', line 81 def self.dependency_in_help "Displays classes that depend on the most other classes." end |
.dependency_out(n) ⇒ Object
93 94 95 |
# File 'lib/ramper.rb', line 93 def self.dependency_out(n) DependencyAnalyzer.new.get_out_stats n end |
.dependency_out_help ⇒ Object
89 90 91 |
# 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) ⇒ Object
101 102 103 104 105 |
# File 'lib/ramper.rb', line 101 def self.file_metrics(file, ) file_metric_calc = RamperFileMetrics.new() puts file_metric_calc.process_file_format puts file_metric_calc.process_file(file) end |
.file_metrics_help ⇒ Object
97 98 99 |
# 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) ⇒ Object
37 38 39 40 41 42 43 |
# 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 ⇒ Object
33 34 35 |
# 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) ⇒ Object
15 16 17 18 |
# 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 ⇒ Object
11 12 13 |
# File 'lib/ramper.rb', line 11 def self.files_with_most_changes_help "Files with most changes" end |
.files_with_most_commit(n) ⇒ Object
24 25 26 27 28 29 30 31 |
# 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 ⇒ Object
20 21 22 |
# File 'lib/ramper.rb', line 20 def self.files_with_most_commit_help "Returns top n files with most commit" end |
.flay(file) ⇒ Object
77 78 79 |
# File 'lib/ramper.rb', line 77 def self.flay(file) `flay #{file}` end |
.flay_help ⇒ Object
73 74 75 |
# 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) ⇒ Object
69 70 71 |
# File 'lib/ramper.rb', line 69 def self.flog(file) `flog #{file}` end |
.flog_help ⇒ Object
65 66 67 |
# 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 ⇒ Object
49 50 51 52 53 54 |
# File 'lib/ramper.rb', line 49 def self.stats require 'rake' require 'code_statistics' Rake::Task[:stats].execute end |
.stats_help ⇒ Object
45 46 47 |
# File 'lib/ramper.rb', line 45 def self.stats_help "Executes rake stats" end |
.version ⇒ Object
7 8 9 |
# File 'lib/ramper.rb', line 7 def self.version puts VERSION end |