Class: Gitstat::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/gitstat/cli.rb

Instance Method Summary collapse

Constructor Details

#initializeCLI

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

#blankObject



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

#timeObject



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