gitstatsakido 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
  SHA1:
3
- metadata.gz: efe2e1ed3118a95823a37ecee8d27323ddaebbaa
4
- data.tar.gz: 3e4c648e0d26f06dc581f06c6306a91e59752e26
3
+ metadata.gz: 5cdf92c5842db20fcb99518acf5de3de1daf96a5
4
+ data.tar.gz: 61fb218e95622048114b1596319a9f0903ac65fe
5
5
  SHA512:
6
- metadata.gz: 1cad1093695028b49bc050a8c1eecb787ce3c4123a5e80db1026d4bbe333571a623405d5da5f81da37ded234b63f7e292feed5e182e2fcc5ddc6da235d71b262
7
- data.tar.gz: b73f98bdfef25d65a934bdab4890b84e539a1a7068d45616ad4c4fb75297bf97710faceedadc0b8996d8fe821025a7784ca5389d6377f4ed488db2fe7a475d4a
6
+ metadata.gz: c289ad3fa5e20c5d867d065b68915c4825b55d72494fac5255af53d655c41fd4546a7444e1bc94c3789e19ecbd39d506f889b1ac2b6789a9b31d6c72380375a2
7
+ data.tar.gz: 29dbcab19f9f2acfde102dbb7de187c9f785f2cff5192cafdd23a84c48f260e0acd7e59e14f64217e2ee42d85942449eb52db6cf287af12a5defcc4a3b9c209b
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitstatsakido
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
  - Lei Wang
@@ -60,24 +60,7 @@ executables:
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
- - ".gitignore"
64
- - ".idea/.rakeTasks"
65
- - ".idea/misc.xml"
66
- - ".idea/modules.xml"
67
- - ".idea/vcs.xml"
68
- - ".rspec"
69
- - ".travis.yml"
70
- - CODE_OF_CONDUCT.md
71
- - Gemfile
72
- - README.md
73
- - Rakefile
74
- - bin/console
75
63
  - bin/gitstats
76
- - bin/setup
77
- - gitstats.gemspec
78
- - lib/b.txt
79
- - lib/gitstats.rb
80
- - lib/gitstats/version.rb
81
64
  homepage: http://www.akidolabs.com
82
65
  licenses:
