Class: Beaker::DSL::Structure::PlatformTagConfiner

Inherits:
Object
  • Object
show all
Defined in:
lib/beaker/dsl/structure.rb

Instance Method Summary collapse

Constructor Details

#initialize(platform_tag_confines_array) ⇒ PlatformTagConfiner

Note:

PlatformTagConfines objects come in the form [

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

]

Constructs the PlatformTagConfiner, transforming the user format

into the internal structure for use by Beaker itself.

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,
    }, ... ]
  }

Parameters:

  • platform_tag_confines_array (Array<Hash{Symbol=>Object}>)

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



379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
# File 'lib/beaker/dsl/structure.rb', line 379

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

Instance Method Details

#confine_details(tags) ⇒ Array<Hash{Symbol=>Object}>

Gets the confine details needed for a set of tags

Parameters:

  • tags (Array<String>)

    Tags of the given test

Returns:

  • (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



405
406
407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/beaker/dsl/structure.rb', line 405

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