Class: SimpleCov::Profiles
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Hash
|
|
|
Instance Chain:
self,
Hash
|
|
| Inherits: |
Hash
|
| Defined in: | lib/simplecov/profiles.rb |
Overview
Profiles are ::SimpleCov configuration procs that can be easily
loaded using start :rails and defined using
SimpleCov.profiles.define :foo do
# SimpleCov configuration here, same as in SimpleCov.configure
end
Instance Method Summary
-
#define(name, &blk)
Define a
::SimpleCovprofile: -
#fetch_proc(name)
Returns the proc registered for the given profile name, autoloading bundled or plugin-gem profiles on first lookup.
-
#load(name)
Applies the profile of given name on
SimpleCov.configure - #autoload_profile(name) private
Instance Method Details
#autoload_profile(name) (private)
[ GitHub ]# File 'lib/simplecov/profiles.rb', line 52
def autoload_profile(name) require "simplecov/profiles/#{name}" rescue LoadError begin # simplecov:disable — third-party gem fallback (no such gem in test env) require "simplecov-profile-#{name}" # simplecov:enable rescue LoadError # fall through; #fetch_proc raises the user-facing error end end
#define(name, &blk)
Define a ::SimpleCov profile:
SimpleCov.profiles.define 'rails' do
# Same as SimpleCov.configure do .. here
end
# File 'lib/simplecov/profiles.rb', line 18
def define(name, &blk) name = name.to_sym raise "SimpleCov Profile '#{name}' is already defined" unless self[name].nil? self[name] = blk end
#fetch_proc(name)
Returns the proc registered for the given profile name, autoloading bundled or plugin-gem profiles on first lookup. Raises if the profile cannot be located.
Lookup order:
1. already registered via #define
2. require "simplecov/profiles/<name>" (bundled profiles)
3. require "simplecov-profile-<name>" (third-party plugin gems)
# File 'lib/simplecov/profiles.rb', line 42
def fetch_proc(name) name = name.to_sym autoload_profile(name) unless key?(name) raise "Could not find SimpleCov Profile called '#{name}'" unless key?(name) self[name] end
#load(name)
Applies the profile of given name on SimpleCov.configure
# File 'lib/simplecov/profiles.rb', line 28
def load(name) SimpleCov.configure(&fetch_proc(name)) end