Class: Chimps::Commands::Test
- Inherits:
-
Chimps::Command
- Object
- Chimps::Command
- Chimps::Commands::Test
- Defined in:
- lib/chimps-cli/commands/test.rb
Constant Summary collapse
- USAGE =
"usage: chimps [OPTIONS] test"
- HELP =
<<EOF Print diagnostic information on the API credentials being used by chimps and send a test request to Infochimps to make sure the API credentials work. EOF
Instance Attribute Summary
Attributes inherited from Chimps::Command
Instance Method Summary collapse
Methods inherited from Chimps::Command
Constructor Details
This class inherits a constructor from Chimps::Command
Instance Method Details
#execute! ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/chimps-cli/commands/test.rb', line 14 def execute! dataset_response = Chimps::Request.new("/me", :sign => true).get query_response = Chimps::QueryRequest.new("soc/net/tw/trstrank", :query => {:screen_name => :infochimps}).get if dataset_response.error? puts "Could not authenticate with Infochimps Dataset API." else dataset_response.parse! username = dataset_response['user']['username'] puts "Authenticated as user '#{username}' for Infochimps Dataset API at http://www.infochimps.com" end if query_response.error? puts "Could not authenticate with Infochimps Query API." else puts "Authenticated for Infochimps Query API at http://api.infochimps.com" end end |