chimps 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/Gemfile +0 -9
- data/VERSION +1 -1
- data/chimps.gemspec +26 -0
- data/examples/query.rb +65 -0
- data/examples/twitter_screen_names.txt +7 -0
- data/lib/chimps.rb +0 -2
- metadata +83 -8
- data/Gemfile.lock +0 -34
- data/examples/batch.yaml +0 -69
- data/examples/query.yaml +0 -11
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,12 +1,3 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
source :gemcutter
|
3
|
-
gem "json", "1.4.6"
|
4
|
-
gem "configliere", ">= 0.3.2"
|
5
|
-
gem 'rest-client', '>= 1.6.1', :require => 'restclient'
|
6
|
-
gem 'addressable', :require => 'addressable/uri'
|
7
|
-
|
8
|
-
group :development do
|
9
|
-
gem "rspec"
|
10
|
-
end
|
11
|
-
|
12
3
|
gemspec
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
data/chimps.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$:.unshift(lib) unless $:.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "chimps"
|
7
|
+
s.version = File.read(File.expand_path("../VERSION", __FILE__))
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Dhruv Bansal"]
|
10
|
+
s.email = ["coders@infochimps.com"]
|
11
|
+
s.homepage = "http://github.com/infochimps/chimps"
|
12
|
+
s.summary = "Chimps is a Ruby interface for the Infochimps Catalog & Query APIs (http://www.infochimps.com/apis)"
|
13
|
+
s.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."
|
14
|
+
s.extra_rdoc_files = ["README.rdoc"]
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_dependency "json"
|
20
|
+
s.add_dependency "configliere", ">= 0.3.2"
|
21
|
+
s.add_dependency "rest-client", ">= 1.6.1"
|
22
|
+
s.add_dependency "addressable"
|
23
|
+
|
24
|
+
s.add_development_dependency "rspec", ">= 2.0.0"
|
25
|
+
end
|
26
|
+
|
data/examples/query.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# This file has some examples that show you how to use Chimps to
|
2
|
+
# access the Infochimps Query API.
|
3
|
+
#
|
4
|
+
# For these exmaples to work you'll need to have signed up for an
|
5
|
+
# account on Infochimps
|
6
|
+
#
|
7
|
+
# http://www.infochimps.com/signup
|
8
|
+
#
|
9
|
+
# and obtain your Query API key from your profile
|
10
|
+
#
|
11
|
+
# http://www.infochimps.com/me
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
$:.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
|
15
|
+
require 'chimps'
|
16
|
+
|
17
|
+
# Assuming you've properly set up your ~/.chimps configuration file
|
18
|
+
# (see the README), have Chimps read it by running:
|
19
|
+
Chimps.boot!
|
20
|
+
|
21
|
+
# Alternatively, you can just directly specify your key and skip the
|
22
|
+
# boot with
|
23
|
+
#
|
24
|
+
# Chimps.config[:query][:key] = "YOUR QUERY API KEY"
|
25
|
+
|
26
|
+
# Say we to sort our friends by their Infochimps TrstRank score. The
|
27
|
+
# TrstRank dataset we're querying is available at
|
28
|
+
#
|
29
|
+
# http://www.infochimps.com/datasets/twitter-census-trst-rank
|
30
|
+
|
31
|
+
# First lets find our friends.
|
32
|
+
screen_names = File.read(File.dirname(__FILE__) + '/twitter_screen_names.txt').split("\n")
|
33
|
+
puts "Going to sort these Twitter users by TrstRank:"
|
34
|
+
screen_names.each { |screen_name| puts " " + screen_name }
|
35
|
+
|
36
|
+
# Now we make a TrstRank Query API request for each of them.
|
37
|
+
trstranks = {}
|
38
|
+
puts "\nMaking requests"
|
39
|
+
screen_names.each do |screen_name|
|
40
|
+
request = Chimps::QueryRequest.new("/soc/net/tw/trstrank", :query_params => { :screen_name => screen_name })
|
41
|
+
|
42
|
+
# We can see the signed URL for each request
|
43
|
+
puts request.url_with_query_string
|
44
|
+
|
45
|
+
# And now let's run the request
|
46
|
+
response = request.get
|
47
|
+
|
48
|
+
# We can print the raw body
|
49
|
+
puts response.body
|
50
|
+
|
51
|
+
# But we can also parse the response to extract its content.
|
52
|
+
response.parse
|
53
|
+
|
54
|
+
trstranks[screen_name] = response['trstrank']
|
55
|
+
end
|
56
|
+
|
57
|
+
# Now let's sort our friends by TrstRank and print them out.
|
58
|
+
puts "\nSorted by TrstRank"
|
59
|
+
trstranks.sort { |a,b| a[1] <=> b[1] }.each do |screen_name, trstrank|
|
60
|
+
puts " #{screen_name}: #{trstrank}"
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
data/lib/chimps.rb
CHANGED
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: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 5
|
10
|
+
version: 0.3.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dhruv Bansal
|
@@ -17,8 +17,83 @@ cert_chain: []
|
|
17
17
|
|
18
18
|
date: 2011-04-12 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: json
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: configliere
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 23
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
- 3
|
47
|
+
- 2
|
48
|
+
version: 0.3.2
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: rest-client
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 13
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 6
|
63
|
+
- 1
|
64
|
+
version: 1.6.1
|
65
|
+
type: :runtime
|
66
|
+
version_requirements: *id003
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: addressable
|
69
|
+
prerelease: false
|
70
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 3
|
76
|
+
segments:
|
77
|
+
- 0
|
78
|
+
version: "0"
|
79
|
+
type: :runtime
|
80
|
+
version_requirements: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: rspec
|
83
|
+
prerelease: false
|
84
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
hash: 15
|
90
|
+
segments:
|
91
|
+
- 2
|
92
|
+
- 0
|
93
|
+
- 0
|
94
|
+
version: 2.0.0
|
95
|
+
type: :development
|
96
|
+
version_requirements: *id005
|
22
97
|
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.
|
23
98
|
email:
|
24
99
|
- coders@infochimps.com
|
@@ -31,15 +106,15 @@ extra_rdoc_files:
|
|
31
106
|
files:
|
32
107
|
- .gitignore
|
33
108
|
- Gemfile
|
34
|
-
- Gemfile.lock
|
35
109
|
- LICENSE
|
36
110
|
- README.rdoc
|
37
111
|
- Rakefile
|
38
112
|
- VERSION
|
39
|
-
-
|
113
|
+
- chimps.gemspec
|
40
114
|
- examples/browse.rb
|
41
115
|
- examples/create_dataset.rb
|
42
|
-
- examples/query.
|
116
|
+
- examples/query.rb
|
117
|
+
- examples/twitter_screen_names.txt
|
43
118
|
- lib/chimps.rb
|
44
119
|
- lib/chimps/config.rb
|
45
120
|
- lib/chimps/error.rb
|
data/Gemfile.lock
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
chimps (0.3.3)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: http://rubygems.org/
|
8
|
-
specs:
|
9
|
-
addressable (2.2.5)
|
10
|
-
configliere (0.3.4)
|
11
|
-
diff-lcs (1.1.2)
|
12
|
-
json (1.4.6)
|
13
|
-
mime-types (1.16)
|
14
|
-
rest-client (1.6.1)
|
15
|
-
mime-types (>= 1.16)
|
16
|
-
rspec (2.5.0)
|
17
|
-
rspec-core (~> 2.5.0)
|
18
|
-
rspec-expectations (~> 2.5.0)
|
19
|
-
rspec-mocks (~> 2.5.0)
|
20
|
-
rspec-core (2.5.1)
|
21
|
-
rspec-expectations (2.5.0)
|
22
|
-
diff-lcs (~> 1.1.2)
|
23
|
-
rspec-mocks (2.5.0)
|
24
|
-
|
25
|
-
PLATFORMS
|
26
|
-
ruby
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
addressable
|
30
|
-
chimps!
|
31
|
-
configliere (>= 0.3.2)
|
32
|
-
json (= 1.4.6)
|
33
|
-
rest-client (>= 1.6.1)
|
34
|
-
rspec
|
data/examples/batch.yaml
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
# This is an example of the expected structure of a file used in a
|
4
|
-
# bulk update.
|
5
|
-
#
|
6
|
-
# It consists of one large array itself consisting of mappings from a
|
7
|
-
# resource name (dataset, license, source) to properties about that
|
8
|
-
# resource.
|
9
|
-
#
|
10
|
-
# Many such documents can be combined together in a YAML stream and
|
11
|
-
# sent as a single request.
|
12
|
-
|
13
|
-
- source:
|
14
|
-
id: ~
|
15
|
-
request_id: foobar
|
16
|
-
title: Foobar the Fake Source
|
17
|
-
description: |
|
18
|
-
|
19
|
-
Foobar generates great data! Unfortunately, it's all of it
|
20
|
-
fake!
|
21
|
-
|
22
|
-
- dataset:
|
23
|
-
# this dataset lacks an ID property so it will be created
|
24
|
-
title: expatriatoro
|
25
|
-
description: |
|
26
|
-
Just some description of my dataset
|
27
|
-
|
28
|
-
tag_list:
|
29
|
-
- foo
|
30
|
-
- bar
|
31
|
-
- baz
|
32
|
-
|
33
|
-
sources:
|
34
|
-
# must all exist
|
35
|
-
- Census Bureau
|
36
|
-
- foobar
|
37
|
-
|
38
|
-
fields:
|
39
|
-
- title: length
|
40
|
-
units: m
|
41
|
-
|
42
|
-
- title: mass
|
43
|
-
units: kg
|
44
|
-
local_paths:
|
45
|
-
- /tmp/waste/waste.c
|
46
|
-
|
47
|
-
- dataset:
|
48
|
-
id: 1
|
49
|
-
title: f
|
50
|
-
description: |
|
51
|
-
Just some description of my dataset
|
52
|
-
|
53
|
-
tag_list:
|
54
|
-
- foo
|
55
|
-
- bar
|
56
|
-
- baz
|
57
|
-
|
58
|
-
sources:
|
59
|
-
# must all exist
|
60
|
-
- Census Bureau
|
61
|
-
- foobar
|
62
|
-
|
63
|
-
snippet:
|
64
|
-
columns: foo, bar,baz
|
65
|
-
data:
|
66
|
-
- [1,2,3]
|
67
|
-
- [4,5,6]
|
68
|
-
- [7,8,9]
|
69
|
-
|
data/examples/query.yaml
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
---
|
2
|
-
# The query command can be fed an array of hashes to run multiple
|
3
|
-
# queries.
|
4
|
-
#
|
5
|
-
# This example will generate three queries of the Wordbag dataset.
|
6
|
-
#
|
7
|
-
# http://api.infochimps.com/describe/soc/net/tw/wordbag
|
8
|
-
|
9
|
-
- screen_name: infochimps
|
10
|
-
- screen_name: aplusk
|
11
|
-
- screen_name: barackobama
|