simplecov-oj 0.18.4 → 0.19.0

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: a52b58ac549b3d82b715da3fa43d20c652c8c22cdc8bf98670d57a14814baf2a
4
- data.tar.gz: e43b431dbf0f1be41ae3dd0689db0a470be28d3881360dace7f7d6f27566333b
3
+ metadata.gz: ee2a41ebe0d37d6c68766300e168be7b004dc8dd57d7b6a1f6f0db61a9936f14
4
+ data.tar.gz: bd7d40c4b67ae26991682dcc71e787c965882fe60fadcb4ccaf2002a41716d8d
5
5
  SHA512:
6
- metadata.gz: 1d381f4bca2f0cbbed401b46a21159558044edb8db4e8899377d626065f2be66f87e7037ffd217326bbc921526571049a41e00746dfe0ff268d04f2e6f0067ff
7
- data.tar.gz: 9294869a32134d92899e05ab84395746499f9e95890762bbf8995ebdf720bc5fb6a6a4a78880891924ba192a92c44ebacea45ea387a39c1ae94e98097a914989
6
+ metadata.gz: 906aad73ac1e73f422b1aca264fae5a0f430675d6ab7ac2d69510ed67c2ca722e6b9dc1f5e45a7f6a03c0560ec1f6fb2b16aab585bcd26aa18bf3e22931b677f
7
+ data.tar.gz: 6b9e5ac80e73a8eace0617d48b5747b92e024b895c6eeb364f52b7905461e4b94bc65cee049fe38b45c87fa4933c8f4c38fa0a59ca796c8464c8b5ccf517b5da
data/README.md CHANGED
@@ -24,31 +24,30 @@ Generated JSON can be found in coverage/coverage.json
24
24
  The format you can expect is:
25
25
  ```json
26
26
  {
27
- "timestamp": 1348489587,
28
- "command_name": "RSpec",
29
- "files": [
30
- {
31
- "filename": "/home/user/rails/environment.rb",
32
- "covered_percent": 50.0,
33
- "coverage": [
34
- null,
35
- 1,
36
- null,
37
- null,
38
- 1
39
- ],
40
- "covered_strength": 0.50,
41
- "covered_lines": 2,
42
- "lines_of_code": 4
43
- },
44
- ...
45
- ],
46
- "metrics": {
47
- "covered_percent": 81.70731707317073,
48
- "covered_strength": 0.8170731707317073,
49
- "covered_lines": 67,
50
- "total_lines": 82
51
- }
27
+ "timestamp": 1348489587,
28
+ "command_name": "RSpec",
29
+ "files": [
30
+ {
31
+ "filename": "/home/user/rails/environment.rb",
32
+ "covered_percent": 50.0,
33
+ "coverage": [
34
+ null,
35
+ 1,
36
+ null,
37
+ null,
38
+ 1
39
+ ],
40
+ "covered_strength": 0.50,
41
+ "covered_lines": 2,
42
+ "lines_of_code": 4
43
+ },
44
+ ],
45
+ "metrics": {
46
+ "covered_percent": 81.70731707317073,
47
+ "covered_strength": 0.8170731707317073,
48
+ "covered_lines": 67,
49
+ "total_lines": 82
50
+ }
52
51
  }
53
52
  ```
54
53
 
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SimpleCov
4
+ #
5
+ # Module FormatResult uses Oj to dup the result to the configured output path
6
+ #
7
+ # @author Mikael Henriksson <mikael@mhenrixon.com>
8
+ #
9
+ module FormatResult
10
+ def self.call(result, output_file_path)
11
+ data = SimpleCov::Oj::ResultToHash.new(result).to_h
12
+ json = ::Oj.dump(data, mode: :compat)
13
+
14
+ File.open(output_file_path, 'w+') do |file|
15
+ file.puts json
16
+ end
17
+
18
+ json
19
+ end
20
+ end
21
+ end
@@ -13,6 +13,7 @@ module SimpleCov
13
13
  #
14
14
  # @return [String] name of the file with coverage.json data
15
15
  FILE_NAME = 'coverage.json'
16
+ OUTPUT_FILE_PATH = File.join(SimpleCov.coverage_path, FILE_NAME)
16
17
 
17
18
  #
18
19
  # Formats the result as a hash, dump it to json with Oj and then save it to disk
@@ -22,30 +23,11 @@ module SimpleCov
22
23
  # @return [<type>] <description>
23
24
  #
24
25
  def format(result)
