Class: Chimps::Commands::Create

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

Overview

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

Constant Summary collapse

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

Create a #{default_resource_type} using the properties and values supplied.

#{how_to_input_data}
#{resources_listing}

Examples:

  $ chimps create title='My Awesome Dataset' description="It is cool"
  $ chimps create source -d my_source.yml
EOF

Instance Attribute Summary

Attributes inherited from Chimps::Command

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::UsesParamValueData

#data, included

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

Class Method Details

.allowed_modelsObject



11
12
13
# File 'lib/chimps-cli/commands/create.rb', line 11

def self.allowed_models
  %w[dataset source license]
end

Instance Method Details

#execute!Object

Issue the POST request.



30
31
32
33
# File 'lib/chimps-cli/commands/create.rb', line 30

def execute!
  ensure_data_is_present!
  Request.new(resources_path, :body => { resource_type => data}, :sign => true).post.print(:yaml => true)
end