Sha256: 8c363b6fc0b4f58f72b00cf5ac100b354b36b3e209206931e98a2fc0ed57e20d

Contents?: true

Size: 1.24 KB

Versions: 8

Compression:

Stored size: 1.24 KB

Contents

require_relative '../control/stack'
require_relative '../dsl/helpers'
require_relative '../model/attributes'
require_relative '../model/template'

module Convection
  module DSL
    ##
    # DSL for Cloudfile
    ##
    module Cloudfile
      include DSL::Helpers

      attribute :name
      attribute :region
      attribute :splay

      ## Helper to define a template in-line
      def template(*args, &block)
        Model::Template.new(*args, &block)
      end

      def attribute(stack, key, value)
        @attributes.set(stack, key, value)
      end

      def stack(stack_name, template, options = {}, &block)
        options[:region] ||= region
        options[:cloud] = name
        options[:attributes] = attributes

        @stacks[stack_name] = Control::Stack.new(stack_name, template, options, &block)
        @deck << @stacks[stack_name]
      end
    end
  end

  module Model
    ##
    # Define your Clouds
    ##
    class Cloudfile
      include DSL::Cloudfile

      attr_reader :attributes
      attr_reader :stacks
      attr_reader :deck

      def initialize(cloudfile)
        @attributes = Model::Attributes.new
        @stacks = {}
        @deck = []

        instance_eval(IO.read(cloudfile), cloudfile, 1)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
convection-0.2.33 lib/convection/model/cloudfile.rb
convection-0.2.32 lib/convection/model/cloudfile.rb
convection-0.2.31 lib/convection/model/cloudfile.rb
convection-0.2.30 lib/convection/model/cloudfile.rb
convection-0.2.29 lib/convection/model/cloudfile.rb
convection-0.2.28 lib/convection/model/cloudfile.rb
convection-0.2.27 lib/convection/model/cloudfile.rb
convection-0.2.26 lib/convection/model/cloudfile.rb