Class: Chimps::Commands::Download

Inherits:
Chimps::Command show all
Includes:
Utils::ActsOnResource
Defined in:
lib/chimps-cli/commands/download.rb

Overview

A command to download data from Infochimps.

Constant Summary collapse

USAGE =
"usage: chimps download [OPTIONS] ID_OR_HANDLE"
HELP =
<<EOF

Download a dataset identified by the given ID_OR_HANDLE.

If the dataset isn't free, you'll have to have purchased it first on
Infochimps.

Examples:

  # download to the current directory
  $ chimps download my-awesome-dataset

  # download to /tmp directory
  $ chimps download my-awesome-dataset --output=/tmp

  # save as ~/data.tar.gz (dangerous if you change the extension!)
  $ chimps download my-awesome-dataset --output=~/data.tar.gz
EOF

Instance Attribute Summary

Attributes inherited from Chimps::Command

#config

Instance Method Summary collapse

Methods included from Utils::ActsOnResource

#first_arg_is_resource_type?, #has_resource_identifier?, included, #plural_resource, #resource_identifier, #resource_path, #resource_type, #resources_path

Methods inherited from Chimps::Command

#initialize, name, #name

Constructor Details

This class inherits a constructor from Chimps::Command

Instance Method Details

#execute!Object



33
34
35
# File 'lib/chimps-cli/commands/download.rb', line 33

def execute!
  Chimps::Download.new(resource_identifier).download(local_path)
end

#local_pathObject



29
30
31
# File 'lib/chimps-cli/commands/download.rb', line 29

def local_path
  config[:output].blank? ? Dir.pwd : File.expand_path(config[:output])
end