Class: Superhosting::ScriptExecutor::Container
- Defined in:
- lib/superhosting/script_executor/container.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#container ⇒ Object
Returns the value of attribute container.
-
#container_lib ⇒ Object
Returns the value of attribute container_lib.
-
#container_name ⇒ Object
Returns the value of attribute container_name.
-
#on_reconfig_only ⇒ Object
Returns the value of attribute on_reconfig_only.
-
#registry_path ⇒ Object
Returns the value of attribute registry_path.
Attributes inherited from Base
Instance Method Summary collapse
- #config(save_to, script, **options) ⇒ Object
-
#initialize(container:, container_name:, container_lib:, registry_path:, on_reconfig_only: false, **kwargs) ⇒ Container
constructor
A new instance of Container.
-
#on_reconfig(cmd) ⇒ Object
def container_config(save_to, script, **options) raise NetStatus::Exception.new(error: :error, message: “File ‘#save_to’ has incorrect name format”) if save_to.include? File::SEPARATOR config(File.join(self.lib_configs._path, save_to), script, options) end.
Methods inherited from Base
Methods included from Helpers
#create_conf, #erb, #instance_variables_to_hash, #remove_line_from_file, #write_if_not_exist
Constructor Details
#initialize(container:, container_name:, container_lib:, registry_path:, on_reconfig_only: false, **kwargs) ⇒ Container
Returns a new instance of Container.
6 7 8 9 10 11 12 13 |
# File 'lib/superhosting/script_executor/container.rb', line 6 def initialize(container:, container_name:, container_lib:, registry_path:, on_reconfig_only: false, **kwargs) self.container = container self.container_name = container_name self.container_lib = container_lib self.registry_path = registry_path self.on_reconfig_only = on_reconfig_only super(**kwargs) end |
Instance Attribute Details
#container ⇒ Object
Returns the value of attribute container.
4 5 6 |
# File 'lib/superhosting/script_executor/container.rb', line 4 def container @container end |
#container_lib ⇒ Object
Returns the value of attribute container_lib.
4 5 6 |
# File 'lib/superhosting/script_executor/container.rb', line 4 def container_lib @container_lib end |
#container_name ⇒ Object
Returns the value of attribute container_name.
4 5 6 |
# File 'lib/superhosting/script_executor/container.rb', line 4 def container_name @container_name end |
#on_reconfig_only ⇒ Object
Returns the value of attribute on_reconfig_only.
4 5 6 |
# File 'lib/superhosting/script_executor/container.rb', line 4 def on_reconfig_only @on_reconfig_only end |
#registry_path ⇒ Object
Returns the value of attribute registry_path.
4 5 6 |
# File 'lib/superhosting/script_executor/container.rb', line 4 def registry_path @registry_path end |
Instance Method Details
#config(save_to, script, **options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/superhosting/script_executor/container.rb', line 15 def config(save_to, script, **) unless self.on_reconfig_only script_mapper = self.container.f(script, default: self.model.f(script)) raise NetStatus::Exception.new(error: :error, message: 'File does not exist') if script_mapper.nil? opts = instance_variables_to_hash(self).merge() FileUtils.mkdir_p File.dirname(save_to) File.open(save_to, 'w') {|f| f.write(erb(script_mapper, **opts)) } create_conf(self.registry_path, save_to) end end |
#on_reconfig(cmd) ⇒ Object
def container_config(save_to, script, **options)
raise NetStatus::Exception.new(error: :error, message: "File '#{save_to}' has incorrect name format") if save_to.include? File::SEPARATOR
config(File.join(self.lib_configs._path, save_to), script, )
end
31 32 33 |
# File 'lib/superhosting/script_executor/container.rb', line 31 def on_reconfig(cmd) self.commands << cmd end |