freebase-api 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Gemfile CHANGED
@@ -6,7 +6,6 @@ group :test do
6
6
  gem 'coveralls', :require => false
7
7
  gem 'rspec', '~> 2.12'
8
8
  gem 'yard', '~> 0.8'
9
- gem 'rspec', '~> 2.12'
10
9
  gem 'simplecov', '~> 0.7', :require => false
11
10
  gem 'redcarpet', '~> 2.2'
12
11
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- freebase-api (0.1.2)
4
+ freebase-api (0.1.3)
5
5
  httparty (~> 0.10)
6
6
 
7
7
  GEM
@@ -15,12 +15,13 @@ GEM
15
15
  simplecov (>= 0.7)
16
16
  thor
17
17
  diff-lcs (1.2.4)
18
- httparty (0.11.0)
19
- multi_json (~> 1.0)
18
+ httparty (0.12.0)
19
+ json (~> 1.8)
20
20
  multi_xml (>= 0.5.2)
21
+ json (1.8.1)
21
22
  mime-types (1.23)
22
23
  multi_json (1.7.2)
23
- multi_xml (0.5.3)
24
+ multi_xml (0.5.5)
24
25
  rake (10.0.4)
25
26
  redcarpet (2.2.2)
26
27
  rest-client (1.6.7)
@@ -21,6 +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
25
  end
25
26
 
26
27
  # Execute a MQL read query
@@ -90,7 +91,9 @@ module FreebaseAPI
90
91
  def get(url, params={}, options={})
91
92
  FreebaseAPI.logger.debug("GET #{url}")
92
93
  params[:key] = @key if @key
93
- response = self.class.get(url, :format => options[:format], :query => params)
94
+ options = { format: options[:format], query: params }
95
+ options.merge!(@proxy_options)
96
+ response = self.class.get(url, options)
94
97
  handle_response(response)
95
98
  end
96
99
 
@@ -110,5 +113,20 @@ module FreebaseAPI
110
113
  end
111
114
  end
112
115
  end
116
+
117
+ # Get the proxy options for HTTParty
118
+ #
119
+ # @return [Hash] the proxy options
120
+ def get_proxy_options
121
+ options = {}
122
+ if url = ENV['HTTPS_PROXY'] || ENV['https_proxy'] || ENV['HTTP_PROXY'] || ENV['http_proxy']
123
+ proxy_uri = URI.parse(url)
124
+ options[:http_proxyaddr] = proxy_uri.host
125
+ options[:http_proxyport] = proxy_uri.port
126
+ options[:http_proxyuser] = proxy_uri.user
127
+ options[:http_proxypass] = proxy_uri.password
128
+ end
129
+ options
130
+ end
113
131
  end
114
132
  end
@@ -1,3 +1,3 @@
1
1
  module FreebaseAPI
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/spec/session_spec.rb CHANGED
@@ -162,4 +162,25 @@ describe FreebaseAPI::Session do
162
162
  end
163
163
  end
164
164
  end
165
+
166
+ describe "#get" do
167
+ let(:session) { FreebaseAPI::Session.new }
168
+
169
+ context "with a proxy env variable" do
170
+ before do
171
+ ENV['http_proxy'] = 'http://user:pass@site.com:2020'
172
+ session.stub(:handle_response)
173
+ end
174
+
175
+ it "should use the proxy" do
176
+ session.class.should_receive(:get) do |url, params, options|
177
+ params[:http_proxyaddr].should eq "site.com"
178
+ params[:http_proxyport].should eq 2020
179
+ params[:http_proxyuser].should eq "user"
180
+ params[:http_proxypass].should eq "pass"
181
+ end
182
+ session.send(:get, 'URL')
183
+ end
184
+ end
185
+ end
165
186
  end
metadata CHANGED
@@ -1,29 +1,32 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freebase-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ prerelease:
5
+ version: 0.1.3
5
6
  platform: ruby
6
7
  authors:
7
8
  - Aymeric Brisse
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-04-30 00:00:00.000000000 Z
12
+ date: 2013-12-05 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
15
+ prerelease: false
14
16
  name: httparty
17
+ type: :runtime
15
18
  requirement: !ruby/object:Gem::Requirement
16
19
  requirements:
17
20
  - - ~>
18
21
  - !ruby/object:Gem::Version
19
22
  version: '0.10'
20
- type: :runtime
21
- prerelease: false
23
+ none: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
23
25
  requirements:
24
26
  - - ~>
25
27
  - !ruby/object:Gem::Version
26
28
  version: '0.10'
29
+ none: false
27
30
  description: A library to use the Freebase API
28
31
  email:
29
32
  - aymeric.brisse@mperfect-memory.com
@@ -60,7 +63,6 @@ files:
60
63
  - travis.yml
61
64
  homepage: https://github.com/PerfectMemory/freebase-api
62
65
  licenses: []
63
- metadata: {}
64
66
  post_install_message:
65
67
  rdoc_options: []
66
68
  require_paths:
@@ -69,17 +71,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
71
  requirements:
70
72
  - - ! '>='
71
73
  - !ruby/object:Gem::Version
74
+ segments:
75
+ - 0
76
+ hash: 2916215866854017455
72
77
  version: '0'
78
+ none: false
73
79
  required_rubygems_version: !ruby/object:Gem::Requirement
74
80
  requirements:
75
81
  - - ! '>='
76
82
  - !ruby/object:Gem::Version
83
+ segments:
84
+ - 0
85
+ hash: 2916215866854017455
77
86
  version: '0'
87
+ none: false
78
88
  requirements: []
79
89
  rubyforge_project:
80
- rubygems_version: 2.0.1
90
+ rubygems_version: 1.8.25
81
91
  signing_key:
82
- specification_version: 4
92
+ specification_version: 3
83
93
  summary: Provides access to both a raw-access and an abstract-layer to the Freebase
84
94
  API
85
95
  test_files:
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MTg1YWI3YTlmNzU4YjY5N2EzNDhiYjE0MzJmMzRjNzVmMmQ1ZTMzNg==
5
- data.tar.gz: !binary |-
6
- NWQ3NGY0MWNhZDNiYWI4ZDg1ZWMyZDQ5NjJkNjI5ZWRkMGNlMDg0NA==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- NTczZTBhOTU1N2I0Zjg4YmI5MGU0ZDlkYTEzODhmZTU4ZTQ3ZTVkMmMzYzcx
10
- YzQzMTIzMDZmMzMzNDZhZDllMDMyMjc3MzJmYTZjYjU5NTk1YTI3ZWFlNzg5
11
- YmFiNTM1ZDIzNGU0M2JkMmY5YmM5OWI3ZGJkZDA3M2E2MzRlOGM=
12
- data.tar.gz: !binary |-
13
- MTJhNDRjYzIzNDM2ZTkyMDc5NTY0OTYzNTE1YzI4OWNmNDc5ZDAzZTI3NjI1
14
- YmU5NGZmODNhNGJmYmVhMTY3ZTJlY2VhZTc1OGYzMGJlNjc5ZGNmY2Y4NDg0
15
- ZjA5NjA3NjBhODY3MDE1ZTlhN2Q5M2NlNTE4MWU3ZjMxMjU1YTA=