Class: SimpleCov::Profiles
- Inherits:
-
Hash
- Object
- Hash
- SimpleCov::Profiles
- Defined in:
- lib/simplecov/profiles.rb,
sig/simplecov.rbs
Overview
Profiles are SimpleCov configuration procs that can be easily loaded using SimpleCov.start :rails and defined using SimpleCov.profiles.define :foo do # SimpleCov configuration here, same as in SimpleCov.configure end
Instance Method Summary collapse
-
#autoload_profile(name) ⇒ void
Tries
require "simplecov/profiles/<name>", thenrequire "simplecov-profile-<name>"; swallows LoadError so fetch_proc raises the user-facing error. -
#define(name) { ... } ⇒ profile_proc
Raises SimpleCov::ConfigurationError when the name is taken.
-
#fetch_proc(name) ⇒ profile_proc
Returns the proc for the given profile name, autoloading bundled ("simplecov/profiles/
") or plugin-gem ("simplecov-profile- ") profiles on first lookup. -
#load(name) ⇒ void
Applies the named profile via SimpleCov.configure.
Instance Method Details
#autoload_profile(name) ⇒ void
This method returns an undefined value.
Tries require "simplecov/profiles/<name>", then
require "simplecov-profile-<name>"; swallows LoadError so
fetch_proc raises the user-facing error.
1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 |
# File 'sig/simplecov.rbs', line 1465 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) { ... } ⇒ profile_proc
Raises SimpleCov::ConfigurationError when the name is taken. The block runs via instance_exec against the SimpleCov module itself (which extends Configuration), not a Configuration instance.
18 19 20 21 22 23 |
# File 'lib/simplecov/profiles.rb', line 18 def define(name, &blk) name = name.to_sym raise SimpleCov::ConfigurationError, "SimpleCov Profile '#{name}' is already defined" unless self[name].nil? self[name] = blk end |
#fetch_proc(name) ⇒ profile_proc
Returns the proc for the given profile name, autoloading bundled
("simplecov/profiles/
42 43 44 45 46 47 48 |
# File 'lib/simplecov/profiles.rb', line 42 def fetch_proc(name) name = name.to_sym autoload_profile(name) unless key?(name) return self[name] if key?(name) raise SimpleCov::ConfigurationError, "Could not find SimpleCov Profile called '#{name}'" end |