Sha256: e704959ddcb1700545b1a5dbd75dfbf436b7438427843d24c32505de6463e4e6

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

module Lopata
  module Config
    extend self

    attr_accessor :build_number, :lopata_host, :only_roles, :role_descriptions, :after_as, :ops

    def init(env)
      require 'yaml'
      @config = YAML::load(File.open("./config/environments/#{env}.yml")) || {}
      init_db
      @role_descriptions ||= {}
      # init_includes
    end

    %w{url name readonly}.each do |opt|
      define_method opt do
        raise "RstConfig unititlalized, use RstConfig#init(env) to set environment" unless @config
        @config[opt]
      end
    end

    def init_db
      ActiveRecord::Base.establish_connection(@config['db']) if @config['db']
    end

    def init_rspec
      require 'lopata/rspec/dsl'
      require 'lopata/rspec/role'
      ::RSpec.configure do |c|
        c.include Lopata::RSpec::DSL
        c.include Lopata::RSpec::Role
      end
    end

    def before_start(&block)
      @before_start = block
    end

    def initialize_test
      @before_start.call if @before_start
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lopata-0.0.5 lib/lopata/config.rb
lopata-0.0.4 lib/lopata/config.rb
lopata-0.0.3 lib/lopata/config.rb
lopata-0.0.2 lib/lopata/config.rb