class Spore::Config

Constants

CONFIG_FILE
DEFAULT_CONFIG
DEPLOYMENT_VAR

Attributes

api[R]
environment[R]

Public Class Methods

is_deployment?() click to toggle source
# File lib/spore/config.rb, line 15
def is_deployment?
  !ENV[DEPLOYMENT_VAR].nil?
end
load() click to toggle source
# File lib/spore/config.rb, line 19
def load
  if is_deployment?
    Spore::DeploymentConfig.new
  else
    Spore::LocalConfig.new
  end
end

Public Instance Methods

config() click to toggle source
# 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
      # ~/.spore/config.json doesn't exist, so just use the default config
      hash
    end
  end
end
fetch(app_id, cell_id) click to toggle source
# 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() click to toggle source
# File lib/spore/config.rb, line 46
def spore_file
  File.expand_path(config["sporeFile"])
end