summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/build/artifacts/adapters/raw_stream.rb
blob: 7cee09b4db7a3cee23a3bc1be412c3a32f350165 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

module Gitlab
  module Ci
    module Build
      module Artifacts
        module Adapters
          class RawStream
            attr_reader :stream

            InvalidStreamError = Class.new(StandardError)

            def initialize(stream)
              raise InvalidStreamError, _("Stream is required") unless stream

              @stream = stream
            end

            def each_blob
              stream.seek(0)

              yield(stream.read, 'raw') unless stream.eof?
            end
          end
        end
      end
    end
  end
end