market_bot 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -13,20 +13,41 @@ Used in production to power [www.droidmeter.com](http://www.droidmeter.com/?t=gi
13
13
 
14
14
  gem install market_bot
15
15
 
16
- ## Usage Examples (using batch API for downloading)
16
+ ## Basic Examples
17
17
 
18
18
  require 'rubygems'
19
19
  require 'market_bot'
20
20
 
21
- # Create a hydra object with 20 http workers.
22
- hydra = Typhoeus::Hydra.new(:max_concurrency => 20)
23
-
24
21
  # Download/parse the leaderboard.
25
- lb = MarketBot::Android::Leaderboard.new(:apps_topselling_paid, :arcade, :hydra => hydra)
26
- lb.enqueue_update
27
- hydra.run
22
+ lb = MarketBot::Android::Leaderboard.new(:topselling_free, :game)
23
+ lb.update
28
24
 
29
25
  # Download/parse the details for the first and last entries of the leaderboard.
26
+ first_app = MarketBot::Android::App.new(lb.results.first[:market_id])
27
+ last_app = MarketBot::Android::App.new(lb.results.last[:market_id])
28
+ first_app.update
29
+ last_app.update
30
+ puts "First place app (#{first_app.title}) price: #{first_app.price}"
31
+ puts "Last place app (#{last_app.title}) price: #{last_app.price}"
32
+
33
+ # Search for apps.
34
+ sq = MarketBot::Android::SearchQuery.new('donkeys')
35
+ sq.update
36
+ puts "Results found: #{sq.results.count}"
37
+
38
+ ## Advanced Examples
39
+
40
+ require 'rubygems'
41
+ require 'market_bot'
42
+
43
+ # Create a reusable hydra object with 5 http workers.
44
+ hydra = Typhoeus::Hydra.new(:max_concurrency => 5)
45
+
46
+ # Download/parse the leaderboard.
47
+ lb = MarketBot::Android::Leaderboard.new(:topselling_free, :game, :hyda => hydra)
48
+ lb.update
49
+
50
+ # Download/parse the details for the first and last entries of the leaderboard using the batch API.
30
51
  first_app = MarketBot::Android::App.new(lb.results.first[:market_id], :hydra => hydra)
31
52
  last_app = MarketBot::Android::App.new(lb.results.last[:market_id], :hydra => hydra)
32
53
  first_app.enqueue_update
@@ -36,7 +57,7 @@ Used in production to power [www.droidmeter.com](http://www.droidmeter.com/?t=gi
36
57
  end
37
58
  hydra.run
38
59
 
39
- # Non-callback example. Note that you must manually check if an error occurred during the hydra.run.
60
+ # You must manually check if an error occurred when using the batch API without callbacks.
40
61
  puts "First place app (#{first_app.title}) price: #{first_app.price}" unless first_app.error
41
62
  puts "Last place app (#{last_app.title}) price: #{last_app.price}" unless last_app.error
42
63
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.6.1
@@ -121,7 +121,7 @@ module MarketBot
121
121
 
122
122
  def initialize(app_id, options={})
123
123
  @app_id = app_id
124
- @hydra = options[:hydra] || Typhoeus::Hydra.hydra
124
+ @hydra = options[:hydra] || Typhoeus::Hydra.new(:max_concurrency => 5)
125
125
  @callback = nil
126
126
  @error = nil
127
127
  end
@@ -66,7 +66,7 @@ module MarketBot
66
66
  def initialize(identifier, category=nil, options={})
67
67
  @identifier = identifier
68
68
  @category = category
69
- @hydra = options[:hydra] || Typhoeus::Hydra.hydra
69
+ @hydra = options[:hydra] || Typhoeus::Hydra.new(:max_concurrency => 5)
70
70
  @parsed_results = []
71
71
  end
72
72
 
data/market_bot.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "market_bot"
8
- s.version = "0.6.0"
8
+ s.version = "0.6.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Chad Remesch"]
@@ -92,6 +92,7 @@ describe 'Leaderboard' do
92
92
  context 'Quick API' do
93
93
  stub_hydra(Typhoeus::Hydra.hydra)
94
94
  lb = Leaderboard.new(test_id, test_category)
95
+ lb.instance_variable_set('@hydra', Typhoeus::Hydra.hydra)
95
96
  lb.update(:min_rank => 1, :max_rank => 96)
96
97
 
97
98
  check_results(lb.results)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: market_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -240,7 +240,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
240
240
  version: '0'
241
241
  segments:
242
242
  - 0
243
- hash: -476793173009451018
243
+ hash: -3676727692499242142
244
244
  required_rubygems_version: !ruby/object:Gem::Requirement
245
245
  none: false
246
246
  requirements: