Sha256: 30150e42d4628b9865c510ca40f159d5fdb5d8b12278b82179dad500e87c53de

Contents?: true

Size: 1.51 KB

Versions: 49

Compression:

Stored size: 1.51 KB

Contents

module Beaker
  module DSL
    # These are simple patterns that appear frequently in beaker test
    # code, and are provided to simplify test construction.
    #
    #
    # It requires the class it is mixed into to provide the attribute
    # `hosts` which contain the hosts to search, these should implement
    # {Beaker::Host}'s interface. They, at least, must have #[]
    # and #to_s available and provide an array when #[]('roles') is called.
    #
    module Patterns

      #Execute a block selecting the hosts that match with the provided criteria
      #@param [Array<Host>, Host, String, Symbol] hosts_or_filter A host role as a String or Symbol that can be
      #                                                used to search for a set of Hosts,  a host name
      #                                                as a String that can be used to search for
      #                                                a set of Hosts, or a {Host}
      #                                                or Array<{Host}> to run the block against
      #@param [Block] block This method will yield to a block of code passed by the caller
      def block_on hosts_or_filter, &block
        block_hosts = nil
        if defined? hosts
          block_hosts = hosts
        end
        filter = nil
        if hosts_or_filter.is_a? String or hosts_or_filter.is_a? Symbol
          filter = hosts_or_filter
        else
          block_hosts = hosts_or_filter
        end
        run_block_on block_hosts, filter, &block
      end

    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
beaker-2.12.0 lib/beaker/dsl/patterns.rb
beaker-2.11.0 lib/beaker/dsl/patterns.rb
beaker-2.10.0 lib/beaker/dsl/patterns.rb
beaker-2.9.0 lib/beaker/dsl/patterns.rb
beaker-2.8.0 lib/beaker/dsl/patterns.rb
beaker-2.7.1 lib/beaker/dsl/patterns.rb
beaker-2.7.0 lib/beaker/dsl/patterns.rb
beaker-2.6.0 lib/beaker/dsl/patterns.rb
beaker-2.5.1 lib/beaker/dsl/patterns.rb
beaker-2.5.0 lib/beaker/dsl/patterns.rb
beaker-2.4.1 lib/beaker/dsl/patterns.rb
beaker-2.4.0 lib/beaker/dsl/patterns.rb
beaker-2.3.0 lib/beaker/dsl/patterns.rb
beaker-2.2.0 lib/beaker/dsl/patterns.rb
beaker-2.1.0 lib/beaker/dsl/patterns.rb
beaker-2.0.0 lib/beaker/dsl/patterns.rb
beaker-1.20.1 lib/beaker/dsl/patterns.rb
beaker-1.20.0 lib/beaker/dsl/patterns.rb
beaker-1.19.1 lib/beaker/dsl/patterns.rb
beaker-1.19.0 lib/beaker/dsl/patterns.rb