Sha256: 087f2b6a5529fbcc03868a3cec47b2ca0e5fa6a42ff91e2b6d87e607b369babf

Contents?: true

Size: 709 Bytes

Versions: 9

Compression:

Stored size: 709 Bytes

Contents

# frozen-string-literal: true

require "down/version"
require "down/chunked_io"
require "down/errors"
require "down/utils"

require "fileutils"

module Down
  class Backend
    def self.download(*args, **options, &block)
      new.download(*args, **options, &block)
    end

    def self.open(*args, **options, &block)
      new.open(*args, **options, &block)
    end

    private

    # If destination path is defined, move tempfile to the destination,
    # otherwise return the tempfile unchanged.
    def download_result(tempfile, destination)
      return tempfile unless destination

      tempfile.close # required for Windows
      FileUtils.mv tempfile.path, destination

      nil
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
down-5.2.4 lib/down/backend.rb
down-5.2.3 lib/down/backend.rb
down-5.2.2 lib/down/backend.rb
down-5.2.1 lib/down/backend.rb
down-5.2.0 lib/down/backend.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/down-5.1.1/lib/down/backend.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/down-5.1.1/lib/down/backend.rb
down-5.1.1 lib/down/backend.rb
down-5.1.0 lib/down/backend.rb