Class: Travis::Config

Inherits:
Hash
  • Object
show all
Defined in:
lib/travis/config.rb

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



5
6
7
# File 'lib/travis/config.rb', line 5

def initialize
  replace(load_env || load_file || {})
end

Instance Method Details

#environmentObject



18
19
20
# File 'lib/travis/config.rb', line 18

def environment
  defined?(Rails) ? Rails.env : 'test'
end

#load_envObject



9
10
11
# File 'lib/travis/config.rb', line 9

def load_env
  YAML.load(ENV['travis_config']) if ENV['travis_config']
end

#load_fileObject



13
14
15
16
# File 'lib/travis/config.rb', line 13

def load_file
  file = File.expand_path('../../../config/travis.yml', __FILE__)
  YAML.load_file(file)[environment] if File.exists?(file)
end