class Beaker::DSL::TestTagging::PlatformTagConfiner

Public Class Methods

new(platform_tag_confines_array) click to toggle source

Constructs the PlatformTagConfiner, transforming the user format

into the internal structure for use by Beaker itself.

@param [Array<Hash{Symbol=>Object}>] platform_tag_confines_array

The array of PlatformTagConfines objects that specify how these
confines should behave. See the note below for more info

@note PlatformTagConfines objects come in the form

  [
    {
      :platform => <platform-regex>,
      :tag_reason_hash => {
        <tag> => <reason to confine>,
        <tag> => <reason to confine>,
        ...etc...
      }
    }
  ]

Internally, we want to turn tag matches into platform
  confine statements. So a better internal structure would
  be something of the form:
  {
    <tag> => [{
      :platform => <platform-regex>,
      :reason => <reason to confine>,
      :type => :except,
    }, ... ]
  }
# File lib/beaker/dsl/test_tagging.rb, line 111
def initialize(platform_tag_confines_array)
  platform_tag_confines_array ||= []
  @tag_confine_details_hash = {}
  platform_tag_confines_array.each do |entry|
    entry[:tag_reason_hash].keys.each do |tag|
      @tag_confine_details_hash[tag] ||= []
      log_msg = "Tag '#{tag}' found, confining: except platforms "
      log_msg << "matching regex '#{entry[:platform]}'. Reason: "
      log_msg << "'#{entry[:tag_reason_hash][tag]}'"
      @tag_confine_details_hash[tag] << {
        :platform_regex => entry[:platform],
        :log_message => log_msg,
        :type => :except,
      }
    end
  end
end

Public Instance Methods

confine_details(tags) click to toggle source

Gets the confine details needed for a set of tags

@param [Array<String>] tags Tags of the given test

@return [Array<Hash{Symbol=>Object}>] an array of

Confine details hashes, which are hashes of symbols
to their properties, which are objects of various
kinds, depending on the key
# File lib/beaker/dsl/test_tagging.rb, line 137
def confine_details(tags)
  tags ||= []
  details = []
  tags.each do |tag|
    tag_confine_array = @tag_confine_details_hash[tag]
    next if tag_confine_array.nil?

    details.push(*tag_confine_array)
    # tag_confine_array.each do |confine_details|
    #   details << confine_details
    # end
  end
  details
end