cobench 0.0.5 → 0.0.8
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/assets/index.xsl +40 -26
- data/bin/cobench +24 -15
- data/cobench.gemspec +1 -1
- data/lib/cobench/match.rb +43 -0
- data/lib/cobench/metrics/issues.rb +10 -10
- data/lib/cobench/metrics/pulls.rb +20 -11
- data/lib/cobench/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1eaf9208a53326a257503d91e54aae018b2dd0964c0ec11ddde8d8b392a036cc
|
4
|
+
data.tar.gz: 5b1d155907221ec14edfbd5ca674f345531303e383c2f13aae88335bdc35c1cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c155780a0a14a843daf36336d66e5a3216b9886b0da46503d0a44ad3994a7e71eb2d4ee15c7bc4edfe3c236591673c7339e918ce9afbe697f7ca5f4bb415614
|
7
|
+
data.tar.gz: 2e7ca41724d9768abfbad82c6cbd2bff175b30783644c4af24650183f5868e65050832d7a72d2f776aa080d30afdb2aaaa4a82d315c5279e8f61a350e7cca72f
|
data/assets/index.xsl
CHANGED
@@ -23,8 +23,7 @@ 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" method="
|
27
|
-
<xsl:key name="metrics" match="/cobench/coders/coder/metrics/m" use="@id"/>
|
26
|
+
<xsl:output encoding="UTF-8" method="html"/>
|
28
27
|
<xsl:template match="/">
|
29
28
|
<html>
|
30
29
|
<head>
|
@@ -35,15 +34,16 @@ SOFTWARE.
|
|
35
34
|
<link rel="icon" href="https://raw.githubusercontent.com/yegor256/cobench/master/logo.svg" type="image/svg"/>
|
36
35
|
<link href="https://cdn.jsdelivr.net/gh/yegor256/tacit@gh-pages/tacit-css.min.css" rel="stylesheet"/>
|
37
36
|
<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
|
-
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.3/js/jquery.tablesorter.min.js"
|
37
|
+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"/>
|
38
|
+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.31.3/js/jquery.tablesorter.min.js"/>
|
40
39
|
<script type="text/javascript">
|
41
40
|
$(function() {
|
42
41
|
$("#metrics").tablesorter();
|
43
42
|
});
|
44
43
|
</script>
|
45
44
|
<style>
|
46
|
-
td, th {
|
45
|
+
td, th { font-family: monospace; font-size: 18px; }
|
46
|
+
.num { text-align: right; }
|
47
47
|
.left { border-bottom: 0; }
|
48
48
|
header { text-align: center; }
|
49
49
|
footer { text-align: center; font-size: 0.8em; }
|
@@ -59,7 +59,10 @@ SOFTWARE.
|
|
59
59
|
</p>
|
60
60
|
</header>
|
61
61
|
<article>
|
62
|
-
<
|
62
|
+
<table id="metrics">
|
63
|
+
<xsl:apply-templates select="cobench/titles"/>
|
64
|
+
<xsl:apply-templates select="cobench/coders"/>
|
65
|
+
</table>
|
63
66
|
</article>
|
64
67
|
<footer>
|
65
68
|
<p>
|
@@ -84,22 +87,23 @@ SOFTWARE.
|
|
84
87
|
</body>
|
85
88
|
</html>
|
86
89
|
</xsl:template>
|
90
|
+
<xsl:template match="cobench/titles">
|
91
|
+
<thead>
|
92
|
+
<tr>
|
93
|
+
<th/>
|
94
|
+
<xsl:for-each select="title">
|
95
|
+
<xsl:sort select="."/>
|
96
|
+
<th class="sorter num">
|
97
|
+
<xsl:value-of select="."/>
|
98
|
+
</th>
|
99
|
+
</xsl:for-each>
|
100
|
+
</tr>
|
101
|
+
</thead>
|
102
|
+
</xsl:template>
|
87
103
|
<xsl:template match="cobench/coders">
|
88
|
-
<
|
89
|
-
<
|
90
|
-
|
91
|
-
<th/>
|
92
|
-
<xsl:for-each select="coder/metrics/m[generate-id() = generate-id(key('metrics', @id)[1])]">
|
93
|
-
<th class="sorter">
|
94
|
-
<xsl:value-of select="@id"/>
|
95
|
-
</th>
|
96
|
-
</xsl:for-each>
|
97
|
-
</tr>
|
98
|
-
</thead>
|
99
|
-
<tbody>
|
100
|
-
<xsl:apply-templates select="coder"/>
|
101
|
-
</tbody>
|
102
|
-
</table>
|
104
|
+
<tbody>
|
105
|
+
<xsl:apply-templates select="coder"/>
|
106
|
+
</tbody>
|
103
107
|
</xsl:template>
|
104
108
|
<xsl:template match="coder">
|
105
109
|
<tr>
|
@@ -109,14 +113,24 @@ SOFTWARE.
|
|
109
113
|
<xsl:value-of select="@id"/>
|
110
114
|
</a>
|
111
115
|
</td>
|
112
|
-
<xsl:
|
116
|
+
<xsl:for-each select="metrics/m">
|
117
|
+
<xsl:sort select="@id"/>
|
118
|
+
<xsl:apply-templates select="."/>
|
119
|
+
</xsl:for-each>
|
113
120
|
</tr>
|
114
121
|
</xsl:template>
|
115
122
|
<xsl:template match="m">
|
116
|
-
<td>
|
117
|
-
<
|
118
|
-
<xsl:
|
119
|
-
|
123
|
+
<td class="num">
|
124
|
+
<xsl:choose>
|
125
|
+
<xsl:when test="@href">
|
126
|
+
<a href="{@href}">
|
127
|
+
<xsl:value-of select="."/>
|
128
|
+
</a>
|
129
|
+
</xsl:when>
|
130
|
+
<xsl:otherwise>
|
131
|
+
<xsl:value-of select="."/>
|
132
|
+
</xsl:otherwise>
|
133
|
+
</xsl:choose>
|
120
134
|
</td>
|
121
135
|
</xsl:template>
|
122
136
|
<xsl:template match="node()|@*">
|
data/bin/cobench
CHANGED
@@ -91,6 +91,7 @@ begin
|
|
91
91
|
end
|
92
92
|
api.auto_paginate = true
|
93
93
|
api = Obk.new(api, pause: 2000)
|
94
|
+
titles = {}
|
94
95
|
opts[:coder].each do |u|
|
95
96
|
loog.info("Scanning #{u}...")
|
96
97
|
data[u] = {}
|
@@ -101,30 +102,38 @@ begin
|
|
101
102
|
require_relative f
|
102
103
|
m = type.split('::').reduce(Module, :const_get).new(api, u, opts)
|
103
104
|
if opts.dry?
|
104
|
-
|
105
|
+
measures = [{ title: 'Mock', total: Random.new.rand(100), href: 'https://github.com/' }]
|
105
106
|
else
|
106
|
-
|
107
|
+
measures = m.take(loog)
|
108
|
+
end
|
109
|
+
measures.each do |d|
|
110
|
+
data[u][d[:title]] = { total: d[:total], href: d[:href] }
|
111
|
+
titles[d[:title]] = d[:title]
|
112
|
+
loog.info("The value of #{u}/#{d[:title]} is #{d[:total]}")
|
107
113
|
end
|
108
|
-
data[u][name] = [v, t]
|
109
|
-
loog.info("The value of #{u}/#{name} is #{v}")
|
110
114
|
end
|
111
115
|
end
|
112
116
|
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
113
|
-
xml.cobench(time: Time.now, days: opts[:days])
|
114
|
-
xml.
|
117
|
+
xml.cobench(time: Time.now, days: opts[:days]) do
|
118
|
+
xml.titles do
|
119
|
+
data.map { |_, ms| ms.keys }.flatten.each do |t|
|
120
|
+
xml.title t
|
121
|
+
end
|
122
|
+
end
|
123
|
+
xml.coders do
|
115
124
|
data.each do |u, ms|
|
116
|
-
xml.coder(id: u)
|
117
|
-
xml.metrics
|
125
|
+
xml.coder(id: u) do
|
126
|
+
xml.metrics do
|
118
127
|
ms.each do |k, v|
|
119
|
-
xml.m(id: k, href: v[
|
120
|
-
xml.text v[
|
121
|
-
|
128
|
+
xml.m(id: k, href: v[:href]) do
|
129
|
+
xml.text v[:total]
|
130
|
+
end
|
122
131
|
end
|
123
|
-
|
124
|
-
|
132
|
+
end
|
133
|
+
end
|
125
134
|
end
|
126
|
-
|
127
|
-
|
135
|
+
end
|
136
|
+
end
|
128
137
|
end
|
129
138
|
index = File.join(home, 'index.xml')
|
130
139
|
xml = builder.to_xml
|
data/cobench.gemspec
CHANGED
@@ -44,7 +44,7 @@ Gem::Specification.new do |s|
|
|
44
44
|
s.add_runtime_dependency 'iri', '~>0.5'
|
45
45
|
s.add_runtime_dependency 'loog', '~>0.2'
|
46
46
|
s.add_runtime_dependency 'nokogiri', '~>1.10'
|
47
|
-
s.add_runtime_dependency 'obk', '
|
47
|
+
s.add_runtime_dependency 'obk', '0.3.0'
|
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'
|
@@ -0,0 +1,43 @@
|
|
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_relative 'mask'
|
22
|
+
|
23
|
+
# Match of masks.
|
24
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
25
|
+
# Copyright:: Copyright (c) 2022 Yegor Bugayenko
|
26
|
+
# License:: MIT
|
27
|
+
class Cobench::Match
|
28
|
+
def initialize(opts)
|
29
|
+
@opts = opts
|
30
|
+
end
|
31
|
+
|
32
|
+
def matches?(repo)
|
33
|
+
if !@opts[:include].empty? && @opts[:include].none? { |m| Cobench::Mask.new(m).matches?(repo) }
|
34
|
+
loog.debug("Excluding #{repo}##{pr} due to lack of --include")
|
35
|
+
return false
|
36
|
+
end
|
37
|
+
if @opts[:exclude].any? { |m| Cobench::Mask.new(m).matches?(repo) }
|
38
|
+
loog.debug("Excluding #{repo}##{pr} due to --exclude")
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
true
|
42
|
+
end
|
43
|
+
end
|
@@ -19,7 +19,7 @@
|
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
21
|
require 'iri'
|
22
|
-
require_relative '../
|
22
|
+
require_relative '../match'
|
23
23
|
|
24
24
|
# Issues in GitHub API.
|
25
25
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
@@ -36,19 +36,19 @@ class Cobench::Issues
|
|
36
36
|
from = (Time.now - (60 * 60 * 24 * @opts[:days])).strftime('%Y-%m-%d')
|
37
37
|
q = "#{@user} in:comments type:issue author:#{@user} created:>#{from}"
|
38
38
|
json = @api.search_issues(q)
|
39
|
+
loog.debug("Found #{json.total_count} issues")
|
39
40
|
total = json.items.count do |p|
|
40
41
|
pr = p.url.split('/')[-1]
|
41
42
|
repo = p.repository_url.split('/')[-2..-1].join('/')
|
42
|
-
|
43
|
-
loog.debug("Excluding #{repo}##{pr} due to lack of --include")
|
44
|
-
next
|
45
|
-
end
|
46
|
-
if @opts[:exclude].any? { |m| Cobench::Mask.new(m).matches?(repo) }
|
47
|
-
loog.debug("Excluding #{repo}##{pr} due to --exclude")
|
48
|
-
next
|
49
|
-
end
|
43
|
+
next unless Cobench::Match.new(@opts).matches?(repo)
|
50
44
|
loog.debug("Including #{repo}#{pr}")
|
51
45
|
end
|
52
|
-
[
|
46
|
+
[
|
47
|
+
{
|
48
|
+
title: 'Issues',
|
49
|
+
total: total,
|
50
|
+
href: Iri.new('https://github.com/search').add(q: q)
|
51
|
+
}
|
52
|
+
]
|
53
53
|
end
|
54
54
|
end
|
@@ -19,7 +19,7 @@
|
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
21
|
require 'iri'
|
22
|
-
require_relative '../
|
22
|
+
require_relative '../match'
|
23
23
|
|
24
24
|
# Pulls in GitHub API.
|
25
25
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
@@ -36,19 +36,28 @@ class Cobench::Pulls
|
|
36
36
|
from = (Time.now - (60 * 60 * 24 * @opts[:days])).strftime('%Y-%m-%d')
|
37
37
|
q = "#{@user} in:comments type:pr author:#{@user} is:merged closed:>#{from}"
|
38
38
|
json = @api.search_issues(q)
|
39
|
+
loog.debug("Found #{json.total_count} pull requests")
|
40
|
+
hoc = 0
|
39
41
|
total = json.items.count do |p|
|
40
42
|
pr = p.pull_request.url.split('/')[-1]
|
41
43
|
repo = p.repository_url.split('/')[-2..-1].join('/')
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
loog.debug("Excluding #{repo}##{pr} due to --exclude")
|
48
|
-
next
|
49
|
-
end
|
50
|
-
loog.debug("Including #{repo}#{pr}")
|
44
|
+
next unless Cobench::Match.new(@opts).matches?(repo)
|
45
|
+
pr_json = @api.pull_request(repo, pr)
|
46
|
+
hocs = pr_json.additions + pr_json.deletions
|
47
|
+
hoc += hocs
|
48
|
+
loog.debug("Including #{repo}##{pr} with #{hocs}")
|
51
49
|
end
|
52
|
-
[
|
50
|
+
[
|
51
|
+
{
|
52
|
+
title: 'Pulls',
|
53
|
+
total: total,
|
54
|
+
href: Iri.new('https://github.com/search').add(q: q)
|
55
|
+
},
|
56
|
+
{
|
57
|
+
title: 'HoC',
|
58
|
+
total: hoc,
|
59
|
+
href: ''
|
60
|
+
}
|
61
|
+
]
|
53
62
|
end
|
54
63
|
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.8
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: obk
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.3.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.3.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: octokit
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -251,6 +251,7 @@ files:
|
|
251
251
|
- features/step_definitions/steps.rb
|
252
252
|
- features/support/env.rb
|
253
253
|
- lib/cobench/mask.rb
|
254
|
+
- lib/cobench/match.rb
|
254
255
|
- lib/cobench/metrics/issues.rb
|
255
256
|
- lib/cobench/metrics/pulls.rb
|
256
257
|
- lib/cobench/version.rb
|