gpr-contrib 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/Rakefile +1 -0
- data/gpr-contrib.gemspec +24 -0
- data/lib/gpr/actions/contrib.rb +24 -0
- data/lib/gpr/commands/contrib.rb +50 -0
- data/lib/gpr/contrib.rb +2 -0
- data/lib/gpr/contrib/version.rb +5 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 428aaf40cacf834e80d6047c7f50638237a5244a
|
4
|
+
data.tar.gz: 5b4f343a7974b21d60495216abb46717b02382cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 52f76cbf14e8e188c99bda5ef3d5fe9704cb69cd82f2d62a2af94e7fe89d81a1cae7827922dd95bdf5bec5debea4879917dfb35ba979e5250f4016161e7f695e
|
7
|
+
data.tar.gz: a880ae7870ae2101c54c5d15dc2a696a90a36418847f77b9ad62edccb2ac2824fb63829c6d4da3a1316b6b49284d6ccd2da03960abcf6a94dd1560ef16255918
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 kaihar4
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Gpr::Contrib
|
2
|
+
|
3
|
+
Gpr plugin to show your contributions of registered repositories.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your gpr's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'gpr-contrib'
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Display your contributions in graph format.
|
16
|
+
|
17
|
+
```sh
|
18
|
+
$ gpr contrib
|
19
|
+
```
|
20
|
+
|
21
|
+
![contrib](http://kaihar4.com/images/github.com/kaihar4/gpr/contrib.png)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/gpr-contrib.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
$LOAD_PATH << File.expand_path('../lib', __FILE__)
|
2
|
+
require 'gpr/contrib/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'gpr-contrib'
|
6
|
+
spec.version = Gpr::Contrib::VERSION
|
7
|
+
spec.authors = ['kaihar4']
|
8
|
+
spec.email = ['kaihar4@gmail.com']
|
9
|
+
spec.summary = 'Gpr plugin to show the status of all registered repositories'
|
10
|
+
spec.description = spec.summary
|
11
|
+
spec.homepage = 'https://github.com/kaihar4/gpr-contrib'
|
12
|
+
spec.license = 'MIT'
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0")
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_dependency 'gpr'
|
20
|
+
spec.add_dependency 'utils_drawer'
|
21
|
+
|
22
|
+
spec.add_development_dependency 'bundler'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Gpr
|
2
|
+
module Actions
|
3
|
+
module Contrib
|
4
|
+
def detect_git_user
|
5
|
+
git_user = File.open("#{ENV['HOME']}/.gitconfig", 'r') do |f|
|
6
|
+
body = f.read
|
7
|
+
body.match(/name\s+=\s+(?<username>.+)/)[:username]
|
8
|
+
end
|
9
|
+
|
10
|
+
git_user
|
11
|
+
end
|
12
|
+
|
13
|
+
def log_by_date(path, user = nil)
|
14
|
+
Dir.chdir(path)
|
15
|
+
if user.nil?
|
16
|
+
`git log --date=short --pretty=format:"%cd"`.split("\n")
|
17
|
+
else
|
18
|
+
`git log --author=#{user} --date=short --pretty=format:"%cd"`.split("\n")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'utils_drawer'
|
2
|
+
|
3
|
+
require 'gpr/actions/contrib'
|
4
|
+
|
5
|
+
module Gpr
|
6
|
+
module Commands
|
7
|
+
class Contrib < Base
|
8
|
+
def initialize(thor)
|
9
|
+
thor.class_eval do
|
10
|
+
include UtilsDrawer
|
11
|
+
include ::Gpr::Actions::Contrib
|
12
|
+
|
13
|
+
desc 'contrib', 'Show your contributions of registered repositories'
|
14
|
+
def contrib(path = nil)
|
15
|
+
user = detect_git_user || ENV['USER']
|
16
|
+
|
17
|
+
if path.nil?
|
18
|
+
repositories = repository_list
|
19
|
+
dates = repositories.each_with_object([]) { |repository, ary|
|
20
|
+
ary << log_by_date(repository, user)
|
21
|
+
}.flatten!
|
22
|
+
else
|
23
|
+
dates = log_by_date(path, user)
|
24
|
+
end
|
25
|
+
|
26
|
+
first_date = Time.parse(dates.sort.first)
|
27
|
+
diff = ((Time.now - first_date).to_i / 86400) + 1
|
28
|
+
|
29
|
+
# Initialize a hash
|
30
|
+
commit_counts = diff.times.each_with_object({}) do |index, hash|
|
31
|
+
date = Time.at(first_date + (86400 * index)).strftime('%Y-%m-%d')
|
32
|
+
hash[date] = 0
|
33
|
+
end
|
34
|
+
|
35
|
+
# Count commits
|
36
|
+
dates.each do |date|
|
37
|
+
commit_counts[date] += 1 if commit_counts[date]
|
38
|
+
end
|
39
|
+
|
40
|
+
graph do
|
41
|
+
commit_counts.sort.each do |date, value|
|
42
|
+
data(date, value)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/gpr/contrib.rb
ADDED
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gpr-contrib
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kaihar4
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: gpr
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: utils_drawer
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Gpr plugin to show the status of all registered repositories
|
70
|
+
email:
|
71
|
+
- kaihar4@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- gpr-contrib.gemspec
|
82
|
+
- lib/gpr/actions/contrib.rb
|
83
|
+
- lib/gpr/commands/contrib.rb
|
84
|
+
- lib/gpr/contrib.rb
|
85
|
+
- lib/gpr/contrib/version.rb
|
86
|
+
homepage: https://github.com/kaihar4/gpr-contrib
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.4.5
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Gpr plugin to show the status of all registered repositories
|
110
|
+
test_files: []
|