Sha256: 8382e9c91a582a771d1832e636a4f615acafeb876c6ff40bb89ac090e6f0c36c
Contents?: true
Size: 913 Bytes
Versions: 1
Compression:
Stored size: 913 Bytes
Contents
require 'net/http' require "open-uri" module Caco class Downloader < Trailblazer::Operation Stubbed = Class.new(Trailblazer::Activity::Signal) step ->(_ctx, stubbed_file: nil, **) { stubbed_file ? Stubbed : true }, Output(Stubbed, :stubbed) => Track(:stubbed), id: :check_stubbed step ->(ctx, url:, **) { ctx[:tempfile] = Down.download(url) }, id: :download_file step ->(ctx, stubbed_file:, **) { ctx[:tempfile] = File.new(ctx[:stubbed_file]) }, magnetic_to: :stubbed, id: :stubbed_download_file step ->(_ctx, **) { true }, id: :check_md5 step :write_file def write_file(ctx, tempfile:, dest:, **) if Caco.config.write_files FileUtils.mkdir_p(File.dirname(dest)) File.rename tempfile.path, dest else tempfile.unlink end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
caco-0.1.0 | lib/caco/downloader.rb |