Module: ONCCertificationG10TestKit::ShortIDManager
- Defined in:
- lib/onc_certification_g10_test_kit/short_id_manager.rb
Overview
This module ensures that short test ids don’t change
Class Method Summary collapse
- .all_children(runnable) ⇒ Object
- .assign_short_ids ⇒ Object
- .current_short_id_map ⇒ Object
-
.save_current_short_id_map ⇒ Object
Run this in an inferno console to save the current short ids.
- .short_id_file_path ⇒ Object
- .short_id_map ⇒ Object
Class Method Details
.all_children(runnable) ⇒ Object
6 7 8 9 10 |
# File 'lib/onc_certification_g10_test_kit/short_id_manager.rb', line 6 def all_children(runnable) runnable .children .flat_map { |child| [child] + all_children(child) } end |
.assign_short_ids ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/onc_certification_g10_test_kit/short_id_manager.rb', line 20 def assign_short_ids all_children(G10CertificationSuite).each do |runnable| short_id = short_id_map.fetch(runnable.id) runnable.define_singleton_method(:short_id) do short_id end rescue KeyError Inferno::Application['logger'].warn("No short id defined for #{runnable.id}") end rescue Errno::ENOENT Inferno::Application['logger'].warn('No short id map found') end |
.current_short_id_map ⇒ Object
40 41 42 43 44 45 |
# File 'lib/onc_certification_g10_test_kit/short_id_manager.rb', line 40 def current_short_id_map @current_short_id_map ||= all_children(G10CertificationSuite).each_with_object({}) do |runnable, mapping| mapping[runnable.id] = runnable.short_id end end |
.save_current_short_id_map ⇒ Object
Run this in an inferno console to save the current short ids
36 37 38 |
# File 'lib/onc_certification_g10_test_kit/short_id_manager.rb', line 36 def save_current_short_id_map File.write(short_id_file_path, current_short_id_map.to_yaml) end |
.short_id_file_path ⇒ Object
12 13 14 |
# File 'lib/onc_certification_g10_test_kit/short_id_manager.rb', line 12 def short_id_file_path File.join(__dir__, 'short_id_map.yml') end |
.short_id_map ⇒ Object
16 17 18 |
# File 'lib/onc_certification_g10_test_kit/short_id_manager.rb', line 16 def short_id_map @short_id_map ||= YAML.load_file(short_id_file_path) end |