Module: Chimps

Defined in:
lib/chimps.rb,
lib/chimps/cli.rb,
lib/chimps/utils.rb,
lib/chimps/config.rb,
lib/chimps/request.rb,
lib/chimps/commands.rb,
lib/chimps/response.rb,
lib/chimps/utils/log.rb,
lib/chimps/workflows.rb,
lib/chimps/typewriter.rb,
lib/chimps/utils/error.rb,
lib/chimps/workflows/up.rb,
lib/chimps/commands/base.rb,
lib/chimps/commands/help.rb,
lib/chimps/commands/list.rb,
lib/chimps/commands/show.rb,
lib/chimps/commands/test.rb,
lib/chimps/commands/batch.rb,
lib/chimps/commands/query.rb,
lib/chimps/commands/create.rb,
lib/chimps/commands/search.rb,
lib/chimps/commands/update.rb,
lib/chimps/commands/upload.rb,
lib/chimps/utils/uses_curl.rb,
lib/chimps/workflows/batch.rb,
lib/chimps/commands/destroy.rb,
lib/chimps/utils/uses_model.rb,
lib/chimps/commands/download.rb,
lib/chimps/utils/uses_yaml_data.rb,
lib/chimps/workflows/downloader.rb,
lib/chimps/workflows/upload/token.rb,
lib/chimps/workflows/upload/bundler.rb,
lib/chimps/workflows/upload/notifier.rb,
lib/chimps/workflows/upload/uploader.rb

Overview

The Chimps module implements a Ruby-based command-line interface to the Infochimps data repository.

Using this tool you can search, download, edit, and upload data and metadata to and from Infochimps.

Defined Under Namespace

Modules: CLI, Commands, Config, Log, Utils, Workflows Classes: Command, QueryRequest, Request, Response, Typewriter

Constant Summary collapse

COMMAND_LINE_OPTIONS =

Options that can be overriden by the command-line.

{
  :identity_file    => File.expand_path(ENV["CHIMPS_RC"] || "~/.chimps"),
  # log_file -- will be specified on command line
  # verbose  -- will be specified on command line
}
CONFIG =

Default configuration for Chimps. User-specific configuration lives in a YAML file ~/.chimps.

{
  :query => {
    :host => ENV["CHIMPS_QUERY_HOST"] || 'http://api.infochimps.com'
  },
  :site => {
    :host => ENV["CHIMPS_HOST"]       || 'http://infochimps.org'
  },
  :timestamp_format => "%Y-%m-%d_%H-%M-%S",
  :plugins => ["/usr/local/share/chimps"]
}
Error =

Base exception class for Chimps. All Chimps exceptions are subclasses of Chimps::Error so they can be easily caught.

Class.new(StandardError)
CLIError =

Raised when the user provides bad input on the command line.

Class.new(Error)
AuthenticationError =

Raised when the user hasn’t specified any API credentials or the server rejects the user’s API credentials.

Roughly corresponds to HTTP status code 401.

Class.new(Error)
ServerError =

Raised when the Infochimps server response is unexpected or missing.

Roughly corresponds to HTTP status code 5xx.

Class.new(Error)
PackagingError =

Raised when IMW fails to properly package files to upload.

Class.new(Error)
UploadError =

Raised when there is an error in uploading to S3 or in notifiying Infochimps of the new package.

Class.new(Error)
NotImplementedError =

Raised when a subclass doesn’t fails to implement required methods.

Class.new(Error)
ParseError =

Raised when the response from Infochimps isn’t well-formed or is unexpected.

Class.new(Error)
PrintingError =

Raised when Chimps encounters response data it doesn’t know how to pretty print.

Class.new(Error)

Class Method Summary collapse

Class Method Details

.boot!Object

Load all configuration, load plugins, and resolve options.



4
5
6
7
8
# File 'lib/chimps/config.rb', line 4

def self.boot!
  Chimps::Config.load
  Chimps::Config.load_plugins
  Chimps::Config.resolve_options!
end

.logLogger

The Chimps logger. Set via Chimps::CONFIG and defaults to $stdout.

Returns:

  • (Logger)


7
8
9
# File 'lib/chimps/utils/log.rb', line 7

def self.log
  @log ||= Log.new_logger
end

.log=(new_log) ⇒ Object

Set the Chimps logger.

Parameters:

  • new_log (Logger)


14
15
16
# File 'lib/chimps/utils/log.rb', line 14

def self.log= new_log
  @log = new_log
end

.usernameString

The username Chimps will pass to Infochimps.

Returns:



40
41
42
# File 'lib/chimps/config.rb', line 40

def self.username
  CONFIG[:site][:username] or raise AuthenticationError.new("No site username set in #{Chimps::CONFIG[:identity_file]}")
end

.verbose?true, ...

Is Chimps in verbose mode?

Returns:

  • (true, false, nil)


33
34
35
# File 'lib/chimps/config.rb', line 33

def self.verbose?
  CONFIG[:verbose]
end