Sha256: e7f70d3dae0af0ecfcef10cb6e797dc8f6128d1d87f0894890f5c48ad23a0db5
Contents?: true
Size: 769 Bytes
Versions: 1
Compression:
Stored size: 769 Bytes
Contents
module SyncFiles module Fixtures class Process attr_reader :filename, :url, :destination def initialize(filename:, url:, destination:) @filename = filename @url = url @destination = destination end def run response = HTTParty.get(url) if response.code != 200 puts "ERROR: #{response.code} #{response.message} for #{url}" return end FileUtils.mkdir_p(write_path) open(write_filename, "wb") do |file| file << response.body end end private def write_filename File.join(::Rails.root.to_s, destination, filename) end def write_path File.dirname(write_filename) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sync_files-0.2.0 | lib/sync_files/fixtures/process.rb |