cobench 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/cobench +8 -3
  3. data/lib/cobench/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c88b2884af1c5f379f0ffc146188ae2b1c7ab4ffd1fa6690a1bebc1120b2f848
4
- data.tar.gz: 4ccd4da7ea79c1f0b121c289a28def7b4decbb6b4792856f59bc0b4ca8cd87d9
3
+ metadata.gz: 8d819cbcfb4db70f384f27e82168b629ff4d5b1da9846edcbde2f2ebea965f86
4
+ data.tar.gz: 8fd71ec9c615bc21e6b33c6ee2b1b30d3e45f6e5c6ca3bcf64b04051861253d2
5
5
  SHA512:
6
- metadata.gz: 884a2cf5e5bff6d1050a94e2abc09ea4c4c96d45144a529ae7e7a9c4b86382ce8ec73841f6119a0c5a42b96896105658b1436e6204ffb99e9bf80733f49204da
7
- data.tar.gz: 9a55303410d004305736bcafa56e61c10e323fe698f7c59b210dbb8135e9c5b21836ae9fc29057b26c31cb3761e0634f3fc94230da830ef2237598ad6a722843
6
+ metadata.gz: ebd6470d05c7883710c2d0b8197e559a9d2fb9c250b290ce6b7ba474b5363d129e67ae8a147f743324f6252d4d3d302e1acf4240cce5f2dbaca6d4397fe78b0d
7
+ data.tar.gz: c0675ef02071fb68f066e61c66184fcc4010685ce442b1345b7c9a16a40f9f187bc23428a689a4a41252dd2493df806d5eb782147c11c2c9fc1410537392f3af
data/bin/cobench CHANGED
@@ -74,6 +74,11 @@ end
74
74
  Encoding.default_external = Encoding::UTF_8
75
75
  Encoding.default_internal = Encoding::UTF_8
76
76
 
77
+ def div(a, b)
78
+ return 0 if b == 0
79
+ a / b
80
+ end
81
+
77
82
  def build_xml(opts, loog)
78
83
  if opts.token?
79
84
  api = Octokit::Client.new(:access_token => opts[:token])
@@ -150,11 +155,11 @@ def build_xml(opts, loog)
150
155
  end
151
156
  averages = {
152
157
  'HpP': {
153
- f: lambda { |ms| ms['HoC'][:total] / ms['Pulls'][:total] },
158
+ f: lambda { |ms| div(ms['HoC'][:total], ms['Pulls'][:total]) },
154
159
  title: 'HoC per Pull'
155
160
  },
156
161
  'HpC': {
157
- f: lambda { |ms| ms['HoC'][:total] / ms['Commits'][:total] },
162
+ f: lambda { |ms| div(ms['HoC'][:total], ms['Commits'][:total]) },
158
163
  title: 'HoC per Commit'
159
164
  }
160
165
  }
@@ -194,7 +199,7 @@ def build_xml(opts, loog)
194
199
  next if t == 'Score'
195
200
  xml.w(id: t) do
196
201
  vals = data.values.map { |ms| ms[t][:total] }.select { |v| v > 0 }
197
- xml.text(vals.inject(&:+) / vals.count)
202
+ xml.text(div(vals.inject(&:+), vals.count))
198
203
  end
199
204
  end
200
205
  end
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2022 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Cobench
26
- VERSION = '0.0.24'.freeze
26
+ VERSION = '0.0.25'.freeze
27
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cobench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko