Class: ArtifactTools::Uploader
- Inherits:
-
Object
- Object
- ArtifactTools::Uploader
- Includes:
- Hasher
- Defined in:
- lib/artifact_tools/uploader.rb
Overview
Uploader allows the user to upload files to a store specified by ConfigFile.
Class Method Summary collapse
-
.parse(arguments) ⇒ Object
Parse command line options to options suitable to Downloader.new.
Instance Method Summary collapse
-
#initialize(config_file:, files:, append: false) ⇒ Uploader
constructor
Upload requested files.
Methods included from Hasher
Constructor Details
#initialize(config_file:, files:, append: false) ⇒ Uploader
Upload requested files
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/artifact_tools/uploader.rb', line 18 def initialize(config_file:, files:, append: false) # TODO: check for clashes of files, do hash checks? @config_file = config_file @append = append @config = load_config(@config_file) c = ArtifactTools::Client.new(config: @config.config) files.each do |file| update_file(c, file) end @config.save(config_file) end |
Class Method Details
.parse(arguments) ⇒ Object
Parse command line options to options suitable to Downloader.new
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/artifact_tools/uploader.rb', line 48 def self.parse(arguments) = { append: @default_append_opt } 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(opts, v, ) } end end.parse!(arguments) raise OptionParser::MissingArgument, 'Missing -c/--configuration option' unless .key?(:config_file) .merge({ files: arguments.dup }) end |