Class: SimpleCov::Profiles

Inherits:
Hash
  • Object
show all
Defined in:
lib/simplecov/profiles.rb,
sig/simplecov.rbs

Overview

Configuration procs loaded with SimpleCov.start :rails and defined with SimpleCov.profiles.define.

Instance Method Summary collapse

Instance Method Details

#autoload_profile(name) ⇒ void

This method returns an undefined value.

Parameters:

  • name (Symbol)


31
32
33
34
35
36
37
38
39
40
# File 'lib/simplecov/profiles.rb', line 31

def autoload_profile(name)
  require "simplecov/profiles/#{name}"
rescue LoadError
  begin
    require "simplecov-profile-#{name}"
  rescue LoadError
    # Neither a bundled profile nor a plugin gem; `fetch_proc` raises the
    # user-facing error.
  end
end

#define(name) { ... } ⇒ profile_proc

Parameters:

  • name (Symbol, String)

Yields:

Yield Returns:

  • (void)

Returns:

  • (profile_proc)

Raises:



7
8
9
10
11
12
# File 'lib/simplecov/profiles.rb', line 7

def define(name, &blk)
  name = name.to_sym
  raise ConfigurationError, "SimpleCov Profile '#{name}' is already defined" unless self[name].nil?

  self[name] = blk
end

#fetch_proc(name) ⇒ profile_proc

Lookup order: already registered via #define, then require "simplecov/profiles/<name>" for the bundled profiles, then require "simplecov-profile-<name>" for third-party plugin gems.

Parameters:

  • name (Symbol, String)

Returns:

  • (profile_proc)

Raises:



21
22
23
24
25
26
27
# File 'lib/simplecov/profiles.rb', line 21

def fetch_proc(name)
  name = name.to_sym
  autoload_profile(name) unless key?(name)
  return fetch(name) if key?(name)

  raise ConfigurationError, "Could not find SimpleCov Profile called '#{name}'"
end

#load(name) ⇒ void

This method returns an undefined value.

Parameters:

  • name (Symbol, String)


14
15
16
# File 'lib/simplecov/profiles.rb', line 14

def load(name)
  SimpleCov.configure(&fetch_proc(name))
end