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

Instance Method Details

#base_short_id_file_folderObject



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_mapHash

Builds and memoizes the current mapping of runnable IDs to their short IDs.

Returns:

  • (Hash)

    current short ID mapping



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_nameObject



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_pathObject



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_mapHash

Loads and memoizes the short ID map from the YAML file.

Returns:

  • (Hash)

    mapping of runnable IDs to their locked short IDs



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