cobench 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/assets/index.xsl +19 -1
- data/bin/cobench +45 -19
- data/features/cli.feature +1 -1
- data/lib/cobench/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 221c41b7266e31f56aa5f90f39010bdd6e453b65ab8585ec20f8783f40e89f20
|
4
|
+
data.tar.gz: 5c163c8fa858234a5598a84a17ee9aa844b6c034fc85dca737e4365573aefe2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c58b0cb4b3f7505970b0c79300fedf7731eebda93c9db619bd687720672fa584aaf293a7cbcd22dde52142b7b494861e368942add8fe7807bff8af029d5c78b5
|
7
|
+
data.tar.gz: 89fc4df3d481cf325bc9524110deefe552c542cbabf73d565469e18567924a579cc2d6d65757a1a28ad1dffa5c75f8f670ce86898d0a6f521242d9ead9a56486
|
data/README.md
CHANGED
@@ -26,6 +26,8 @@ Then, run it locally and read its output:
|
|
26
26
|
$ cobench --coder yegor256 --verbose
|
27
27
|
```
|
28
28
|
|
29
|
+
This is how our report [looks like](https://github.com/cqfn/bench).
|
30
|
+
|
29
31
|
## How to contribute
|
30
32
|
|
31
33
|
Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
data/assets/index.xsl
CHANGED
@@ -187,7 +187,7 @@ SOFTWARE.
|
|
187
187
|
</tr>
|
188
188
|
</xsl:template>
|
189
189
|
<xsl:template match="m">
|
190
|
-
<
|
190
|
+
<xsl:variable name="body">
|
191
191
|
<xsl:choose>
|
192
192
|
<xsl:when test="@href = ''">
|
193
193
|
<xsl:value-of select="."/>
|
@@ -198,6 +198,24 @@ SOFTWARE.
|
|
198
198
|
</a>
|
199
199
|
</xsl:otherwise>
|
200
200
|
</xsl:choose>
|
201
|
+
</xsl:variable>
|
202
|
+
<td class="num">
|
203
|
+
<xsl:if test="@actual">
|
204
|
+
<xsl:choose>
|
205
|
+
<xsl:when test="@actual">
|
206
|
+
<span class="firebrick">
|
207
|
+
<xsl:value-of select="$body"/>
|
208
|
+
</span>
|
209
|
+
</xsl:when>
|
210
|
+
<xsl:otherwise>
|
211
|
+
<xsl:value-of select="$body"/>
|
212
|
+
</xsl:otherwise>
|
213
|
+
</xsl:choose>
|
214
|
+
<br/>
|
215
|
+
<span class="subtitle" title="The actual value of the metric was capped">
|
216
|
+
<xsl:value-of select="@actual"/>
|
217
|
+
</span>
|
218
|
+
</xsl:if>
|
201
219
|
</td>
|
202
220
|
</xsl:template>
|
203
221
|
<xsl:template match="node()|@*">
|
data/bin/cobench
CHANGED
@@ -35,7 +35,7 @@ loog = Loog::REGULAR
|
|
35
35
|
def config(path)
|
36
36
|
f = File.expand_path(path)
|
37
37
|
args = []
|
38
|
-
args += File.readlines(f).map(&:strip) if File.exist?(f)
|
38
|
+
args += File.readlines(f).map(&:strip).reject { |a| a.empty? } if File.exist?(f)
|
39
39
|
args
|
40
40
|
end
|
41
41
|
|
@@ -47,6 +47,7 @@ opts = Slop.parse(args, strict: true, help: true) do |o|
|
|
47
47
|
o.bool '--version', 'Show current version'
|
48
48
|
o.bool '--verbose', 'Print as much log messages as possible'
|
49
49
|
o.bool '--dry', 'Make no real round trips to GitHub'
|
50
|
+
o.bool '--reuse', 'Don\'t fetch from GitHub, reuse the existing XML file'
|
50
51
|
o.integer '--days', 'How many days to measure', default: 7
|
51
52
|
o.string '--to', 'Directory where to save all files to', default: './cobench'
|
52
53
|
o.string '--token', 'GitHub authentication token'
|
@@ -73,17 +74,7 @@ end
|
|
73
74
|
Encoding.default_external = Encoding::UTF_8
|
74
75
|
Encoding.default_internal = Encoding::UTF_8
|
75
76
|
|
76
|
-
|
77
|
-
|
78
|
-
begin
|
79
|
-
home = File.absolute_path(opts[:to])
|
80
|
-
loog.debug("All files generated will be saved to #{home}")
|
81
|
-
if File.exist?(home)
|
82
|
-
loog.debug("Directory #{home} exists")
|
83
|
-
else
|
84
|
-
FileUtils.mkdir_p(home)
|
85
|
-
loog.debug("Directory #{home} created")
|
86
|
-
end
|
77
|
+
def build_xml(opts, loog)
|
87
78
|
if opts.token?
|
88
79
|
api = Octokit::Client.new(:access_token => opts[:token])
|
89
80
|
else
|
@@ -94,6 +85,7 @@ begin
|
|
94
85
|
api = Obk.new(api, pause: 2000)
|
95
86
|
loog.info("Reading GitHub data for the last #{opts[:days]} days")
|
96
87
|
titles = {}
|
88
|
+
data = {}
|
97
89
|
opts[:coder].each do |u|
|
98
90
|
user = u.downcase
|
99
91
|
loog.info("Scanning #{user}...")
|
@@ -111,9 +103,10 @@ begin
|
|
111
103
|
if opts.dry?
|
112
104
|
measures = [
|
113
105
|
{ title: 'Issues', total: Random.new.rand(100), href: 'https://github.com/' },
|
114
|
-
{ title: 'Pulls', total: Random.new.rand(100)
|
115
|
-
{ title: '
|
116
|
-
{ title: 'HoC', total: Random.new.rand(100)
|
106
|
+
{ title: 'Pulls', total: Random.new.rand(100) },
|
107
|
+
{ title: 'Commits', total: Random.new.rand(100) },
|
108
|
+
{ title: 'HoC', total: Random.new.rand(100) },
|
109
|
+
{ title: 'HoC', total: Random.new.rand(100) }
|
117
110
|
]
|
118
111
|
else
|
119
112
|
measures = m.take(loog)
|
@@ -127,6 +120,20 @@ begin
|
|
127
120
|
end
|
128
121
|
end
|
129
122
|
end
|
123
|
+
caps = {
|
124
|
+
'HoC' => lambda { |ms| ms['Commits'][:total] * 1000 },
|
125
|
+
}
|
126
|
+
data.each do |u, ms|
|
127
|
+
ms.map do |t, h|
|
128
|
+
next unless caps.key?(t)
|
129
|
+
cap = caps[t].call(ms)
|
130
|
+
if h[:total] > cap
|
131
|
+
data[u][t][:actual] = h[:total]
|
132
|
+
data[u][t][:total] = cap
|
133
|
+
end
|
134
|
+
end
|
135
|
+
data[u] = ms
|
136
|
+
end
|
130
137
|
weights = {
|
131
138
|
'HoC' => 1,
|
132
139
|
'Pulls' => 200,
|
@@ -157,10 +164,13 @@ begin
|
|
157
164
|
end
|
158
165
|
xml.coders do
|
159
166
|
data.each do |u, ms|
|
160
|
-
xml.coder(id: u
|
167
|
+
xml.coder(id: u) do
|
168
|
+
xml.parent.set_attribute('details', api.user(u).name)
|
161
169
|
xml.metrics do
|
162
170
|
ms.each do |k, v|
|
163
171
|
xml.m(id: k, href: v[:href]) do
|
172
|
+
xml.parent.set_attribute('actual', v[:actual]) unless v[:actual].nil?
|
173
|
+
xml.parent.set_attribute('href', v[:href]) unless v[:href].nil?
|
164
174
|
xml.text v[:total]
|
165
175
|
end
|
166
176
|
end
|
@@ -170,11 +180,27 @@ begin
|
|
170
180
|
end
|
171
181
|
end
|
172
182
|
end
|
173
|
-
index = File.join(home, 'index.xml')
|
174
183
|
xml = builder.to_xml
|
175
184
|
loog.debug(xml)
|
176
|
-
|
177
|
-
|
185
|
+
xml
|
186
|
+
end
|
187
|
+
begin
|
188
|
+
home = File.absolute_path(opts[:to])
|
189
|
+
loog.debug("All files generated will be saved to #{home}")
|
190
|
+
if File.exist?(home)
|
191
|
+
loog.debug("Directory #{home} exists")
|
192
|
+
else
|
193
|
+
FileUtils.mkdir_p(home)
|
194
|
+
loog.debug("Directory #{home} created")
|
195
|
+
end
|
196
|
+
index = File.join(home, 'index.xml')
|
197
|
+
if opts[:reuse]
|
198
|
+
xml = File.read(index)
|
199
|
+
else
|
200
|
+
xml = build_xml(opts, loog)
|
201
|
+
File.write(index, xml)
|
202
|
+
loog.debug("XML saved to #{index} (#{File.size(index)} bytes)")
|
203
|
+
end
|
178
204
|
xslt = Nokogiri::XSLT(File.read(File.join(__dir__, '../assets/index.xsl')))
|
179
205
|
html = xslt.transform(Nokogiri::XML(xml), 'version' => "'#{Cobench::VERSION}'")
|
180
206
|
loog.debug(html)
|
data/features/cli.feature
CHANGED
@@ -11,7 +11,7 @@ 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 --coder
|
14
|
+
When I run bin/cobench with "--coder yegor256 --coder Jeff --verbose --dry --to foo"
|
15
15
|
Then Stdout contains "XML saved to"
|
16
16
|
And Exit code is zero
|
17
17
|
|
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.19
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backtrace
|