Sha256: 0c16580bdafe94fcdde5f611524d849d1fa776839d72f3b58c2224f43910b5a8

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'blazing/target'
require 'blazing/recipe'
require 'blazing/dsl_setter'

class Blazing::Config

  extend Blazing::DSLSetter

  attr_reader :file
  attr_accessor :targets, :recipes
  dsl_setter :repository, :rvm, :rake

  class << self

    def parse(configuration_file = nil)
      config = self.new(configuration_file)
      config.instance_eval(File.read(config.file))

      config
    end

  end

  def initialize(configuration_file = nil)
    @file = configuration_file || Blazing::DEFAULT_CONFIG_LOCATION
    @targets = []
    @recipes = []
  end

  def target(name, location, options = {})
    raise "Name already taken" if targets.find { |t| t.name == name }
    targets << Blazing::Target.new(name, location, self, options)
  end

  def recipe(name, options = {})
    @recipes << Blazing::Recipe.init_by_name(name, options)
  end

  def default_target
    if @targets.size > 1
      default = @targets.find { |t| t.options[:default] == true }
      raise 'could not find default target' unless default
      default
    else
      @targets.first
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blazing-0.1.0.alpha4 lib/blazing/config.rb