Sha256: 3bfa64bfd2dab58d5ef66c61b446e8a10566d509fcf2593ffcdf94d67d8bf2b4

Contents?: true

Size: 1.96 KB

Versions: 38

Compression:

Stored size: 1.96 KB

Contents

module PoolParty
  module ResourcingDsl
    # Overrides for syntax
    # Allows us to send require to require a resource
    def require(str="")
      str ? options.merge!(:require => str) : options[:require]
    end
    def requires(str=nil)
      # str ? options.append!(:require => str) : options[:require]
      str ? options.append!(:require => send_if_method(str)) : options[:require]
    end 
    def ensures(str="running")
      if %w(absent running).map {|a| self.send a.to_sym}.include?(str)
        str == "absent" ? is_absent : is_present
      else
        options.append!(:ensure => str)
      end
      str
    end
    # Allows us to send an ensure to ensure the presence of a resource
    def is_present(*args)
      options.merge!(:ensure => present)
    end
    # Ensures that what we are sending is absent
    def is_absent(*args)
      options.merge!(:ensure => absent)
    end
    # Alias for unless
    def ifnot(str="")
      options.merge!(:unless => str)
    end
    def present
      "present"
    end
    def absent
      "absent"
    end
    def cancel(*args)
      options[:cancelled] = args.empty? ? true : args[0]
    end
    def cancelled?
      options[:cancelled] || false
    end
    # Give us a template to work with on the resource
    # Make sure this template is moved to the tmp directory as well
    # 
    # TODO: Change this method to store the template files for later
    # copying to prevent unnecessary copying and tons of directories
    # everywhere
    def template(file, opts={})
      raise TemplateNotFound.new("no template given") unless file
      raise TemplateNotFound.new("template cannot be found #{file}") unless ::File.file?(file)
      unless opts[:just_copy]          
        options.merge!({:content => "template(\"#{::File.basename(file)}\")"})
        options.delete(:source) if options.has_key?(:source)
        copy_template_to_storage_directory(file)
      else
        copy_file_to_storage_directory(file)
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
auser-poolparty-0.2.20 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.21 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.22 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.23 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.24 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.25 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.26 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.35 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.36 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.37 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.38 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.39 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.40 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.41 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.42 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.44 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.45 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.46 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.47 lib/poolparty/modules/resourcing_dsl.rb
auser-poolparty-0.2.48 lib/poolparty/modules/resourcing_dsl.rb