Module: CemAcpt::Platform
- Extended by:
- Logging
- Defined in:
- lib/cem_acpt/platform.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
Constant Summary collapse
- PLATFORM_DIR =
File.(File.join(__dir__, 'platform'))
Constants included from Logging
Class Method Summary collapse
-
.get(platform) ⇒ 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, test_data) ⇒ Object
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
Class Method Details
.get(platform) ⇒ Object
Returns an un-initialized platform specific Class of the given platform.
35 36 37 38 39 |
# File 'lib/cem_acpt/platform.rb', line 35 def get(platform) raise Error, "Platform #{platform} is not supported" unless platforms.include?(platform) platform_class(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.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cem_acpt/platform.rb', line 46 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 "Discovered platform(s): #{@platforms}" @platforms end |
.use(platform, config, test_data) ⇒ Object
Creates a new platform specific object of the given platform for each item in the test data.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cem_acpt/platform.rb', line 21 def use(platform, config, test_data) raise Error, "Platform #{platform} is not supported" unless platforms.include?(platform) raise Error, 'test_data must be an Array' unless test_data.is_a?(Array) logger.info "Using #{platform} for #{test_data.length} tests..." test_data.each_with_object([]) do |single_test_data, ary| #local_port = local_port_allocator.allocate #logger.debug("Allocated local port #{local_port} for test #{single_test_data[:test_name]}") ary << new_platform_object(platform, config, single_test_data) end end |