Module: CemAcpt::Platform
- Extended by:
- Logging
- Defined in:
- lib/cem_acpt/platform.rb,
lib/cem_acpt/platform/gcp.rb,
lib/cem_acpt/platform/base.rb
Overview
CemAcpt::Platform manages creating and configring platform specific objects for the acceptance test suites.
Defined Under Namespace
Modules: Mixin Classes: Base, Error, TestBase
Constant Summary collapse
- PLATFORM_DIR =
File.(File.join(__dir__, 'platform'))
- BASE_TYPES =
%i[base test].freeze
Constants included from Logging
Class Method Summary collapse
-
.get(platform, base_type: :test) ⇒ Object
Returns an un-initialized platform specific Class of the given platform.
-
.platforms ⇒ Object
Returns an array of the names of the supported platforms.
-
.use(platform, config, run_data) ⇒ Array<CemAcpt::Platform::Base>
Creates a new platform specific object of the given platform for each item in the test data.
Methods included from Logging
current_log_config, current_log_config, current_log_format, current_log_format, current_log_level, current_log_level, included, logger, logger, new_log_config, new_log_config, new_log_formatter, new_log_formatter, new_log_level, new_log_level, new_logger, new_logger, verbose?, verbose?
Class Method Details
.get(platform, base_type: :test) ⇒ Object
Returns an un-initialized platform specific Class of the given platform.
44 45 46 47 48 49 |
# File 'lib/cem_acpt/platform.rb', line 44 def get(platform, base_type: :test) raise Error, "Platform #{platform} is not supported" unless platforms.include?(platform) raise Error, "Base type #{base_type} is not supported" unless BASE_TYPES.include?(base_type.to_sym) platform_class(base_type, platform) end |
.platforms ⇒ Object
Returns an array of the names of the supported platforms. Supported platforms are discovered by looking for files in the platform directory, and platform names are the basename (no extension) of the files. We deliberately exclude the base class, as it is not a platform.
56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cem_acpt/platform.rb', line 56 def platforms return @platforms if defined?(@platforms) @platforms = Dir.glob(File.join(PLATFORM_DIR, '*.rb')).map do |file| File.basename(file, '.rb') unless file.end_with?('base.rb') end @platforms.compact! logger.debug('CemAcpt::Platform') { "Discovered platform(s): #{@platforms}" } @platforms end |
.use(platform, config, run_data) ⇒ Array<CemAcpt::Platform::Base>
Creates a new platform specific object of the given platform for each item in the test data.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/cem_acpt/platform.rb', line 29 def use(platform, config, run_data) raise Error, "Platform #{platform} is not supported" unless platforms.include?(platform) raise Error, 'run_data must be an Hash' unless run_data.is_a?(Hash) raise Error, 'run_data must include a :test_data key' unless run_data.key?(:test_data) raise Error, 'run_data[:test_data] must be an Array' unless run_data[:test_data].is_a?(Array) logger.info('CemAcpt::Platform') { "Using #{platform} for #{run_data[:test_data].length} tests..." } run_data[:test_data].dup.each_with_object([]) do |single_test_data, ary| ary << new_test_platform_object(platform, config, single_test_data, **run_data.reject { |k, _| k == :test_data }) end end |