git-age 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9ee1f171ee1fc257032663614b5b13ccadf62e2181450af785d45b98a5c91e17
4
- data.tar.gz: 5607965e9be16da07a2d3a757cd8372fdf160e5263c897f51868179b6a310ebc
3
+ metadata.gz: 3609bcc6cce83c461c4b72a3c2dc52e0b9ee4a8256616b3d08b5e788b3f2dafb
4
+ data.tar.gz: dbeb93657c9a244efaea22e7af4d7d12e35dd2affa4eceece7be00e25f5185c3
5
5
  SHA512:
6
- metadata.gz: 652a2263c2d1cac464b48fc98caeaaf0eb1af076fa06d14982fb2051f31e402a83e5fe73cb911de1111d868f190905d0dd8999ca02af3eda12345079fc2aea39
7
- data.tar.gz: 9ba360f91613ca3928e02237ac232d9076d9ac92782f638ba85d3a95da7500b81dbc2c849abd62350d097c77f807665a1cae301fb2130d0e17230bc21c34a8ef
6
+ metadata.gz: 27c0b90c32a6d11c98ac0513fee1f55a793e7393c61be5ec6aab83a4f9bd89fb329c88e8b6162a11bd7103d68fdee97e6b8193e26df28086753892810421fa6d
7
+ data.tar.gz: 9663c06613211e3d46052891f293134fd07f991804d380a627bc7adfe9375a4415856bc15c5422b8c676181ed3856ea142af280740a676daedfd01f4cbbe22ad
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -21,6 +21,8 @@ Go to your repository and run:
21
21
 
22
22
  ```
23
23
  Usage: git-age [options]
24
+ -b, --branch=BRANCH Git branch
25
+ -m, --map Create a file with processed files and dates
24
26
  -o, --output=FILE Output file
25
27
  -i, --image=FILE Image file
26
28
  -g, --graph=PROCESSOR Graphic processor
@@ -32,8 +34,23 @@ Usage: git-age [options]
32
34
  Example:
33
35
 
34
36
  ```
37
+ $ git-age -o /tmp/data.csv -t 'Test project' -x 'Dates here' -y 'Lines here' -i /tmp/data.png
35
38
  ```
36
39
 
40
+ Supported image processors:
41
+
42
+ - [graph-cli](https://github.com/mcastorina/graph-cli)
43
+
44
+ Default options are:
45
+
46
+ - branch: master
47
+ - output: git-age.csv
48
+ - image: git-age.png
49
+ - graph: graph-cli
50
+ - title: Git age statistics
51
+ - xtitle: Dates
52
+ - ytitle: Lines
53
+
37
54
  ## Development
38
55
 
39
56
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/bin/git-age CHANGED
@@ -13,6 +13,11 @@ opts.on('-b', '--branch=BRANCH', 'Git branch') do |branch|
13
13
  options.branch = branch
14
14
  end
15
15
 
16
+ opts.on('-m', '--map', 'Create a file with processed files and dates') do
17
+ STDOUT.puts "Creating map file"
18
+ options.map = true
19
+ end
20
+
16
21
  opts.on('-o', '--output=FILE', 'Output file') do |file|
17
22
  STDOUT.puts "Output to #{file}"
18
23
  options.output = file
data/lib/git/age/main.rb CHANGED
@@ -1,13 +1,14 @@
1
+ require 'io/console'
2
+
1
3
  module Git
2
4
  module Age
3
5
  class Main
4
- JUSTIFICATION = 150
5
-
6
6
  def initialize
7
7
  STDOUT.puts "Waiting, analysing your repository ..."
8
8
 
9
- @dates = Hash.new(0)
10
- @files = files
9
+ @dates = Hash.new(0)
10
+ @files = files
11
+ @winsize = IO.console.winsize
11
12
  end
12
13
 
13
14
  def run
@@ -22,24 +23,34 @@ module Git
22
23
  private
23
24
 
24
25
  def read_files
25
- cnt = 0
26
- total = @files.size
26
+ cnt = 0
27
+ total = @files.size
28
+ mapfile = Git::Age::Options.instance.map ? File.open("/tmp/git-age.map", 'w') : nil
29
+
27
30
 
28
31
  @files.each do |file|
29
32
  cnt += 1
30
33
  next unless text?(file)
31
34
 
32
- print "Checking [#{cnt}/#{total}] #{file.ljust(JUSTIFICATION)} ...\r"
35
+ print "Checking [#{cnt}/#{total}] #{file} ...".ljust(@winsize[1]) + "\r"
33
36
 
34
- IO.popen("git blame #{file} | iconv -t utf8") do |io|
35
- io.read.split("\n")
36
- end.each do |line|
37
- matches = line.match(/\(.*(?<date>\d{4}-\d{2})-\d{2}.*\)/)
38
- next unless matches
37
+ begin
38
+ IO.popen("git blame #{file} | iconv -t utf8") do |io|
39
+ io.read.split("\n")
40
+ end.each do |line|
41
+ matches = line.match(/[\w^]+\s\([\w\s]+(?<date>\d{4}-\d{2})-\d{2}/)
42
+ next unless matches
39
43
 
40
- @dates[matches[:date]] += 1
44
+ mapfile << "#{file}: #{line}\n" if mapfile
45
+
46
+ @dates[matches[:date]] += 1
47
+ end
48
+ rescue => blame
49
+ print "Error on file: #{file}\r"
41
50
  end
42
51
  end
52
+
53
+ mapfile.close if mapfile
43
54
  rescue => e
44
55
  STDERR.puts "Error reading files: #{e}"
45
56
  end
@@ -50,7 +61,7 @@ module Git
50
61
 
51
62
  def create_csv
52
63
  output = Git::Age::Options.instance.output
53
- STDOUT.puts "Creating CSV file #{output} ...".ljust(JUSTIFICATION)
64
+ STDOUT.puts "Creating CSV file #{output} ...".ljust(@winsize[1])
54
65
 
55
66
  File.open(output, 'w') do |file|
56
67
  @dates.each do |key, value|
@@ -4,7 +4,7 @@ module Git
4
4
  module Age
5
5
  class Options
6
6
  include Singleton
7
- attr_accessor :branch, :output, :title, :processor, :image, :xtitle, :ytitle
7
+ attr_accessor :branch, :output, :title, :processor, :image, :xtitle, :ytitle, :map
8
8
 
9
9
  def initialize
10
10
  @branch = 'master'
@@ -14,6 +14,7 @@ module Git
14
14
  @image = 'git-age.png'
15
15
  @xtitle = 'Dates'
16
16
  @ytitle = 'Lines'
17
+ @map = false
17
18
  end
18
19
  end
19
20
  end
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Age
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
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.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eustaquio Rangel
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubygems_version: 3.3.7
86
+ rubygems_version: 3.0.3
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Create a CSV file with line year and month from your Git repository
metadata.gz.sig CHANGED
Binary file