cobench 0.0.14 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/index.xsl +23 -8
- data/bin/cobench +6 -4
- data/features/cli.feature +12 -1
- data/lib/cobench/metrics/pulls.rb +1 -1
- data/lib/cobench/metrics/reviews.rb +54 -0
- data/lib/cobench/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b84694d76fb95dc4c62d1c4ba42d4d4bee5c8c193c33c241b02964d44816e91
|
4
|
+
data.tar.gz: a56793bef0c5d3bdda384ddd553a47cf135c51cead18e73ed984a7a5f4922077
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fee03b92b8a370f39bc207012bf777b54f459c903b08e25e75e469d98f458d599c85f2bccb51892c165b837192a3450da23d545f84c33263c07bf7469ed6261
|
7
|
+
data.tar.gz: 71bb57a42b734c46f865beda63815ad1984964bf96a690a4c94c9e67ca6eb32199a59c7efb12e0c5fa99423cd54f7087aa72c2443864ea96ad091fb2e7124bc3
|
data/assets/index.xsl
CHANGED
@@ -50,6 +50,9 @@ SOFTWARE.
|
|
50
50
|
header { text-align: center; }
|
51
51
|
footer { text-align: center; font-size: 0.8em; line-height: 1.2em; color: gray; }
|
52
52
|
article { width: 60em; border: 0; }
|
53
|
+
td.avatar { vertical-align: middle; text-align: center; }
|
54
|
+
td.avatar img { width: 1.5em; height: 1.5em; vertical-align: middle; }
|
55
|
+
.subtitle { font-size: 0.8em; line-height: 1em; color: gray; }
|
53
56
|
.sorter { cursor: pointer; }
|
54
57
|
</style>
|
55
58
|
</head>
|
@@ -57,7 +60,9 @@ SOFTWARE.
|
|
57
60
|
<section>
|
58
61
|
<header>
|
59
62
|
<p>
|
60
|
-
<
|
63
|
+
<a href="">
|
64
|
+
<img src="https://raw.githubusercontent.com/yegor256/cobench/master/logo.svg" style="width:64px"/>
|
65
|
+
</a>
|
61
66
|
</p>
|
62
67
|
</header>
|
63
68
|
<article>
|
@@ -82,12 +87,12 @@ SOFTWARE.
|
|
82
87
|
<xsl:text>Git commits</xsl:text>
|
83
88
|
</a>
|
84
89
|
<xsl:text> authored by the user. </xsl:text>
|
85
|
-
<xsl:text>"HoC" is the total number of user's
|
90
|
+
<xsl:text>"HoC" is the total number of user's </xsl:text>
|
86
91
|
<a href="https://www.yegor256.com/2014/11/14/hits-of-code.html">
|
87
92
|
<xsl:text>hits of code</xsl:text>
|
88
93
|
</a>
|
89
94
|
<xsl:text>. </xsl:text>
|
90
|
-
<xsl:text>"Issues" is the total number of issues. </xsl:text>
|
95
|
+
<xsl:text>"Issues" is the total number of issues submitted by the user. </xsl:text>
|
91
96
|
<a href="https://docs.github.com/en/issues">
|
92
97
|
<xsl:text>issues</xsl:text>
|
93
98
|
</a>
|
@@ -96,12 +101,14 @@ SOFTWARE.
|
|
96
101
|
<a href="https://docs.github.com/en/pull-requests">
|
97
102
|
<xsl:text>pull requests</xsl:text>
|
98
103
|
</a>
|
99
|
-
<xsl:text> created by the user and merged. </xsl:text>
|
100
|
-
<xsl:text>"
|
104
|
+
<xsl:text> created by the user and already merged. </xsl:text>
|
105
|
+
<xsl:text>"Reviews" is the total number of merged pull requests that were reviewed by the user. </xsl:text>
|
106
|
+
<xsl:text>"Score" is an arithmetic summary of all metrics with multipliers: </xsl:text>
|
101
107
|
<xsl:text>one Pull costs 100 points, </xsl:text>
|
102
|
-
<xsl:text>one Issue 50 points, </xsl:text>
|
103
|
-
<xsl:text>one
|
104
|
-
<xsl:text>one
|
108
|
+
<xsl:text>one Issue — 50 points, </xsl:text>
|
109
|
+
<xsl:text>one Review — 40 points, </xsl:text>
|
110
|
+
<xsl:text>one Commit — 5 points, </xsl:text>
|
111
|
+
<xsl:text>one HoC — just 1 point.</xsl:text>
|
105
112
|
</p>
|
106
113
|
<p>
|
107
114
|
<xsl:text>The numbers you see reflect the activity of the last </xsl:text>
|
@@ -119,6 +126,7 @@ SOFTWARE.
|
|
119
126
|
<xsl:template match="cobench/titles">
|
120
127
|
<thead>
|
121
128
|
<tr>
|
129
|
+
<th/>
|
122
130
|
<th/>
|
123
131
|
<xsl:for-each select="title[generate-id() = generate-id(key('titles', .)[1])]">
|
124
132
|
<xsl:sort select="."/>
|
@@ -136,11 +144,18 @@ SOFTWARE.
|
|
136
144
|
</xsl:template>
|
137
145
|
<xsl:template match="coder">
|
138
146
|
<tr>
|
147
|
+
<td class="avatar">
|
148
|
+
<img src="https://socatar.com/github/{@id}/64-64"/>
|
149
|
+
</td>
|
139
150
|
<td>
|
140
151
|
<a href="https://github.com/{@id}">
|
141
152
|
<xsl:text>@</xsl:text>
|
142
153
|
<xsl:value-of select="@id"/>
|
143
154
|
</a>
|
155
|
+
<br/>
|
156
|
+
<span class="subtitle">
|
157
|
+
<xsl:value-of select="@details"/>
|
158
|
+
</span>
|
144
159
|
</td>
|
145
160
|
<xsl:for-each select="metrics/m">
|
146
161
|
<xsl:sort select="@id"/>
|
data/bin/cobench
CHANGED
@@ -107,7 +107,7 @@ begin
|
|
107
107
|
type = "Cobench::#{name.capitalize}"
|
108
108
|
loog.info("Reading #{user}/#{name}...")
|
109
109
|
require_relative f
|
110
|
-
m = type.split('::').reduce(Module, :const_get).new(api,
|
110
|
+
m = type.split('::').reduce(Module, :const_get).new(api, user, opts)
|
111
111
|
if opts.dry?
|
112
112
|
measures = [
|
113
113
|
{ title: 'Issues', total: Random.new.rand(100), href: 'https://github.com/' },
|
@@ -120,8 +120,8 @@ begin
|
|
120
120
|
end
|
121
121
|
measures.each do |d|
|
122
122
|
before = 0
|
123
|
-
before += data[
|
124
|
-
data[
|
123
|
+
before += data[user][d[:title]][:total] if data[user][d[:title]] != nil
|
124
|
+
data[user][d[:title]] = { total: d[:total] + before, href: d[:href] }
|
125
125
|
titles[d[:title]] = d[:title]
|
126
126
|
loog.info("The value of #{user}/#{d[:title]} is #{d[:total]}")
|
127
127
|
end
|
@@ -137,6 +137,8 @@ begin
|
|
137
137
|
50
|
138
138
|
elsif t == 'Commits'
|
139
139
|
5
|
140
|
+
elsif t == 'Reviews'
|
141
|
+
40
|
140
142
|
else
|
141
143
|
raise "Unknown title '#{t}'"
|
142
144
|
end
|
@@ -152,7 +154,7 @@ begin
|
|
152
154
|
end
|
153
155
|
xml.coders do
|
154
156
|
data.each do |u, ms|
|
155
|
-
xml.coder(id: u) do
|
157
|
+
xml.coder(id: u, details: api.user(u).name) do
|
156
158
|
xml.metrics do
|
157
159
|
ms.each do |k, v|
|
158
160
|
xml.m(id: k, href: v[:href]) do
|
data/features/cli.feature
CHANGED
@@ -11,7 +11,18 @@ Feature: Simple Reporting
|
|
11
11
|
Then Exit code is zero
|
12
12
|
|
13
13
|
Scenario: Simple report
|
14
|
-
When I run bin/cobench with "--coder yegor256 --verbose --dry --to foo"
|
14
|
+
When I run bin/cobench with "--coder yegor256 --coder John --verbose --dry --to foo"
|
15
|
+
Then Stdout contains "XML saved to"
|
16
|
+
And Exit code is zero
|
17
|
+
|
18
|
+
Scenario: Simple report with defaults
|
19
|
+
Given I have a ".cobench" file with content:
|
20
|
+
"""
|
21
|
+
--verbose
|
22
|
+
|
23
|
+
--coder=john
|
24
|
+
"""
|
25
|
+
When I run bin/cobench with "--dry"
|
15
26
|
Then Stdout contains "XML saved to"
|
16
27
|
And Exit code is zero
|
17
28
|
|
@@ -34,7 +34,7 @@ class Cobench::Pulls
|
|
34
34
|
|
35
35
|
def take(loog)
|
36
36
|
from = (Time.now - (60 * 60 * 24 * @opts[:days])).strftime('%Y-%m-%d')
|
37
|
-
q = "in:comments type:pr author:#{@user} is:merged
|
37
|
+
q = "in:comments type:pr author:#{@user} is:merged merged:>#{from}"
|
38
38
|
json = @api.search_issues(q)
|
39
39
|
loog.debug("Found #{json.total_count} pull requests")
|
40
40
|
hoc = 0
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Copyright (c) 2022 Yegor Bugayenko
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
11
|
+
# copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
# SOFTWARE.
|
20
|
+
|
21
|
+
require 'iri'
|
22
|
+
require_relative '../match'
|
23
|
+
|
24
|
+
# Reviews in GitHub API.
|
25
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
26
|
+
# Copyright:: Copyright (c) 2022 Yegor Bugayenko
|
27
|
+
# License:: MIT
|
28
|
+
class Cobench::Reviews
|
29
|
+
def initialize(api, user, opts)
|
30
|
+
@api = api
|
31
|
+
@user = user
|
32
|
+
@opts = opts
|
33
|
+
end
|
34
|
+
|
35
|
+
def take(loog)
|
36
|
+
from = (Time.now - (60 * 60 * 24 * @opts[:days])).strftime('%Y-%m-%d')
|
37
|
+
q = "reviewed-by:#{@user} merged:>#{from}"
|
38
|
+
json = @api.search_issues(q)
|
39
|
+
loog.debug("Found #{json.total_count} reviews")
|
40
|
+
total = json.items.count do |p|
|
41
|
+
pr = p.pull_request.url.split('/')[-1]
|
42
|
+
repo = p.repository_url.split('/')[-2..-1].join('/')
|
43
|
+
next unless Cobench::Match.new(@opts, loog).matches?(repo)
|
44
|
+
loog.debug("Including #{repo}##{pr} reviewed by #{@user}")
|
45
|
+
end
|
46
|
+
[
|
47
|
+
{
|
48
|
+
title: 'Reviews',
|
49
|
+
total: total,
|
50
|
+
href: Iri.new('https://github.com/search').add(q: q)
|
51
|
+
}
|
52
|
+
]
|
53
|
+
end
|
54
|
+
end
|
data/lib/cobench/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cobench
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -255,6 +255,7 @@ files:
|
|
255
255
|
- lib/cobench/metrics/commits.rb
|
256
256
|
- lib/cobench/metrics/issues.rb
|
257
257
|
- lib/cobench/metrics/pulls.rb
|
258
|
+
- lib/cobench/metrics/reviews.rb
|
258
259
|
- lib/cobench/version.rb
|
259
260
|
- logo.svg
|
260
261
|
- test/test__helper.rb
|