Class: Chimps::Commands::Upload
- Inherits:
-
Chimps::Command
- Object
- OptionParser
- Chimps::Command
- Chimps::Commands::Upload
- Defined in:
- lib/chimps/commands/upload.rb
Overview
A command for uploading data to Infochimps.
Constant Summary collapse
- BANNER =
"usage: chimps upload [OPTIONS] ID_OR_HANDLE PATH [PATH] ..."- HELP =
<<EOF Upload data from your local machine for an existing dataset identified by ID_OR_HANDLE on Infochimps. chimps will package all paths supplied into a local archive and then upload this archive to Infochimps. The local archive defaults to a sensible name in the current directory but can also be customized. If the only file to be packaged is already a package (.zip, .tar, .tar.gz, &c.) then it will not be packaged again. Supplied paths are allowed to be remote files so someting like chimps upload my-dataset path/to/local/file.txt http://my-site.com/path/to/remote/file.txt will work. EOF
Instance Attribute Summary collapse
-
#archive ⇒ Object
readonly
The path to the archive.
-
#fmt ⇒ Object
readonly
The data format to annotate the upload with.
Attributes inherited from Chimps::Command
Instance Method Summary collapse
-
#dataset ⇒ String
The ID or handle of the dataset to upload data for.
- #define_upload_options ⇒ Object
-
#execute! ⇒ Object
Upload the data.
-
#paths ⇒ Array<String>
A list of paths to upload.
Methods inherited from Chimps::Command
Constructor Details
This class inherits a constructor from Chimps::Command
Instance Attribute Details
#archive ⇒ Object (readonly)
The path to the archive
28 29 30 |
# File 'lib/chimps/commands/upload.rb', line 28 def archive @archive end |
#fmt ⇒ Object (readonly)
The data format to annotate the upload with.
Chimps will try to guess if this isn’t given.
33 34 35 |
# File 'lib/chimps/commands/upload.rb', line 33 def fmt @fmt end |
Instance Method Details
#dataset ⇒ String
The ID or handle of the dataset to upload data for.
38 39 40 41 |
# File 'lib/chimps/commands/upload.rb', line 38 def dataset raise CLIError.new("Must provide an ID or URL-escaped handle as the first argument") if argv.first.blank? argv.first end |
#define_upload_options ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/chimps/commands/upload.rb', line 51 def on_tail("-a", "--archive-path", "Path to the archive to be created. Defaults to a timestamped ZIP file named after the dataset in the current directory.") do |path| @archive = path end on_tail("-f", "--format FORMAT", "Data format to annotate upload with. Tries to guess if not given.") do |f| @fmt = f end end |