Sha256: f0988d47d7824c24d69088ca03a372a8157b6df2533f5e9287f457a31a26a105

Contents?: true

Size: 1.42 KB

Versions: 57

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

module Avm
  module EacWebappBase0
    module Instances
      class Deploy
        class SetupFilesUnit < ::SimpleDelegator
          enable_method_class
          attr_reader :data_key, :fs_path_subpath

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

          def result
            assert_source_directory
            link_source_target
          end

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

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

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

          def link_source_target
            infom "Linking \"#{data_key}\" directory..."
            return unless remove_target

            instance.host_env.command('ln', '-s', source_path, target_path).execute!
          end

          private

          # @return [Boolean]
          def remove_target
            instance.host_env.command('rm', '-rf', target_path).execute.fetch(:exit_code).zero?
          end
        end
      end
    end
  end
end

Version data entries

57 entries across 57 versions & 2 rubygems

Version Path
avm-eac_webapp_base0-0.20.1 lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.94.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
avm-eac_webapp_base0-0.20.0 lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.93.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
avm-eac_webapp_base0-0.19.0 lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.87.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
avm-eac_webapp_base0-0.18.4 lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.86.8 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.84.2 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
avm-eac_webapp_base0-0.18.3 lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.84.1 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.84.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.83.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.82.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.81.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.80.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.79.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.78.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.77.1 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb
eac_tools-0.77.0 sub/avm-eac_webapp_base0/lib/avm/eac_webapp_base0/instances/deploy/setup_files_unit.rb