Sha256: 57c89f6827f67856d3e596bc0bd82c5b8737179d0e82bb52264de0899a4c59d2

Contents?: true

Size: 929 Bytes

Versions: 13

Compression:

Stored size: 929 Bytes

Contents

require 'picsolve_docker_builder/base'

module PicsolveDockerBuilder
  module Builder
    # File helper to add files to tars
    class File
      include PicsolveDockerBuilder::Base
      attr_reader :path
      def initialize(path, opts = {})
        @opts = opts
        @path = path
      end

      def content
        return @opts[:content] if @opts.key? :content

        return read_source if @opts.key? :source

        fail 'No content found'
      end

      def destination
        @opts[:destination]
      end

      def add_to_image?
        @opts.key? :destination
      end

      def source
        @opts[:source]
      end

      def mode
        ::File.stat(source).mode
      end

      def add_to_tar(tar)
        log.debug "add file from #{source} to #{path} in tar"
        tar.add_file path, mode do |tf|
          ::File.open(source, 'rb') { |f| tf.write f.read }
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
picsolve_docker_builder-0.5.5 lib/picsolve_docker_builder/builder/file.rb
picsolve_docker_builder-0.5.4 lib/picsolve_docker_builder/builder/file.rb
picsolve_docker_builder-0.5.3 lib/picsolve_docker_builder/builder/file.rb
picsolve_docker_builder-0.5.2 lib/picsolve_docker_builder/builder/file.rb
picsolve_docker_builder-0.5.1 lib/picsolve_docker_builder/builder/file.rb
picsolve_docker_builder-0.5.0 lib/picsolve_docker_builder/builder/file.rb
picsolve_docker_builder-0.4.0 lib/picsolve_docker_builder/builder/file.rb
picsolve_docker_builder-0.3.2 lib/picsolve_docker_builder/builder/file.rb
picsolve_docker_builder-0.3.1 lib/picsolve_docker_builder/builder/file.rb
picsolve_docker_builder-0.3.0 lib/picsolve_docker_builder/builder/file.rb
picsolve_docker_builder-0.2.0 lib/picsolve_docker_builder/builder/file.rb
picsolve_docker_builder-0.1.1 lib/picsolve_docker_builder/builder/file.rb
picsolve_docker_builder-0.1.0 lib/picsolve_docker_builder/builder/file.rb