Skip to content

Commit

Permalink
Merge pull request #631 from thomas07vt/simplify_defaults
Browse files Browse the repository at this point in the history
Break default profiles out into new files
  • Loading branch information
PragTob authored Oct 8, 2017
2 parents 6fd6fd0 + 1e7f4f3 commit ebc0bac
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 37 deletions.
41 changes: 4 additions & 37 deletions lib/simplecov/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,10 @@
# Load default formatter gem
require "simplecov-html"
require "pathname"

SimpleCov.profiles.define "root_filter" do
# Exclude all files outside of simplecov root
root_filter = nil
add_filter do |src|
root_filter ||= /\A#{Regexp.escape(SimpleCov.root + File::SEPARATOR)}/io
src.filename !~ root_filter
end
end

SimpleCov.profiles.define "test_frameworks" do
add_filter "/test/"
add_filter "/features/"
add_filter "/spec/"
add_filter "/autotest/"
end

SimpleCov.profiles.define "bundler_filter" do
add_filter "/vendor/bundle/"
end

SimpleCov.profiles.define "rails" do
load_profile "test_frameworks"

add_filter %r{^/config/}
add_filter %r{^/db/}

add_group "Controllers", "app/controllers"
add_group "Channels", "app/channels" if defined?(ActionCable)
add_group "Models", "app/models"
add_group "Mailers", "app/mailers"
add_group "Helpers", "app/helpers"
add_group "Jobs", %w[app/jobs app/workers]
add_group "Libraries", "lib"

track_files "{app,lib}/**/*.rb"
end
require "simplecov/profiles/root_filter"
require "simplecov/profiles/test_frameworks"
require "simplecov/profiles/bundler_filter"
require "simplecov/profiles/rails"

# Default configuration
SimpleCov.configure do
Expand Down
5 changes: 5 additions & 0 deletions lib/simplecov/profiles/bundler_filter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

SimpleCov.profiles.define "bundler_filter" do
add_filter "/vendor/bundle/"
end
18 changes: 18 additions & 0 deletions lib/simplecov/profiles/rails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true

SimpleCov.profiles.define "rails" do
load_profile "test_frameworks"

add_filter %r{^/config/}
add_filter %r{^/db/}

add_group "Controllers", "app/controllers"
add_group "Channels", "app/channels" if defined?(ActionCable)
add_group "Models", "app/models"
add_group "Mailers", "app/mailers"
add_group "Helpers", "app/helpers"
add_group "Jobs", %w[app/jobs app/workers]
add_group "Libraries", "lib"

track_files "{app,lib}/**/*.rb"
end
10 changes: 10 additions & 0 deletions lib/simplecov/profiles/root_filter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

SimpleCov.profiles.define "root_filter" do
# Exclude all files outside of simplecov root
root_filter = nil
add_filter do |src|
root_filter ||= /\A#{Regexp.escape(SimpleCov.root + File::SEPARATOR)}/io
src.filename !~ root_filter
end
end
8 changes: 8 additions & 0 deletions lib/simplecov/profiles/test_frameworks.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

SimpleCov.profiles.define "test_frameworks" do
add_filter "/test/"
add_filter "/features/"
add_filter "/spec/"
add_filter "/autotest/"
end

0 comments on commit ebc0bac

Please sign in to comment.