Sha256: 97e2de3322f8bb42f811a528b4fa10e6b76196424264ee48d23bea13638ddb9f

Contents?: true

Size: 884 Bytes

Versions: 2

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

#
# Copyright (c) 2020-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#

require_relative 'base'

module Burner
  class Jobs
    module IO
      # Read value from disk.
      class Read < Base
        attr_reader :binary

        def initialize(name:, path:, binary: false)
          super(name: name, path: path)

          @binary = binary || false

          freeze
        end

        def perform(output, payload)
          compiled_path = job_string_template(path, output, payload)

          output.detail("Reading: #{compiled_path}")

          payload.value = File.open(compiled_path, mode, &:read)

          nil
        end

        private

        def mode
          binary ? 'rb' : 'r'
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
burner-1.0.0.pre.alpha.5 lib/burner/jobs/io/read.rb
burner-1.0.0.pre.alpha.4 lib/burner/jobs/io/read.rb