Class: Chimps::Commands::Create

Inherits:
Chimps::Command show all
Includes:
Utils::UsesModel, Utils::UsesYamlData
Defined in:
lib/chimps/commands/create.rb

Overview

A command to issue a POST requst to create a resource at Infochimps.

Constant Summary collapse

"usage: chimps create [OPTIONS] [PROP=VALUE] ..."
HELP =
<<EOF

Create a single resource (defaults to a dataset) using the properties
and values supplied.

Properties and values can be supplied directly on the command line,
from an input YAML file, or multiple YAML documents streamed in via
STDIN, in order of decreasing precedence.
EOF
MODELS =

Models this command applies to (default first)

%w[dataset source license]

Instance Attribute Summary

Attributes included from Utils::UsesYamlData

#data_file

Attributes inherited from Chimps::Command

#argv

Instance Method Summary collapse

Methods included from Utils::UsesYamlData

#data, #ignore_first_arg_on_command_line, #ignore_yaml_files_on_command_line

Methods included from Utils::UsesModel

#define_model_option, #model, #model=, #model_identifier, #model_path, #models_path, #models_string, #plural_model

Methods inherited from Chimps::Command

#initialize, name, #name

Constructor Details

This class inherits a constructor from Chimps::Command

Instance Method Details

#execute!Object

Issue the POST request.



25
26
27
28
# File 'lib/chimps/commands/create.rb', line 25

def execute!
  ensure_data_is_present!
  Request.new(models_path, :data => {model.to_sym => data } , :authenticate => true).post.print
end