Class: Heroku::Scalr::Config

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

Overview

Loads a config file and evaluates the stored configuration

Examples:

of a config file


defaults email: "[email protected]", token: "d728201893d47607ec382", interval: 60
app "lonely-warrior-45", url: "http://cnamed.host/robots.txt"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Config

Returns a new instance of Config.

Parameters:

  • path (String)

    file path containing a configuration



13
14
15
16
17
# File 'lib/heroku/scalr/config.rb', line 13

def initialize(path)
  @defaults = {}
  @apps     = []
  instance_eval File.read(path)
end

Instance Attribute Details

#appsObject (readonly)

Returns the value of attribute apps.



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

def apps
  @apps
end

Instance Method Details

#app(name, opts = {}) ⇒ Object

Parameters:

  • name (String)

    the Heroku app name

  • opts (Hash) (defaults to: {})

    configuration options

See Also:



28
29
30
31
# File 'lib/heroku/scalr/config.rb', line 28

def app(name, opts = {})
  opts = @defaults.merge(opts)
  @apps << Heroku::Scalr::App.new(name, opts)
end

#defaults(opts = {}) ⇒ Object

Parameters:

  • opts (Hash) (defaults to: {})

    updates for defaults

See Also:



21
22
23
# File 'lib/heroku/scalr/config.rb', line 21

def defaults(opts = {})
  @defaults.update(opts)
end