git-age 0.1.6 → 0.1.7

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: 0af8c2ed2b23e1c87fb85a906b68e032870c1b8a196185ac599ac34e97491828
4
- data.tar.gz: 412ecb46c57e359a4f13800f37df589c6e3e38cf078ed2ec8fe17930e4005b14
3
+ metadata.gz: 1fbe783975bcef6d1078e1a9f164f8879318b2d92e205fd3a4303960f094451b
4
+ data.tar.gz: 4a5d7ad103214b16e53ec2cc4f04f1b77641943dc48ee42198b91a4e89758b5c
5
5
  SHA512:
6
- metadata.gz: 3642b48474489273d6199776a1a60a4c228d50ddd713f048ee2611c658d7eded9a3a46aa8d331ccbbd874aa1f646f697a310d5f7763ca8b5fddd1661f9febe55
7
- data.tar.gz: dcda04fa314058efb654e2e62e8cb6d8de298418a07d3bb43003d9e4fbe96a99835f5960f97ed26b02747ac050975a63c32b2869ef57684323ce949c46a92e32
6
+ metadata.gz: bff7fdd7358c94f99cb6d67cfb118d16eebb0b3cb28b381087041be75a4292849351b46ec350caa14b1d38fef0ea578e829decf312c9e3f15baede30bac90ef2
7
+ data.tar.gz: e4b1102f940e665915ba7f207fe6259c430bf84cd13c9ccae9edcc339ab6bdc2e001abadf8ab7b30efbbc347137d0021a0d9f529e8f3ac83b388cc35d51491d5
checksums.yaml.gz.sig CHANGED
Binary file
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git-age (0.1.6)
4
+ git-age (0.1.7)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -32,6 +32,7 @@ Usage: git-age [options]
32
32
  -c, --code=PATTERN Code dir pattern
33
33
  -e, --test=PATTERN Test dir pattern
34
34
  -p, --type=TYPE Graph type, default to bar
35
+ -a, --authors [FILE] Create statistics by author
35
36
  -v, --version Show version
36
37
  ```
37
38
 
data/bin/git-age CHANGED
@@ -68,6 +68,11 @@ opts.on('-v', '--version', 'Show version') do
68
68
  return
69
69
  end
70
70
 
71
+ opts.on('-a', '--authors [FILE]', 'Create authors file') do |file|
72
+ STDOUT.puts "Creating authors file"
73
+ options.authors = file.to_s.strip.size > 0 ? file : "git-age-authors.csv"
74
+ end
75
+
71
76
  opts.parse!
72
77
 
73
78
  Git::Age::Main.new.run
data/lib/git/age/main.rb CHANGED
@@ -8,12 +8,15 @@ module Git
8
8
 
9
9
  def initialize
10
10
  STDOUT.puts "Waiting, analysing your repository ..."
11
+ options = Git::Age::Options.instance
11
12
 
12
13
  @dates = Hash.new { |hash, key| hash[key] = { code: 0, test: 0 } }
13
14
  @files = fill_files
14
15
  @winsize = IO.console.winsize
15
- @test = Git::Age::Options.instance.test
16
- @code = Git::Age::Options.instance.code
16
+ @test = options.test
17
+ @code = options.code
18
+ @mapfile = options.map ? File.open("/tmp/git-age.map", 'w') : nil
19
+ @authors = options.authors ? Hash.new(0) : nil
17
20
 
18
21
  @test_regexp = @test ? %r{^#{@test}} : nil
19
22
  @code_regexp = @code ? %r{^#{@code}} : nil
@@ -43,7 +46,6 @@ module Git
43
46
  def read_files
44
47
  cnt = 0
45
48
  total = @files.size
46
- mapfile = Git::Age::Options.instance.map ? File.open("/tmp/git-age.map", 'w') : nil
47
49
 
48
50
  @files.each do |file|
49
51
  cnt += 1
@@ -55,25 +57,43 @@ module Git
55
57
  IO.popen("git blame #{file} | iconv -t utf8") do |io|
56
58
  io.read.split("\n")
57
59
  end.each do |line|
58
- matches = line.match(/[\w^]+\s\([\w\s]+(?<date>\d{4}-\d{2})-\d{2}/)
60
+ matches = line.match(/[\w^]+\s\((?<author>[\w\s]+)(?<date>\d{4}-\d{2})-\d{2}/)
59
61
  next unless matches
60
62
 
63
+ tokens = line.strip.split(')')
64
+ contents = tokens[1..-1].join.strip.chomp
65
+ next if contents.size == 0
66
+
61
67
  type = file_type(file)
62
- mapfile << "#{file}[#{type}]: #{line}\n" if mapfile
68
+ @mapfile << "#{file}[#{type}]: #{line}\n" if @mapfile
63
69
 
64
70
  @dates[matches[:date]][:test] += 1 if type == :t
65
71
  @dates[matches[:date]][:code] += 1 if type == :c
72
+
73
+ @authors[matches[:author].strip.chomp] += 1 if @authors
66
74
  end
67
75
  rescue => exc
68
76
  print "Error on file: #{file}: #{exc}\r"
69
77
  end
70
78
  end
71
79
 
72
- mapfile.close if mapfile
80
+ @mapfile.close if @mapfile
81
+ write_authors if @authors
73
82
  rescue => e
74
83
  STDERR.puts "Error reading files: #{e}"
75
84
  end
76
85
 
86
+ def write_authors
87
+ path = Git::Age::Options.instance.authors
88
+ STDOUT.puts "\nWriting authors file #{path} ..."
89
+
90
+ File.open(path, 'w') do |file|
91
+ @authors.each do |author, lines|
92
+ file << "#{author}: #{lines}\n"
93
+ end
94
+ end
95
+ end
96
+
77
97
  def sort_dates
78
98
  @dates = @dates.sort_by { |k, v| k }
79
99
  end
@@ -4,7 +4,8 @@ module Git
4
4
  module Age
5
5
  class Options
6
6
  include Singleton
7
- attr_accessor :branch, :output, :title, :processor, :image, :xtitle, :ytitle, :map, :test, :code, :type
7
+ attr_accessor :branch, :output, :title, :processor, :image, :xtitle,
8
+ :ytitle, :map, :test, :code, :type, :authors
8
9
 
9
10
  def initialize
10
11
  @branch = 'master'
@@ -18,6 +19,7 @@ module Git
18
19
  @code = nil
19
20
  @type = 'bar'
20
21
  @map = false
22
+ @authors = nil
21
23
  end
22
24
  end
23
25
  end
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Age
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.7"
4
4
  end
5
5
  end
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.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eustaquio Rangel
@@ -36,7 +36,7 @@ cert_chain:
36
36
  7NRJmY9c84Zb3sCf0DV6UH+d2id9Dndp9ewchgDOSwGznt+oJmjDFZ9gYd8IP2Ol
37
37
  1eLrW8x4LHV+EVEIaiVTvmKt
38
38
  -----END CERTIFICATE-----
39
- date: 2022-12-22 00:00:00.000000000 Z
39
+ date: 2023-01-03 00:00:00.000000000 Z
40
40
  dependencies: []
41
41
  description: Check all the repository files lines dates and group it by year and month,
42
42
  allowing check how old code is still in use
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
- rubygems_version: 3.3.3
88
+ rubygems_version: 3.0.3
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: Create a CSV file with line year and month from your Git repository
metadata.gz.sig CHANGED
Binary file