-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #183 from danmayer/feature/gem_tracking
WIP: Feature/gem tracking
- Loading branch information
Showing
30 changed files
with
567 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
# | ||
# Applies the configured groups to the given array of Coverband::SourceFile items | ||
# | ||
module Coverband | ||
module Utils | ||
class FileGroups | ||
def initialize(files) | ||
@grouped = {} | ||
@files = files | ||
filter_to_groups | ||
end | ||
|
||
def grouped_results | ||
@grouped | ||
end | ||
|
||
private | ||
|
||
def filter_to_groups | ||
grouped_files = [] | ||
Coverband.configuration.groups.each do |name, filter| | ||
if name == 'Gems' | ||
gem_lists = gem_files(name, filter) | ||
grouped_files.concat(gem_lists.flatten) if gem_lists.flatten.any? | ||
else | ||
app_files(name, filter) | ||
grouped_files += @grouped[name] | ||
end | ||
end | ||
if !Coverband.configuration.groups.empty? && !(other_files = @files.reject do |source_file| | ||
grouped_files.include?(source_file) | ||
end).empty? | ||
@grouped['Ungrouped'] = Coverband::Utils::FileList.new(other_files) | ||
end | ||
end | ||
|
||
def gem_files(name, filter) | ||
grouped_gems = @files.select { |source_file| source_file.filename =~ /#{filter}/ }.group_by(&:gem_name) | ||
gem_lists = grouped_gems.values.map { |gem_files| Coverband::Utils::FileList.new(gem_files) } | ||
@grouped[name] = Coverband::Utils::GemList.new(gem_lists) if gem_lists.flatten.any? | ||
gem_lists | ||
end | ||
|
||
def app_files(name, filter) | ||
@grouped[name] = Coverband::Utils::FileList.new(@files.select do |source_file| | ||
source_file.filename =~ /#{filter}/ && source_file.filename !~ /#{Coverband.configuration.gem_paths.first}/ | ||
end) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
#### | ||
# An array of FileLists instances with helpers to roll up the stats | ||
# methods for calculating coverage across them etc. | ||
#### | ||
module Coverband | ||
module Utils | ||
class GemList < FileList | ||
# Returns the count of lines that have coverage | ||
def covered_lines | ||
to_a.map(&:covered_lines).inject(:+) | ||
end | ||
|
||
# Returns the count of lines that have been missed | ||
def missed_lines | ||
to_a.map(&:missed_lines).inject(:+) | ||
end | ||
|
||
# Returns the count of lines that are not relevant for coverage | ||
def never_lines | ||
to_a.map(&:never_lines).inject(:+) | ||
end | ||
|
||
# Returns the count of skipped lines | ||
def skipped_lines | ||
to_a.map(&:skipped_lines).inject(:+) | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.