Class: Spore::Config
- Inherits:
-
Object
show all
- Defined in:
- lib/spore/config.rb
Constant Summary
collapse
- DEPLOYMENT_VAR =
"SPORE_DEPLOYMENT"
- CONFIG_FILE =
"config.json"
- DEFAULT_CONFIG =
File.expand_path(
"../config/default.json", File.dirname(__FILE__))
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
7
8
9
|
# File 'lib/spore/config.rb', line 7
def api
@api
end
|
#environment ⇒ Object
Returns the value of attribute environment.
6
7
8
|
# File 'lib/spore/config.rb', line 6
def environment
@environment
end
|
Class Method Details
.is_deployment? ⇒ Boolean
15
16
17
|
# File 'lib/spore/config.rb', line 15
def is_deployment?
!ENV[DEPLOYMENT_VAR].nil?
end
|
Instance Method Details
#config ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/spore/config.rb', line 28
def config
@config ||= begin
file = File.read DEFAULT_CONFIG
hash = JSON.parse file
config_file = File.join(ENV["SPORE_HOME"] || "~/.spore", CONFIG_FILE)
begin
hash.update(JSON.parse(File.read(File.expand_path(config_file))))
rescue Errno::ENOENT
hash
end
end
end
|
#fetch(app_id, cell_id) ⇒ Object
42
43
44
|
# File 'lib/spore/config.rb', line 42
def fetch(app_id, cell_id)
api.get_cell(app_id, environment, cell_id)["value"]
end
|
#spore_file ⇒ Object
46
47
48
|
# File 'lib/spore/config.rb', line 46
def spore_file
File.expand_path(config["sporeFile"])
end
|