Class: Slnky::Config
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Data
#delete, #initialize, parse, #to_s
Methods inherited from DeepStruct
#initialize, #to_h
Constructor Details
This class inherits a constructor from Slnky::Data
Class Method Details
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/slnky/config.rb', line 18
def configure(name, config={})
config.deep_stringify_keys!
@name = name
@environment = ENV['SLNKY_ENV'] || config['environment'] || 'development'
config['service'] = name
config['environment'] = @environment
file = ENV['SLNKY_CONFIG']||"~/.slnky/config.yaml"
config.merge!(config_file(file))
server = ENV['SLNKY_URL']||config['url']
config.merge!(config_server(server))
@config = self.new(config)
end
|
.instance ⇒ Object
def load_file(file)
self.load(YAML.load_file(File.expand_path(file)))
end
35
36
37
|
# File 'lib/slnky/config.rb', line 35
def instance
@config || configure('unknown')
end
|
.reset! ⇒ Object
39
40
41
|
# File 'lib/slnky/config.rb', line 39
def reset!
@config = nil
end
|
Instance Method Details
#development? ⇒ Boolean
74
75
76
|
# File 'lib/slnky/config.rb', line 74
def development?
!self.environment || self.environment == 'development'
end
|
#production? ⇒ Boolean
78
79
80
|
# File 'lib/slnky/config.rb', line 78
def production?
self.environment == 'production'
end
|
#test? ⇒ Boolean
82
83
84
|
# File 'lib/slnky/config.rb', line 82
def test?
self.environment == 'test'
end
|