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.39.0 sub/avm-files/lib/avm/files/deploy.rb
avm-files-0.6.0 lib/avm/files/deploy.rb
eac_tools-0.38.0 sub/avm-files/lib/avm/files/deploy.rb
avm-files-0.5.0 lib/avm/files/deploy.rb
eac_tools-0.37.2 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.37.1 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.37.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.36.1 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.36.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.35.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.34.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.33.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.32.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.31.1 sub/avm-files/lib/avm/files/deploy.rb
avm-files-0.4.1 lib/avm/files/deploy.rb
eac_tools-0.31.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.30.0 sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.129.0 sub/avm-files/lib/avm/files/deploy.rb
eac_tools-0.16.0 sub/avm-tools/sub/avm-files/lib/avm/files/deploy.rb
avm-tools-0.128.0 sub/avm-files/lib/avm/files/deploy.rb