cobench 0.0.7 → 0.0.10
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 +38 -21
- data/bin/cobench +28 -16
- data/lib/cobench/match.rb +44 -0
- data/lib/cobench/metrics/issues.rb +10 -10
- data/lib/cobench/metrics/pulls.rb +20 -11
- data/lib/cobench/version.rb +1 -1
- data/test/test_match.rb +41 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 625fd5b08eece40f4c28722c9258b730336e360cd6d3c51e67a8a6cc969072cd
|
4
|
+
data.tar.gz: 5e5e65c72b3568c12edf3cbca87c20526e40704388d31dec0221a5b0fe526a4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3a6ffbbe1ba49ece0b153abe1c98e5885295a32aa834c5ba0972ec15e01a3c3dc61d2032f9e3f281614b25567e3f0003357f6fec17728a9e45651739238ce05
|
7
|
+
data.tar.gz: bf16dac666f420e6b576fa0a086d2c1dfd84d8193acec2e863c8ed1be140f722db8ac3d186fa8448a7ae9015a2be9b588a56fc1e933c045b034b4eeab4d492a4
|
data/assets/index.xsl
CHANGED
@@ -24,7 +24,8 @@ SOFTWARE.
|
|
24
24
|
-->
|
25
25
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
|
26
26
|
<xsl:output encoding="UTF-8" method="html"/>
|
27
|
-
<xsl:
|
27
|
+
<xsl:param name="version"/>
|
28
|
+
<xsl:key name="titles" match="/cobench/titles/title" use="."/>
|
28
29
|
<xsl:template match="/">
|
29
30
|
<html>
|
30
31
|
<head>
|
@@ -60,13 +61,18 @@ SOFTWARE.
|
|
60
61
|
</p>
|
61
62
|
</header>
|
62
63
|
<article>
|
63
|
-
<
|
64
|
+
<table id="metrics">
|
65
|
+
<xsl:apply-templates select="cobench/titles"/>
|
66
|
+
<xsl:apply-templates select="cobench/coders"/>
|
67
|
+
</table>
|
64
68
|
</article>
|
65
69
|
<footer>
|
66
70
|
<p>
|
67
71
|
<xsl:text>The page was generated by </xsl:text>
|
68
72
|
<a href="https://github.com/yegor256/cobench">
|
69
73
|
<xsl:text>cobench</xsl:text>
|
74
|
+
<xsl:text> </xsl:text>
|
75
|
+
<xsl:value-of select="$version"/>
|
70
76
|
</a>
|
71
77
|
<xsl:text> on </xsl:text>
|
72
78
|
<xsl:value-of select="cobench/@time"/>
|
@@ -85,22 +91,23 @@ SOFTWARE.
|
|
85
91
|
</body>
|
86
92
|
</html>
|
87
93
|
</xsl:template>
|
94
|
+
<xsl:template match="cobench/titles">
|
95
|
+
<thead>
|
96
|
+
<tr>
|
97
|
+
<th/>
|
98
|
+
<xsl:for-each select="title[generate-id() = generate-id(key('titles', .)[1])]">
|
99
|
+
<xsl:sort select="."/>
|
100
|
+
<th class="sorter num">
|
101
|
+
<xsl:value-of select="."/>
|
102
|
+
</th>
|
103
|
+
</xsl:for-each>
|
104
|
+
</tr>
|
105
|
+
</thead>
|
106
|
+
</xsl:template>
|
88
107
|
<xsl:template match="cobench/coders">
|
89
|
-
<
|
90
|
-
<
|
91
|
-
|
92
|
-
<th/>
|
93
|
-
<xsl:for-each select="coder/metrics/m[generate-id() = generate-id(key('metrics', @id)[1])]">
|
94
|
-
<th class="sorter num">
|
95
|
-
<xsl:value-of select="@id"/>
|
96
|
-
</th>
|
97
|
-
</xsl:for-each>
|
98
|
-
</tr>
|
99
|
-
</thead>
|
100
|
-
<tbody>
|
101
|
-
<xsl:apply-templates select="coder"/>
|
102
|
-
</tbody>
|
103
|
-
</table>
|
108
|
+
<tbody>
|
109
|
+
<xsl:apply-templates select="coder"/>
|
110
|
+
</tbody>
|
104
111
|
</xsl:template>
|
105
112
|
<xsl:template match="coder">
|
106
113
|
<tr>
|
@@ -110,14 +117,24 @@ SOFTWARE.
|
|
110
117
|
<xsl:value-of select="@id"/>
|
111
118
|
</a>
|
112
119
|
</td>
|
113
|
-
<xsl:
|
120
|
+
<xsl:for-each select="metrics/m">
|
121
|
+
<xsl:sort select="@id"/>
|
122
|
+
<xsl:apply-templates select="."/>
|
123
|
+
</xsl:for-each>
|
114
124
|
</tr>
|
115
125
|
</xsl:template>
|
116
126
|
<xsl:template match="m">
|
117
127
|
<td class="num">
|
118
|
-
<
|
119
|
-
<xsl:
|
120
|
-
|
128
|
+
<xsl:choose>
|
129
|
+
<xsl:when test="@href">
|
130
|
+
<a href="{@href}">
|
131
|
+
<xsl:value-of select="."/>
|
132
|
+
</a>
|
133
|
+
</xsl:when>
|
134
|
+
<xsl:otherwise>
|
135
|
+
<xsl:value-of select="."/>
|
136
|
+
</xsl:otherwise>
|
137
|
+
</xsl:choose>
|
121
138
|
</td>
|
122
139
|
</xsl:template>
|
123
140
|
<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,41 @@ 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 = [
|
106
|
+
{ title: 'Test1', total: Random.new.rand(100), href: 'https://github.com/' },
|
107
|
+
{ title: 'Test2', total: Random.new.rand(100), href: 'https://github.com/' }
|
108
|
+
]
|
105
109
|
else
|
106
|
-
|
110
|
+
measures = m.take(loog)
|
111
|
+
end
|
112
|
+
measures.each do |d|
|
113
|
+
data[u][d[:title]] = { total: d[:total], href: d[:href] }
|
114
|
+
titles[d[:title]] = d[:title]
|
115
|
+
loog.info("The value of #{u}/#{d[:title]} is #{d[:total]}")
|
107
116
|
end
|
108
|
-
data[u][name] = [v, t]
|
109
|
-
loog.info("The value of #{u}/#{name} is #{v}")
|
110
117
|
end
|
111
118
|
end
|
112
119
|
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
|
113
|
-
xml.cobench(time: Time.now, days: opts[:days])
|
114
|
-
xml.
|
120
|
+
xml.cobench(time: Time.now, days: opts[:days]) do
|
121
|
+
xml.titles do
|
122
|
+
data.map { |_, ms| ms.keys }.flatten.each do |t|
|
123
|
+
xml.title t
|
124
|
+
end
|
125
|
+
end
|
126
|
+
xml.coders do
|
115
127
|
data.each do |u, ms|
|
116
|
-
xml.coder(id: u)
|
117
|
-
xml.metrics
|
128
|
+
xml.coder(id: u) do
|
129
|
+
xml.metrics do
|
118
130
|
ms.each do |k, v|
|
119
|
-
xml.m(id: k, href: v[
|
120
|
-
xml.text v[
|
121
|
-
|
131
|
+
xml.m(id: k, href: v[:href]) do
|
132
|
+
xml.text v[:total]
|
133
|
+
end
|
122
134
|
end
|
123
|
-
|
124
|
-
|
135
|
+
end
|
136
|
+
end
|
125
137
|
end
|
126
|
-
|
127
|
-
|
138
|
+
end
|
139
|
+
end
|
128
140
|
end
|
129
141
|
index = File.join(home, 'index.xml')
|
130
142
|
xml = builder.to_xml
|
@@ -132,7 +144,7 @@ begin
|
|
132
144
|
File.write(index, xml)
|
133
145
|
loog.debug("XML saved to #{index} (#{File.size(index)} bytes)")
|
134
146
|
xslt = Nokogiri::XSLT(File.read(File.join(__dir__, '../assets/index.xsl')))
|
135
|
-
html = xslt.transform(Nokogiri::XML(xml))
|
147
|
+
html = xslt.transform(Nokogiri::XML(xml), 'version' => "'#{Cobench::VERSION}'")
|
136
148
|
loog.debug(html)
|
137
149
|
front = File.join(home, 'index.html')
|
138
150
|
File.write(front, html)
|
@@ -0,0 +1,44 @@
|
|
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, loog)
|
29
|
+
@opts = opts
|
30
|
+
@loog = loog
|
31
|
+
end
|
32
|
+
|
33
|
+
def matches?(repo)
|
34
|
+
if !@opts[:include].empty? && @opts[:include].none? { |m| Cobench::Mask.new(m).matches?(repo) }
|
35
|
+
@loog.debug("Excluding #{repo} due to lack of --include")
|
36
|
+
return false
|
37
|
+
end
|
38
|
+
if @opts[:exclude].any? { |m| Cobench::Mask.new(m).matches?(repo) }
|
39
|
+
@loog.debug("Excluding #{repo} due to --exclude")
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
true
|
43
|
+
end
|
44
|
+
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, loog).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, loog).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
data/test/test_match.rb
ADDED
@@ -0,0 +1,41 @@
|
|
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 'minitest/autorun'
|
22
|
+
require 'loog'
|
23
|
+
require_relative '../lib/cobench/match'
|
24
|
+
|
25
|
+
# Test for Match.
|
26
|
+
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
27
|
+
# Copyright:: Copyright (c) 2022 Yegor Bugayenko
|
28
|
+
# License:: MIT
|
29
|
+
class TestMatch < Minitest::Test
|
30
|
+
def test_positive
|
31
|
+
loog = Loog::NULL
|
32
|
+
opts = { include: [], exclude: [] }
|
33
|
+
assert Cobench::Match.new(opts, loog).matches?('foo/bar')
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_negative
|
37
|
+
loog = Loog::NULL
|
38
|
+
opts = { include: ['*/*'], exclude: ['foo/*'] }
|
39
|
+
assert !Cobench::Match.new(opts, loog).matches?('foo/bar')
|
40
|
+
end
|
41
|
+
end
|
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.10
|
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
|
@@ -251,12 +251,14 @@ 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
|
257
258
|
- logo.svg
|
258
259
|
- test/test__helper.rb
|
259
260
|
- test/test_mask.rb
|
261
|
+
- test/test_match.rb
|
260
262
|
homepage: http://github.com/yegor256/cobench
|
261
263
|
licenses:
|
262
264
|
- MIT
|