freebase-api 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/{travis.yml → .travis.yml} +2 -2
- data/Gemfile +1 -2
- data/README.markdown +2 -1
- data/lib/freebase_api/session.rb +3 -3
- data/lib/freebase_api/version.rb +1 -1
- data/spec/image_spec.rb +1 -1
- data/spec/session_spec.rb +20 -2
- data/spec/support/helpers.rb +1 -1
- metadata +14 -25
- data/Gemfile.lock +0 -54
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1b7e8a2c6fe8238795c80a201f277020c42ea8ea
|
4
|
+
data.tar.gz: e627b3686db5e0db9f374b9130f720e3ae5e2aed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a8074d7dc7be46e31da0c6bff00e6f021dbf1fd477a2d2a00130277e30f96cec052b70aa07056a7625eb71f2817ce10f5bb5b1b703b4c24aa4f83f14de2f84dc
|
7
|
+
data.tar.gz: d989451faf085ac0cf720e1d5c666115b785912ab05641a6fb237d4337efabdc647b95f60dcf2a48db69c331ce1a236eeea9cec6dadd003fe45fbcb05c4eca5c
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/{travis.yml → .travis.yml}
RENAMED
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -30,13 +30,14 @@ If you have a [Google API key](https://code.google.com/apis/console), you can se
|
|
30
30
|
You can override the default session by providing some options, like the language or the environment.
|
31
31
|
|
32
32
|
```ruby
|
33
|
-
FreebaseAPI.session = FreebaseAPI::Session.new(key: 'GOOGLE_API_KEY', env:
|
33
|
+
FreebaseAPI.session = FreebaseAPI::Session.new(key: 'GOOGLE_API_KEY', env: :stable)
|
34
34
|
```
|
35
35
|
|
36
36
|
Options are :
|
37
37
|
|
38
38
|
* `:key` : your Google API key
|
39
39
|
* `:env` : the environment (sandbox or stable) (default is :stable)
|
40
|
+
* `:proxy` : an optional url for a proxy that requests will be sent through
|
40
41
|
* `:query_options` : some options that will be used in each query
|
41
42
|
* `:limit` : the number of items returned (default is 10)
|
42
43
|
* `:lang` : the language you would like the content in (default is 'en')
|
data/lib/freebase_api/session.rb
CHANGED
@@ -21,7 +21,7 @@ module FreebaseAPI
|
|
21
21
|
@env = options[:env]
|
22
22
|
@key = options[:key] || ENV['GOOGLE_API_KEY']
|
23
23
|
@query_options = options[:query_options]
|
24
|
-
@proxy_options = get_proxy_options
|
24
|
+
@proxy_options = get_proxy_options(options[:proxy])
|
25
25
|
end
|
26
26
|
|
27
27
|
# Execute a MQL read query
|
@@ -117,9 +117,9 @@ module FreebaseAPI
|
|
117
117
|
# Get the proxy options for HTTParty
|
118
118
|
#
|
119
119
|
# @return [Hash] the proxy options
|
120
|
-
def get_proxy_options
|
120
|
+
def get_proxy_options(url=nil)
|
121
121
|
options = {}
|
122
|
-
if url = ENV['HTTPS_PROXY'] || ENV['https_proxy'] || ENV['HTTP_PROXY'] || ENV['http_proxy']
|
122
|
+
if url = url || ENV['HTTPS_PROXY'] || ENV['https_proxy'] || ENV['HTTP_PROXY'] || ENV['http_proxy']
|
123
123
|
proxy_uri = URI.parse(url)
|
124
124
|
options[:http_proxyaddr] = proxy_uri.host
|
125
125
|
options[:http_proxyport] = proxy_uri.port
|
data/lib/freebase_api/version.rb
CHANGED
data/spec/image_spec.rb
CHANGED
data/spec/session_spec.rb
CHANGED
@@ -45,7 +45,7 @@ describe FreebaseAPI::Session do
|
|
45
45
|
end
|
46
46
|
|
47
47
|
context "in a stable environnment" do
|
48
|
-
it "should return the
|
48
|
+
it "should return the stable service URL" do
|
49
49
|
session.send(:surl, 'service').should == 'https://www.googleapis.com/freebase/v1/service'
|
50
50
|
end
|
51
51
|
end
|
@@ -182,5 +182,23 @@ describe FreebaseAPI::Session do
|
|
182
182
|
session.send(:get, 'URL')
|
183
183
|
end
|
184
184
|
end
|
185
|
+
|
186
|
+
context "with a proxy configuration" do
|
187
|
+
let(:session) { FreebaseAPI::Session.new(:proxy => 'http://user:pass@site.com:2020') }
|
188
|
+
|
189
|
+
before do
|
190
|
+
session.stub(:handle_response)
|
191
|
+
end
|
192
|
+
|
193
|
+
it "should use the proxy" do
|
194
|
+
session.class.should_receive(:get) do |url, params, options|
|
195
|
+
params[:http_proxyaddr].should eq "site.com"
|
196
|
+
params[:http_proxyport].should eq 2020
|
197
|
+
params[:http_proxyuser].should eq "user"
|
198
|
+
params[:http_proxypass].should eq "pass"
|
199
|
+
end
|
200
|
+
session.send(:get, 'URL')
|
201
|
+
end
|
202
|
+
end
|
185
203
|
end
|
186
|
-
end
|
204
|
+
end
|
data/spec/support/helpers.rb
CHANGED
metadata
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: freebase-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.1.3
|
4
|
+
version: 0.1.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Aymeric Brisse
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
prerelease: false
|
16
14
|
name: httparty
|
17
|
-
type: :runtime
|
18
15
|
requirement: !ruby/object:Gem::Requirement
|
19
16
|
requirements:
|
20
|
-
- - ~>
|
17
|
+
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: '0.10'
|
23
|
-
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
23
|
requirements:
|
26
|
-
- - ~>
|
24
|
+
- - "~>"
|
27
25
|
- !ruby/object:Gem::Version
|
28
26
|
version: '0.10'
|
29
|
-
none: false
|
30
27
|
description: A library to use the Freebase API
|
31
28
|
email:
|
32
29
|
- aymeric.brisse@mperfect-memory.com
|
@@ -34,10 +31,10 @@ executables: []
|
|
34
31
|
extensions: []
|
35
32
|
extra_rdoc_files: []
|
36
33
|
files:
|
37
|
-
- .gitignore
|
38
|
-
- .rspec
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rspec"
|
36
|
+
- ".travis.yml"
|
39
37
|
- Gemfile
|
40
|
-
- Gemfile.lock
|
41
38
|
- LICENSE.txt
|
42
39
|
- README.markdown
|
43
40
|
- Rakefile
|
@@ -60,36 +57,28 @@ files:
|
|
60
57
|
- spec/spec_helper.rb
|
61
58
|
- spec/support/helpers.rb
|
62
59
|
- spec/topic_spec.rb
|
63
|
-
- travis.yml
|
64
60
|
homepage: https://github.com/PerfectMemory/freebase-api
|
65
61
|
licenses: []
|
62
|
+
metadata: {}
|
66
63
|
post_install_message:
|
67
64
|
rdoc_options: []
|
68
65
|
require_paths:
|
69
66
|
- lib
|
70
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
68
|
requirements:
|
72
|
-
- -
|
69
|
+
- - ">="
|
73
70
|
- !ruby/object:Gem::Version
|
74
|
-
segments:
|
75
|
-
- 0
|
76
|
-
hash: 2916215866854017455
|
77
71
|
version: '0'
|
78
|
-
none: false
|
79
72
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
73
|
requirements:
|
81
|
-
- -
|
74
|
+
- - ">="
|
82
75
|
- !ruby/object:Gem::Version
|
83
|
-
segments:
|
84
|
-
- 0
|
85
|
-
hash: 2916215866854017455
|
86
76
|
version: '0'
|
87
|
-
none: false
|
88
77
|
requirements: []
|
89
78
|
rubyforge_project:
|
90
|
-
rubygems_version:
|
79
|
+
rubygems_version: 2.2.1
|
91
80
|
signing_key:
|
92
|
-
specification_version:
|
81
|
+
specification_version: 4
|
93
82
|
summary: Provides access to both a raw-access and an abstract-layer to the Freebase
|
94
83
|
API
|
95
84
|
test_files:
|
data/Gemfile.lock
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
freebase-api (0.1.3)
|
5
|
-
httparty (~> 0.10)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
colorize (0.5.8)
|
11
|
-
coveralls (0.6.7)
|
12
|
-
colorize
|
13
|
-
multi_json (~> 1.3)
|
14
|
-
rest-client
|
15
|
-
simplecov (>= 0.7)
|
16
|
-
thor
|
17
|
-
diff-lcs (1.2.4)
|
18
|
-
httparty (0.12.0)
|
19
|
-
json (~> 1.8)
|
20
|
-
multi_xml (>= 0.5.2)
|
21
|
-
json (1.8.1)
|
22
|
-
mime-types (1.23)
|
23
|
-
multi_json (1.7.2)
|
24
|
-
multi_xml (0.5.5)
|
25
|
-
rake (10.0.4)
|
26
|
-
redcarpet (2.2.2)
|
27
|
-
rest-client (1.6.7)
|
28
|
-
mime-types (>= 1.16)
|
29
|
-
rspec (2.13.0)
|
30
|
-
rspec-core (~> 2.13.0)
|
31
|
-
rspec-expectations (~> 2.13.0)
|
32
|
-
rspec-mocks (~> 2.13.0)
|
33
|
-
rspec-core (2.13.1)
|
34
|
-
rspec-expectations (2.13.0)
|
35
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
36
|
-
rspec-mocks (2.13.1)
|
37
|
-
simplecov (0.7.1)
|
38
|
-
multi_json (~> 1.0)
|
39
|
-
simplecov-html (~> 0.7.1)
|
40
|
-
simplecov-html (0.7.1)
|
41
|
-
thor (0.18.1)
|
42
|
-
yard (0.8.6.1)
|
43
|
-
|
44
|
-
PLATFORMS
|
45
|
-
ruby
|
46
|
-
|
47
|
-
DEPENDENCIES
|
48
|
-
coveralls
|
49
|
-
freebase-api!
|
50
|
-
rake (~> 10.0)
|
51
|
-
redcarpet (~> 2.2)
|
52
|
-
rspec (~> 2.12)
|
53
|
-
simplecov (~> 0.7)
|
54
|
-
yard (~> 0.8)
|