Class: Travis::Config

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = nil, *args) ⇒ Config

Returns a new instance of Config.



35
36
37
38
# File 'lib/travis/config.rb', line 35

def initialize(data = nil, *args)
  data ||= self.class.load_env || self.class.load_file || {}
  super
end

Class Method Details

.envObject



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

def env
 defined?(Rails) ? Rails.env : ENV['RAILS_ENV'] || ENV['ENV'] || 'test'
end

.filenameObject



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

def filename
  @filename ||= File.expand_path('../../../config/travis.yml', __FILE__)
end

.load_envObject



7
8
9
# File 'lib/travis/config.rb', line 7

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

.load_fileObject



11
12
13
# File 'lib/travis/config.rb', line 11

def load_file
  YAML.load_file(filename)[env] if File.exists?(filename)
end

Instance Method Details

#envObject



40
41
42
# File 'lib/travis/config.rb', line 40

def env
  self.class.env
end