market_bot 0.13.0 → 0.14.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: dc3bf94ee5caead2d8b1869f2d7904f187506536
4
- data.tar.gz: e1c18d9ceeded15add6d00679761e1dd534018b5
3
+ metadata.gz: c2993089a057ffbcdbed68f9765c677a92136e1a
4
+ data.tar.gz: 7951dd169f17d3a9d1ffdd2a924be6dd2c3a1288
5
5
  SHA512:
6
- metadata.gz: 6b1ceb0acb0c08b9ef3adacfa0c44da103ed6adab5ffaaf68071db526bd330ec2129ec0ab55d60bbde78b2d8ca0d44207e28be364a4ae4018cf94b5bdab53085
7
- data.tar.gz: 0214e11c5b691f007641ba5c2c85d5489d3d1b6afa502119a3a827d55097d8466fcb1c0cfe2e464076a75fb732beada19ffcd0f8a3a382ffc2c5753683785279
6
+ metadata.gz: ee503d79c22db7b5f41870033863c366367ac8d66ee87d71b73f0107fc187be7e952de7ca11a9ea94deaffab2ed4607fd8c3d8bca5318f8a4015aa46965b7d54
7
+ data.tar.gz: 5c5e7a1311c467034dfc4a88e39af38a6ac193bb1bc8fb90cebef296b2ce14132910c1acd650c6249e9e7f797ec2ac6943b67c7255fb7813b7b780f4895e8825
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- market_bot (0.12.2)
4
+ market_bot (0.13.0)
5
5
  nokogiri
6
6
  typhoeus (>= 0.6.0)
7
7
 
data/README.markdown CHANGED
@@ -1,13 +1,14 @@
1
1
  # Market Bot - Ruby scraper for Google Play (Android Market)
2
2
 
3
3
  Market Bot is a high performance Ruby scraper for Google's Android Market with a simple to use API.
4
- Currently it supports scraping apps, leaderboards, and app searches.
5
- Books, music, movies, etc aren't currently supported.
4
+ Currently it can: scrape apps, app leaderboards, movies, and tv shows. It can also search for apps.
6
5
  It is built on top of Nokogiri and Typhoeus.
