project-health 0.0.2 → 0.0.3
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.
- data/README.md +1 -1
- data/bin/project-health +1 -6
- data/lib/project-health.rb +4 -1
- data/lib/project-health/config.rb +6 -2
- data/lib/project-health/project.rb +4 -3
- data/lib/project-health/report/issues.rb +78 -0
- data/lib/project-health/report/pull_requests.rb +33 -33
- data/lib/project-health/reports.rb +1 -0
- data/lib/project-health/version.rb +1 -1
- metadata +4 -2
data/README.md
CHANGED
data/bin/project-health
CHANGED
@@ -15,11 +15,6 @@ end
|
|
15
15
|
|
16
16
|
def show_project_stats(repo)
|
17
17
|
extend Hirb::Console
|
18
|
-
|
19
|
-
ProjectHealth.config do |c|
|
20
|
-
c.login = ENV["GITHUB_USERNAME"]
|
21
|
-
c.password = ENV["GITHUB_PASSWORD"]
|
22
|
-
end
|
23
18
|
project = ProjectHealth.new(repo)
|
24
19
|
puts "Project Health Version: #{ProjectHealth::VERSION}"
|
25
20
|
puts
|
@@ -50,7 +45,7 @@ rescue Interrupt
|
|
50
45
|
`stty icanon echo`
|
51
46
|
puts "Command cancelled."
|
52
47
|
rescue => error
|
53
|
-
|
48
|
+
p error
|
54
49
|
exit(1)
|
55
50
|
end
|
56
51
|
|
data/lib/project-health.rb
CHANGED
@@ -8,6 +8,10 @@ class Numeric
|
|
8
8
|
end
|
9
9
|
|
10
10
|
module ProjectHealth
|
11
|
-
|
12
|
-
|
11
|
+
class Project
|
12
|
+
include ActiveSupport::Configurable
|
13
|
+
config_accessor :login, :password
|
14
|
+
self.login = ENV["GITHUB_USERNAME"]
|
15
|
+
self.password = ENV["GITHUB_PASSWORD"]
|
16
|
+
end
|
13
17
|
end
|
@@ -4,13 +4,14 @@ module ProjectHealth
|
|
4
4
|
attr_reader :name
|
5
5
|
|
6
6
|
def initialize(name)
|
7
|
-
@oct = Octokit::Client.new(:
|
8
|
-
:
|
9
|
-
:
|
7
|
+
@oct = Octokit::Client.new(auto_traversal: true,
|
8
|
+
per_page: 500, login: config.login,
|
9
|
+
password: config.password)
|
10
10
|
@name = name
|
11
11
|
@reports = []
|
12
12
|
add_report :basic
|
13
13
|
add_report :pull_requests
|
14
|
+
add_report :issues
|
14
15
|
end
|
15
16
|
|
16
17
|
def add_report(report)
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module ProjectHealth
|
2
|
+
class IssuesReport
|
3
|
+
|
4
|
+
attr_reader :open, :closed, :all
|
5
|
+
|
6
|
+
def initialize(oct, name)
|
7
|
+
@open_times = []
|
8
|
+
@open = oct.issues(name, {state: :open}).tap{|x| x.each(&method(:calc_open_issue_time)) }.count
|
9
|
+
@closed = oct.issues(name, {state: :closed}).count
|
10
|
+
@all = open + closed
|
11
|
+
end
|
12
|
+
|
13
|
+
def stats
|
14
|
+
{
|
15
|
+
"Issues"=>
|
16
|
+
{
|
17
|
+
'All' => all,
|
18
|
+
'Open' => open,
|
19
|
+
'Closed' => closed,
|
20
|
+
'Open %' => open_percent.to_f.round(2),
|
21
|
+
'Closed %' => closed_percent.to_f.round(2),
|
22
|
+
'Open/Closed % ratio' => open_closed_ratio.to_f.round(2),
|
23
|
+
'Open time in days' => open_time,
|
24
|
+
'Min open time in days' => min_open_time,
|
25
|
+
'Max open time in days' => max_open_time,
|
26
|
+
'Average days issue is opened' => average_open_time,
|
27
|
+
'Health' => health
|
28
|
+
}
|
29
|
+
}.delete_if{|k,v| v.kind_of?(Float) && v.nan?}
|
30
|
+
end
|
31
|
+
|
32
|
+
def open_percent
|
33
|
+
open.percent_of all
|
34
|
+
end
|
35
|
+
|
36
|
+
def closed_percent
|
37
|
+
closed.percent_of all
|
38
|
+
end
|
39
|
+
|
40
|
+
def open_closed_ratio
|
41
|
+
result = open_percent / closed_percent
|
42
|
+
end
|
43
|
+
|
44
|
+
def open_time
|
45
|
+
@open_times.inject(:+) || 0
|
46
|
+
end
|
47
|
+
|
48
|
+
def average_open_time
|
49
|
+
open_time / open if open > 0
|
50
|
+
end
|
51
|
+
|
52
|
+
def min_open_time
|
53
|
+
@open_times.min
|
54
|
+
end
|
55
|
+
|
56
|
+
def max_open_time
|
57
|
+
@open_times.max
|
58
|
+
end
|
59
|
+
|
60
|
+
def health
|
61
|
+
case open_closed_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_issue_time(issue)
|
75
|
+
@open_times << (DateTime.now.to_i - issue.created_at.to_datetime.to_i)/60/60/24
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -1,64 +1,64 @@
|
|
1
1
|
module ProjectHealth
|
2
2
|
class PullRequestsReport
|
3
3
|
|
4
|
-
attr_reader :
|
4
|
+
attr_reader :open, :closed, :all
|
5
5
|
|
6
6
|
def initialize(oct, name)
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@
|
7
|
+
@open_times = []
|
8
|
+
@open = oct.pull_requests(name, :open).tap{|x| x.each(&method(:calc_open_pull_time)) }.count
|
9
|
+
@closed = oct.pull_requests(name, :closed).count
|
10
|
+
@all = open + closed
|
11
11
|
end
|
12
12
|
|
13
13
|
def stats
|
14
14
|
{
|
15
15
|
"Pull Requests"=>
|
16
16
|
{
|
17
|
-
'All' =>
|
18
|
-
'Open' =>
|
19
|
-
'Closed' =>
|
20
|
-
'Open %' =>
|
21
|
-
'Closed %' =>
|
22
|
-
'Open/Closed % ratio' =>
|
23
|
-
'Open time in days' =>
|
24
|
-
'Min open time in days' =>
|
25
|
-
'Max open time in days' =>
|
26
|
-
'Average days request is opened' =>
|
27
|
-
'Health' =>
|
17
|
+
'All' => all,
|
18
|
+
'Open' => open,
|
19
|
+
'Closed' => closed,
|
20
|
+
'Open %' => open_percent.to_f.round(2),
|
21
|
+
'Closed %' => closed_percent.to_f.round(2),
|
22
|
+
'Open/Closed % ratio' => open_closed_ratio.to_f.round(2),
|
23
|
+
'Open time in days' => open_time,
|
24
|
+
'Min open time in days' => min_open_time,
|
25
|
+
'Max open time in days' => max_open_time,
|
26
|
+
'Average days request is opened' => average_open_time,
|
27
|
+
'Health' => health
|
28
28
|
}
|
29
29
|
}.delete_if{|k,v| v.kind_of?(Float) && v.nan?}
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
|
32
|
+
def open_percent
|
33
|
+
open.percent_of all
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
37
|
-
|
36
|
+
def closed_percent
|
37
|
+
closed.percent_of all
|
38
38
|
end
|
39
39
|
|
40
|
-
def
|
41
|
-
result =
|
40
|
+
def open_closed_ratio
|
41
|
+
result = open_percent / closed_percent
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
45
|
-
@
|
44
|
+
def open_time
|
45
|
+
@open_times.inject(:+) || 0
|
46
46
|
end
|
47
47
|
|
48
|
-
def
|
49
|
-
|
48
|
+
def average_open_time
|
49
|
+
open_time / open if open > 0
|
50
50
|
end
|
51
51
|
|
52
|
-
def
|
53
|
-
@
|
52
|
+
def min_open_time
|
53
|
+
@open_times.min
|
54
54
|
end
|
55
55
|
|
56
|
-
def
|
57
|
-
@
|
56
|
+
def max_open_time
|
57
|
+
@open_times.max
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
61
|
-
case
|
60
|
+
def health
|
61
|
+
case open_closed_ratio.to_f
|
62
62
|
when 0..0.1
|
63
63
|
"Good"
|
64
64
|
when 0.1..0.2
|
@@ -72,7 +72,7 @@ module ProjectHealth
|
|
72
72
|
|
73
73
|
private
|
74
74
|
def calc_open_pull_time(pull)
|
75
|
-
@
|
75
|
+
@open_times << (DateTime.now.to_i - pull.created_at.to_datetime.to_i)/60/60/24
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: project-health
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-11-
|
12
|
+
date: 2012-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: octokit
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- lib/project-health/config.rb
|
80
80
|
- lib/project-health/project.rb
|
81
81
|
- lib/project-health/report/basic.rb
|
82
|
+
- lib/project-health/report/issues.rb
|
82
83
|
- lib/project-health/report/pull_requests.rb
|
83
84
|
- lib/project-health/reports.rb
|
84
85
|
- lib/project-health/version.rb
|
@@ -109,3 +110,4 @@ specification_version: 3
|
|
109
110
|
summary: Library for calculating project health report and analysis based on GitHub
|
110
111
|
Activity data
|
111
112
|
test_files: []
|
113
|
+
has_rdoc:
|