Class: CemAcpt::Platform::Base

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/cem_acpt/platform/base.rb

Overview

Base class for all platform classes. This class provides an API for interacting with the underlying platform.

Constant Summary

Constants included from Logging

Logging::LEVEL_MAP

Instance Attribute Summary collapse

Instance Method Summary collapse

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

Constructor Details

#initialize(config, single_test_data) ⇒ Base

Returns a new instance of Base.

Parameters:

  • conf (CemAcpt::Config)

    the config object.

  • single_test_data (Hash)

    the test data for the current test.

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
# File 'lib/cem_acpt/platform/base.rb', line 18

def initialize(config, single_test_data)
  raise ArgumentError, 'single_test_data must be a Hash' unless single_test_data.is_a?(Hash)

  @config = config
  @test_data = single_test_data
  @node_name = @test_data[:node_name] || random_node_name
end

Instance Attribute Details

#node_nameObject (readonly)

Returns the value of attribute node_name.



14
15
16
# File 'lib/cem_acpt/platform/base.rb', line 14

def node_name
  @node_name
end

#test_dataObject (readonly)

Returns the value of attribute test_data.



14
15
16
# File 'lib/cem_acpt/platform/base.rb', line 14

def test_data
  @test_data
end

Instance Method Details

#image_nameObject

Generates or retrieves an image name from the test data.



51
52
53
# File 'lib/cem_acpt/platform/base.rb', line 51

def image_name
  @image_name ||= (@config.has?('image_name_builder') ? image_name_builder(@config, test_data) : test_data[:image_name])
end

#node_dataObject

Data specific to the current node.

Raises:

  • (NotImplementedError)


46
47
48
# File 'lib/cem_acpt/platform/base.rb', line 46

def node_data
  raise NotImplementedError, 'node_data must be implemented by the specific platform module'
end

#platform_dataObject

Data common to all nodes of the same platform.

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/cem_acpt/platform/base.rb', line 41

def platform_data
  raise NotImplementedError, 'common_data must be implemented by the specific platform module'
end

#to_hObject



26
27
28
29
30
31
32
33
34
# File 'lib/cem_acpt/platform/base.rb', line 26

def to_h
  {
    node_name: node_name,
    image_name: image_name,
    test_data: test_data,
    platform_data: platform_data,
    node_data: node_data,
  }
end

#to_json(*args) ⇒ Object



36
37
38
# File 'lib/cem_acpt/platform/base.rb', line 36

def to_json(*args)
  to_h.to_json(*args)
end