Sha256: 88c6dcd5e76915d2489bf04b7e83076550fbde99927ce377f168732d84112353

Contents?: true

Size: 1.52 KB

Versions: 164

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require 'addressable'
require 'avm/files/appendable'
require 'eac_ruby_utils/core_ext'

module Avm
  module Files
    class Deploy
      include ::Avm::Files::Appendable
      enable_simple_cache

      attr_reader :build_dir, :target_env, :target_path

      common_constructor :target_env, :target_path

      def run
        on_build_dir do
          copy_content_to_build_dir
          mkdir_target
          clear_content
          send_untar_package
          set_target_permission
        end
      end

      private

      def on_build_dir
        @build_dir = ::Dir.mktmpdir
        yield
      ensure
        ::FileUtils.rm_rf(@build_dir)
      end

      def copy_content_to_build_dir
        write_appended_on(build_dir)
      end

      def mkdir_target
        target_env.command('mkdir', '-p', target_path).execute!
      end

      def clear_content
        target_env.command(
          'find', target_path, '-mindepth', '1', '-maxdepth', '1', '-exec', 'rm', '-rf', '{}', ';'
        ).execute!
      end

      def send_untar_package
        tar_build_command.pipe(untar_build_command).execute!
      end

      def set_target_permission
        target_env.command('chmod', '755', target_path).execute!
      end

      def tar_build_command
        source_env.command('tar', '-czO', '-C', build_dir, '.')
      end

      def untar_build_command
        target_env.command('tar', '-xzf', '-', '-C', target_path)
      end

      def source_env
        ::EacRubyUtils::Envs.local
      end
    end
  end
end

Version data entries

164 entries across 164 versions & 4 rubygems

Version Path
eac_tools-0.15.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.14.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.13.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.127.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.12.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.126.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.11.1 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.125.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.11.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.124.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.10.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.123.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.9.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.122.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.8.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.7.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.6.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.121.2 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.5.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.4.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb