codeclimate-test-reporter 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  module CodeClimate
2
2
  module TestReporter
3
- VERSION = "0.0.10"
3
+ VERSION = "0.0.11"
4
4
 
5
5
  def self.start
6
6
  if run?
@@ -9,7 +9,7 @@ module CodeClimate
9
9
  module TestReporter
10
10
  class Formatter
11
11
  def format(result)
12
- print "Coverage = #{result.covered_percent.round(2)}%. "
12
+ print "Coverage = #{round(result.covered_percent, 2)}%. "
13
13
 
14
14
  payload = to_payload(result)
15
15
  if tddium? || ENV["TO_FILE"]
@@ -45,8 +45,8 @@ module CodeClimate
45
45
  name: short_filename(file.filename),
46
46
  blob_id: calculate_blob_id(file.filename),
47
47
  coverage: file.coverage.to_json,
48
- covered_percent: file.covered_percent.round(2),
49
- covered_strength: file.covered_strength.round(2),
48
+ covered_percent: round(file.covered_percent, 2),
49
+ covered_strength: round(file.covered_strength, 2),
50
50
  line_counts: {
51
51
  total: file.lines.count,
52
52
  covered: file.covered_lines.count,
@@ -59,8 +59,8 @@ module CodeClimate
59
59
  repo_token: ENV["CODECLIMATE_REPO_TOKEN"],
60
60
  source_files: source_files,
61
61
  run_at: result.created_at,
62
- covered_percent: result.covered_percent.round(2),
63
- covered_strength: result.covered_strength.round(2),
62
+ covered_percent: round(result.covered_percent, 2),
63
+ covered_strength: round(result.covered_strength, 2),
64
64
  line_counts: totals,
65
65
  partial: partial?,
66
66
  git: {
@@ -149,7 +149,7 @@ module CodeClimate
149
149
  def compute_branch(payload)
150
150
  git_branch = payload[:git][:branch]
151
151
  ci_branch = payload[:ci_service][:branch]
152
-
152
+
153
153
  if ci_branch.to_s.strip.size > 0
154
154
  ci_branch.sub(/^origin\//, "")
155
155
  elsif git_branch.to_s.strip.size > 0 && !git_branch.to_s.strip.start_with?("(")
@@ -158,6 +158,12 @@ module CodeClimate
158
158
  "master"
159
159
  end
160
160
  end
161
+
162
+ # Convert to Float before rounding.
163
+ # Fixes [#7] possible segmentation fault when calling #round on a Rational
164
+ def round(numeric, precision)
165
+ Float(numeric).round(precision)
166
+ end
161
167
  end
162
168
  end
163
169
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeclimate-test-reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-18 00:00:00.000000000 Z
12
+ date: 2013-09-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: simplecov