Class: FigNewton::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/fig-newton/config.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, filename) ⇒ Config

Returns a new instance of Config.



17
18
19
20
# File 'lib/fig-newton/config.rb', line 17

def initialize(data, filename)
  @data = data
  @filename = filename
end

Class Method Details

.filepath_from_stack(config_dir, stack_name) ⇒ Object



6
7
8
# File 'lib/fig-newton/config.rb', line 6

def self.filepath_from_stack(config_dir, stack_name)
  File.join(config_dir, "#{stack_name}.yml")
end

.from_file(config_dir, stack_name) ⇒ Object



10
11
12
13
14
15
# File 'lib/fig-newton/config.rb', line 10

def self.from_file(config_dir, stack_name)
  filename = absolute_path(config_dir, stack_name)
  data = YAML::load_file(filename)

  new(data, filename)
end

Instance Method Details

#appsObject



26
27
28
29
30
31
32
# File 'lib/fig-newton/config.rb', line 26

def apps
  @apps ||= data["apps"].each_with_object({}) do |app, apps|
    name, config = app.flatten
    apps[name] = FigNewton::App.new(name, config)
    apps
  end
end

#nameObject



22
23
24
# File 'lib/fig-newton/config.rb', line 22

def name
  data["name"]
end