Class: ArtifactTools::Downloader
- Inherits:
-
Object
- Object
- ArtifactTools::Downloader
- Defined in:
- lib/artifact_tools/downloader.rb
Overview
Downloader allows the user to fetch files from a store specified. All this information is provided by ConfigFile.
Class Method Summary collapse
-
.parse(arguments) ⇒ Object
Parse command line options to options suitable to Downloader.new.
Instance Method Summary collapse
-
#initialize(args = { verify: true, force: false }) ⇒ Downloader
constructor
Downloads requested files.
Constructor Details
#initialize(args = { verify: true, force: false }) ⇒ Downloader
Downloads requested files
22 23 24 25 26 |
# 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 |
Class Method Details
.parse(arguments) ⇒ Object
Parse command line options to options suitable to Downloader.new
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/artifact_tools/downloader.rb', line 64 def self.parse(arguments) = @default_opts arguments << '-h' if arguments.empty? OptionParser.new do |opts| opts. = "Usage: #{__FILE__} [options]" @parse_opts_handlers.each do |args, handler| opts.on(*args) { |v| handler.call(v, , opts) } end end.parse!(arguments) raise OptionParser::MissingArgument, 'Missing -c/--configuration option' unless .key?(:config_file) end |