Sha256: 2dd018eb7bfeba430fd481ad4ad7523ee16ac6ebcaeefc9153dccd923e32eeca

Contents?: true

Size: 931 Bytes

Versions: 3

Compression:

Stored size: 931 Bytes

Contents

require 'praegustator'
module Praegustator
  class Dsl
    def initialize
      @suits = []
    end

    def environment(name, &block)
      @environment = name
    end

    def role(name, &block)
      search("role:#{name}",&block)
    end

    def recipe(name, &block)
      name = name.gsub(":","\\:")
      search("run_list:recipe\\[#{name}\\]",&block)
    end

    def ip(address, &block)
      search("ipaddress:#{address}",&block)
    end

    def search(query, &block)
      query = "#{query} AND chef_environment:#{@environment}" if @environment
      suite = TestSuite.new(query)
      suite.instance_eval(&block)
      @suits << suite
      suite.nodes
    end

    def parse_file(filename)
      if File.exists?(filename) && File.readable?(filename)
        self.instance_eval(IO.read(filename), filename, 1)
      else
        raise IOError, "Cannot open or read #{filename}!"
      end
      @suits
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
praegustator-0.3.0 lib/praegustator/dsl.rb
praegustator-0.2.0 lib/praegustator/dsl.rb
praegustator-0.1.0 lib/praegustator/dsl.rb