Class: HerokuRails::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/heroku-rails/config.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_filepath) ⇒ Config

Returns a new instance of Config.



17
18
19
20
21
22
23
# File 'lib/heroku-rails/config.rb', line 17

def initialize(config_filepath)
  if File.exists?(config_filepath)
    self.settings = YAML.load(ERB.new(File.read(config_filepath)).result) || {}
  else
    self.settings = {}
  end
end

Instance Attribute Details

#settingsObject

Returns the value of attribute settings.



15
16
17
# File 'lib/heroku-rails/config.rb', line 15

def settings
  @settings
end

Class Method Details

.rootObject



7
8
9
# File 'lib/heroku-rails/config.rb', line 7

def root
  @heroku_rails_root || ENV["RAILS_ROOT"] || "."
end

.root=(root) ⇒ Object



10
11
12
# File 'lib/heroku-rails/config.rb', line 10

def root=(root)
  @heroku_rails_root = root
end

Instance Method Details

#addons(app_env) ⇒ Object

return a list of addons for a particular app environment



72
73
74
# File 'lib/heroku-rails/config.rb', line 72

def addons(app_env)
  app_setting_list('addons', app_env)
end

#app_environmentsObject



33
34
35
# File 'lib/heroku-rails/config.rb', line 33

def app_environments
  apps.keys
end

#app_namesObject



29
30
31
# File 'lib/heroku-rails/config.rb', line 29

def app_names
  apps.values
end

#appsObject



25
26
27
# File 'lib/heroku-rails/config.rb', line 25

def apps
  self.settings['apps'] || {}
end

#collaborators(app_env) ⇒ Object

return a list of collaborators for a particular app environment



67
68
69
# File 'lib/heroku-rails/config.rb', line 67

def collaborators(app_env)
  app_setting_list('collaborators', app_env)
end

#config(app_env) ⇒ Object

pull out the config setting hash for a particular app environment



52
53
54
55
56
57
58
# File 'lib/heroku-rails/config.rb', line 52

def config(app_env)
  config = self.settings['config'] || {}
  all = config['all'] || {}

  # overwrite all configs with the environment specific ones
  all.merge(config[app_env] || {})
end

#domains(app_env) ⇒ Object

return a list of domains for a particular app environment



61
62
63
64
# File 'lib/heroku-rails/config.rb', line 61

def domains(app_env)
  domains = self.settings['domains'] || {}
  domains[app_env] || []
end

#rake_cmd(app_env) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/heroku-rails/config.rb', line 43

def rake_cmd(app_env)
  if self.stack(app_env) =~ /cedar/i
    'heroku run rake'
  else
    'heroku rake'
  end
end

#stack(app_env) ⇒ Object

return the stack setting for a particular app environment



38
39
40
41
# File 'lib/heroku-rails/config.rb', line 38

def stack(app_env)
  stacks = self.settings['stacks'] || {}
  stacks[app_env] || stacks['all']
end