Sha256: 036cd9b28fe0b97b0b22bdd9d736b21fa50d936ce230a2a295e68c035c3408c7

Contents?: true

Size: 1.12 KB

Versions: 18

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.exists?(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

18 entries across 18 versions & 1 rubygems

Version Path
lopata-0.1.31 lib/lopata/environment.rb
lopata-0.1.30 lib/lopata/environment.rb
lopata-0.1.29 lib/lopata/environment.rb
lopata-0.1.28 lib/lopata/environment.rb
lopata-0.1.27 lib/lopata/environment.rb
lopata-0.1.26 lib/lopata/environment.rb
lopata-0.1.25 lib/lopata/environment.rb
lopata-0.1.24 lib/lopata/environment.rb
lopata-0.1.23 lib/lopata/environment.rb
lopata-0.1.22 lib/lopata/environment.rb
lopata-0.1.21 lib/lopata/environment.rb
lopata-0.1.20 lib/lopata/environment.rb
lopata-0.1.19 lib/lopata/environment.rb
lopata-0.1.18 lib/lopata/environment.rb
lopata-0.1.17 lib/lopata/environment.rb
lopata-0.1.16 lib/lopata/environment.rb
lopata-0.1.15 lib/lopata/environment.rb
lopata-0.1.14 lib/lopata/environment.rb