simplecov-compare 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e1c84aeb5ca7098e9ef46d238a442ff1033e3ab9591cb035b010a51db6e64cf0
4
+ data.tar.gz: de4cdfdf2bd6ad0dddffba37a480c0f14d26a51b93721628bf43ebeabe51529f
5
+ SHA512:
6
+ metadata.gz: 8243f62a3094c48af6fd763fbaece4ac75a5d4a54b38e01154ff609ac4ecd868e3a455b12d7fc552d1e3aa839240ba292065d2d4d8dc52227602e0fc2014e066
7
+ data.tar.gz: d9ff76b1d1035420e950fc5b5ceb2a4affc74cd68f024c39cfdd1493e3ff6c308e9546b1ff39a1427a5986baf2271d9b279c38fedab2fc7b191b1df1b6456378
@@ -0,0 +1,91 @@
1
+
2
+ # Contributor Covenant 3.0 Code of Conduct
3
+
4
+ ## Our Pledge
5
+
6
+ We pledge to make our community welcoming, safe, and equitable for all.
7
+
8
+ We are committed to fostering an environment that respects and promotes the dignity, rights, and contributions of all individuals, regardless of characteristics including race, ethnicity, caste, color, age, physical characteristics, neurodiversity, disability, sex or gender, gender identity or expression, sexual orientation, language, philosophy or religion, national or social origin, socio-economic position, level of education, or other status. The same privileges of participation are extended to everyone who participates in good faith and in accordance with this Covenant.
9
+
10
+ ## Encouraged Behaviors
11
+
12
+ While acknowledging differences in social norms, we all strive to meet our community's expectations for positive behavior. We also understand that our words and actions may be interpreted differently than we intend based on culture, background, or native language.
13
+
14
+ With these considerations in mind, we agree to behave mindfully toward each other and act in ways that center our shared values, including:
15
+
16
+ 1. Respecting the **purpose of our community**, our activities, and our ways of gathering.
17
+ 2. Engaging **kindly and honestly** with others.
18
+ 3. Respecting **different viewpoints** and experiences.
19
+ 4. **Taking responsibility** for our actions and contributions.
20
+ 5. Gracefully giving and accepting **constructive feedback**.
21
+ 6. Committing to **repairing harm** when it occurs.
22
+ 7. Behaving in other ways that promote and sustain the **well-being of our community**.
23
+
24
+
25
+ ## Restricted Behaviors
26
+
27
+ We agree to restrict the following behaviors in our community. Instances, threats, and promotion of these behaviors are violations of this Code of Conduct.
28
+
29
+ 1. **Harassment.** Violating explicitly expressed boundaries or engaging in unnecessary personal attention after any clear request to stop.
30
+ 2. **Character attacks.** Making insulting, demeaning, or pejorative comments directed at a community member or group of people.
31
+ 3. **Stereotyping or discrimination.** Characterizing anyone’s personality or behavior on the basis of immutable identities or traits.
32
+ 4. **Sexualization.** Behaving in a way that would generally be considered inappropriately intimate in the context or purpose of the community.
33
+ 5. **Violating confidentiality**. Sharing or acting on someone's personal or private information without their permission.
34
+ 6. **Endangerment.** Causing, encouraging, or threatening violence or other harm toward any person or group.
35
+ 7. Behaving in other ways that **threaten the well-being** of our community.
36
+
37
+ ### Other Restrictions
38
+
39
+ 1. **Misleading identity.** Impersonating someone else for any reason, or pretending to be someone else to evade enforcement actions.
40
+ 2. **Failing to credit sources.** Not properly crediting the sources of content you contribute.
41
+ 3. **Promotional materials**. Sharing marketing or other commercial content in a way that is outside the norms of the community.
42
+ 4. **Irresponsible communication.** Failing to responsibly present content which includes, links or describes any other restricted behaviors.
43
+
44
+
45
+ ## Reporting an Issue
46
+
47
+ Tensions can occur between community members even when they are trying their best to collaborate. Not every conflict represents a code of conduct violation, and this Code of Conduct reinforces encouraged behaviors and norms that can help avoid conflicts and minimize harm.
48
+
49
+ When an incident does occur, it is important to report it promptly. To report a possible violation, **email one of the authors, as specified in the gemspec.**
50
+
51
+ Community Moderators take reports of violations seriously and will make every effort to respond in a timely manner. They will investigate all reports of code of conduct violations, reviewing messages, logs, and recordings, or interviewing witnesses and other participants. Community Moderators will keep investigation and enforcement actions as transparent as possible while prioritizing safety and confidentiality. In order to honor these values, enforcement actions are carried out in private with the involved parties, but communicating to the whole community may be part of a mutually agreed upon resolution.
52
+
53
+
54
+ ## Addressing and Repairing Harm
55
+
56
+ ****
57
+
58
+ If an investigation by the Community Moderators finds that this Code of Conduct has been violated, the following enforcement ladder may be used to determine how best to repair harm, based on the incident's impact on the individuals involved and the community as a whole. Depending on the severity of a violation, lower rungs on the ladder may be skipped.
59
+
60
+ 1) Warning
61
+ 1) Event: A violation involving a single incident or series of incidents.
62
+ 2) Consequence: A private, written warning from the Community Moderators.
63
+ 3) Repair: Examples of repair include a private written apology, acknowledgement of responsibility, and seeking clarification on expectations.
64
+ 2) Temporarily Limited Activities
65
+ 1) Event: A repeated incidence of a violation that previously resulted in a warning, or the first incidence of a more serious violation.
66
+ 2) Consequence: A private, written warning with a time-limited cooldown period designed to underscore the seriousness of the situation and give the community members involved time to process the incident. The cooldown period may be limited to particular communication channels or interactions with particular community members.
67
+ 3) Repair: Examples of repair may include making an apology, using the cooldown period to reflect on actions and impact, and being thoughtful about re-entering community spaces after the period is over.
68
+ 3) Temporary Suspension
69
+ 1) Event: A pattern of repeated violation which the Community Moderators have tried to address with warnings, or a single serious violation.
70
+ 2) Consequence: A private written warning with conditions for return from suspension. In general, temporary suspensions give the person being suspended time to reflect upon their behavior and possible corrective actions.
71
+ 3) Repair: Examples of repair include respecting the spirit of the suspension, meeting the specified conditions for return, and being thoughtful about how to reintegrate with the community when the suspension is lifted.
72
+ 4) Permanent Ban
73
+ 1) Event: A pattern of repeated code of conduct violations that other steps on the ladder have failed to resolve, or a violation so serious that the Community Moderators determine there is no way to keep the community safe with this person as a member.
74
+ 2) Consequence: Access to all community spaces, tools, and communication channels is removed. In general, permanent bans should be rarely used, should have strong reasoning behind them, and should only be resorted to if working through other remedies has failed to change the behavior.
75
+ 3) Repair: There is no possible repair in cases of this severity.
76
+
77
+ This enforcement ladder is intended as a guideline. It does not limit the ability of Community Managers to use their discretion and judgment, in keeping with the best interests of our community.
78
+
79
+
80
+ ## Scope
81
+
82
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public or other spaces. Examples of representing our community include using an official email address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
83
+
84
+
85
+ ## Attribution
86
+
87
+ This Code of Conduct is adapted from the Contributor Covenant, version 3.0, permanently available at [https://www.contributor-covenant.org/version/3/0/](https://www.contributor-covenant.org/version/3/0/).
88
+
89
+ Contributor Covenant is stewarded by the Organization for Ethical Source and licensed under CC BY-SA 4.0. To view a copy of this license, visit [https://creativecommons.org/licenses/by-sa/4.0/](https://creativecommons.org/licenses/by-sa/4.0/)
90
+
91
+ For answers to common questions about Contributor Covenant, see the FAQ at [https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq). Translations are provided at [https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations). Additional enforcement and community guideline resources can be found at [https://www.contributor-covenant.org/resources](https://www.contributor-covenant.org/resources). The enforcement ladder was inspired by the work of [Mozilla’s code of conduct team](https://github.com/mozilla/inclusion).
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Kevin Murphy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Simplecov::Compare
2
+
3
+ Simplecov's coverage report will tell the coverage of an application at a moment
4
+ of time. You may want to track differences over time though. This provides a
5
+ mechanism to compare two Simplecov results.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ Given an earlier coverage JSON output named `path/to/before.json` and a later
26
+ report named `path/to/after.json`, you can run:
27
+
28
+ ```ruby
29
+ Simplecov::Compare.report(
30
+ base_path: "path/to/before.json",
31
+ to_path: "path/to/after.json",
32
+ )
33
+ ```
34
+
35
+ ## Development
36
+
37
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
38
+
39
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kevin-j-m/simplecov-compare. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/kevin-j-m/simplecov-compare/blob/main/CODE_OF_CONDUCT.md).
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
48
+
49
+ ## Code of Conduct
50
+
51
+ Everyone interacting in the Simplecov::Compare project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kevin-j-m]/simplecov-compare/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << "test"
8
+ t.test_files = FileList["test/**/*_test.rb"]
9
+ end
10
+
11
+ task default: :test
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/simplecov/compare"
4
+
5
+ Simplecov::Compare.report(
6
+ base_path: ARGV[0],
7
+ to_path: ARGV[1],
8
+ )
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Simplecov
4
+ module Compare
5
+ class FileComparison
6
+ def initialize(base, to:)
7
+ @base = base
8
+ @other = to
9
+ end
10
+
11
+ def same_file?
12
+ return false if @base.nil?
13
+
14
+ @base.same_file?(@other)
15
+ end
16
+
17
+ def filename
18
+ @base&.filename || @other&.filename
19
+ end
20
+
21
+ def lines_coverage_different?
22
+ !lines_coverage_equal?
23
+ end
24
+
25
+ def lines_coverage_equal?
26
+ lines_coverage_delta_points.zero?
27
+ end
28
+
29
+ def lines_coverage_increased?
30
+ lines_coverage_delta_points.positive?
31
+ end
32
+
33
+ def lines_coverage_decreased?
34
+ lines_coverage_delta_points.negative?
35
+ end
36
+
37
+ def lines_coverage_delta_points
38
+ return @other.lines_covered_percent if @base.nil?
39
+ return (-@base.lines_covered_percent) if @other.nil?
40
+
41
+ @other.lines_covered_percent - @base.lines_covered_percent
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Simplecov
4
+ module Compare
5
+ class FileLine
6
+ # https://github.com/simplecov-ruby/simplecov/blob/main/lib/simplecov/source_file/line.rb
7
+ attr_reader :line_number
8
+
9
+ def initialize(line_number:, covered_count:)
10
+ @line_number = line_number
11
+ @covered_count = covered_count
12
+ end
13
+
14
+ def covered?
15
+ relevant? && @covered_count.positive?
16
+ end
17
+
18
+ def missed?
19
+ relevant? && @covered_count.zero?
20
+ end
21
+
22
+ def relevant?
23
+ !irrelevant?
24
+ end
25
+
26
+ def irrelevant?
27
+ @covered_count.nil?
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Simplecov
4
+ module Compare
5
+ class FileResult
6
+ # https://github.com/simplecov-ruby/simplecov/blob/main/lib/simplecov/source_file.rb
7
+ attr_reader :filename
8
+
9
+ def initialize(filename, coverage_data:)
10
+ @filename = filename
11
+ @coverage_data = coverage_data
12
+ end
13
+
14
+ def lines
15
+ return @lines if defined?(@lines)
16
+ return @lines = [] unless @coverage_data
17
+ lines_coverage = @coverage_data["lines"]
18
+
19
+ if lines_coverage
20
+ @lines = lines_coverage.map.with_index do |coverage, index|
21
+ FileLine.new(line_number: index + 1, covered_count: coverage)
22
+ end
23
+ else
24
+ @lines = []
25
+ end
26
+ end
27
+
28
+ def relevant_lines
29
+ lines.select { _1.relevant? }
30
+ end
31
+
32
+ def covered_lines
33
+ lines.select { _1.covered? }
34
+ end
35
+
36
+ def lines_covered_percent
37
+ return 100 if relevant_lines.size.zero?
38
+
39
+ ((covered_lines.size / relevant_lines.size.to_f) * 100).round(2)
40
+ end
41
+
42
+ def same_file?(other)
43
+ return false unless other.is_a?(Simplecov::Compare::FileResult)
44
+
45
+ filename.to_s.downcase == other.filename.to_s.downcase
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Simplecov
4
+ module Compare
5
+ module Formatter
6
+ class MarkdownFormatter
7
+ def format(result_set_comparison)
8
+ <<~MARKDOWN
9
+ #{heading}
10
+
11
+ #{overall_impact(result_set_comparison)}
12
+ #{file_differences(result_set_comparison)}
13
+ MARKDOWN
14
+ end
15
+
16
+ private
17
+
18
+ def heading
19
+ "# Coverage Comparison"
20
+ end
21
+
22
+ def overall_impact(result_set_comparison)
23
+ if result_set_comparison.lines_coverage_increased?
24
+ overall_coverage_increased(result_set_comparison)
25
+ elsif result_set_comparison.lines_coverage_decreased?
26
+ overall_coverage_decreased(result_set_comparison)
27
+ else
28
+ overall_coverage_equal(result_set_comparison)
29
+ end
30
+ end
31
+
32
+ def overall_coverage_increased(result_set_comparison)
33
+ <<~OVERALL_IMPACT
34
+ ## Overall Impact: 📈
35
+
36
+ Coverage increased #{result_set_comparison.lines_coverage_delta_points} points from #{result_set_comparison.original_lines_covered_percent}% to #{result_set_comparison.new_lines_covered_percent}%.
37
+ OVERALL_IMPACT
38
+ end
39
+
40
+ def overall_coverage_decreased(result_set_comparison)
41
+ <<~OVERALL_IMPACT
42
+ ## Overall Impact: 📉
43
+
44
+ Coverage decreased #{result_set_comparison.lines_coverage_delta_points * -1} points from #{result_set_comparison.original_lines_covered_percent}% to #{result_set_comparison.new_lines_covered_percent}%.
45
+ OVERALL_IMPACT
46
+ end
47
+
48
+ def overall_coverage_equal(result_set_comparison)
49
+ <<~OVERALL_IMPACT
50
+ ## Overall Impact: 🟰
51
+
52
+ Coverage maintained at #{result_set_comparison.original_lines_covered_percent}%.
53
+ OVERALL_IMPACT
54
+ end
55
+
56
+ def file_differences(result_set_comparison)
57
+ if result_set_comparison.file_differences?
58
+ <<~FILE_DIFF
59
+ ## File Differences
60
+
61
+ | File Name | Coverage Change |
62
+ | --------- | --------------- |
63
+ #{file_differences_table_contents(result_set_comparison)}
64
+ FILE_DIFF
65
+ else
66
+ <<~NO_FILE_DIFF
67
+ ## File Differences
68
+
69
+ All files maintained the same level of coverage.
70
+ NO_FILE_DIFF
71
+ end
72
+ end
73
+
74
+ def file_differences_table_contents(result_set_comparison)
75
+ result_set_comparison
76
+ .file_differences
77
+ .sort_by { _1.lines_coverage_delta_points }
78
+ .each_with_object(+"") do |file_difference, output|
79
+ output << "| #{file_difference.filename} | #{file_difference.lines_coverage_delta_points} |\n"
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "glamour"
4
+
5
+ module Simplecov
6
+ module Compare
7
+ module Reporter
8
+ class GlamourReporter
9
+ def report(output)
10
+ puts Glamour.render(output)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Simplecov
4
+ module Compare
5
+ module Reporter
6
+ class SimpleReporter
7
+ def report(output)
8
+ puts output
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Simplecov
6
+ module Compare
7
+ class ResultFile
8
+ def initialize(file_path)
9
+ @file_path = file_path
10
+ end
11
+
12
+ def coverage_data
13
+ return @coverage_data if defined?(@coverage_data)
14
+
15
+ @coverage_data =
16
+ parse_file
17
+ .map { |command_name, data| [[command_name], data.fetch("coverage")] }
18
+ .first
19
+ .last
20
+ end
21
+
22
+ private
23
+
24
+ def parse_file
25
+ data = read_file
26
+ parse_json(data)
27
+ end
28
+
29
+ def read_file
30
+ return unless File.exist?(@file_path)
31
+
32
+ data = File.read(@file_path)
33
+ return if data.nil? || data.length < 2
34
+
35
+ data
36
+ end
37
+
38
+ def parse_json(content)
39
+ return {} unless content
40
+
41
+ JSON.parse(content) || {}
42
+ rescue StandardError
43
+ {}
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Simplecov
4
+ module Compare
5
+ class ResultSet
6
+ # https://github.com/simplecov-ruby/simplecov/blob/main/lib/simplecov/file_list.rb
7
+
8
+ def initialize(coverage_data)
9
+ @coverage_data = coverage_data
10
+ end
11
+
12
+ def files
13
+ return @files if defined?(@files)
14
+
15
+ @files =
16
+ @coverage_data
17
+ .map { |filename, coverage| FileResult.new(filename, coverage_data: JSON.parse(JSON.dump(coverage))) }
18
+ .compact
19
+ .sort_by { _1.filename }
20
+ end
21
+
22
+ def num_relevant_lines
23
+ files.sum { _1.relevant_lines.size }
24
+ end
25
+
26
+ def num_covered_lines
27
+ files.sum { _1.covered_lines.size }
28
+ end
29
+
30
+ def lines_covered_percent
31
+ return 100 if num_relevant_lines.zero?
32
+
33
+ ((num_covered_lines / num_relevant_lines.to_f) * 100).round(2)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Simplecov
4
+ module Compare
5
+ class ResultSetComparison
6
+ def initialize(base, to:)
7
+ @base = base
8
+ @other = to
9
+ end
10
+
11
+ def original_lines_covered_percent
12
+ @base.lines_covered_percent
13
+ end
14
+
15
+ def new_lines_covered_percent
16
+ @other.lines_covered_percent
17
+ end
18
+
19
+ def lines_coverage_increased?
20
+ lines_coverage_delta_points.positive?
21
+ end
22
+
23
+ def lines_coverage_decreased?
24
+ lines_coverage_delta_points.negative?
25
+ end
26
+
27
+ def lines_coverage_delta_points
28
+ return new_lines_covered_percent if @base.nil?
29
+ return -original_lines_covered_percent if @other.nil?
30
+
31
+ new_lines_covered_percent - original_lines_covered_percent
32
+ end
33
+
34
+ def file_differences
35
+ return @file_differences if defined?(@file_differences)
36
+
37
+ compare
38
+ @file_differences
39
+ end
40
+
41
+ def file_differences?
42
+ !file_differences.empty?
43
+ end
44
+
45
+ private
46
+
47
+ def compare
48
+ @file_differences = []
49
+ add_differences_from_base
50
+ add_new_files_from_other
51
+ end
52
+
53
+ def add_differences_from_base
54
+ base_file_set.each do |base_file|
55
+ match = other_file_set.find { base_file.same_file?(_1) }
56
+ if match
57
+ other_file_set.delete(match)
58
+ end
59
+
60
+ file_comparison = FileComparison.new(base_file, to: match)
61
+ if file_comparison.lines_coverage_different?
62
+ @file_differences << file_comparison
63
+ end
64
+ end
65
+ end
66
+
67
+ def add_new_files_from_other
68
+ other_file_set.each do |other_file|
69
+ file_comparison = FileComparison.new(nil, to: other_file)
70
+ @file_differences << file_comparison
71
+ end
72
+ end
73
+
74
+ def base_file_set
75
+ @base_file_set ||= @base.files.dup
76
+ end
77
+
78
+ def other_file_set
79
+ @other_file_set ||= @other.files.dup
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Simplecov
4
+ module Compare
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "compare/version"
4
+ require_relative "compare/file_comparison"
5
+ require_relative "compare/file_line"
6
+ require_relative "compare/file_result"
7
+ require_relative "compare/formatter/markdown_formatter"
8
+ require_relative "compare/reporter/glamour_reporter"
9
+ require_relative "compare/reporter/simple_reporter"
10
+ require_relative "compare/result_file"
11
+ require_relative "compare/result_set"
12
+ require_relative "compare/result_set_comparison"
13
+
14
+ module Simplecov
15
+ module Compare
16
+ def self.report(base_path:, to_path:, formatter_class: Formatter::MarkdownFormatter, reporter_class: Reporter::GlamourReporter)
17
+ base = ResultSet.new(ResultFile.new(base_path).coverage_data)
18
+ other = ResultSet.new(ResultFile.new(to_path).coverage_data)
19
+ comparison = ResultSetComparison.new(base, to: other)
20
+
21
+ formatted = formatter_class.new.format(comparison)
22
+ reporter_class.new.report(formatted)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,6 @@
1
+ module Simplecov
2
+ module Compare
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ {
2
+ "RSpec": {
3
+ "coverage": {
4
+ "/path/to/app/helpers/application_helper.rb": {
5
+ "lines": [
6
+ 0,
7
+ null
8
+ ]
9
+ }
10
+ },
11
+ "timestamp": 1770264586
12
+ }
13
+ }