7
- Used in production to power [www.droidmeter.com](http://www.droidmeter.com/?t=github).
8
6
 
9
7
  **This project is currently seeking developers to help maintain it.
10
- Please send pull requests or contact me if you are able to help out.**
8
+ Please send pull requests or contact me if you are able to help out.
9
+ The best ways to get started are to fix bugs, improve documentation,
10
+ and merge useful changes from public forks. By working together we
11
+ can make the best scraper for the Google Play Store!**
11
12
 
12
13
  ## Dependencies
13
14
 
@@ -17,25 +18,25 @@ Please send pull requests or contact me if you are able to help out.**
17
18
  ## Installation
18
19
 
19
20
  gem install market_bot
20
-
21
+
21
22
  ## Getting Started Example
22
23
 
23
24
  require 'rubygems'
24
25
  require 'market_bot'
25
-
26
+
26
27
  # Download all the data for the Facebook app.
27
28
  app = MarketBot::Android::App.new('com.facebook.katana')
28
29
  app.update
29
-
30
+
30
31
  # Here we will print out the title of the app.
31
32
  puts app.title
32
-
33
+
33
34
  # Here we will print out the rating of the app.
34
35
  puts app.rating
35
-
36
+
36
37
  # And the price...
37
38
  puts app.price
38
-
39
+
39
40
  # market_bot has many other attributes for each app.
40
41
  # You can see what attributes are available in your version of
41
42
  # market_bot by printing a simple constant included in the gem.
@@ -67,7 +68,7 @@ Please send pull requests or contact me if you are able to help out.**
67
68
  developer = MarketBot::Android::Developer.new('Zynga')
68
69
  developer.update
69
70
  puts "Results found: #{developer.results.count}"
70
-
71
+
71
72
  # Print the rating for an app.
72
73
  puts MarketBot::Android::App.new('com.king.candycrushsaga').update.rating
73
74
 
@@ -125,6 +126,6 @@ Please contact me if you are looking for commercial data solutions.
125
126
 
126
127
  ## Copyright
127
128
 
128
- Copyright (c) 2011 - 2012 Chad Remesch. See LICENSE.txt for
129
+ Copyright (c) 2011 - 2015 Chad Remesch. See LICENSE.txt for
129
130
  further details.
130
131
 
data/lib/market_bot.rb CHANGED
@@ -4,6 +4,7 @@ require 'typhoeus'
4
4
  require 'nokogiri'
5
5
 
6
6
  require 'market_bot/version'
7
+ require 'market_bot/exceptions'
7
8
  require 'market_bot/android/app'
8
9
  require 'market_bot/android/leaderboard/constants'
9
10
  require 'market_bot/android/leaderboard'
@@ -153,7 +153,7 @@ module MarketBot
153
153
 
154
154
  def update
155
155
  resp = Typhoeus::Request.get(market_url, @request_opts)
156
- result = App.parse(resp.body)
156
+ result = handle_response(resp)
157
157
  update_callback(result)
158
158
 
159
159
  self
@@ -166,13 +166,10 @@ module MarketBot
166
166
  request = Typhoeus::Request.new(market_url, @request_opts)
167
167
 
168
168
  request.on_complete do |response|
169
- # HACK: Typhoeus <= 0.4.2 returns a response, 0.5.0pre returns the request.
170
- response = response.response if response.is_a?(Typhoeus::Request)
171
-
172
169
  result = nil
173
170
 
174
171
  begin
175
- result = App.parse(response.body)
172
+ result = handle_response(response)
176
173
  rescue Exception => e
177
174
  @error = e
178
175
  end
@@ -186,6 +183,15 @@ module MarketBot
186
183
  end
187
184
 
188
185
  private
186
+
187
+ def handle_response(response)
188
+ if response.success?
189
+ App.parse(response.body)
190
+ else
191
+ raise MarketBot::ResponseError.new("Got unexpected response code: #{response.code}")
192
+ end
193
+ end
194
+
189
195
  def update_callback(result)
190
196
  unless @error
191
197
  MARKET_ATTRIBUTES.each do |a|
@@ -0,0 +1,4 @@
1
+ module MarketBot
2
+ # Exception raised when an unsuccessful response is indicated by Typhoeus
3
+ class ResponseError < StandardError; end
4
+ end
@@ -1,3 +1,3 @@
1
1
  module MarketBot
2
- VERSION = '0.13.0'
2
+ VERSION = '0.14.0'
3
3
  end
@@ -179,6 +179,21 @@ describe 'App' do
179
179
  check_getters(app)
180
180
  end
181
181
 
182
+ context "Quick API not found" do
183
+ let(:app) { App.new(test_id) }
184
+
185
+ before do
186
+ response = Typhoeus::Response.new(:code => 404)
187
+ Typhoeus.stub(app.market_url).and_return(response)
188
+ end
189
+
190
+ it "raises a ResponseError" do
191
+ expect {
192
+ app.update
193
+ }.to raise_error(MarketBot::ResponseError)
194
+ end
195
+ end
196
+
182
197
  context 'Batch API' do
183
198
  hydra = Typhoeus::Hydra.new
184
199
  app = App.new(test_id, :hydra => hydra)
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.13.0
4
+ version: 0.14.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: 2015-02-05 00:00:00.000000000 Z
11
+ date: 2015-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus
@@ -74,6 +74,7 @@ files:
74
74
  - lib/market_bot/android/leaderboard.rb
75
75
  - lib/market_bot/android/leaderboard/constants.rb
76
76
  - lib/market_bot/android/search_query.rb
77
+ - lib/market_bot/exceptions.rb
77
78
  - lib/market_bot/movie/leaderboard.rb
78
79
  - lib/market_bot/movie/leaderboard/constants.rb
79
80
  - lib/market_bot/movie/search_query.rb
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
116
  version: '0'
116
117
  requirements: []
117
118
  rubyforge_project:
118
- rubygems_version: 2.2.2
119
+ rubygems_version: 2.4.5
119
120
  signing_key:
120
121
  specification_version: 4
121
122
  summary: 'Market Bot: High performance Ruby scraper for Google''s Android Market'