Class: Syrup::ApplicationConfiguration

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(name, path) ⇒ ApplicationConfiguration

Returns a new instance of ApplicationConfiguration.



61
62
63
64
65
66
# File 'lib/syrup/config_store.rb', line 61

def initialize(name, path)
  @name = name
  @path = path
  @properties = StoredHash.new File.join(@path, 'props')
  @start_parameters = if File.file? start_params_fn then YAML::load_file(start_params_fn) else [] end
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



58
59
60
# File 'lib/syrup/config_store.rb', line 58

def name
  @name
end

#propertiesObject (readonly)

Returns the value of attribute properties.



59
60
61
# File 'lib/syrup/config_store.rb', line 59

def properties
  @properties
end

Instance Method Details

#activated_fnObject



110
111
112
# File 'lib/syrup/config_store.rb', line 110

def activated_fn
  File.join(@path, 'activated')
end

#appObject



68
69
70
71
# File 'lib/syrup/config_store.rb', line 68

def app
  return File.read(activated_fn) if File.file? activated_fn
  return nil
end

#app=(path) ⇒ Object



73
74
75
76
77
78
79
# File 'lib/syrup/config_store.rb', line 73

def app=(path)
  unless path.nil?
    File.open(activated_fn, 'w'){ |f| f.write(File.expand_path(path)) }
  else
    File.delete activated_fn if File.file? activated_fn
  end
end

#fabric_fnObject



118
119
120
# File 'lib/syrup/config_store.rb', line 118

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

#pidObject



81
82
83
84
85
86
# File 'lib/syrup/config_store.rb', line 81

def pid
  result = File.read(pid_fn) rescue nil
  return result.to_i unless result.nil?
  
  nil
end

#pid=(i) ⇒ Object



88
89
90
91
92
93
94
# File 'lib/syrup/config_store.rb', line 88

def pid=(i)
  unless i.nil?
    File.open(pid_fn, 'w'){ |f| f.write(i) }
  else
    File.delete pid_fn if File.file? pid_fn
  end
end

#pid_fnObject



126
127
128
# File 'lib/syrup/config_store.rb', line 126

def pid_fn
  File.join(@path, 'pid')
end

#props_fnObject



114
115
116
# File 'lib/syrup/config_store.rb', line 114

def props_fn
  File.join(@path, 'props')
end

#start_parametersObject



96
97
98
# File 'lib/syrup/config_store.rb', line 96

def start_parameters
  @start_parameters
end

#start_parameters=(params) ⇒ Object



100
101
102
103
104
105
106
107
108
# File 'lib/syrup/config_store.rb', line 100

def start_parameters=(params)
  @start_parameters = params
  
  unless params.nil? or params.length == 0
    File.open(start_params_fn, 'w') { |f| f.write(params.to_yaml) }
  else
    File.delete start_params_fn if File.file? start_params_fn
  end
end

#start_params_fnObject



122
123
124
# File 'lib/syrup/config_store.rb', line 122

def start_params_fn
  File.join(@path, 'start_params')
end