cobench 0.0.28 → 0.0.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +8 -1
- data/assets/index.xsl +80 -9
- 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>
|
@@ -35,23 +36,38 @@ SOFTWARE.
|
|
35
36
|
<link rel="icon" href="https://raw.githubusercontent.com/yegor256/cobench/master/logo.svg" type="image/svg"/>
|
36
37
|
<link href="https://cdn.jsdelivr.net/gh/yegor256/tacit@gh-pages/tacit-css.min.css" rel="stylesheet"/>
|
37
38
|
<link href="https://cdn.jsdelivr.net/gh/yegor256/drops@gh-pages/drops.min.css" rel="stylesheet"/>
|
38
|
-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"
|
39
|
-
|
39
|
+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js">
|
40
|
+
<xsl:text> </xsl:text>
|
41
|
+
</script>
|
42
|
+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.3/js/jquery.tablesorter.min.js">
|
43
|
+
<xsl:text> </xsl:text>
|
44
|
+
</script>
|
40
45
|
<script type="text/javascript">
|
41
46
|
$(function() {
|
42
47
|
$("#metrics").tablesorter();
|
43
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
|
+
});
|
44
59
|
</script>
|
45
60
|
<style>
|
46
61
|
td, th { font-family: monospace; font-size: 18px; }
|
47
62
|
.num { text-align: right; }
|
48
63
|
.left { border-bottom: 0; }
|
49
|
-
section { width:
|
64
|
+
section { width: auto; }
|
50
65
|
header { text-align: center; }
|
51
66
|
footer { text-align: center; font-size: 0.8em; line-height: 1.2em; color: gray; }
|
52
67
|
article { border: 0; }
|
53
68
|
td.avatar { vertical-align: middle; text-align: center; }
|
54
|
-
td.avatar img
|
69
|
+
td.avatar img,
|
70
|
+
td.orgs img { width: 1.5em; height: 1.5em; vertical-align: middle; }
|
55
71
|
.subtitle { font-size: 0.8em; line-height: 1em; color: gray; }
|
56
72
|
.sorter { cursor: pointer; }
|
57
73
|
</style>
|
@@ -66,14 +82,30 @@ SOFTWARE.
|
|
66
82
|
</p>
|
67
83
|
</header>
|
68
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>
|
69
99
|
<table id="metrics">
|
70
100
|
<colgroup>
|
71
101
|
<col/>
|
102
|
+
<col style="width: 2.5em;"/>
|
72
103
|
<col/>
|
73
104
|
<xsl:for-each select="cobench/titles/title">
|
74
105
|
<xsl:sort select="."/>
|
75
106
|
<col/>
|
76
107
|
</xsl:for-each>
|
108
|
+
<col/>
|
77
109
|
</colgroup>
|
78
110
|
<thead>
|
79
111
|
<xsl:apply-templates select="cobench/titles"/>
|
@@ -81,7 +113,7 @@ SOFTWARE.
|
|
81
113
|
<xsl:apply-templates select="cobench/coders"/>
|
82
114
|
<tfoot>
|
83
115
|
<xsl:apply-templates select="cobench/totals"/>
|
84
|
-
|
116
|
+
<xsl:apply-templates select="cobench/averages"/>
|
85
117
|
</tfoot>
|
86
118
|
</table>
|
87
119
|
</article>
|
@@ -181,19 +213,27 @@ SOFTWARE.
|
|
181
213
|
</xsl:template>
|
182
214
|
<xsl:template match="cobench/titles">
|
183
215
|
<tr>
|
184
|
-
<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>
|
185
222
|
<xsl:for-each select="title">
|
186
223
|
<xsl:sort select="."/>
|
187
224
|
<th class="sorter num">
|
188
225
|
<xsl:value-of select="."/>
|
189
226
|
</th>
|
190
227
|
</xsl:for-each>
|
228
|
+
<th>
|
229
|
+
<xsl:text>Orgs</xsl:text>
|
230
|
+
</th>
|
191
231
|
</tr>
|
192
232
|
</xsl:template>
|
193
233
|
<xsl:template match="cobench/totals">
|
194
234
|
<xsl:variable name="totals" select="."/>
|
195
235
|
<tr>
|
196
|
-
<td colspan="
|
236
|
+
<td colspan="3" style="text-align:right">Total:</td>
|
197
237
|
<xsl:for-each select="/cobench/titles/title">
|
198
238
|
<xsl:sort select="."/>
|
199
239
|
<xsl:variable name="t" select="."/>
|
@@ -201,12 +241,13 @@ SOFTWARE.
|
|
201
241
|
<xsl:value-of select="$totals/w[@id=$t]"/>
|
202
242
|
</td>
|
203
243
|
</xsl:for-each>
|
244
|
+
<td/>
|
204
245
|
</tr>
|
205
246
|
</xsl:template>
|
206
247
|
<xsl:template match="cobench/averages">
|
207
248
|
<xsl:variable name="averages" select="."/>
|
208
249
|
<tr>
|
209
|
-
<td colspan="
|
250
|
+
<td colspan="3" style="text-align:right">Average:</td>
|
210
251
|
<xsl:for-each select="/cobench/titles/title">
|
211
252
|
<xsl:sort select="."/>
|
212
253
|
<xsl:variable name="t" select="."/>
|
@@ -214,6 +255,7 @@ SOFTWARE.
|
|
214
255
|
<xsl:value-of select="$averages/w[@id=$t]"/>
|
215
256
|
</td>
|
216
257
|
</xsl:for-each>
|
258
|
+
<td/>
|
217
259
|
</tr>
|
218
260
|
</xsl:template>
|
219
261
|
<xsl:template match="cobench/coders">
|
@@ -223,6 +265,14 @@ SOFTWARE.
|
|
223
265
|
</xsl:template>
|
224
266
|
<xsl:template match="coder">
|
225
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>
|
226
276
|
<td class="avatar">
|
227
277
|
<img src="https://socatar.com/github/{@id}/64-64"/>
|
228
278
|
</td>
|
@@ -242,6 +292,27 @@ SOFTWARE.
|
|
242
292
|
<xsl:sort select="@id"/>
|
243
293
|
<xsl:apply-templates select="."/>
|
244
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>
|
245
316
|
</tr>
|
246
317
|
</xsl:template>
|
247
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
|