class ArtifactTools::Downloader

Downloader allows the user to fetch files from a store specified. All this information is provided by {ConfigFile}.

Public Class Methods

new(args = { verify: true, force: false }) click to toggle source

Downloads requested files

@param [Hash] args the arguments for downloading artifacts @argument args :config_file [String] Path to configuration file @argument args :user [String] User to use for download connection @argument args :dest_dir [String] Where to download artifacts to @argument args :verify [Boolean] Whether to verify checksums after download. @argument args :force [Boolean] Whether to download files even if they are already

present with the exected hash

@argument args :match [Regexp] Whether to verify checksums after download.

# File lib/artifact_tools/downloader.rb, line 22
def initialize(args = { verify: true, force: false })
  config = load_config(args[:config_file])
  c = ArtifactTools::Client.new(config: config.config, user: args[:user])
  c.fetch(dest: args[:dest_dir], verify: args[:verify], match: args[:match], force: args[:force])
end
parse(arguments) click to toggle source

Parse command line options to options suitable to Downloader.new

@param arguments [Array(String)] Command line options to parse and use.

Hint: pass ARGV
# File lib/artifact_tools/downloader.rb, line 64
def self.parse(arguments)
  options = @default_opts
  arguments << '-h' if arguments.empty?
  OptionParser.new do |opts|
    opts.banner = "Usage: #{__FILE__} [options]"
    @parse_opts_handlers.each do |args, handler|
      opts.on(*args) { |v|  handler.call(v, options, opts) }
    end
  end.parse!(arguments)

  raise OptionParser::MissingArgument, 'Missing -c/--configuration option' unless options.key?(:config_file)

  options
end

Private Instance Methods

load_config(config_file) click to toggle source
# File lib/artifact_tools/downloader.rb, line 81
def load_config(config_file)
  ArtifactTools::ConfigFile.from_file(config_file)
  # TODO: error check
end