Module: My::Config

Extended by:
Config
Included in:
Config
Defined in:
lib/my/config.rb

Overview

My::Config is the wrapper around all configurable options within the My gem. It tracks the version of the My gem, the environment in which My has been run, and the location of the My script registry.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#environmentObject

Returns the value of attribute environment.



15
16
17
# File 'lib/my/config.rb', line 15

def environment
  @environment
end

#versionObject

Returns the value of attribute version.



15
16
17
# File 'lib/my/config.rb', line 15

def version
  @version
end

Instance Method Details

#scriptsObject

Returns the location of the My script registry, depending on the current environment.

My::Config.environment = 'production'
My::Config.scripts
  # => "/home/gisikw/.my_scripts"

My::Config.environment = 'test'
My::Config.scripts
  # => "/home/gisikw/.rvm/gems/ruby-1.8.7-p249/gems/my-0.3.0/test.yml"


27
28
29
30
31
32
33
34
35
36
# File 'lib/my/config.rb', line 27

def scripts
  case self.environment||='production'
    when /^production$/
      return File.expand_path("~/.my_scripts")
    when /^test$/
      return File.expand_path(File.join(File.dirname(__FILE__),'../../test.yml'))
    when /^cucumber$/
      return File.expand_path(File.join(File.dirname(__FILE__),'../../test.yml'))
  end
end