market_bot 0.15.1 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a132519979029bc7d49f9f186b9828b60e660c6
4
- data.tar.gz: c3b9091cf1cac5ff307ed753b2071c5a9f7bd159
3
+ metadata.gz: 59cd879c52da9961e36e4ef57a63dc9713f024ca
4
+ data.tar.gz: 7312a30bed4ab78a77560be7ab7551beb9be1e7a
5
5
  SHA512:
6
- metadata.gz: 6bd264489a56f09546b2c53a9410a8a1812af6c850c5b5572c3df8f7bcc07cba7bb8db85cb309fc2138539ca4f4ccb115e65ed3cd1be6d41382dc62c27e72dd0
7
- data.tar.gz: 9c378875de61ea8c38d70a09f4b0ee946a3faca02dab4e9e7e8869a2e091b98e0d0e1d2667ced52f92893fa5e7eb529fb466cc0bb901f2d009daf473528afddd
6
+ metadata.gz: 91741e2d5550b7adfd1efdae920f4590a94502d1f03c2ebdc6b4fd06be2ffa8aa629a856e0157eb064233c33b3019e78a08885d7e9fcdf03d0e0a4eccfa4571f
7
+ data.tar.gz: a1de07b3787e5665447739a72f8918c8031bf00381a953b55a2ae68024946362aa7266ad3643c57ceacaa4aba0c51aa234c42353b542df6ac2184c24fbe7a7d8
data/lib/market_bot.rb CHANGED
@@ -17,5 +17,21 @@ module MarketBot
17
17
  def self.hydra
18
18
  @hydra ||= Typhoeus::Hydra.new(:max_concurrency => 5)
19
19
  end
20
+
21
+ def self.timeout
22
+ @timeout ||= 10
23
+ end
24
+
25
+ def self.timeout=(val)
26
+ @timeout = val
27
+ end
28
+
29
+ def self.connecttimeout
30
+ @connecttimeout ||= 10
31
+ end
32
+
33
+ def self.connecttimeout=(val)
34
+ @connecttimeout = val
35
+ end
20
36
  end
21
37
 
@@ -175,9 +175,11 @@ module MarketBot
175
175
  @app_id = app_id
176
176
  @hydra = options[:hydra] || MarketBot.hydra
177
177
  @lang = options[:lang] || 'en'
178
- @request_opts = options[:request_opts] || {}
179
178
  @callback = nil
180
179
  @error = nil
180
+ @request_opts = options[:request_opts] || {}
181
+ @request_opts[:timeout] ||= MarketBot.timeout
182
+ @request_opts[:connecttimeout] ||= MarketBot.connecttimeout
181
183
  end
182
184
 
183
185
  def market_url
@@ -222,7 +224,13 @@ module MarketBot
222
224
  if response.success?
223
225
  App.parse(response.body)
224
226
  else
225
- raise MarketBot::ResponseError.new("Got unexpected response code: #{response.code}")
227
+ codes = "code=#{response.code}, return_code=#{response.return_code}"
228
+ case response.code
229
+ when 404
230
+ raise MarketBot::AppNotFoundError.new("Unable to find app in store: #{codes}")
231
+ else
232
+ raise MarketBot::ResponseError.new("Unhandled response: #{codes}")
233
+ end
226
234
  end
227
235
  end
228
236
 
@@ -139,9 +139,11 @@ module MarketBot
139
139
  @identifier = identifier
140
140
  @category = category
141
141
  @hydra = options[:hydra] || MarketBot.hydra
142
- @request_opts = options[:request_opts] || {}
143
142
  @parsed_results = []
144
143
  @pending_pages = []
144
+ @request_opts = options[:request_opts] || {}
145
+ @request_opts[:timeout] ||= MarketBot.timeout
146
+ @request_opts[:connecttimeout] ||= MarketBot.connecttimeout
145
147
  end
146
148
 
147
149
  def market_urls(options={})
@@ -1,4 +1,5 @@
1
1
  module MarketBot
2
- # Exception raised when an unsuccessful response is indicated by Typhoeus
3
- class ResponseError < StandardError; end
2
+ class MarketBotError < StandardError; end
3
+ class ResponseError < MarketBotError; end
4
+ class AppNotFoundError < ResponseError; end
4
5
  end
@@ -1,3 +1,3 @@
1
1
  module MarketBot
2
- VERSION = '0.15.1'
2
+ VERSION = '0.16.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: market_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.1
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chad Remesch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-01 00:00:00.000000000 Z
11
+ date: 2016-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus