Class: Avm::EacWebappBase0::Deploy::FileUnit

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/avm/eac_webapp_base0/deploy/file_unit.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(deploy, data_key, fs_path_subpath) ⇒ FileUnit

Returns a new instance of FileUnit.



9
10
11
12
13
# File 'lib/avm/eac_webapp_base0/deploy/file_unit.rb', line 9

def initialize(deploy, data_key, fs_path_subpath)
  super(deploy)
  @data_key = data_key
  @fs_path_subpath = fs_path_subpath
end

Instance Attribute Details

#data_keyObject (readonly)

Returns the value of attribute data_key.



7
8
9
# File 'lib/avm/eac_webapp_base0/deploy/file_unit.rb', line 7

def data_key
  @data_key
end

#fs_path_subpathObject (readonly)

Returns the value of attribute fs_path_subpath.



7
8
9
# File 'lib/avm/eac_webapp_base0/deploy/file_unit.rb', line 7

def fs_path_subpath
  @fs_path_subpath
end

Instance Method Details

#assert_source_directoryObject



20
21
22
23
# File 'lib/avm/eac_webapp_base0/deploy/file_unit.rb', line 20

def assert_source_directory
  infom "Asserting \"#{data_key}\" source directory..."
  instance.host_env.command('mkdir', '-p', source_path).execute!
end


34
35
36
37
38
# File 'lib/avm/eac_webapp_base0/deploy/file_unit.rb', line 34

def link_source_target
  infom "Linking \"#{data_key}\" directory..."
  instance.host_env.command('rm', '-rf', target_path).execute!
  instance.host_env.command('ln', '-s', source_path, target_path).execute!
end

#runObject



15
16
17
18
# File 'lib/avm/eac_webapp_base0/deploy/file_unit.rb', line 15

def run
  assert_source_directory
  link_source_target
end

#source_pathObject



25
26
27
# File 'lib/avm/eac_webapp_base0/deploy/file_unit.rb', line 25

def source_path
  ::File.join(instance.read_entry(:data_fs_path), data_key.to_s)
end

#target_pathObject



29
30
31
32
# File 'lib/avm/eac_webapp_base0/deploy/file_unit.rb', line 29

def target_path
  ::File.join(instance.read_entry(::Avm::Instances::EntryKeys::FS_PATH),
              fs_path_subpath.to_s)
end