Class: StartupTime::Registry
- Inherits:
-
Object
- Object
- StartupTime::Registry
- Defined in:
- lib/startup_time/registry.rb
Overview
StartupTime::Registry - an interface to the tests configured in resources/tests.yaml
Constant Summary collapse
- TEST_DATA =
the path to the test configuration file
File.join(__dir__, '../../resources/tests.yaml')
- GROUPS =
map each group (e.g. “jvm”) to an array of its member IDs (e.g. [“java”, “kotlin”, “scala”])
Hash.new { |h, k| h[k] = [] }.with_indifferent_access
- TESTS =
the top-level hash in tests.yaml. keys are test IDs (e.g. “ruby”); values are test specs
YAML.safe_load(File.read(TEST_DATA)).with_indifferent_access
Class Method Summary collapse
-
.ids_to_groups(format: :ascii) ⇒ Object
a hash which maps test IDs (e.g. “scala”) to their corresponding group names (e.g. [“compiled”, “jvm”, “slow”]).
Instance Method Summary collapse
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
-
#omit(id) ⇒ Object
add the specified test(s) to the set of disabled tests.
-
#only(id) ⇒ Object
add the specified test(s) to the set of enabled tests.
-
#selected_tests ⇒ Object
the subset of candidate tests which satisfy the ‘only` and `omit` criteria.
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
49 50 51 52 |
# File 'lib/startup_time/registry.rb', line 49 def initialize @omit = Set.new @only = Set.new end |
Class Method Details
.ids_to_groups(format: :ascii) ⇒ Object
a hash which maps test IDs (e.g. “scala”) to their corresponding group names (e.g. [“compiled”, “jvm”, “slow”])
39 40 41 42 43 44 45 46 47 |
# File 'lib/startup_time/registry.rb', line 39 def self.ids_to_groups(format: :ascii) if format == :json TESTS.entries.each_with_object({}) do |(id, test), target| target[id] = test[:groups].sort end else # ASCII TESTS.entries.map { |id, test| [id, test[:groups].sort.join(', ')] } end end |
Instance Method Details
#omit(id) ⇒ Object
add the specified test(s) to the set of disabled tests
55 56 57 |
# File 'lib/startup_time/registry.rb', line 55 def omit(id) @omit.merge(ids_for(id)) end |
#only(id) ⇒ Object
add the specified test(s) to the set of enabled tests
60 61 62 |
# File 'lib/startup_time/registry.rb', line 60 def only(id) @only.merge(ids_for(id)) end |