cobench 0.0.18 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ebe9e177a3dbecdb610079242b819c7f35188a15ea362f9b14b2f3f4d5b7d87
4
- data.tar.gz: b17a94e0a3ea2f9f57184860f7747ebe232b2ea7af19a42ebb81dea59d4b29c9
3
+ metadata.gz: 6117bbba07444b2da4210d173981f6199005ac182482fca43aa36c04d919ef1b
4
+ data.tar.gz: 38172dfd6d7cb9cb8604d051ca0cf82b53aebb89c604edf23ac1bcb12a6c5c86
5
5
  SHA512:
6
- metadata.gz: 8c891cf36011771f14f89c2b762ea57ce53d44af35d3fcbb8033fef402453ed1f7911ed191f243492c2ac4d83ae2e6c32079a3a454a35bdaaa5888fefbc20a08
7
- data.tar.gz: 072a7bb771a409c753be6a1027f024d72cd887eddf3c5a6ec02c992e04ae4ce0dd7f39ef9b41437cc0bf607e49965748548edc39b92534fb1a06c37ff121b9e6
6
+ metadata.gz: f37e7867a1359bc99291f7607ec43f3c7ced2039fb46e2cefd8b50a2a3c1aeabaef18ac095a1579cc3a1e265a5132809a567504782211f593a1b79a72d8415e4
7
+ data.tar.gz: 36115b07683f34eed5ea446a455ec4ab7b8b18bd70bf27e860c281d4711ebcdf5b9221d7730da3a3b80355328585c316c1599162619d585dd9652f19d1bd5bf4
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
- <td class="num">
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:choose>
204
+ <xsl:when test="@actual">
205
+ <span class="firebrick">
206
+ <xsl:value-of select="$body"/>
207
+ </span>
208
+ </xsl:when>
209
+ <xsl:otherwise>
210
+ <xsl:value-of select="$body"/>
211
+ </xsl:otherwise>
212
+ </xsl:choose>
213
+ <xsl:if test="@actual">
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
- data = {}
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), href: '' },
115
- { title: 'HoC', total: Random.new.rand(100), href: '' },
116
- { title: 'HoC', total: Random.new.rand(100), href: '' }
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] * 512 },
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, details: api.user(u).name) do
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
- File.write(index, xml)
177
- loog.debug("XML saved to #{index} (#{File.size(index)} bytes)")
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 John --verbose --dry --to foo"
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
 
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2022 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Cobench
26
- VERSION = '0.0.18'.freeze
26
+ VERSION = '0.0.21'.freeze
27
27
  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.18
4
+ version: 0.0.21
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-24 00:00:00.000000000 Z
11
+ date: 2022-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace