Class: Kibo::Config

Inherits:
Mash
  • Object
show all
Defined in:
lib/kibo/config.rb,
lib/kibo/config.rb

Constant Summary collapse

DEFAULTS =
{
  "heroku"          => {
    "mode" => "freemium"
  },
  "deployment"      => {},
  "collaborations"  => {},
  "source"          => {},
  "sharing"         => [],
  "addons"          => {}
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kibofile, environment) ⇒ Config

Returns a new instance of Config.



18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/kibo/config.rb', line 18

def initialize(kibofile, environment)
  @kibofile, @environment = kibofile, environment
  @kibofile = File.expand_path @kibofile
  
  kibo = begin
    YAML.load File.read(kibofile)
  rescue Errno::ENOENT
    E "No such file", File.expand_path(@kibofile)
  end

  build_config(kibo)
  verify_config
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



16
17
18
# File 'lib/kibo/config.rb', line 16

def environment
  @environment
end

Instance Method Details

#freemium?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/kibo/config.rb', line 37

def freemium?
  heroku.mode == "freemium"
end

#instancesObject

return an array of instances.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/kibo/config.rb', line 109

def instances
  instances = if freemium?
    processes.map do |process, count|
      1.upto(count).map { |idx| 
        Kibo::Instance::Freemium.new self, process, idx 
      }
    end.flatten
  else
    processes.map do |process, count|
      Kibo::Instance.new self, process, count
    end
  end

  instances.sort_by(&:to_s)
end

#namespaceObject



41
42
43
# File 'lib/kibo/config.rb', line 41

def namespace
  heroku.namespace
end

#processesObject



32
33
34
35
# File 'lib/kibo/config.rb', line 32

def processes
  return unless processes = super
  processes.reject { |k,v| v.to_s.to_i <= 0 } 
end