Class: Henitai::Integration::LoadedFeatures
- Inherits:
-
Object
- Object
- Henitai::Integration::LoadedFeatures
- Defined in:
- lib/henitai/integration/loaded_features.rb,
sig/henitai.rbs
Overview
Answers whether a test file has already been required, by matching it
against $LOADED_FEATURES.
Both sides need normalizing: $LOADED_FEATURES holds absolute paths for
required files but callers hand over repository-relative test paths, and
either side may or may not carry the .rb suffix. A feature string that
cannot be expanded (invalid encoding, for instance) falls back to its raw
form rather than aborting the whole check — this runs inside a mutant
child whose only job is diagnostics.
Instance Method Summary collapse
- #candidates_for(file) ⇒ Array[String]
- #include?(file) ⇒ Boolean
- #map(files) ⇒ Array[[String, bool]]
- #normalize(feature) ⇒ String
Instance Method Details
#candidates_for(file) ⇒ Array[String]
26 27 28 29 |
# File 'lib/henitai/integration/loaded_features.rb', line 26 def candidates_for(file) = File.(file) [, "#{}.rb", file, "#{file}.rb"].uniq end |
#include?(file) ⇒ Boolean
15 16 17 18 19 20 |
# File 'lib/henitai/integration/loaded_features.rb', line 15 def include?(file) candidates = candidates_for(file) $LOADED_FEATURES.any? do |feature| candidates.include?(feature) || candidates.include?(normalize(feature)) end end |
#map(files) ⇒ Array[[String, bool]]
22 |
# File 'lib/henitai/integration/loaded_features.rb', line 22 def map(files) = files.map { |file| [file, include?(file)] } |
#normalize(feature) ⇒ String
31 32 33 34 35 |
# File 'lib/henitai/integration/loaded_features.rb', line 31 def normalize(feature) File.(feature) rescue StandardError feature end |