Module: Inferno::DSL::ShortIDManager
- Included in:
- Entities::TestSuite
- Defined in:
- lib/inferno/dsl/short_id_manager.rb
Overview
This module manages and locks short IDs, ensuring that short IDs remain stable and do not change unexpectedly.
Instance Method Summary collapse
-
#base_short_id_file_folder ⇒ Object
-
#current_short_id_map ⇒ Hash
Builds and memoizes the current mapping of runnable IDs to their short IDs.
-
#short_id_file_name ⇒ Object
-
#short_id_file_path ⇒ Object
-
#short_id_map ⇒ Hash
Loads and memoizes the short ID map from the YAML file.
Instance Method Details
#base_short_id_file_folder ⇒ Object
6 7 8 |
# File 'lib/inferno/dsl/short_id_manager.rb', line 6 def base_short_id_file_folder File.join(Dir.pwd, 'lib', name.split('::').first.underscore) end |
#current_short_id_map ⇒ Hash
Builds and memoizes the current mapping of runnable IDs to their short IDs.
47 48 49 50 51 52 |
# File 'lib/inferno/dsl/short_id_manager.rb', line 47 def current_short_id_map @current_short_id_map ||= all_descendants.each_with_object({}) do |runnable, mapping| mapping[runnable.id] = runnable.short_id end end |
#short_id_file_name ⇒ Object
10 11 12 |
# File 'lib/inferno/dsl/short_id_manager.rb', line 10 def short_id_file_name "#{name.demodulize.underscore}_short_id_map.yml" end |
#short_id_file_path ⇒ Object
14 15 16 |
# File 'lib/inferno/dsl/short_id_manager.rb', line 14 def short_id_file_path File.join(base_short_id_file_folder, short_id_file_name).freeze end |
#short_id_map ⇒ Hash
Loads and memoizes the short ID map from the YAML file.
21 22 23 24 25 |
# File 'lib/inferno/dsl/short_id_manager.rb', line 21 def short_id_map return unless File.exist?(short_id_file_path) @short_id_map ||= YAML.load_file(short_id_file_path) end |