project-health 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +44 -0
- data/LICENSE.txt +22 -0
- data/README.md +67 -0
- data/Rakefile +1 -0
- data/bin/project-health +50 -0
- data/lib/project-health/config.rb +17 -0
- data/lib/project-health/project.rb +27 -0
- data/lib/project-health/report/basic.rb +14 -0
- data/lib/project-health/report/pull_requests.rb +78 -0
- data/lib/project-health/reports.rb +2 -0
- data/lib/project-health/version.rb +3 -0
- data/lib/project-health.rb +13 -0
- data/project-health.gemspec +24 -0
- metadata +111 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
project-health (0.0.1)
|
5
|
+
activesupport (~> 3.2.8)
|
6
|
+
hirb (~> 0.7)
|
7
|
+
octokit (~> 1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (3.2.8)
|
13
|
+
i18n (~> 0.6)
|
14
|
+
multi_json (~> 1.0)
|
15
|
+
addressable (2.3.2)
|
16
|
+
coderay (1.0.6)
|
17
|
+
faraday (0.8.4)
|
18
|
+
multipart-post (~> 1.1)
|
19
|
+
faraday_middleware (0.9.0)
|
20
|
+
faraday (>= 0.7.4, < 0.9)
|
21
|
+
hashie (1.2.0)
|
22
|
+
hirb (0.7.0)
|
23
|
+
i18n (0.6.1)
|
24
|
+
method_source (0.7.1)
|
25
|
+
multi_json (1.3.7)
|
26
|
+
multipart-post (1.1.5)
|
27
|
+
octokit (1.18.0)
|
28
|
+
addressable (~> 2.2)
|
29
|
+
faraday (~> 0.8)
|
30
|
+
faraday_middleware (~> 0.8)
|
31
|
+
hashie (~> 1.2)
|
32
|
+
multi_json (~> 1.3)
|
33
|
+
pry (0.9.9.6)
|
34
|
+
coderay (~> 1.0.5)
|
35
|
+
method_source (~> 0.7.1)
|
36
|
+
slop (>= 2.4.4, < 3)
|
37
|
+
slop (2.4.4)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
project-health!
|
44
|
+
pry
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Serg Podtynnyi
|
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,67 @@
|
|
1
|
+
# Project Health
|
2
|
+
|
3
|
+
Library for calculating project health report and analysis based on GitHub Activity data
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'project-health'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```bash
|
22
|
+
gem install project-health
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'pp'
|
29
|
+
require 'project-health'
|
30
|
+
|
31
|
+
ProjectHealth.configure do |config|
|
32
|
+
#config.login = '' # use your github name
|
33
|
+
#config.password = '' # use your github password
|
34
|
+
end
|
35
|
+
|
36
|
+
project = ProjectHealth.new('capistrano/capistrano')
|
37
|
+
|
38
|
+
pp project.stats
|
39
|
+
```
|
40
|
+
|
41
|
+
Result
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
{"Project"=>
|
45
|
+
{"Name"=>"capistrano/capistrano",
|
46
|
+
"Pull Requests"=>
|
47
|
+
{"All"=>142,
|
48
|
+
"Open"=>8,
|
49
|
+
"Closed"=>134,
|
50
|
+
"Open %"=>5.63,
|
51
|
+
"Closed %"=>94.37,
|
52
|
+
"Open/Closed % ratio"=>0.06,
|
53
|
+
"Open time in days"=>801,
|
54
|
+
"Min open time in days"=>5,
|
55
|
+
"Max open time in days"=>389,
|
56
|
+
"Average open time in days per request"=>100,
|
57
|
+
"Health"=>"Good"}}}
|
58
|
+
```
|
59
|
+
|
60
|
+
|
61
|
+
## Contributing
|
62
|
+
|
63
|
+
1. Fork it
|
64
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
65
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
66
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
67
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/project-health
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'project-health'
|
3
|
+
require 'pp'
|
4
|
+
require 'hirb'
|
5
|
+
|
6
|
+
def help_general
|
7
|
+
puts "Project Health Version: #{ProjectHealth::VERSION}"
|
8
|
+
puts
|
9
|
+
puts "Usage: project-health username/repo "
|
10
|
+
puts
|
11
|
+
puts "Example: project-health capistrano/capistrano"
|
12
|
+
puts
|
13
|
+
puts
|
14
|
+
end
|
15
|
+
|
16
|
+
def show_project_stats(repo)
|
17
|
+
extend Hirb::Console
|
18
|
+
project = ProjectHealth.new(repo)
|
19
|
+
puts "Project Health Version: #{ProjectHealth::VERSION}"
|
20
|
+
puts
|
21
|
+
puts "Showing project health for #{repo}"
|
22
|
+
puts
|
23
|
+
project.stats['Project'].each{|c| table c.last}
|
24
|
+
puts
|
25
|
+
puts
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
if $stdin.isatty
|
30
|
+
$stdin.sync = true
|
31
|
+
end
|
32
|
+
if $stdout.isatty
|
33
|
+
$stdout.sync = true
|
34
|
+
end
|
35
|
+
args = *ARGV
|
36
|
+
command = args.shift.strip rescue 'help'
|
37
|
+
if command == 'help'
|
38
|
+
help_general
|
39
|
+
else
|
40
|
+
show_project_stats(command)
|
41
|
+
end
|
42
|
+
rescue Interrupt
|
43
|
+
`stty icanon echo`
|
44
|
+
puts "Command cancelled."
|
45
|
+
rescue => error
|
46
|
+
puts error
|
47
|
+
exit(1)
|
48
|
+
end
|
49
|
+
|
50
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "active_support/core_ext"
|
2
|
+
require 'octokit'
|
3
|
+
|
4
|
+
class Numeric
|
5
|
+
def percent_of(n)
|
6
|
+
self.to_f / n.to_f * 100.0
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module ProjectHealth
|
11
|
+
module Config
|
12
|
+
mattr_accessor :login, :password
|
13
|
+
def configure
|
14
|
+
yield self
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ProjectHealth
|
2
|
+
class Project
|
3
|
+
|
4
|
+
attr_reader :name
|
5
|
+
|
6
|
+
def initialize(name)
|
7
|
+
@oct = Octokit::Client.new(:auto_traversal => true,
|
8
|
+
:per_page => 500, :login => Config.login,
|
9
|
+
:password=> Config.password)
|
10
|
+
@name = name
|
11
|
+
@reports = []
|
12
|
+
add_report :basic
|
13
|
+
add_report :pull_requests
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_report(report)
|
17
|
+
@reports << ProjectHealth.const_get("#{report}_report".to_s.camelize).new(@oct, name)
|
18
|
+
end
|
19
|
+
|
20
|
+
def stats
|
21
|
+
result = {}
|
22
|
+
@reports.map{|x| result.merge!(x.stats) }
|
23
|
+
{ "Project" => result }
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module ProjectHealth
|
2
|
+
class PullRequestsReport
|
3
|
+
|
4
|
+
attr_reader :pulls_open, :pulls_closed, :pulls_all
|
5
|
+
|
6
|
+
def initialize(oct, name)
|
7
|
+
@pull_open_time = []
|
8
|
+
@pulls_open = oct.pull_requests(name, :open).tap{|x| x.each(&method(:calc_open_pull_time)) }.count
|
9
|
+
@pulls_closed = oct.pull_requests(name, :closed).count
|
10
|
+
@pulls_all = pulls_open + pulls_closed
|
11
|
+
end
|
12
|
+
|
13
|
+
def stats
|
14
|
+
{
|
15
|
+
"Pull Requests"=>
|
16
|
+
{
|
17
|
+
'All' => pulls_all,
|
18
|
+
'Open' => pulls_open,
|
19
|
+
'Closed' => pulls_closed,
|
20
|
+
'Open %' => pulls_open_percent.to_f.round(2),
|
21
|
+
'Closed %' => pulls_closed_percent.to_f.round(2),
|
22
|
+
'Open/Closed % ratio' => open_closed_pull_ratio.to_f.round(2),
|
23
|
+
'Open time in days' => pull_open_time,
|
24
|
+
'Min open time in days' => pull_min_open_time,
|
25
|
+
'Max open time in days' => pull_max_open_time,
|
26
|
+
'Average days request is opened' => pull_average_open_time,
|
27
|
+
'Health' => pulls_health
|
28
|
+
}
|
29
|
+
}.delete_if{|k,v| v.kind_of?(Float) && v.nan?}
|
30
|
+
end
|
31
|
+
|
32
|
+
def pulls_open_percent
|
33
|
+
pulls_open.percent_of(pulls_all)
|
34
|
+
end
|
35
|
+
|
36
|
+
def pulls_closed_percent
|
37
|
+
pulls_closed.percent_of(pulls_all)
|
38
|
+
end
|
39
|
+
|
40
|
+
def open_closed_pull_ratio
|
41
|
+
result = pulls_open_percent / pulls_closed_percent
|
42
|
+
end
|
43
|
+
|
44
|
+
def pull_open_time
|
45
|
+
@pull_open_time.inject(:+)
|
46
|
+
end
|
47
|
+
|
48
|
+
def pull_average_open_time
|
49
|
+
pull_open_time / pulls_open
|
50
|
+
end
|
51
|
+
|
52
|
+
def pull_min_open_time
|
53
|
+
@pull_open_time.min
|
54
|
+
end
|
55
|
+
|
56
|
+
def pull_max_open_time
|
57
|
+
@pull_open_time.max
|
58
|
+
end
|
59
|
+
|
60
|
+
def pulls_health
|
61
|
+
case open_closed_pull_ratio.to_f
|
62
|
+
when 0..0.1
|
63
|
+
"Good"
|
64
|
+
when 0.1..0.2
|
65
|
+
"Normal"
|
66
|
+
when 0.2..1
|
67
|
+
"Bad"
|
68
|
+
else
|
69
|
+
"Unknown"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
def calc_open_pull_time(pull)
|
75
|
+
@pull_open_time << (DateTime.now.to_i - pull.created_at.to_datetime.to_i)/60/60/24
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'project-health/version'
|
2
|
+
require 'project-health/config'
|
3
|
+
require 'project-health/reports'
|
4
|
+
require 'project-health/project'
|
5
|
+
|
6
|
+
module ProjectHealth
|
7
|
+
class << self
|
8
|
+
include Config
|
9
|
+
def new(*args)
|
10
|
+
ProjectHealth::Project.new(*args)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'project-health/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "project-health"
|
8
|
+
gem.version = ProjectHealth::VERSION
|
9
|
+
gem.authors = ["Serg Podtynnyi"]
|
10
|
+
gem.email = ["serg@podtynnyi.com"]
|
11
|
+
gem.description = %q{Library for calculating project health report and analysis based on GitHub Activity data}
|
12
|
+
gem.summary = gem.description
|
13
|
+
gem.homepage = "https://github.com/shtirlic/project-health"
|
14
|
+
|
15
|
+
gem.add_dependency "octokit", "~> 1.0"
|
16
|
+
gem.add_dependency "activesupport", "~> 3.2.8"
|
17
|
+
gem.add_dependency "hirb", "~> 0.7"
|
18
|
+
|
19
|
+
gem.executables = "project-health"
|
20
|
+
gem.files = `git ls-files`.split($/)
|
21
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
22
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
23
|
+
gem.require_paths = ["lib"]
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: project-health
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Serg Podtynnyi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-11-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: octokit
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: activesupport
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: 3.2.8
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.2.8
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: hirb
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.7'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.7'
|
62
|
+
description: Library for calculating project health report and analysis based on GitHub
|
63
|
+
Activity data
|
64
|
+
email:
|
65
|
+
- serg@podtynnyi.com
|
66
|
+
executables:
|
67
|
+
- project-health
|
68
|
+
extensions: []
|
69
|
+
extra_rdoc_files: []
|
70
|
+
files:
|
71
|
+
- .gitignore
|
72
|
+
- Gemfile
|
73
|
+
- Gemfile.lock
|
74
|
+
- LICENSE.txt
|
75
|
+
- README.md
|
76
|
+
- Rakefile
|
77
|
+
- bin/project-health
|
78
|
+
- lib/project-health.rb
|
79
|
+
- lib/project-health/config.rb
|
80
|
+
- lib/project-health/project.rb
|
81
|
+
- lib/project-health/report/basic.rb
|
82
|
+
- lib/project-health/report/pull_requests.rb
|
83
|
+
- lib/project-health/reports.rb
|
84
|
+
- lib/project-health/version.rb
|
85
|
+
- project-health.gemspec
|
86
|
+
homepage: https://github.com/shtirlic/project-health
|
87
|
+
licenses: []
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 1.8.24
|
107
|
+
signing_key:
|
108
|
+
specification_version: 3
|
109
|
+
summary: Library for calculating project health report and analysis based on GitHub
|
110
|
+
Activity data
|
111
|
+
test_files: []
|