Sha256: d4293bc5d1f57f5db16de18a0fc927fc07795255ab119622f7485d13f4f138e4

Contents?: true

Size: 1.22 KB

Versions: 25

Compression:

Stored size: 1.22 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 = {})
        options[:region] ||= region
        options[:cloud] = name
        options[:attributes] = attributes

        @stacks[stack_name] = Control::Stack.new(stack_name, template, options)
        @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

25 entries across 25 versions & 1 rubygems

Version Path
convection-0.2.25 lib/convection/model/cloudfile.rb
convection-0.2.24 lib/convection/model/cloudfile.rb
convection-0.2.23 lib/convection/model/cloudfile.rb
convection-0.2.22 lib/convection/model/cloudfile.rb
convection-0.2.21 lib/convection/model/cloudfile.rb
convection-0.2.20 lib/convection/model/cloudfile.rb
convection-0.2.19 lib/convection/model/cloudfile.rb
convection-0.2.18 lib/convection/model/cloudfile.rb
convection-0.2.17 lib/convection/model/cloudfile.rb
convection-0.2.16 lib/convection/model/cloudfile.rb
convection-0.2.15 lib/convection/model/cloudfile.rb
convection-0.2.14 lib/convection/model/cloudfile.rb
convection-0.2.13 lib/convection/model/cloudfile.rb
convection-0.2.12 lib/convection/model/cloudfile.rb
convection-0.2.11 lib/convection/model/cloudfile.rb
convection-0.2.10 lib/convection/model/cloudfile.rb
convection-0.2.9 lib/convection/model/cloudfile.rb
convection-0.2.8 lib/convection/model/cloudfile.rb
convection-0.2.7 lib/convection/model/cloudfile.rb
convection-0.2.6 lib/convection/model/cloudfile.rb