Class: Crystalball::MapGenerator::ObjectSourcesDetector
- Inherits:
-
Object
- Object
- Crystalball::MapGenerator::ObjectSourcesDetector
- Includes:
- Helpers::PathFilter
- Defined in:
- lib/crystalball/map_generator/object_sources_detector.rb,
lib/crystalball/map_generator/object_sources_detector/definition_tracer.rb,
lib/crystalball/map_generator/object_sources_detector/hierarchy_fetcher.rb
Overview
Class for files paths affected object definition
Defined Under Namespace
Classes: DefinitionTracer, HierarchyFetcher
Instance Attribute Summary collapse
-
#definition_tracer ⇒ Object
readonly
Returns the value of attribute definition_tracer.
-
#hierarchy_fetcher ⇒ Object
readonly
Returns the value of attribute hierarchy_fetcher.
Attributes included from Helpers::PathFilter
Instance Method Summary collapse
- #after_register ⇒ Object
- #before_finalize ⇒ Object
-
#detect(objects) ⇒ Array<String>
Detects files affected during example execution.
-
#initialize(root_path:, definition_tracer: DefinitionTracer.new(root_path), hierarchy_fetcher: HierarchyFetcher.new) ⇒ ObjectSourcesDetector
constructor
A new instance of ObjectSourcesDetector.
Methods included from Helpers::PathFilter
Constructor Details
#initialize(root_path:, definition_tracer: DefinitionTracer.new(root_path), hierarchy_fetcher: HierarchyFetcher.new) ⇒ ObjectSourcesDetector
Returns a new instance of ObjectSourcesDetector.
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/crystalball/map_generator/object_sources_detector.rb', line 15 def initialize( root_path:, definition_tracer: DefinitionTracer.new(root_path), hierarchy_fetcher: HierarchyFetcher.new ) super(root_path) @definition_tracer = definition_tracer @hierarchy_fetcher = hierarchy_fetcher end |
Instance Attribute Details
#definition_tracer ⇒ Object (readonly)
Returns the value of attribute definition_tracer.
13 14 15 |
# File 'lib/crystalball/map_generator/object_sources_detector.rb', line 13 def definition_tracer @definition_tracer end |
#hierarchy_fetcher ⇒ Object (readonly)
Returns the value of attribute hierarchy_fetcher.
13 14 15 |
# File 'lib/crystalball/map_generator/object_sources_detector.rb', line 13 def hierarchy_fetcher @hierarchy_fetcher end |
Instance Method Details
#after_register ⇒ Object
26 27 28 |
# File 'lib/crystalball/map_generator/object_sources_detector.rb', line 26 def after_register definition_tracer.start end |
#before_finalize ⇒ Object
30 31 32 |
# File 'lib/crystalball/map_generator/object_sources_detector.rb', line 30 def before_finalize definition_tracer.stop end |
#detect(objects) ⇒ Array<String>
Detects files affected during example execution. Transforms absolute paths to relative. Exclude paths outside of repository
@param list of files affected before example execution
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/crystalball/map_generator/object_sources_detector.rb', line 39 def detect(objects) modules = objects.map do |object| object.is_a?(Module) ? object : object.class end.uniq paths = modules.flat_map do |mod| hierarchy_fetcher.ancestors_for(mod).flat_map do |ancestor| definition_tracer.constants_definition_paths[ancestor] end end.compact.uniq filter paths end |