Class: Gitstat::CLI
- Inherits:
-
Object
- Object
- Gitstat::CLI
- Defined in:
- lib/gitstat/cli.rb
Instance Method Summary collapse
- #author ⇒ Object
- #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 11 12 13 14 15 |
# File 'lib/gitstat/cli.rb', line 4 def initialize(*) string = "" if ARGV.empty? string = blank elsif ARGV.include? "-a" string = elsif ARGV.include? "-t" string = time end system "bash", "-c", string end |
Instance Method Details
#author ⇒ Object
27 28 29 30 |
# File 'lib/gitstat/cli.rb', line 27 def user = ARGV[1] str = %q{git log --numstat --pretty="%H"} + %{--author="#{user}"} + %q{ | awk 'NF==3 {plus+=$1; minus+=$2} NF==1 {total++} END {printf("lines added: +%d\nlines deleted: -%d\ntotal commits: %d\n", plus, minus, total)}'} end |
#blank ⇒ Object
17 18 19 |
# File 'lib/gitstat/cli.rb', line 17 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} end |
#time ⇒ Object
21 22 23 24 25 |
# File 'lib/gitstat/cli.rb', line 21 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} end |