Class: Crystalball::Rails::TablesMapGenerator
- Inherits:
-
Object
- Object
- Crystalball::Rails::TablesMapGenerator
- Extended by:
- Forwardable
- Defined in:
- lib/crystalball/rails/tables_map_generator.rb,
lib/crystalball/rails/tables_map_generator/configuration.rb
Overview
Class to generate tables to files map during RSpec build execution
Defined Under Namespace
Classes: Configuration
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
- #map ⇒ Crystalball::Rails::TablesMap readonly
Class Method Summary collapse
-
.start!(&block) ⇒ Object
Registers Crystalball handlers to generate execution map during specs execution.
Instance Method Summary collapse
-
#finalize! ⇒ Object
Finalizes and saves map.
-
#initialize {|@configuration| ... } ⇒ TablesMapGenerator
constructor
A new instance of TablesMapGenerator.
-
#start! ⇒ Object
Prepares metadata for execution map.
Constructor Details
#initialize {|@configuration| ... } ⇒ TablesMapGenerator
Returns a new instance of TablesMapGenerator.
29 30 31 32 33 34 |
# File 'lib/crystalball/rails/tables_map_generator.rb', line 29 def initialize @configuration = Configuration.new @configuration.commit = repo.object('HEAD').sha if repo yield @configuration if block_given? object_sources_detector.after_register end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
12 13 14 |
# File 'lib/crystalball/rails/tables_map_generator.rb', line 12 def configuration @configuration end |
#map ⇒ Crystalball::Rails::TablesMap
57 58 59 |
# File 'lib/crystalball/rails/tables_map_generator.rb', line 57 def map @map ||= TablesMap.new(metadata: {commit: configuration.commit, version: configuration.version}) end |
Class Method Details
.start!(&block) ⇒ Object
Registers Crystalball handlers to generate execution map during specs execution
19 20 21 22 23 24 25 26 |
# File 'lib/crystalball/rails/tables_map_generator.rb', line 19 def start!(&block) generator = new(&block) ::RSpec.configure do |c| c.before(:suite) { generator.start! } c.after(:suite) { generator.finalize! } end end |
Instance Method Details
#finalize! ⇒ Object
Finalizes and saves map
47 48 49 50 51 52 53 54 |
# File 'lib/crystalball/rails/tables_map_generator.rb', line 47 def finalize! return unless started collect_tables_info object_sources_detector.before_finalize map_storage.dump(map.example_groups) if map.size.positive? end |
#start! ⇒ Object
Prepares metadata for execution map
37 38 39 40 41 42 43 44 |
# File 'lib/crystalball/rails/tables_map_generator.rb', line 37 def start! self.map = nil map_storage.clear! map_storage.dump(map..to_h) self.started = true end |