Class: Gitstat::CLI
- Inherits:
-
Object
- Object
- Gitstat::CLI
- Defined in:
- lib/gitstat/cli.rb
Instance Method Summary collapse
- #blank ⇒ Object
-
#initialize ⇒ CLI
constructor
A new instance of CLI.
- #time ⇒ Object
Constructor Details
#initialize ⇒ CLI
Returns a new instance of CLI.
5 6 7 8 9 10 11 12 |
# File 'lib/gitstat/cli.rb', line 5 def initialize(*) if ARGV.empty? blank elsif ARGV[0] == "time" time end end |
Instance Method Details
#blank ⇒ Object
14 15 16 17 |
# File 'lib/gitstat/cli.rb', line 14 def blank str = %q{git log --format='%aN' | sort -u | while read name; do echo "Author >>>> " "$name\t"; git log --numstat --pretty="%H" --author="$name" | awk 'NF==3 {plus+=$1; minus+=$2} NF==1 {total++} END {printf("lines added: +%d lines \t | \t deleted: -%d lines \t | \t total commits: %d\n**************************************************************************\n\n", plus, minus, total)}' -; done} exec str end |
#time ⇒ Object
19 20 21 22 23 24 |
# File 'lib/gitstat/cli.rb', line 19 def time(*) from = ARGV[1] to = ARGV[2] str = %q{git log --format='%aN' | sort -u | while read name; do echo "Author >>>> " "$name\t"; git log --numstat --pretty="%H" --author="$name"} + %{ --since '#{from}' --until '#{to}' } + %q{| awk 'NF==3 {plus+=$1; minus+=$2} NF==1 {total++} END {printf("******************************************\nlines added: \t +%d lines \ndeleted: \t -%d lines \ntotal commits: \t %d\n******************************************\n\n", plus, minus, total)}' -; done} exec str end |