chimps 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -1
- data/Gemfile.lock +8 -2
- data/README.rdoc +20 -19
- data/Rakefile +2 -22
- data/VERSION +1 -1
- data/examples/browse.rb +82 -0
- data/examples/create_dataset.rb +11 -0
- data/lib/chimps/config.rb +4 -11
- data/lib/chimps/request.rb +6 -6
- data/lib/chimps/response.rb +16 -33
- data/lib/chimps/utils.rb +0 -1
- data/lib/chimps/workflows/download.rb +2 -0
- data/lib/chimps.rb +2 -1
- data/spec/chimps/request_spec.rb +6 -6
- metadata +7 -5
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,13 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
chimps (0.3.3)
|
5
|
+
|
1
6
|
GEM
|
2
7
|
remote: http://rubygems.org/
|
3
8
|
specs:
|
4
|
-
addressable (2.2.
|
5
|
-
configliere (0.3.
|
9
|
+
addressable (2.2.5)
|
10
|
+
configliere (0.3.4)
|
6
11
|
diff-lcs (1.1.2)
|
7
12
|
json (1.4.6)
|
8
13
|
mime-types (1.16)
|
@@ -22,6 +27,7 @@ PLATFORMS
|
|
22
27
|
|
23
28
|
DEPENDENCIES
|
24
29
|
addressable
|
30
|
+
chimps!
|
25
31
|
configliere (>= 0.3.2)
|
26
32
|
json (= 1.4.6)
|
27
33
|
rest-client (>= 1.6.1)
|
data/README.rdoc
CHANGED
@@ -5,7 +5,7 @@ and repository where anyone can find, share, and sell data.
|
|
5
5
|
|
6
6
|
Infochimps offers two APIs for users to access and modify data
|
7
7
|
|
8
|
-
- a {
|
8
|
+
- a {Catalog API}[http://www.infochimps.com/catalog-api] to list, show, create, update, and destroy datasets and associated resources on Infochimps[http://www.infochimps.com]
|
9
9
|
- a {Query API}[http://www.infochimps.com/apis] to query data from particular rows of these datasets
|
10
10
|
|
11
11
|
*Chimps* is a Ruby library that makes interacting with Infochimps' APIs as easy as
|
@@ -15,8 +15,8 @@ Infochimps offers two APIs for users to access and modify data
|
|
15
15
|
|
16
16
|
# Sign up for an Infochimps account and get your keys from
|
17
17
|
# http://www.infochimps.com/me
|
18
|
-
Chimps.config[:
|
19
|
-
Chimps.config[:
|
18
|
+
Chimps.config[:catalog][:key] = "Your Catalog API key"
|
19
|
+
Chimps.config[:catalog][:secret] = "Your Catalog API secret"
|
20
20
|
|
21
21
|
# list datasets in JSON
|
22
22
|
Chimps::Request.new("/datasets").get.print
|
@@ -50,7 +50,7 @@ Then you can install Chimps with
|
|
50
50
|
You'll need a Dataset API key and secret from Infochimps before you
|
51
51
|
can start adding or modifying datasets via the Dataset API. {Sign up
|
52
52
|
for an Infochimps account}[http://www.infochimps.com/signup] and get
|
53
|
-
your {
|
53
|
+
your {Catalog API key}[http://www.infochimps.com/me].
|
54
54
|
|
55
55
|
To query particular rows from a dataset, you'll also need to get a
|
56
56
|
{Query API key}[http://www.infochimps.com/apis].
|
@@ -67,7 +67,7 @@ configuration file looks like
|
|
67
67
|
|
68
68
|
# -*-yaml-*-
|
69
69
|
# ~/.chimps
|
70
|
-
:
|
70
|
+
:catalog:
|
71
71
|
:key: xxxxxxxxxxxxxxxx
|
72
72
|
:secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
73
73
|
:query:
|
@@ -89,23 +89,23 @@ when you require it:
|
|
89
89
|
|
90
90
|
= Making Requests
|
91
91
|
|
92
|
-
==
|
92
|
+
== Catalog API
|
93
93
|
|
94
|
-
You can use the {
|
95
|
-
search, list, show, create, update, or destroy datasets and other
|
94
|
+
You can use the {Catalog API}[http://www.infochimps.com/catalog-api]
|
95
|
+
to search, list, show, create, update, or destroy datasets and other
|
96
96
|
resources at Infochimps.
|
97
97
|
|
98
98
|
If instead of _creating_ a dataset with 100,000 baby names you want to
|
99
99
|
_query_ a dataset of 100,000 baby names then you should skip down to
|
100
100
|
the Query API section below.
|
101
101
|
|
102
|
-
You can find a complete list of
|
102
|
+
You can find a complete list of Catalog API endpoints, expected
|
103
103
|
parameters, return codes, documentation, and authentication
|
104
|
-
requirements at http://www.infochimps.com/
|
104
|
+
requirements at http://www.infochimps.com/catalog-api.
|
105
105
|
|
106
106
|
=== A Simple +GET+ Request
|
107
107
|
|
108
|
-
The <tt>Chimps::Request</tt> class makes requests against the
|
108
|
+
The <tt>Chimps::Request</tt> class makes requests against the Catalog
|
109
109
|
API. Create a request by specifying a path on the Infochimps server.
|
110
110
|
The extension of the path determines the MIME type that Infochimps
|
111
111
|
will respond with:
|
@@ -137,12 +137,13 @@ look inside:
|
|
137
137
|
|
138
138
|
=== A Signed +GET+ Request
|
139
139
|
|
140
|
-
Many
|
140
|
+
Many Catalog API calls at Infochimps (like listing datasets, above) do
|
141
141
|
not require the request to be signed in any way. Other requests,
|
142
142
|
which reveal your private information or create new datasets, &c. on
|
143
|
-
Infochimps will require your
|
144
|
-
a full list of the
|
145
|
-
requests to each need to be signed at
|
143
|
+
Infochimps will require your Catalog API secret to sign. You can see
|
144
|
+
a full list of the Catalog API endpoints available and whether or not
|
145
|
+
requests to each need to be signed at
|
146
|
+
http://www.infochimps.com/catalog-api.
|
146
147
|
|
147
148
|
Assuming you've properly configured Chimps (see above) you ask the
|
148
149
|
request to sign itself.
|
@@ -153,7 +154,7 @@ request to sign itself.
|
|
153
154
|
response.print
|
154
155
|
# lotsa JSON...but only about *your* datasets
|
155
156
|
|
156
|
-
The authentication mechanism uses the
|
157
|
+
The authentication mechanism uses the Catalog API secret (which is
|
157
158
|
shared between you and Infochimps) to sign either the query string
|
158
159
|
(for the case of +GET+ and +DELETE+ requests) or the request body (for
|
159
160
|
+POST+ and +PUT+ requests).
|
@@ -173,9 +174,9 @@ Here's how to you might create a new dataset via a +POST+ request:
|
|
173
174
|
response.parse!
|
174
175
|
response['dataset']['id'] #=> 20876
|
175
176
|
|
176
|
-
You can find a complete list of what
|
177
|
+
You can find a complete list of what Catalog API endpoints are
|
177
178
|
available and what parameters they take at
|
178
|
-
http://www.infochimps.com/
|
179
|
+
http://www.infochimps.com/catalog-api.
|
179
180
|
|
180
181
|
=== Using the Query API
|
181
182
|
|
@@ -212,7 +213,7 @@ through the Infochimps website.
|
|
212
213
|
= Contributing
|
213
214
|
|
214
215
|
Chimps is an open source project created by the Infochimps team to
|
215
|
-
encourage adoption of Infochimps'
|
216
|
+
encourage adoption of Infochimps' Catalog & Query APIs. The official
|
216
217
|
repository is hosted on GitHub
|
217
218
|
|
218
219
|
http://github.com/infochimps/chimps
|
data/Rakefile
CHANGED
@@ -1,25 +1,5 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
3
|
|
4
|
-
begin
|
5
|
-
# http://github.com/technicalpickles/jeweler
|
6
|
-
require 'jeweler'
|
7
|
-
Jeweler::Tasks.new do |gem|
|
8
|
-
gem.name = "chimps"
|
9
|
-
gem.summary = "Chimps is a Ruby interface for the Infochimps Dataset & Query APIs (http://www.infochimps.com/api)"
|
10
|
-
gem.description = "Chimps allows you to easily make API calls against Infochimps web services. Chimps!'s Request and Response classes take care of all the details so you can remain calm and RESTful."
|
11
|
-
gem.email = "coders@infochimps.com"
|
12
|
-
gem.homepage = "http://github.com/infochimps/chimps"
|
13
|
-
gem.authors = ["Dhruv Bansal"]
|
14
|
-
gem.files.exclude "old/**/*"
|
15
|
-
end
|
16
|
-
Jeweler::GemcutterTasks.new
|
17
|
-
rescue LoadError
|
18
|
-
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
|
-
end
|
20
4
|
|
21
|
-
desc "Build tags"
|
22
|
-
task :tags do
|
23
|
-
system "etags -R README.rdoc examples lib spec"
|
24
|
-
end
|
25
5
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
data/examples/browse.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# Here are some examples of how to search, list, and show information
|
2
|
+
# about datasets on Infochimps.
|
3
|
+
#
|
4
|
+
# All the Catalog API calls utilized in this file are documented at
|
5
|
+
#
|
6
|
+
# http://www.infochimps.com/catalog-api
|
7
|
+
#
|
8
|
+
# None of the examples in this file require authentication with
|
9
|
+
# Infochimps so there's no need to configure Chimps in any way or to
|
10
|
+
# even have an Infochimps account.
|
11
|
+
#
|
12
|
+
# Other examples which modify data in the Infochimps Catalog will
|
13
|
+
# require you to have an Infochimps account and to properly configure
|
14
|
+
# Chimps to use it.
|
15
|
+
|
16
|
+
require 'rubygems'
|
17
|
+
$:.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
|
18
|
+
require 'chimps'
|
19
|
+
|
20
|
+
# Say we wanted to find a list of sources who have contributed
|
21
|
+
# downloadable music datasets to Infochimps.
|
22
|
+
#
|
23
|
+
# We'll do this by searching for datasets about 'music' and examining
|
24
|
+
# each one to find its source (there are other ways to do this ;).
|
25
|
+
#
|
26
|
+
# The first call we'll need to make is the search. This is documented
|
27
|
+
# at
|
28
|
+
#
|
29
|
+
# http://www.infochimps.com/catalog-api#search
|
30
|
+
request = Chimps::Request.new('/search', :query_params => { :query => 'music', :dataset_type => 'download' })
|
31
|
+
|
32
|
+
# We can see the URL that's generated for this query:
|
33
|
+
puts "URL for search of downloadable music datasets:"
|
34
|
+
puts request.url_with_query_string
|
35
|
+
|
36
|
+
# Let's run the query by sending off an HTTP GET request.
|
37
|
+
puts "\nSending GET request"
|
38
|
+
response = request.get
|
39
|
+
|
40
|
+
# The response knows about its HTTP response code and its headers
|
41
|
+
puts "\nReceived a #{response.code} response with the following headers"
|
42
|
+
p response.headers
|
43
|
+
|
44
|
+
# The response has a raw body but we can also parse it.
|
45
|
+
response.parse
|
46
|
+
puts "\nThere were #{response.size} results:"
|
47
|
+
|
48
|
+
# Lets print the titles of each of the datasets. This works because
|
49
|
+
# we just parsed the response above.
|
50
|
+
response.each do |result|
|
51
|
+
dataset = result['dataset']
|
52
|
+
puts ""
|
53
|
+
puts dataset['title']
|
54
|
+
if dataset['sources'] && (!dataset['sources'].empty?)
|
55
|
+
dataset['sources'].each do |source|
|
56
|
+
puts " Source: " + source['title']
|
57
|
+
end
|
58
|
+
else
|
59
|
+
puts " No sources."
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Let's look a little deeper at the first result.
|
64
|
+
puts("No results!") && exit(1) if response.empty?
|
65
|
+
dataset = response.first['dataset']
|
66
|
+
|
67
|
+
# Let's get more detail about this dataset. This uses the "Show
|
68
|
+
# Dataset" API documented at
|
69
|
+
#
|
70
|
+
# http://www.infochimps.com/catalog-api#dataset_show
|
71
|
+
id = dataset['cached_slug'] # we can also use ID here
|
72
|
+
dataset_request = Chimps::Request.new("/datasets/#{id}")
|
73
|
+
|
74
|
+
# Let's run this next query
|
75
|
+
puts "\n\nURL for details on dataset #{id}"
|
76
|
+
puts dataset_request.url_with_query_string
|
77
|
+
puts "\nSending GET request"
|
78
|
+
dataset_response = dataset_request.get
|
79
|
+
|
80
|
+
# Let's just print the body of the response this time.
|
81
|
+
puts ""
|
82
|
+
puts dataset_response.body
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Chimps needs a little configuring to enable authentication with
|
2
|
+
# Infochimps. If you have a ~/.chimps file then you can make Chimps
|
3
|
+
# read it like this:
|
4
|
+
Chimps.boot!
|
5
|
+
|
6
|
+
# You could also explicitly set the minimum required configuration
|
7
|
+
# directly:
|
8
|
+
#
|
9
|
+
# Chimps.config[:catalog][:key] = "YOUR CATALOG API KEY"
|
10
|
+
# Chimps.config[:catalog][:secret] = "YOUR CATALOG API SECRET"
|
11
|
+
# Chimps.config[:query][:key] = "YOUR QUERY API KEY"
|
data/lib/chimps/config.rb
CHANGED
@@ -25,10 +25,10 @@ module Chimps
|
|
25
25
|
config.define 'query.host', :description => "Host to send Query API requests to", :type => String, :default => "http://api.infochimps.com", :no_help => true, :env_var => "APEYEYE", :no_help => true
|
26
26
|
config.define 'query.key', :description => "API key for the Query API", :type => String, :no_help => true
|
27
27
|
|
28
|
-
config.define '
|
29
|
-
config.define '
|
30
|
-
config.define '
|
31
|
-
config.define '
|
28
|
+
config.define 'catalog.username', :description => "Your Infochimps username", :type => String
|
29
|
+
config.define 'catalog.host', :description => "Host to send Catalog API requests to", :type => String, :default => "http://www.infochimps.com", :env_var => "GEORGE", :no_help => true
|
30
|
+
config.define 'catalog.key', :description => "API key for the Catalog API", :type => String
|
31
|
+
config.define 'catalog.secret', :description => "API secret for the Catalog API", :type => String
|
32
32
|
end
|
33
33
|
define_config
|
34
34
|
|
@@ -39,13 +39,6 @@ module Chimps
|
|
39
39
|
config[:verbose]
|
40
40
|
end
|
41
41
|
|
42
|
-
# The username Chimps will pass to Infochimps.
|
43
|
-
#
|
44
|
-
# @return [String]
|
45
|
-
def self.username
|
46
|
-
config[:dataset][:username] or raise AuthenticationError.new("No Dataset API username set in #{Chimps.config[:config]} or #{Chimps.config[:site_config]}")
|
47
|
-
end
|
48
|
-
|
49
42
|
# The current Chimps library version.
|
50
43
|
#
|
51
44
|
# @return [String]
|
data/lib/chimps/request.rb
CHANGED
@@ -102,7 +102,7 @@ module Chimps
|
|
102
102
|
#
|
103
103
|
# @return [true, false]
|
104
104
|
def authenticable?
|
105
|
-
!Chimps.config[:
|
105
|
+
!Chimps.config[:catalog][:key].blank? && !Chimps.config[:catalog][:secret].blank?
|
106
106
|
end
|
107
107
|
alias_method :signable?, :authenticable?
|
108
108
|
|
@@ -110,7 +110,7 @@ module Chimps
|
|
110
110
|
#
|
111
111
|
# @return [String]
|
112
112
|
def host
|
113
|
-
@host ||= Chimps.config[:
|
113
|
+
@host ||= Chimps.config[:catalog][:host]
|
114
114
|
end
|
115
115
|
|
116
116
|
# Return the base URL for this request, consisting of the host and
|
@@ -203,9 +203,9 @@ module Chimps
|
|
203
203
|
# false.
|
204
204
|
def authenticate_if_necessary!
|
205
205
|
return unless authenticate? && should_encode?
|
206
|
-
raise Chimps::AuthenticationError.new("
|
206
|
+
raise Chimps::AuthenticationError.new("Catalog API key (Chimps.config[:catalog][:key]) or secret (Chimps.config[:catalog][:secret]) missing from #{Chimps.config[:config]} or #{Chimps.config[:site_config]}") unless (authenticable? || @forgive_authentication_error)
|
207
207
|
query_params[:requested_at] = Time.now.to_i.to_s
|
208
|
-
query_params[:apikey] = Chimps.config[:
|
208
|
+
query_params[:apikey] = Chimps.config[:catalog][:key]
|
209
209
|
end
|
210
210
|
|
211
211
|
# Return an unsigned query string for this request.
|
@@ -246,9 +246,9 @@ module Chimps
|
|
246
246
|
# @param [String]
|
247
247
|
# @return [String]
|
248
248
|
def sign string
|
249
|
-
raise Chimps::AuthenticationError.new("No API secret stored in #{Chimps.config[:config]} or #{Chimps.config[:site_config]}.") unless (authenticable? || @forgive_authentication_error)
|
249
|
+
raise Chimps::AuthenticationError.new("No Catalog API secret stored in #{Chimps.config[:config]} or #{Chimps.config[:site_config]}. Set Chimps.config[:catalog][:secret].") unless (authenticable? || @forgive_authentication_error)
|
250
250
|
require 'digest/md5'
|
251
|
-
Digest::MD5.hexdigest(string + Chimps.config[:
|
251
|
+
Digest::MD5.hexdigest(string + Chimps.config[:catalog][:secret])
|
252
252
|
end
|
253
253
|
|
254
254
|
# Append the signature to the unsigned query string.
|
data/lib/chimps/response.rb
CHANGED
@@ -4,11 +4,14 @@ require 'json'
|
|
4
4
|
module Chimps
|
5
5
|
|
6
6
|
# A class to wrap responses from the Infochimps API.
|
7
|
-
class Response
|
7
|
+
class Response
|
8
8
|
|
9
9
|
# The response body.
|
10
10
|
attr_reader :body
|
11
11
|
|
12
|
+
# The parsed data of the body
|
13
|
+
attr_reader :data
|
14
|
+
|
12
15
|
# The error message for this response, if it was an error.
|
13
16
|
#
|
14
17
|
# This is actually generated within RestClient from the HTTP
|
@@ -16,8 +19,7 @@ module Chimps
|
|
16
19
|
# initializing a Chimps::Response by a Chimps::Request.
|
17
20
|
attr_reader :error
|
18
21
|
|
19
|
-
# Return a
|
20
|
-
# RestClient::Response module mixed-in.
|
22
|
+
# Return a Response from the +body+.
|
21
23
|
#
|
22
24
|
# If <tt>:error</tt> is passed then this response is is considered
|
23
25
|
# an error with the given message.
|
@@ -27,7 +29,6 @@ module Chimps
|
|
27
29
|
# @option options [String] error the error message
|
28
30
|
# @return [Chimps::Response]
|
29
31
|
def initialize body, options={}
|
30
|
-
super()
|
31
32
|
@body = body
|
32
33
|
@error = options[:error]
|
33
34
|
end
|
@@ -64,15 +65,7 @@ module Chimps
|
|
64
65
|
#
|
65
66
|
# @return [Chimps::Response]
|
66
67
|
def parse!
|
67
|
-
data
|
68
|
-
case data
|
69
|
-
# hack...sometimes we get back an array instead of a
|
70
|
-
# hash...should change the API at Chimps end
|
71
|
-
when Hash then merge!(data)
|
72
|
-
when Array then self[:array] = data
|
73
|
-
when String then self[:string] = data
|
74
|
-
else nil
|
75
|
-
end
|
68
|
+
@data = parse_response_body
|
76
69
|
@parsed = true
|
77
70
|
self
|
78
71
|
end
|
@@ -98,20 +91,6 @@ module Chimps
|
|
98
91
|
!! @error
|
99
92
|
end
|
100
93
|
|
101
|
-
# Return a new Hash consisting of the data from this response.
|
102
|
-
#
|
103
|
-
# FIXME This is used when pretty printing -- though it shouldn't
|
104
|
-
# be necessary.
|
105
|
-
#
|
106
|
-
# @return [Hash]
|
107
|
-
def data
|
108
|
-
{}.tap do |d|
|
109
|
-
each_pair do |key, value|
|
110
|
-
d[key] = value
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
94
|
# Print this response.
|
116
95
|
#
|
117
96
|
# @param [Hash] options
|
@@ -121,23 +100,23 @@ module Chimps
|
|
121
100
|
output = (options[:to] || $stdout)
|
122
101
|
if error?
|
123
102
|
parse!
|
124
|
-
output.puts
|
125
|
-
output.puts
|
103
|
+
output.puts data['errors'] if data['errors']
|
104
|
+
output.puts data['message'] if data['message']
|
126
105
|
else
|
127
106
|
case
|
128
107
|
when options[:yaml]
|
129
108
|
parse!
|
130
|
-
output.puts
|
109
|
+
output.puts data.to_yaml
|
131
110
|
when options[:json] && options[:pretty]
|
132
111
|
parse!
|
133
112
|
if options[:pretty]
|
134
|
-
output.puts JSON.pretty_generate(
|
113
|
+
output.puts JSON.pretty_generate(data)
|
135
114
|
else
|
136
|
-
output.puts
|
115
|
+
output.puts data.to_json
|
137
116
|
end
|
138
117
|
when headers[:content_type] =~ /json/i && options[:pretty]
|
139
118
|
parse!
|
140
|
-
output.puts JSON.pretty_generate(
|
119
|
+
output.puts JSON.pretty_generate(data)
|
141
120
|
when headers[:content_type] =~ /tab/i && options[:pretty]
|
142
121
|
Utils::Typewriter.new(self).print
|
143
122
|
else
|
@@ -153,6 +132,10 @@ module Chimps
|
|
153
132
|
end
|
154
133
|
end
|
155
134
|
|
135
|
+
def method_missing name, *args, &block
|
136
|
+
data.send(name, *args, &block)
|
137
|
+
end
|
138
|
+
|
156
139
|
protected
|
157
140
|
|
158
141
|
# Construct and return a line of diagnostic information on this
|
data/lib/chimps/utils.rb
CHANGED
data/lib/chimps.rb
CHANGED
@@ -21,8 +21,9 @@ module Chimps
|
|
21
21
|
def self.boot!
|
22
22
|
config.read config[:site_config] if config[:site_config] && File.exist?(config[:site_config])
|
23
23
|
config.read config[:config] if config[:config] && File.exist?(config[:config])
|
24
|
+
config[:catalog] = config[:site] if (! config[:catalog]) && config[:site] # backwards compatibility
|
25
|
+
config[:catalog] = config[:dataset] if (! config[:catalog]) && config[:dataset] # backwards compatibility
|
24
26
|
config.resolve!
|
25
|
-
config[:dataset] = config[:site] if (! config[:dataset]) && config[:site] # backwards compatibility
|
26
27
|
true
|
27
28
|
end
|
28
29
|
|
data/spec/chimps/request_spec.rb
CHANGED
@@ -3,9 +3,9 @@ require File.expand_path('../spec_helper', File.dirname(__FILE__))
|
|
3
3
|
describe Chimps::Request do
|
4
4
|
|
5
5
|
before do
|
6
|
-
Chimps.config[:
|
7
|
-
Chimps.config[:
|
8
|
-
Chimps.config[:
|
6
|
+
Chimps.config[:catalog][:host] = 'http://foobar.com'
|
7
|
+
Chimps.config[:catalog][:key] = 'spec_key'
|
8
|
+
Chimps.config[:catalog][:secret] = 'secret'
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "generating the base URL with query string" do
|
@@ -38,12 +38,12 @@ describe Chimps::Request do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should raise an error if asked to sign and no credentials are available" do
|
41
|
-
Chimps.config[:
|
41
|
+
Chimps.config[:catalog][:key] = nil
|
42
42
|
lambda { Chimps::Request.new('/path/to/something', :sign => true).query_string }.should raise_error(Chimps::AuthenticationError)
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should not raise an error if asked to sign_if_possible and no credentials are avialable" do
|
46
|
-
Chimps.config[:
|
46
|
+
Chimps.config[:catalog][:key] = nil
|
47
47
|
lambda { Chimps::Request.new('/path/to/something', :sign_if_possible => true).query_string }.should_not raise_error(Chimps::AuthenticationError)
|
48
48
|
end
|
49
49
|
|
@@ -79,7 +79,7 @@ describe Chimps::Request do
|
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should swallow application-level errors" do
|
82
|
-
Chimps.config[:
|
82
|
+
Chimps.config[:catalog][:host] = 'http://www.infochimps.com'
|
83
83
|
Chimps::Request.new('/some/made/up/path').get.code.should == 404
|
84
84
|
end
|
85
85
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chimps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 4
|
10
|
+
version: 0.3.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dhruv Bansal
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-04-12 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -37,6 +37,8 @@ files:
|
|
37
37
|
- Rakefile
|
38
38
|
- VERSION
|
39
39
|
- examples/batch.yaml
|
40
|
+
- examples/browse.rb
|
41
|
+
- examples/create_dataset.rb
|
40
42
|
- examples/query.yaml
|
41
43
|
- lib/chimps.rb
|
42
44
|
- lib/chimps/config.rb
|
@@ -89,7 +91,7 @@ rubyforge_project:
|
|
89
91
|
rubygems_version: 1.3.7
|
90
92
|
signing_key:
|
91
93
|
specification_version: 3
|
92
|
-
summary: Chimps is a Ruby interface for the Infochimps
|
94
|
+
summary: Chimps is a Ruby interface for the Infochimps Catalog & Query APIs (http://www.infochimps.com/apis)
|
93
95
|
test_files:
|
94
96
|
- spec/chimps/query_request_spec.rb
|
95
97
|
- spec/chimps/request_spec.rb
|