chimps 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +37 -13
- data/VERSION +1 -1
- data/lib/chimps/request.rb +8 -3
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -28,7 +28,7 @@ Then you can install Chimps with
|
|
28
28
|
== API keys
|
29
29
|
|
30
30
|
You'll need an API key and secret from Infochimps before you can start
|
31
|
-
adding or modifying datasets via the
|
31
|
+
adding or modifying datasets via the Dataset API. {Sign up for an
|
32
32
|
Infochimps account}[http://infochimps.org/signup] and register for an
|
33
33
|
API key.
|
34
34
|
|
@@ -46,7 +46,6 @@ Once you've registered for the API(s) you'll need to put them in your
|
|
46
46
|
:query:
|
47
47
|
:username: monkeyboy
|
48
48
|
:key: xxxxxxxxxxxxxxxxx
|
49
|
-
:secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
50
49
|
|
51
50
|
= Usage
|
52
51
|
|
@@ -72,7 +71,7 @@ performing.
|
|
72
71
|
|
73
72
|
=== Testing
|
74
73
|
|
75
|
-
You can test whether or not you have access to the Infochimps
|
74
|
+
You can test whether or not you have access to the Infochimps Dataset API
|
76
75
|
with
|
77
76
|
|
78
77
|
chimps test
|
@@ -220,22 +219,47 @@ being made (to the same dataset)
|
|
220
219
|
You can also use Chimps in your own code to handle making requests of
|
221
220
|
Infochimps.
|
222
221
|
|
223
|
-
|
222
|
+
At present, Chimps' classes internally use the JSON API so you'll have
|
223
|
+
to as well -- support for the XML API will be coming soon...
|
224
|
+
|
225
|
+
=== Configuration Options
|
226
|
+
|
227
|
+
When invoked from the command-line, Chimps automatically reads
|
228
|
+
configuration files before executing requests. When used as a library
|
229
|
+
via
|
230
|
+
|
231
|
+
require 'rubygems'
|
232
|
+
require 'chimps'
|
233
|
+
|
234
|
+
Chimps will *NOT* read default configuration files. You can force it
|
235
|
+
to do so by calling
|
236
|
+
|
237
|
+
Chimps::Config.load
|
238
|
+
|
239
|
+
which will load from the configuration file defined in
|
240
|
+
Chimps::CONFIG[:identity_file]. You can alternatively set
|
241
|
+
configuration options directly in Chimps::CONFIG yourself (they should
|
242
|
+
match the structure of a <tt>~/.chimps</tt> file).
|
243
|
+
|
244
|
+
=== Using the Dataset API
|
245
|
+
|
246
|
+
You can find a complete list of Dataset API endpoints, expected
|
247
|
+
parameters, return codes, documentation, and authentication
|
248
|
+
requirements at http://infochimps.com/api.
|
224
249
|
|
225
|
-
The Chimps::Request class makes requests against the
|
226
|
-
a request by specifying a path on the Infochimps server (it
|
227
|
-
with <tt>.json</tt>).
|
250
|
+
The Chimps::Request class makes requests against the Dataset API.
|
251
|
+
Create a request by specifying a path on the Infochimps server (it
|
252
|
+
_must_ end with <tt>.json</tt> for now).
|
228
253
|
|
229
254
|
list_dataset_request = Chimps::Request.new('/datasets.json')
|
230
255
|
list_dataset_request.get
|
231
256
|
|
232
|
-
|
233
|
-
|
234
|
-
the arrangement of the <tt>~/.chimps</tt> configuration file) you can
|
235
|
-
simply ask the request to sign itself
|
257
|
+
Assuming you've properly configured Chimps (see above) you ask the
|
258
|
+
request to sign itself.
|
236
259
|
|
237
260
|
authenticated_list_datasets_request = Chimps::Request.new('/datasets.json', :authenticate => true)
|
238
261
|
|
262
|
+
(not necessary for a list datasets request, but you get the idea).
|
239
263
|
You can also pass in query params
|
240
264
|
|
241
265
|
authenticated_list_datasets_request_with_params = Chimps::Request.new('/datasets.json', :query_params => { :id => 'infochimps' }, :authenticate => true)
|
@@ -257,7 +281,7 @@ It works just the similarly to the Chimps::Request except that the
|
|
257
281
|
path supplied is the path to the corresponding dataset on the {Query
|
258
282
|
API}[http://api.infochimps.com].
|
259
283
|
|
260
|
-
All QueryRequests
|
284
|
+
All QueryRequests will automatically be signed.
|
261
285
|
|
262
286
|
authenticated_query_request = Chimps::QueryRequest.new('soc/net/tw/trstrank.json', :query_params => { :screen_name => 'infochimps' } )
|
263
287
|
authenticated_query_request.get
|
@@ -271,7 +295,7 @@ authorization tokens).
|
|
271
295
|
|
272
296
|
The three workflows implemented so far include
|
273
297
|
|
274
|
-
- Chimps::Workflows::
|
298
|
+
- Chimps::Workflows::Up
|
275
299
|
- Chimps::Workflows::Downloader
|
276
300
|
- Chimps::Workflows::BatchUpdater
|
277
301
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.7
|
data/lib/chimps/request.rb
CHANGED
@@ -250,7 +250,7 @@ module Chimps
|
|
250
250
|
#
|
251
251
|
# @return [true, false]
|
252
252
|
def authenticable?
|
253
|
-
!Chimps::CONFIG[:query][:key].blank?
|
253
|
+
!Chimps::CONFIG[:query][:key].blank?
|
254
254
|
end
|
255
255
|
|
256
256
|
# The host to send requests to.
|
@@ -260,6 +260,13 @@ module Chimps
|
|
260
260
|
@host ||= Chimps::CONFIG[:query][:host]
|
261
261
|
end
|
262
262
|
|
263
|
+
# All Query API requests must be signed.
|
264
|
+
#
|
265
|
+
# @return [true]
|
266
|
+
def authenticate?
|
267
|
+
return true
|
268
|
+
end
|
269
|
+
|
263
270
|
# Authenticate this request by stuffing the <tt>:requested_at</tt>
|
264
271
|
# and <tt>:apikey</tt> properties into its <tt>:query_params</tt>
|
265
272
|
# hash.
|
@@ -296,8 +303,6 @@ module Chimps
|
|
296
303
|
unsigned_query_string
|
297
304
|
end
|
298
305
|
|
299
|
-
|
300
|
-
|
301
306
|
end
|
302
307
|
|
303
308
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chimps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dhruv Bansal
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-06-
|
12
|
+
date: 2010-06-18 00:00:00 -05:00
|
13
13
|
default_executable: chimps
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|