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
avm-files-0.3.0 lib/avm/files/deploy.rb
avm-tools-0.114.1 sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.114.0 sub/avm-files/lib/avm/files/deploy.rb
avm-files-0.2.1 lib/avm/files/deploy.rb
avm-tools-0.113.6 sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.113.5 sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.113.4 sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.113.3 sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.113.2 sub/avm-files/lib/avm/files/deploy.rb
avm-files-0.2.0 lib/avm/files/deploy.rb
avm-tools-0.110.0 vendor/avm-files/lib/avm/files/deploy.rb
avm-tools-0.109.1 vendor/avm-files/lib/avm/files/deploy.rb
avm-files-0.1.0 lib/avm/files/deploy.rb
avm-tools-0.109.0 vendor/avm-files/lib/avm/files/deploy.rb
avm-0.5.0 lib/avm/files/deploy.rb
avm-tools-0.108.0 vendor/avm/lib/avm/files/deploy.rb
avm-0.4.0 lib/avm/files/deploy.rb
avm-tools-0.107.0 vendor/avm/lib/avm/files/deploy.rb
avm-tools-0.106.0 vendor/avm/lib/avm/files/deploy.rb
avm-0.3.2 lib/avm/files/deploy.rb