Class: Travis::Config
- Inherits:
-
Hashr
- Object
- Hashr
- Travis::Config
- Defined in:
- lib/travis/config.rb
Class Method Summary collapse
Instance Method Summary collapse
- #env ⇒ Object
-
#initialize(data = nil, *args) ⇒ Config
constructor
A new instance of Config.
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
.env ⇒ Object
19 20 21 |
# File 'lib/travis/config.rb', line 19 def env defined?(Rails) ? Rails.env : ENV['RAILS_ENV'] || ENV['ENV'] || 'test' end |
.filename ⇒ Object
15 16 17 |
# File 'lib/travis/config.rb', line 15 def filename @filename ||= File.('../../../config/travis.yml', __FILE__) end |
.load_env ⇒ Object
7 8 9 |
# File 'lib/travis/config.rb', line 7 def load_env YAML.load(ENV['travis_config']) if ENV['travis_config'] end |
.load_file ⇒ Object
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
#env ⇒ Object
40 41 42 |
# File 'lib/travis/config.rb', line 40 def env self.class.env end |