83
66
  - MIT
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- /.idea/
2
- /.bundle/
3
- /Gemfile.lock
4
- /pkg/
data/.idea/.rakeTasks DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Settings><!--This file was automatically generated by Ruby plugin.
3
- You are allowed to:
4
- 1. Remove rake task
5
- 2. Add existing rake tasks
6
- To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build gitstats-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install gitstats-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install gitstats-0.1.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.0 and build and push gitstats-0.1.0.gem to Rubygems" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="Run RSpec code examples" fullCmd="spec" taksId="spec" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
data/.idea/misc.xml DELETED
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectLevelVcsManager" settingsEditedManually="false">
4
- <OptionsSetting value="true" id="Add" />
5
- <OptionsSetting value="true" id="Remove" />
6
- <OptionsSetting value="true" id="Checkout" />
7
- <OptionsSetting value="true" id="Update" />
8
- <OptionsSetting value="true" id="Status" />
9
- <OptionsSetting value="true" id="Edit" />
10
- <ConfirmationsSetting value="0" id="Add" />
11
- <ConfirmationsSetting value="0" id="Remove" />
12
- </component>
13
- <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-2.2.1" project-jdk-type="RUBY_SDK" />
14
- </project>
data/.idea/modules.xml DELETED
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/gitstats.iml" filepath="$PROJECT_DIR$/.idea/gitstats.iml" />
6
- </modules>
7
- </component>
8
- </project>
data/.idea/vcs.xml DELETED
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
- </component>
6
- </project>
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.2.1
5
- before_install: gem install bundler -v 1.12.1
data/CODE_OF_CONDUCT.md DELETED
@@ -1,49 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, and in the interest of
4
- fostering an open and welcoming community, we pledge to respect all people who
5
- contribute through reporting issues, posting feature requests, updating
6
- documentation, submitting pull requests or patches, and other activities.
7
-
8
- We are committed to making participation in this project a harassment-free
9
- experience for everyone, regardless of level of experience, gender, gender
10
- identity and expression, sexual orientation, disability, personal appearance,
11
- body size, race, ethnicity, age, religion, or nationality.
12
-
13
- Examples of unacceptable behavior by participants include:
14
-
15
- * The use of sexualized language or imagery
16
- * Personal attacks
17
- * Trolling or insulting/derogatory comments
18
- * Public or private harassment
19
- * Publishing other's private information, such as physical or electronic
20
- addresses, without explicit permission
21
- * Other unethical or unprofessional conduct
22
-
23
- Project maintainers have the right and responsibility to remove, edit, or
24
- reject comments, commits, code, wiki edits, issues, and other contributions
25
- that are not aligned to this Code of Conduct, or to ban temporarily or
26
- permanently any contributor for other behaviors that they deem inappropriate,
27
- threatening, offensive, or harmful.
28
-
29
- By adopting this Code of Conduct, project maintainers commit themselves to
30
- fairly and consistently applying these principles to every aspect of managing
31
- this project. Project maintainers who do not follow or enforce the Code of
32
- Conduct may be permanently removed from the project team.
33
-
34
- This code of conduct applies both within project spaces and in public spaces
35
- when an individual is representing the project or its community.
36
-
37
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
- reported by contacting a project maintainer at lei@akidolabs.com. All
39
- complaints will be reviewed and investigated and will result in a response that
40
- is deemed necessary and appropriate to the circumstances. Maintainers are
41
- obligated to maintain confidentiality with regard to the reporter of an
42
- incident.
43
-
44
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
- version 1.3.0, available at
46
- [http://contributor-covenant.org/version/1/3/0/][version]
47
-
48
- [homepage]: http://contributor-covenant.org
49
- [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in gitstats.gemspec
4
- gemspec
data/README.md DELETED
@@ -1,38 +0,0 @@
1
- # Gitstats
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gitstats`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Install it to your local directory by running:
10
-
11
- $ gem install gitstatsakido
12
-
13
- ## Example Usage and Output (run in a git directory)
14
-
15
- ~/ruby/gitstats $ gitstats
16
-
17
- Author <lei@akidolabs.com>:
18
- `Total # of commits: 14`
19
- `Total # of files changed: 64`
20
- `Total # of lines changed: 1117`
21
- `# of inserts: 767`
22
- `# of deletes: 350`
23
-
24
- ## Development
25
-
26
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
27
-
28
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
29
-
30
- ## Contributing
31
-
32
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gitstats. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
33
-
34
-
35
- ## License
36
-
37
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
38
-
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "gitstats"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/gitstats.gemspec DELETED
@@ -1,24 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'gitstats/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "gitstatsakido"
8
- spec.version = Gitstats::VERSION
9
- spec.authors = ["Lei Wang"]
10
- spec.email = ["lei@akidolabs.com"]
11
-
12
- spec.summary = %q{Display Git Coding Stats}
13
- spec.description = %q{Display code change stats for the current git repository by Author}
14
- spec.homepage = "http://www.akidolabs.com"
15
- spec.license = "MIT"
16
-
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.executables = ["gitstats"]
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.12"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec", "~> 3.0"
24
- end
data/lib/b.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2016 Lei Wang
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
@@ -1,3 +0,0 @@
1
- module Gitstats
2
- VERSION = "0.1.2"
3
- end
data/lib/gitstats.rb DELETED
@@ -1,231 +0,0 @@
1
- require "gitstats/version"
2
- require "open3"
3
-
4
- module Gitstats
5
-
6
- class Commit
7
- def initialize(id, commit_text_chunk)
8
- # ignore_files = []
9
- ignore_files = ['.txt', '.dat', '.csv', 'out', 'swp', '.class', '.pdf', '.html', '.versionsBackup']
10
- @id = id
11
- @text = commit_text_chunk
12
- @ignore_add = 0
13
- @ignore_del = 0
14
- @inserts = 0
15
- @deletes = 0
16
- @files = 0
17
- minus_c = 0
18
- plus_c = 0
19
- minus_count = 0
20
- plus_count = 0
21
- commit_text_chunk.split(/\r?\n/).each do |line|
22
- # if @id.index('12226') != nil
23
- # puts line
24
- # end
25
- words = line.split()
26
- if /Author: [^<]+<[^>]+>/.match(line)
27
- # TODO use name instead of email
28
- @author = words[-1]
29
- elsif /Date: /.match(line)
30
- @time = Time.parse(line[7..-1])
31
- elsif / [0-9]+ files? changed/.match(line)
32
- words.each_with_index do |item, index|
33
- if item[0..3] == 'file'
34
- @files = words[index-1].to_i
35
- elsif item[0..3] == 'inse'
36
- @inserts = words[index-1].to_i
37
- elsif item[0..3] == 'dele'
38
- @deletes = words[index-1].to_i
39
- end
40
- end
41
- @inserts -= @ignore_add
42
- @deletes -= @ignore_del
43
- @files = words[0].to_i
44
- elsif / [^|]+\|[ ]+[0-9]+ [+-]+/.match(line)
45
- if words[3] == '|'
46
- words = words[2..-1]
47
- end
48
- file_name = words[0].split()[-1]
49
- count = words[2].to_i
50
- plus_count = 0
51
- minus_count = 0
52
- plus_c = 0
53
- minus_c = 0
54
- if count > 0
55
- words[3].each_char do |c|
56
- if c == '+'
57
- plus_count += 1
58
- else
59
- minus_count += 1
60
- end
61
- end
62
- plus_c = count * plus_count / (plus_count + minus_count)
63
- minus_c = count - plus_c
64
- end
65
- ignore_files.each do |ext|
66
- comp_length = ext.length
67
- if file_name[-1 * comp_length..-1] == ext
68
- @ignore_add += plus_c
69
- @ignore_del += minus_c
70
- # puts "#{@id} #{@inserts} #{@deletes} #{plus_c} #{minus_c} #{minus_count} #{plus_count}"
71
- break
72
- end
73
- end
74
- end
75
- end
76
- end
77
-
78
- def print_info
79
- puts "Commit: #{@id} Author: #{@author} Time: #{@time} Files changed: #{@files} Inserts #{@inserts} Deletes #{@deletes}"
80
- end
81
-
82
- def author()
83
- @author
84
- end
85
-
86
- def set_author(author)
87
- @author = author
88
- end
89
-
90
- def inserts()
91
- @inserts
92
- end
93
-
94
- def deletes
95
- @deletes
96
- end
97
-
98
- def loc
99
- @inserts + @deletes
100
- end
101
-
102
- def files
103
- @files
104
- end
105
- end
106
-
107
- class Author
108
- def initialize(name)
109
- @name = name
110
- @commits = Array.new
111
- @total_lines = 0
112
- @total_files = 0
113
- @total_inserts = 0
114
- @total_deletes = 0
115
- end
116
-
117
- def add_commit(commit)
118
- @commits << commit
119
-
120
- if commit.inserts != nil
121
- @total_lines += commit.inserts
122
- @total_inserts += commit.inserts
123
- end
124
- if commit.deletes != nil
125
- @total_lines += commit.deletes
126
- @total_deletes += commit.deletes
127
- end
128
-
129
- @total_files += commit.files
130
- end
131
-
132
- def total_commits
133
- @commits.length
134
- end
135
-
136
- def total_lines
137
- @total_lines
138
- end
139
-
140
- def total_files
141
- @total_files
142
- end
143
-
144
- def total_inserts
145
- @total_inserts
146
- end
147
-
148
- def total_deletes
149
- @total_deletes
150
- end
151
-
152
- def print_commits_sorted
153
- s = @commits.sort { |y, x| (x.inserts + x.deletes) <=> (y.inserts + y.deletes) }
154
- total = 10
155
- s.each do |c|
156
- if total < 0
157
- break
158
- end
159
- c.print_info
160
- total -= 1
161
- end
162
- end
163
- end
164
-
165
-
166
-
167
- class Stats
168
- output, error, status = Open3.capture3('git log --stat -M')
169
- error = error.strip
170
- @@authors = Hash.new
171
- auth_mapping = {"<hgordon@gmail.com>" => "<hugh@akidolabs.com>", "hgordon@gmail.com" => "<hugh@akidolabs.com", "<hugh@Hugh-Mac.local>" => "<hugh@akidolabs.com>"}
172
- auth_mapping["<poksay.andrew@gmail.com>"] = "<andrew@akidolabs.com>"
173
- if error == 'fatal: Not a git repository (or any of the parent directories): .git'
174
- @@result = "Please run this gem from a git repository's directory (that you have run git init on)"
175
- elsif !error.empty?
176
- @@result = 'Unknown error from git: ' + error
177
- else
178
- @@result = 'Running git log --stat -M'
179
- commit_regex = /commit [a-z0-9]{40}\r?\n/
180
- commits = output.enum_for(:scan, commit_regex).map { Regexp.last_match.begin(0) }
181
- commits.each_with_index do |x, index|
182
- if index >= commits.length - 1
183
- end_match = output.length
184
- else
185
- end_match = commits[index+1]
186
- end
187
-
188
- commit_data = Commit.new(output[x+7,40], output[x+48..end_match-1])
189
- if auth_mapping.key?(commit_data.author)
190
- commit_data.set_author(auth_mapping[commit_data.author])
191
- end
192
- if commit_data.author.index("andrew") != nil
193
- puts @@authors[commit_data.author]
194
- puts @@authors.keys
195
- end
196
- auth = commit_data.author
197
- if !@@authors.key?(auth)
198
- @@authors[auth] = Author.new(auth)
199
- end
200
- @@authors[auth].add_commit(commit_data)
201
- end
202
- end
203
-
204
- def print_info
205
- puts @@result, "\n"
206
- if @@authors.size > 0
207
- sorted_authors = @@authors.keys.sort { |y, x| @@authors[y].total_commits <=> @@authors[x].total_commits }
208
- sorted_authors.each do |k|
209
- v = @@authors[k]
210
- puts "Author #{k}:"
211
- puts " Total # of commits: #{v.total_commits}"
212
- puts " Total # of files changed: #{v.total_files}"
213
- puts " Total # of lines changed: #{v.total_lines}"
214
- puts " # of inserts: #{v.total_inserts}"
215
- puts " # of deletes: #{v.total_deletes}"
216
- end
217
- end
218
- end
219
-
220
- def print_commits
221
- if @@authors.size > 0
222
- puts "\nTop 10 commits by lines changed:"
223
- @@authors.each do |k, v|
224
- puts "\n#################\nAuthor #{k}:"
225
- v.print_commits_sorted
226
- end
227
- end
228
- end
229
- end
230
-
231
- end