25
- json = dump_json(result)
26
- puts SimpleCov::Oj::OutputMessage.new(result, output_filepath)
26
+ json = SimpleCov::FormatResult.call(result, OUTPUT_FILE_PATH)
27
+ puts SimpleCov::Oj::OutputMessage.new(result, OUTPUT_FILE_PATH)
27
28
 
28
29
  json
29
30
  end
30
-
31
- private
32
-
33
- # @private
34
- def dump_json(result)
35
- data = SimpleCov::Oj::ResultToHash.new(result).to_h
36
- json = ::Oj.dump(data, mode: :compat)
37
-
38
- File.open(output_filepath, 'w+') do |file|
39
- file.puts json
40
- end
41
-
42
- json
43
- end
44
-
45
- # @private
46
- def output_filepath
47
- File.join(SimpleCov.coverage_path, FILE_NAME)
48
- end
49
31
  end
50
32
  end
51
33
  end
@@ -9,6 +9,6 @@ module SimpleCov
9
9
  module Oj
10
10
  #
11
11
  # @return [String] the current version of the gem
12
- VERSION = '0.18.4'
12
+ VERSION = '0.19.0'
13
13
  end
14
14
  end
@@ -6,7 +6,7 @@ require 'oj'
6
6
  require 'simple_cov/oj/result_wrapper'
7
7
  require 'simple_cov/oj/source_file_wrapper'
8
8
  require 'simple_cov/oj/result_to_hash'
9
- require 'simple_cov/oj/result_to_hash'
10
9
  require 'simple_cov/oj/output_message'
11
10
  require 'simple_cov/oj/version'
11
+ require 'simple_cov/formatter/format_result'
12
12
  require 'simple_cov/formatter/oj_formatter'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov-oj
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.4
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikael Henriksson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-14 00:00:00.000000000 Z
11
+ date: 2020-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oj
@@ -135,33 +135,33 @@ dependencies:
135
135
  - !ruby/object:Gem::Version
136
136
  version: '3.9'
137
137
  - !ruby/object:Gem::Dependency
138
- name: github-markup
138
+ name: github_changelog_generator
139
139
  requirement: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - "~>"
142
142
  - !ruby/object:Gem::Version
143
- version: '3.0'
143
+ version: '1.14'
144
144
  type: :development
145
145
  prerelease: false
146
146
  version_requirements: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - "~>"
149
149
  - !ruby/object:Gem::Version
150
- version: '3.0'
150
+ version: '1.14'
151
151
  - !ruby/object:Gem::Dependency
152
- name: github_changelog_generator
152
+ name: github-markup
153
153
  requirement: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - "~>"
156
156
  - !ruby/object:Gem::Version
157
- version: '1.14'
157
+ version: '3.0'
158
158
  type: :development
159
159
  prerelease: false
160
160
  version_requirements: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - "~>"
163
163
  - !ruby/object:Gem::Version
164
- version: '1.14'
164
+ version: '3.0'
165
165
  - !ruby/object:Gem::Dependency
166
166
  name: yard
167
167
  requirement: !ruby/object:Gem::Requirement
@@ -188,6 +188,7 @@ files:
188
188
  - CHANGELOG.md
189
189
  - LICENSE
190
190
  - README.md
191
+ - lib/simple_cov/formatter/format_result.rb
191
192
  - lib/simple_cov/formatter/oj_formatter.rb
192
193
  - lib/simple_cov/oj/output_message.rb
193
194
  - lib/simple_cov/oj/result_to_hash.rb
@@ -207,23 +208,23 @@ metadata:
207
208
  documentation_uri: https://mhenrixon.github.io/simplecov-oj
208
209
  source_code_uri: https://github.com/mhenrixon/simplecov-oj
209
210
  changelog_uri: https://github.com/mhenrixon/simplecov-oj/CHANGELOG.md
210
- post_install_message:
211
+ post_install_message:
211
212
  rdoc_options: []
212
213
  require_paths:
213
214
  - lib
214
215
  required_ruby_version: !ruby/object:Gem::Requirement
215
216
  requirements:
216
- - - ">="
217
+ - - "~>"
217
218
  - !ruby/object:Gem::Version
218
- version: '0'
219
+ version: '2.5'
219
220
  required_rubygems_version: !ruby/object:Gem::Requirement
220
221
  requirements:
221
222
  - - ">="
222
223
  - !ruby/object:Gem::Version
223
224
  version: '0'
224
225
  requirements: []
225
- rubygems_version: 3.1.2
226
- signing_key:
226
+ rubygems_version: 3.1.4
227
+ signing_key:
227
228
  specification_version: 4
228
229
  summary: Oj formatter for SimpleCov code coverage tool for ruby 2.4+
229
230
  test_files: