Class: Syrup::ApplicationConfiguration
- Inherits:
-
Object
- Object
- Syrup::ApplicationConfiguration
- Includes:
- WithFabric
- Defined in:
- lib/syrup/config_store.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
- #activated_fn ⇒ Object
- #app ⇒ Object
- #app=(path) ⇒ Object
- #fabric_fn ⇒ Object
-
#initialize(name, path) ⇒ ApplicationConfiguration
constructor
A new instance of ApplicationConfiguration.
- #pid ⇒ Object
- #pid=(i) ⇒ Object
- #pid_fn ⇒ Object
- #props_fn ⇒ Object
- #start_parameters ⇒ Object
- #start_parameters=(params) ⇒ Object
- #start_params_fn ⇒ Object
Methods included from WithFabric
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
#name ⇒ Object (readonly)
Returns the value of attribute name.
58 59 60 |
# File 'lib/syrup/config_store.rb', line 58 def name @name end |
#properties ⇒ Object (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_fn ⇒ Object
110 111 112 |
# File 'lib/syrup/config_store.rb', line 110 def activated_fn File.join(@path, 'activated') end |
#app ⇒ Object
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.(path)) } else File.delete activated_fn if File.file? activated_fn end end |
#fabric_fn ⇒ Object
118 119 120 |
# File 'lib/syrup/config_store.rb', line 118 def fabric_fn File.join(@path, 'fabric') end |
#pid ⇒ Object
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_fn ⇒ Object
126 127 128 |
# File 'lib/syrup/config_store.rb', line 126 def pid_fn File.join(@path, 'pid') end |
#props_fn ⇒ Object
114 115 116 |
# File 'lib/syrup/config_store.rb', line 114 def props_fn File.join(@path, 'props') end |
#start_parameters ⇒ Object
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_fn ⇒ Object
122 123 124 |
# File 'lib/syrup/config_store.rb', line 122 def start_params_fn File.join(@path, 'start_params') end |