Module: QAT::Configuration::Environment

Included in:
QAT::Configuration
Defined in:
lib/qat/configuration/environment.rb

Overview

Namespace for environment helper methods

Since:

  • 0.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#directoryObject

Since:

  • 0.1.0



5
6
7
# File 'lib/qat/configuration/environment.rb', line 5

def directory
  @directory
end

#environmentObject

Since:

  • 0.1.0



5
6
7
# File 'lib/qat/configuration/environment.rb', line 5

def environment
  @environment
end

Instance Method Details

#each_environment {|Configuration| ... } ⇒ Object

Executes a code block in all environments of the current configuration directory

Yields:

  • block to execute

Yield Parameters:

Since:

  • 0.1.0



74
75
76
77
78
79
80
81
82
# File 'lib/qat/configuration/environment.rb', line 74

def each_environment(&block)
  old_env = @environment
  environments.sort.each do |env|
    self.environment = env
    block.call(self)
  end
ensure
  self.environment = old_env
end

#environmentsArray<String>

Returns all the defined environments in the configuration directory

Returns:

  • (Array<String>)

    All environments defined

Since:

  • 0.1.0



66
67
68
# File 'lib/qat/configuration/environment.rb', line 66

def environments
  Dir.glob(File.join directory, '*/').map { |entry| File.basename(entry) }.reject { |entry| entry == 'common' }
end