Class: Syrup::ConfigStore

Inherits:
Object
  • Object
show all
Includes:
WithFabric
Defined in:
lib/syrup/config_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WithFabric

#fabric, #fabric=

Constructor Details

#initialize(path) ⇒ ConfigStore

Initializes the configuration store with the given storage directory.



25
26
27
28
# File 'lib/syrup/config_store.rb', line 25

def initialize(path)
  @path = path
  @properties = StoredHash.new File.join(@path, 'props')
end

Instance Attribute Details

#propertiesObject (readonly)

Returns the value of attribute properties.



22
23
24
# File 'lib/syrup/config_store.rb', line 22

def properties
  @properties
end

Instance Method Details

#applicationsObject

Retrieves all of the applications that are configured within the system



31
32
33
34
35
36
37
38
39
40
# File 'lib/syrup/config_store.rb', line 31

def applications
  apps = {}
  Dir[File.join(@path, '*')].each do |store_dir|
    name = File.basename(store_dir)
    
    apps[name] = ApplicationConfiguration.new name, store_dir
  end
  
  apps
end

#create_application(name) ⇒ Object

Creates a new application



43
44
45
46
47
48
# File 'lib/syrup/config_store.rb', line 43

def create_application(name)
  store_dir = File.join(@path, name)
  FileUtils.mkdir_p store_dir
  
  ApplicationConfiguration.new name, store_dir
end

#fabric_fnObject



50
51
52
# File 'lib/syrup/config_store.rb', line 50

def fabric_fn
  File.join(@path, 'fabric')
end