Sha256: 0beb70f28b2c59b2e19c61a938661d0adc0c8da6849c1058f5d258e4dbd5d606

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

module Lopata
  # Settings of test enviromnet the scenarios to be runned.
  #
  # Lopata allows to define different environments the scenarios to be runned on.
  # Set environment name via command line 'lopata -e stage' or via configuration:
  #
  #     Lopata.configure do |c|
  #       c.env = :stage
  #     end
  #
  # The environment params are loaded from './config/environments/<env>.yml'.
  class Environment
    # Loads environment configuration for given env
    # @param env [Symbol] environment key
    #    Loads golobl configured environment if not given.
    # @see Lopata::Configuration#env
    def initialize(env = Lopata.configuration.env)
      require 'yaml'
      @config = {}
      config_filename = "./config/environments/#{Lopata.configuration.env}.yml"
      @config = YAML::load(File.open(config_filename)) if File.exist?(config_filename)
    end

    # Access to environment settings
    # @param key [Symbol] environment configuration key is set on yml configuration.
    def [](key)
      @config[key]
    end

    %w{url}.each do |opt|
      define_method opt do
        @config[opt]
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lopata-0.1.32 lib/lopata/environment.rb