Sha256: 35b2199090725948d655e6c293a045ea0b1712501889e8297ae50bc8a3fc2feb

Contents?: true

Size: 848 Bytes

Versions: 5

Compression:

Stored size: 848 Bytes

Contents

require 'dply/helper'
module Dply
  class ConfigDownloader

    include Helper
    attr_writer :config_skip_download

    def initialize(config_files , base_url)
      @config_files = config_files
      @base_url = base_url
    end

    def download_all
      @config_files.each do |f|
        if config_skip_download.include? f
          logger.debug "skipping to download file #{f}"
          next
        end
        download f
      end
    end

    private

    def download(file)
      url = "#{@base_url}/#{file}"
      logger.bullet "downloading #{file}"
      http_status = `curl -w "%{http_code}" -f -s -o 'config/#{file}' '#{url}' `
      if http_status != "200"
        error "failed to download #{file}, http status #{http_status}"
      end
    end


    def config_skip_download
      @config_skip_download ||= []
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dply-0.1.2 lib/dply/config_downloader.rb
dply-0.1.1 lib/dply/config_downloader.rb
dply-0.1.0 lib/dply/config_downloader.rb
dply-0.0.8 lib/dply/config_downloader.rb
dply-0.0.7 lib/dply/config_downloader.rb