git-age 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ca88ce726a22c3d328f0b6835f6a8d8bb4fe536f94758ac379affd74e60186c
4
- data.tar.gz: 967fdf60b74d412fc14018a53b90f448a616866a8d1bcbbe38a63d5864cb8fd2
3
+ metadata.gz: 4085ff2fcbb2716f679f72390a9f896892a2623fea3635ae234539471cf154a7
4
+ data.tar.gz: 4666d870907b6aecf5490eb01ddbcb6dfe6957705616ea697d935bc98b2ee6b4
5
5
  SHA512:
6
- metadata.gz: a681fea9df900e90e6a24412fee946c04345871834a93d055837c3f8077521b9c9539c51255673892d4c1f9cb47c9da383c7a3e25a6a80b43aec5a9950dc0d25
7
- data.tar.gz: 888a69bac791c31113da473ce63ea3377ca139fc4db8961466f24094b04c7134562373439f548ad172f28dafec688ad00bb15754316d6c76dd6f616087917ad1
6
+ metadata.gz: 7f8636eddb349efa34d91d05cfbf49d165834bf3d22d188bf1160276eb4ff1dfea73761283cac50b49638a158a44582478d09284e626e0843430c6d935489c12
7
+ data.tar.gz: e9c065d66218683e39b6a3b719e8ae95abfd89163d14505f4221fc0856a9749ae5f4409c6f3cc4e0e255c72c5227136fcdf74a0b153277a0f1033c1d4369bfd0
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -41,6 +41,10 @@ Supported image processors:
41
41
 
42
42
  - [graph-cli](https://github.com/mcastorina/graph-cli)
43
43
 
44
+ Example image:
45
+
46
+ ![graph-cli graph](https://github.com/taq/git-age/blob/master/graph-cli.png?raw=true)
47
+
44
48
  Default options are:
45
49
 
46
50
  - branch: master
data/graph-cli.png ADDED
Binary file
@@ -11,11 +11,10 @@ module Git
11
11
  options = Git::Age::Options.instance
12
12
  STDOUT.puts "Creating image #{options.image} ..."
13
13
 
14
- cmd = "graph #{input} --bar -o #{options.image} --title '#{options.title}' --xlabel='#{options.xtitle}' --ylabel='#{options.ytitle}' --xtick-fontsize 5 --time-format-output '%Y-%m-%d' --legend=''"
14
+ cmd = "graph #{input} --bar -o #{options.image} --title '#{options.title}' --xlabel='#{options.xtitle}' --ylabel='#{options.ytitle}' --xtick-fontsize 5 --time-format-output '%Y-%m-%d' --legend='' 2> /dev/null"
15
15
  rst = IO.popen(cmd) do |io|
16
16
  io.read
17
17
  end
18
- STDOUT.puts rst
19
18
  end
20
19
  end
21
20
  end
data/lib/git/age/main.rb CHANGED
@@ -1,8 +1,11 @@
1
+ require 'date'
1
2
  require 'io/console'
2
3
 
3
4
  module Git
4
5
  module Age
5
6
  class Main
7
+ attr_reader :dates, :files
8
+
6
9
  def initialize
7
10
  STDOUT.puts "Waiting, analysing your repository ..."
8
11
 
@@ -16,6 +19,7 @@ module Git
16
19
  sort_dates
17
20
  create_csv
18
21
  create_image
22
+ show_stats
19
23
  rescue => e
20
24
  STDERR.puts "Error: #{e}"
21
25
  end
@@ -27,7 +31,6 @@ module Git
27
31
  total = @files.size
28
32
  mapfile = Git::Age::Options.instance.map ? File.open("/tmp/git-age.map", 'w') : nil
29
33
 
30
-
31
34
  @files.each do |file|
32
35
  cnt += 1
33
36
  next unless text?(file)
@@ -109,6 +112,19 @@ module Git
109
112
  io.read
110
113
  end.match?(/\Atext/)
111
114
  end
115
+
116
+ def show_stats
117
+ stats = Git::Age::Stats.new(self)
118
+ first = Date.parse(stats.first_commit)
119
+ last = Date.parse(stats.last_commit)
120
+ diff = (last - first).to_i
121
+ ustats = stats.unchanged_stats
122
+
123
+ puts "First commit in: #{first}"
124
+ puts "Last commit in: #{last}"
125
+ puts "Repository is #{diff} days old"
126
+ puts "Month with more lines unchanged: #{ustats[:bigger][:date]} (#{ustats[:bigger][:lines]} lines)"
127
+ end
112
128
  end
113
129
  end
114
130
  end
@@ -0,0 +1,32 @@
1
+ module Git
2
+ module Age
3
+ class Stats
4
+ def initialize(data)
5
+ @data = data
6
+ end
7
+
8
+ def first_commit
9
+ commit_date('--reverse')
10
+ end
11
+
12
+ def last_commit
13
+ commit_date
14
+ end
15
+
16
+ def unchanged_stats
17
+ max = @data.dates.max_by { |key, value| value }
18
+ { bigger: { date: max[0], lines: max[1] } }
19
+ end
20
+
21
+ private
22
+
23
+ def commit_date(order = nil)
24
+ cmd = "git log #{order} --pretty=format:%ad --date=short | head -n1"
25
+
26
+ IO.popen(cmd) do |io|
27
+ io.read.chomp.strip
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Age
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
data/lib/git/age.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require_relative 'age/main'
2
2
  require_relative 'age/options'
3
+ require_relative 'age/stats'
3
4
  require_relative 'age/graph_cli'
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-age
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eustaquio Rangel
@@ -58,10 +58,12 @@ files:
58
58
  - bin/setup
59
59
  - gem-public_cert.pem
60
60
  - git-age.gemspec
61
+ - graph-cli.png
61
62
  - lib/git/age.rb
62
63
  - lib/git/age/graph_cli.rb
63
64
  - lib/git/age/main.rb
64
65
  - lib/git/age/options.rb
66
+ - lib/git/age/stats.rb
65
67
  - lib/git/age/version.rb
66
68
  homepage: https://github.com/taq/git-age
67
69
  licenses: []
metadata.gz.sig CHANGED
Binary file