Class: Crystalball::MapGenerator::AllocatedObjectsStrategy
- Inherits:
-
Object
- Object
- Crystalball::MapGenerator::AllocatedObjectsStrategy
- Extended by:
- Forwardable
- Includes:
- BaseStrategy
- Defined in:
- lib/crystalball/map_generator/allocated_objects_strategy.rb,
lib/crystalball/map_generator/allocated_objects_strategy/object_tracker.rb
Overview
Map generator strategy to get paths to files contains definition for all objects and its ancestors allocated during test example.
Defined Under Namespace
Classes: ObjectTracker
Instance Attribute Summary collapse
-
#execution_detector ⇒ Object
readonly
Returns the value of attribute execution_detector.
-
#object_tracker ⇒ Object
readonly
Returns the value of attribute object_tracker.
Class Method Summary collapse
Instance Method Summary collapse
-
#call(example_map, example) ⇒ Object
Adds to the used files every file which contain the definition of the classes of the objects allocated during the spec execution.
-
#initialize(execution_detector:, object_tracker:) ⇒ AllocatedObjectsStrategy
constructor
A new instance of AllocatedObjectsStrategy.
Methods included from BaseStrategy
#after_register, #after_start, #before_finalize
Constructor Details
#initialize(execution_detector:, object_tracker:) ⇒ AllocatedObjectsStrategy
Returns a new instance of AllocatedObjectsStrategy.
28 29 30 31 |
# File 'lib/crystalball/map_generator/allocated_objects_strategy.rb', line 28 def initialize(execution_detector:, object_tracker:) @object_tracker = object_tracker @execution_detector = execution_detector end |
Instance Attribute Details
#execution_detector ⇒ Object (readonly)
Returns the value of attribute execution_detector.
15 16 17 |
# File 'lib/crystalball/map_generator/allocated_objects_strategy.rb', line 15 def execution_detector @execution_detector end |
#object_tracker ⇒ Object (readonly)
Returns the value of attribute object_tracker.
15 16 17 |
# File 'lib/crystalball/map_generator/allocated_objects_strategy.rb', line 15 def object_tracker @object_tracker end |
Class Method Details
.build(only: [], root: Dir.pwd) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/crystalball/map_generator/allocated_objects_strategy.rb', line 19 def self.build(only: [], root: Dir.pwd) hierarchy_fetcher = ObjectSourcesDetector::HierarchyFetcher.new(only) execution_detector = ObjectSourcesDetector.new(root_path: root, hierarchy_fetcher: hierarchy_fetcher) new(execution_detector: execution_detector, object_tracker: ObjectTracker.new(only_of: only)) end |
Instance Method Details
#call(example_map, example) ⇒ Object
Adds to the used files every file which contain the definition of the classes of the objects allocated during the spec execution.
37 38 39 40 41 42 |
# File 'lib/crystalball/map_generator/allocated_objects_strategy.rb', line 37 def call(example_map, example) classes = object_tracker.used_classes_during do yield example_map, example end example_map.push(*execution_detector.detect(classes)) end |