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.
4 5 6 7 8 9 10 |
# File 'lib/gitstat/cli.rb', line 4 def initialize(*) if ARGV.empty? blank elsif ARGV[0] == "time" time end end |
Instance Method Details
#blank ⇒ Object
12 13 14 15 16 |
# File 'lib/gitstat/cli.rb', line 12 def blank str = %q{git log --format='%aN' | sort -u | while read name; do echo "Author >>>> " "$name"; 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} system "bash", "-c", str end |
#time ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/gitstat/cli.rb', line 18 def time(*) from = ARGV[1] to = ARGV[2] str = %q{git log --format='%aN' | sort -u | while read name; do echo "Author >>>> " "$name"; 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} system "bash", "-c", str end |