Sha256: 399ff12d498d76f2e0afbb5da5aa3fb6ddbeb5444ff52f48e5d693fda8b1493a

Contents?: true

Size: 488 Bytes

Versions: 1

Compression:

Stored size: 488 Bytes

Contents

require 'open-uri'
require 'openssl'

module TerraformDevKit
  def self.download_file(url, filename, force_download: false)
    unless File.exist?(filename) && !force_download
      dirname = File.dirname(filename)
      FileUtils.mkdir_p(dirname) unless Dir.exist?(dirname)

      puts "Downloading #{url} to #{filename}..."

      open(filename, 'wb') do |file|
        file << URI.open(url, ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE).read
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
TerraformDevKit-0.4.0 lib/TerraformDevKit/download.rb