cobench 0.0.30 → 0.0.31
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.
- checksums.yaml +4 -4
- data/Rakefile +8 -1
- data/assets/index.xsl +73 -6
- data/bin/cobench +22 -7
- data/cobench.gemspec +1 -0
- data/lib/cobench/metrics/pulls.rb +7 -0
- data/lib/cobench/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b950466b65dafeb1dc0ec2066fcd3a61e75d0470b2810944181a0a7704d8b2d6
|
|
4
|
+
data.tar.gz: cb692c9353443c05b1b4912a76305617212d532da458ff86ea1df12e2d11f406
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5bbbbe914c7a2a627d518d1eb5b5baf1466bd60d15252098fcf9d0e2b7a3b41c3ceaeed22df4603b7e8ae404dff45e155b876290866e6ade19dffa47673e70f0
|
|
7
|
+
data.tar.gz: 460efed0d36d92adbe5549cb3299cf0071aa299dadf98e45a964b6e79f75d838b4f44d74a7d24a4532b9cb3f3c96d0b5e4c4ec9d3ecb129d42a9e79039c463eb
|
data/Rakefile
CHANGED
|
@@ -31,7 +31,7 @@ def version
|
|
|
31
31
|
Gem::Specification.load(Dir['*.gemspec'].first).version
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
task default: %i[clean test features rubocop copyright]
|
|
34
|
+
task default: %i[clean test features rubocop xcop copyright]
|
|
35
35
|
|
|
36
36
|
require 'rake/testtask'
|
|
37
37
|
desc 'Run all unit tests'
|
|
@@ -59,6 +59,13 @@ RuboCop::RakeTask.new(:rubocop) do |task|
|
|
|
59
59
|
task.options = ['--display-cop-names']
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
require 'xcop/rake_task'
|
|
63
|
+
Xcop::RakeTask.new(:xcop) do |task|
|
|
64
|
+
task.license = 'LICENSE.txt'
|
|
65
|
+
task.includes = ['**/*.xml', '**/*.xsl', '**/*.xsd', '**/*.html']
|
|
66
|
+
task.excludes = ['cobench/**', 'coverage/**']
|
|
67
|
+
end
|
|
68
|
+
|
|
62
69
|
require 'cucumber/rake/task'
|
|
63
70
|
Cucumber::Rake::Task.new(:features) do
|
|
64
71
|
Rake::Cleaner.cleanup_files(['coverage'])
|
data/assets/index.xsl
CHANGED
|
@@ -23,7 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
23
23
|
SOFTWARE.
|
|
24
24
|
-->
|
|
25
25
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
|
|
26
|
-
<xsl:output encoding="UTF-8"
|
|
26
|
+
<xsl:output method="xml" doctype-system="about:legacy-compat" encoding="UTF-8" indent="yes"/>
|
|
27
|
+
<xsl:strip-spaces select="*"/>
|
|
27
28
|
<xsl:param name="version"/>
|
|
28
29
|
<xsl:template match="/">
|
|
29
30
|
<html>
|
|
@@ -45,6 +46,16 @@ SOFTWARE.
|
|
|
45
46
|
$(function() {
|
|
46
47
|
$("#metrics").tablesorter();
|
|
47
48
|
});
|
|
49
|
+
$(function() {
|
|
50
|
+
let params = (new URL(document.location)).searchParams;
|
|
51
|
+
let org = params.get('org');
|
|
52
|
+
if (org) {
|
|
53
|
+
$('#metrics tbody tr:not(:has(>td.org-' + org + '))').hide();
|
|
54
|
+
$('#org').text('@' + org);
|
|
55
|
+
$('#org-head').css('visibility', 'visible');
|
|
56
|
+
console.log('Showing @' + org + ' org');
|
|
57
|
+
}
|
|
58
|
+
});
|
|
48
59
|
</script>
|
|
49
60
|
<style>
|
|
50
61
|
td, th { font-family: monospace; font-size: 18px; }
|
|
@@ -55,7 +66,8 @@ SOFTWARE.
|
|
|
55
66
|
footer { text-align: center; font-size: 0.8em; line-height: 1.2em; color: gray; }
|
|
56
67
|
article { border: 0; }
|
|
57
68
|
td.avatar { vertical-align: middle; text-align: center; }
|
|
58
|
-
td.avatar img
|
|
69
|
+
td.avatar img,
|
|
70
|
+
td.orgs img { width: 1.5em; height: 1.5em; vertical-align: middle; }
|
|
59
71
|
.subtitle { font-size: 0.8em; line-height: 1em; color: gray; }
|
|
60
72
|
.sorter { cursor: pointer; }
|
|
61
73
|
</style>
|
|
@@ -70,14 +82,30 @@ SOFTWARE.
|
|
|
70
82
|
</p>
|
|
71
83
|
</header>
|
|
72
84
|
<article>
|
|
85
|
+
<p id="org-head" style="visibility: hidden;">
|
|
86
|
+
<xsl:text>You only see people who contributed to </xsl:text>
|
|
87
|
+
<strong>
|
|
88
|
+
<span id="org">
|
|
89
|
+
<xsl:text>@???</xsl:text>
|
|
90
|
+
</span>
|
|
91
|
+
</strong>
|
|
92
|
+
<xsl:text>. </xsl:text>
|
|
93
|
+
<xsl:text>Click </xsl:text>
|
|
94
|
+
<a href="index.html">
|
|
95
|
+
<xsl:text>here</xsl:text>
|
|
96
|
+
</a>
|
|
97
|
+
<xsl:text> to see all.</xsl:text>
|
|
98
|
+
</p>
|
|
73
99
|
<table id="metrics">
|
|
74
100
|
<colgroup>
|
|
75
101
|
<col/>
|
|
102
|
+
<col style="width: 2.5em;"/>
|
|
76
103
|
<col/>
|
|
77
104
|
<xsl:for-each select="cobench/titles/title">
|
|
78
105
|
<xsl:sort select="."/>
|
|
79
106
|
<col/>
|
|
80
107
|
</xsl:for-each>
|
|
108
|
+
<col/>
|
|
81
109
|
</colgroup>
|
|
82
110
|
<thead>
|
|
83
111
|
<xsl:apply-templates select="cobench/titles"/>
|
|
@@ -85,7 +113,7 @@ SOFTWARE.
|
|
|
85
113
|
<xsl:apply-templates select="cobench/coders"/>
|
|
86
114
|
<tfoot>
|
|
87
115
|
<xsl:apply-templates select="cobench/totals"/>
|
|
88
|
-
|
|
116
|
+
<xsl:apply-templates select="cobench/averages"/>
|
|
89
117
|
</tfoot>
|
|
90
118
|
</table>
|
|
91
119
|
</article>
|
|
@@ -185,19 +213,27 @@ SOFTWARE.
|
|
|
185
213
|
</xsl:template>
|
|
186
214
|
<xsl:template match="cobench/titles">
|
|
187
215
|
<tr>
|
|
188
|
-
<th
|
|
216
|
+
<th class="sorter num">
|
|
217
|
+
<xsl:text>Top</xsl:text>
|
|
218
|
+
</th>
|
|
219
|
+
<th colspan="2">
|
|
220
|
+
<xsl:text>Programmer</xsl:text>
|
|
221
|
+
</th>
|
|
189
222
|
<xsl:for-each select="title">
|
|
190
223
|
<xsl:sort select="."/>
|
|
191
224
|
<th class="sorter num">
|
|
192
225
|
<xsl:value-of select="."/>
|
|
193
226
|
</th>
|
|
194
227
|
</xsl:for-each>
|
|
228
|
+
<th>
|
|
229
|
+
<xsl:text>Orgs</xsl:text>
|
|
230
|
+
</th>
|
|
195
231
|
</tr>
|
|
196
232
|
</xsl:template>
|
|
197
233
|
<xsl:template match="cobench/totals">
|
|
198
234
|
<xsl:variable name="totals" select="."/>
|
|
199
235
|
<tr>
|
|
200
|
-
<td colspan="
|
|
236
|
+
<td colspan="3" style="text-align:right">Total:</td>
|
|
201
237
|
<xsl:for-each select="/cobench/titles/title">
|
|
202
238
|
<xsl:sort select="."/>
|
|
203
239
|
<xsl:variable name="t" select="."/>
|
|
@@ -205,12 +241,13 @@ SOFTWARE.
|
|
|
205
241
|
<xsl:value-of select="$totals/w[@id=$t]"/>
|
|
206
242
|
</td>
|
|
207
243
|
</xsl:for-each>
|
|
244
|
+
<td/>
|
|
208
245
|
</tr>
|
|
209
246
|
</xsl:template>
|
|
210
247
|
<xsl:template match="cobench/averages">
|
|
211
248
|
<xsl:variable name="averages" select="."/>
|
|
212
249
|
<tr>
|
|
213
|
-
<td colspan="
|
|
250
|
+
<td colspan="3" style="text-align:right">Average:</td>
|
|
214
251
|
<xsl:for-each select="/cobench/titles/title">
|
|
215
252
|
<xsl:sort select="."/>
|
|
216
253
|
<xsl:variable name="t" select="."/>
|
|
@@ -218,6 +255,7 @@ SOFTWARE.
|
|
|
218
255
|
<xsl:value-of select="$averages/w[@id=$t]"/>
|
|
219
256
|
</td>
|
|
220
257
|
</xsl:for-each>
|
|
258
|
+
<td/>
|
|
221
259
|
</tr>
|
|
222
260
|
</xsl:template>
|
|
223
261
|
<xsl:template match="cobench/coders">
|
|
@@ -227,6 +265,14 @@ SOFTWARE.
|
|
|
227
265
|
</xsl:template>
|
|
228
266
|
<xsl:template match="coder">
|
|
229
267
|
<tr>
|
|
268
|
+
<td class="num">
|
|
269
|
+
<xsl:variable name="score" select="metrics/m[@id='Score']"/>
|
|
270
|
+
<xsl:variable name="pos" select="count(/cobench/coders/coder[metrics/m[@id='Score'] < $score]) + 1"/>
|
|
271
|
+
<xsl:if test="$pos <= 8">
|
|
272
|
+
<xsl:text>#</xsl:text>
|
|
273
|
+
<xsl:value-of select="$pos"/>
|
|
274
|
+
</xsl:if>
|
|
275
|
+
</td>
|
|
230
276
|
<td class="avatar">
|
|
231
277
|
<img src="https://socatar.com/github/{@id}/64-64"/>
|
|
232
278
|
</td>
|
|
@@ -246,6 +292,27 @@ SOFTWARE.
|
|
|
246
292
|
<xsl:sort select="@id"/>
|
|
247
293
|
<xsl:apply-templates select="."/>
|
|
248
294
|
</xsl:for-each>
|
|
295
|
+
<td class="orgs">
|
|
296
|
+
<xsl:attribute name="class">
|
|
297
|
+
<xsl:text>orgs</xsl:text>
|
|
298
|
+
<xsl:for-each select="orgs/org">
|
|
299
|
+
<xsl:text> org-</xsl:text>
|
|
300
|
+
<xsl:value-of select="."/>
|
|
301
|
+
</xsl:for-each>
|
|
302
|
+
</xsl:attribute>
|
|
303
|
+
<xsl:for-each select="orgs/org">
|
|
304
|
+
<xsl:sort select="."/>
|
|
305
|
+
<xsl:if test="position() > 1">
|
|
306
|
+
<xsl:text> </xsl:text>
|
|
307
|
+
</xsl:if>
|
|
308
|
+
<a href="?org={.}" title="{.}">
|
|
309
|
+
<xsl:value-of select="substring(., 1, 2)"/>
|
|
310
|
+
<xsl:if test="string-length(.) > 2">
|
|
311
|
+
<xsl:text>…</xsl:text>
|
|
312
|
+
</xsl:if>
|
|
313
|
+
</a>
|
|
314
|
+
</xsl:for-each>
|
|
315
|
+
</td>
|
|
249
316
|
</tr>
|
|
250
317
|
</xsl:template>
|
|
251
318
|
<xsl:template match="m">
|
data/bin/cobench
CHANGED
|
@@ -96,6 +96,7 @@ def build_xml(opts, loog)
|
|
|
96
96
|
loog.info("Reading GitHub data for the last #{opts[:days]} days")
|
|
97
97
|
titles = {}
|
|
98
98
|
data = {}
|
|
99
|
+
orgs = {}
|
|
99
100
|
opts[:coder].each do |u|
|
|
100
101
|
user = u.downcase
|
|
101
102
|
loog.info("Scanning #{user}...")
|
|
@@ -116,17 +117,24 @@ def build_xml(opts, loog)
|
|
|
116
117
|
{ title: 'Pulls', total: Random.new.rand(100) },
|
|
117
118
|
{ title: 'Commits', total: Random.new.rand(100) },
|
|
118
119
|
{ title: 'HoC', total: Random.new.rand(100) },
|
|
119
|
-
{ title: 'HoC', total: Random.new.rand(100) }
|
|
120
|
+
{ title: 'HoC', total: Random.new.rand(100) },
|
|
121
|
+
{ meta: true, title: 'Orgs', list: ['objectionary', 'artipie'] },
|
|
120
122
|
]
|
|
121
123
|
else
|
|
122
124
|
measures = m.take(loog)
|
|
123
125
|
end
|
|
124
|
-
measures.each do |
|
|
126
|
+
measures.reject {|ms| ms.key?(:meta)}.each do |ms|
|
|
125
127
|
before = 0
|
|
126
|
-
before += data[user][
|
|
127
|
-
data[user][
|
|
128
|
-
titles[
|
|
129
|
-
loog.info("The value of #{user}/#{
|
|
128
|
+
before += data[user][ms[:title]][:total] if data[user][ms[:title]] != nil
|
|
129
|
+
data[user][ms[:title]] = { total: ms[:total] + before, href: ms[:href] }
|
|
130
|
+
titles[ms[:title]] = ms[:title]
|
|
131
|
+
loog.info("The value of #{user}/#{ms[:title]} is #{ms[:total]}")
|
|
132
|
+
end
|
|
133
|
+
measures.select {|ms| ms.key?(:meta)}.each do |ms|
|
|
134
|
+
if ms[:title] == 'Orgs'
|
|
135
|
+
orgs[user] = [] unless orgs.key?(user)
|
|
136
|
+
end
|
|
137
|
+
orgs[user] += ms[:list]
|
|
130
138
|
end
|
|
131
139
|
end
|
|
132
140
|
end
|
|
@@ -212,6 +220,13 @@ def build_xml(opts, loog)
|
|
|
212
220
|
data.each do |u, ms|
|
|
213
221
|
xml.coder(id: u) do
|
|
214
222
|
xml.parent.set_attribute('details', api.user(u).name) unless opts[:dry]
|
|
223
|
+
if orgs.key?(u)
|
|
224
|
+
xml.orgs do
|
|
225
|
+
orgs[u].uniq.each do |o|
|
|
226
|
+
xml.org o
|
|
227
|
+
end
|
|
228
|
+
end
|
|
229
|
+
end
|
|
215
230
|
xml.metrics do
|
|
216
231
|
ms.each do |k, v|
|
|
217
232
|
xml.m(id: k) do
|
|
@@ -251,7 +266,7 @@ begin
|
|
|
251
266
|
html = xslt.transform(Nokogiri::XML(xml), 'version' => "'#{Cobench::VERSION}'")
|
|
252
267
|
loog.debug(html)
|
|
253
268
|
front = File.join(home, 'index.html')
|
|
254
|
-
File.write(front, html)
|
|
269
|
+
File.write(front, html.to_html(indent: 0).gsub("\n", ''))
|
|
255
270
|
loog.debug("HTML saved to #{front} (#{File.size(front)} bytes)")
|
|
256
271
|
rescue StandardError => e
|
|
257
272
|
loog.error(Backtrace.new(e))
|
data/cobench.gemspec
CHANGED
|
@@ -48,6 +48,7 @@ Gem::Specification.new do |s|
|
|
|
48
48
|
s.add_runtime_dependency 'octokit', '~>4.0'
|
|
49
49
|
s.add_runtime_dependency 'rainbow', '~>3.0'
|
|
50
50
|
s.add_runtime_dependency 'slop', '~>4.4'
|
|
51
|
+
s.add_runtime_dependency 'xcop', '~>0.6'
|
|
51
52
|
s.add_development_dependency 'codecov', '0.6.0'
|
|
52
53
|
s.add_development_dependency 'cucumber', '8.0.0'
|
|
53
54
|
s.add_development_dependency 'minitest', '5.15.0'
|
|
@@ -38,16 +38,23 @@ class Cobench::Pulls
|
|
|
38
38
|
json = @api.search_issues(q)
|
|
39
39
|
loog.debug("Found #{json.total_count} pull requests")
|
|
40
40
|
hoc = 0
|
|
41
|
+
orgs = []
|
|
41
42
|
total = json.items.count do |p|
|
|
42
43
|
pr = p.pull_request.url.split('/')[-1]
|
|
43
44
|
repo = p.repository_url.split('/')[-2..-1].join('/')
|
|
44
45
|
next unless Cobench::Match.new(@opts, loog).matches?(repo)
|
|
46
|
+
orgs += p.repository_url.split('/')[-2]
|
|
45
47
|
pr_json = @api.pull_request(repo, pr)
|
|
46
48
|
hocs = pr_json.additions + pr_json.deletions
|
|
47
49
|
hoc += hocs
|
|
48
50
|
loog.debug("Including #{repo}##{pr} with #{hocs}")
|
|
49
51
|
end
|
|
50
52
|
[
|
|
53
|
+
{
|
|
54
|
+
meta: true,
|
|
55
|
+
title: 'Orgs',
|
|
56
|
+
list: orgs
|
|
57
|
+
},
|
|
51
58
|
{
|
|
52
59
|
title: 'Pulls',
|
|
53
60
|
total: total,
|
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.31
|
|
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-09-
|
|
11
|
+
date: 2022-09-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: backtrace
|
|
@@ -122,6 +122,20 @@ dependencies:
|
|
|
122
122
|
- - "~>"
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
124
|
version: '4.4'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: xcop
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0.6'
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0.6'
|
|
125
139
|
- !ruby/object:Gem::Dependency
|
|
126
140
|
name: codecov
|
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|