Sha256: e79a3d127ba85cc644cf49799b9d953fe65f4cfbfe971e990b2b3b81c66764d0

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

# Author::      Kevin W. Gisi (mailto:kevin@kevingisi.com)
# Copyright::   Copyright (c) 2010 Kevin W. Gisi
# License::     Distributed under the MIT License

module My
  # 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.
  module Config
    extend self 

    @version = File.read(File.dirname(__FILE__)+"/../../VERSION").chomp

    attr_accessor :environment,:version

    # 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"
    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
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
my-0.3.0 lib/my/config.rb