graf 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d7748fe57dd64ba90a9aee48dddeddf21a3917c0
4
+ data.tar.gz: 9edc33d7bd5ab5c67a827549d8fa4843c8d8c341
5
+ SHA512:
6
+ metadata.gz: 7a19d972d16bfe71694c24bf211b47638095f5a3483cb116fcbf61e72a99c1e037a3d55159dcd984bbe8b6f0b6392e20020230faff84345567b431006fcb25d3
7
+ data.tar.gz: e0a7d1151798fd77c0f1829f0c40e43ca84ce3f3e5eb4c0ff71574323c5cfcb8322aa1f0496c026b05e06145d2e4e530b71178f37c028cc184a5f2b727cccbd8
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Graf
1
+ # Graf [![Gem Version](https://badge.fury.io/rb/graf.png)](http://rubygems.org/gems/graf) [![Dependency Status](https://gemnasium.com/abhshkdz/graf.png)](https://gemnasium.com/abhshkdz/graf)
2
2
 
3
3
  Graf is a simple git log analyzer gem.
4
4
 
data/bin/graf CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  $:.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
5
5
 
6
+ require 'open3'
6
7
  require_relative '../lib/graf'
7
8
 
8
- puts Graf::Source.authors
9
+ puts Graf::Filter.process
@@ -1,2 +1,3 @@
1
1
  require 'graf/version'
2
- require 'graf/source'
2
+ require 'graf/filter'
3
+ require 'graf/source'
@@ -0,0 +1,26 @@
1
+ #encoding: utf-8
2
+
3
+ module Graf
4
+ class Filter
5
+ class << self
6
+ IS_GIT = 'git rev-parse --is-inside-work-tree'
7
+ IS_LOG = 'git log'
8
+
9
+ def process
10
+ o, e, s = Open3.capture3(IS_GIT)
11
+
12
+ if e.include? 'Not a git repository'
13
+ return 'Not a git repository (or any of the parent directories)'
14
+ else
15
+ o, e, s = Open3.capture3(IS_LOG)
16
+
17
+ if e.include? 'bad default revision'
18
+ return 'This git repository don\'t have any commits yet'
19
+ else
20
+ Source.authors()
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,33 +1,39 @@
1
1
  #encoding: utf-8
2
2
 
3
3
  module Graf
4
- class Source
5
- class << self
6
- TICK = '▇'
7
- def authors
8
- log = `git shortlog -se`
9
- log = log.scan(/(\d+)\t(.*)\<(.*)\>/)
10
- frequency = {}
11
- log.each do |row|
12
- count, username, email = *row
13
- username.strip!
14
- email.strip!
15
- email.gsub!(/(.*)@.*/, '\1')
16
- frequency[email] ||= {}
17
- frequency[email][:count] ||= 0
18
- frequency[email][:count] += count.to_i
19
- frequency[email][:username] = username
20
- end
21
- max = frequency.map {|v|v.last[:count]}.max
22
- authors = frequency.keys.sort_by do |author|
23
- frequency[author][:count]
24
- end.reverse.map do |author|
25
- TICK * (frequency[author][:count] * 70 / max) +
26
- " #{frequency[author][:username]} (#{frequency[author][:count]} commit" +
27
- (frequency[author][:count] == 1 ? ")" : "s)")
28
- end
29
- return authors
30
- end
31
- end
32
- end
4
+ class Source
5
+ class << self
6
+ TICK = '▇'
7
+
8
+ def authors
9
+ log = `git shortlog -se`
10
+ log = log.scan(/(\d+)\t(.*)\<(.*)\>/)
11
+ frequency = {}
12
+
13
+ log.each do |row|
14
+ count, username, email = *row
15
+ username.strip!
16
+ email.strip!
17
+ email.gsub!(/(.*)@.*/, '\1')
18
+
19
+ frequency[email] ||= {}
20
+ frequency[email][:count] ||= 0
21
+ frequency[email][:count] += count.to_i
22
+ frequency[email][:username] = username
23
+ end
24
+
25
+ max = frequency.map { |v| v.last[:count] }.max
26
+
27
+ authors = frequency.keys.sort_by { |author| frequency[author][:count] }
28
+ .reverse.map do |author|
29
+ data = TICK * (frequency[author][:count] * 70 / max)
30
+ data << " #{frequency[author][:username]}"
31
+ data << " (#{frequency[author][:count]} commit"
32
+ data << (frequency[author][:count] == 1 ? ")" : "s)")
33
+ end
34
+
35
+ authors
36
+ end
37
+ end
38
+ end
33
39
  end
@@ -1,3 +1,3 @@
1
1
  module Graf
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,46 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Abhishek Das
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-05 00:00:00.000000000 Z
11
+ date: 2014-07-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  description: A simple git log analyzer gem
@@ -51,7 +46,7 @@ executables:
51
46
  extensions: []
52
47
  extra_rdoc_files: []
53
48
  files:
54
- - .gitignore
49
+ - ".gitignore"
55
50
  - Gemfile
56
51
  - LICENSE.txt
57
52
  - README.md
@@ -59,6 +54,7 @@ files:
59
54
  - bin/graf
60
55
  - graf.gemspec
61
56
  - lib/graf.rb
57
+ - lib/graf/filter.rb
62
58
  - lib/graf/source.rb
63
59
  - lib/graf/version.rb
64
60
  - test/lib/graf/version_test.rb
@@ -66,27 +62,26 @@ files:
66
62
  homepage: https://github.com/abhshkdz/graf
67
63
  licenses:
68
64
  - MIT
65
+ metadata: {}
69
66
  post_install_message:
70
67
  rdoc_options: []
71
68
  require_paths:
72
69
  - lib
73
70
  required_ruby_version: !ruby/object:Gem::Requirement
74
- none: false
75
71
  requirements:
76
- - - ! '>='
72
+ - - ">="
77
73
  - !ruby/object:Gem::Version
78
74
  version: '0'
79
75
  required_rubygems_version: !ruby/object:Gem::Requirement
80
- none: false
81
76
  requirements:
82
- - - ! '>='
77
+ - - ">="
83
78
  - !ruby/object:Gem::Version
84
79
  version: '0'
85
80
  requirements: []
86
81
  rubyforge_project:
87
- rubygems_version: 1.8.23
82
+ rubygems_version: 2.2.2
88
83
  signing_key:
89
- specification_version: 3
84
+ specification_version: 4
90
85
  summary: A simple git log analyzer gem
91
86
  test_files:
92
87
  - test/lib/graf/version_test.rb