market_bot 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -11,6 +11,7 @@ module MarketBot
11
11
  attr_reader *MARKET_ATTRIBUTES
12
12
  attr_reader :hydra
13
13
  attr_reader :callback
14
+ attr_reader :error
14
15
 
15
16
  def self.parse(html)
16
17
  result = {}
@@ -84,6 +85,7 @@ module MarketBot
84
85
  @app_id = app_id
85
86
  @hydra = options[:hydra] || Typhoeus::Hydra.hydra
86
87
  @callback = nil
88
+ @error = nil
87
89
  end
88
90
 
89
91
  def market_url
@@ -100,11 +102,19 @@ module MarketBot
100
102
 
101
103
  def enqueue_update(&block)
102
104
  @callback = block
105
+ @error = nil
103
106
 
104
107
  request = Typhoeus::Request.new(market_url)
105
108
 
106
109
  request.on_complete do |response|
107
- result = App.parse(response.body)
110
+ result = nil
111
+
112
+ begin
113
+ result = App.parse(response.body)
114
+ rescue Exception => e
115
+ @error = e
116
+ end
117
+
108
118
  update_callback(result)
109
119
  end
110
120
 
@@ -115,10 +125,12 @@ module MarketBot
115
125
 
116
126
  private
117
127
  def update_callback(result)
118
- MARKET_ATTRIBUTES.each do |a|
119
- attr_name = "@#{a}"
120
- attr_value = result[a]
121
- instance_variable_set(attr_name, attr_value)
128
+ unless @error
129
+ MARKET_ATTRIBUTES.each do |a|
130
+ attr_name = "@#{a}"
131
+ attr_value = result[a]
132
+ instance_variable_set(attr_name, attr_value)
133
+ end
122
134
  end
123
135
 
124
136
  @callback.call(self) if @callback
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "market_bot"
8
- s.version = "0.2.3"
8
+ s.version = "0.2.4"
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"]
@@ -132,6 +132,7 @@ describe 'App' do
132
132
  hydra.stub(:get, app.market_url).and_return(response)
133
133
 
134
134
  callback_flag = false
135
+
135
136
  app.enqueue_update do |a|
136
137
  callback_flag = true
137
138
  end
@@ -144,5 +145,30 @@ describe 'App' do
144
145
 
145
146
  check_getters(app)
146
147
  end
148
+
149
+ context 'Batch API parser error' do
150
+ hydra = Typhoeus::Hydra.new
151
+ app = App.new(test_id, :hydra => hydra)
152
+ response = Typhoeus::Response.new(:code => 200, :headers => '', :body => 'some broken app page')
153
+ hydra.stub(:get, app.market_url).and_return(response)
154
+
155
+ callback_flag = false
156
+ error = nil
157
+
158
+ app.enqueue_update do |a|
159
+ callback_flag = true
160
+ error = a.error
161
+ end
162
+
163
+ hydra.run
164
+
165
+ it 'should call the callback' do
166
+ callback_flag.should be(true)
167
+ end
168
+
169
+ it 'should set error to the exception' do
170
+ error.should be_a(Exception)
171
+ end
172
+ end
147
173
  end
148
174
  end
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.2.3
4
+ version: 0.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-11-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: typhoeus
16
- requirement: &70261668665780 !ruby/object:Gem::Requirement
16
+ requirement: &70310725834360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70261668665780
24
+ version_requirements: *70310725834360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: nokogiri
27
- requirement: &70261668665300 !ruby/object:Gem::Requirement
27
+ requirement: &70310725833880 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70261668665300
35
+ version_requirements: *70310725833880
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70261668664820 !ruby/object:Gem::Requirement
38
+ requirement: &70310725833400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.3.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70261668664820
46
+ version_requirements: *70310725833400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
- requirement: &70261668664340 !ruby/object:Gem::Requirement
49
+ requirement: &70310725832920 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.0.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70261668664340
57
+ version_requirements: *70310725832920
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: jeweler
60
- requirement: &70261668663860 !ruby/object:Gem::Requirement
60
+ requirement: &70310725832440 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.6.4
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70261668663860
68
+ version_requirements: *70310725832440
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rcov
71
- requirement: &70261668663380 !ruby/object:Gem::Requirement
71
+ requirement: &70310725831960 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70261668663380
79
+ version_requirements: *70310725831960
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: ZenTest
82
- requirement: &70261668662900 !ruby/object:Gem::Requirement
82
+ requirement: &70310725848620 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 4.6.2
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70261668662900
90
+ version_requirements: *70310725848620
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: ruby-debug19
93
- requirement: &70261668662420 !ruby/object:Gem::Requirement
93
+ requirement: &70310725848140 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 0.11.6
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70261668662420
101
+ version_requirements: *70310725848140
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdoc
104
- requirement: &70261668661940 !ruby/object:Gem::Requirement
104
+ requirement: &70310725847660 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: 3.9.4
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70261668661940
112
+ version_requirements: *70310725847660
113
113
  description: Market Bot is a high performance Ruby scraper for Google's Android Market
114
114
  with a simple to use API. It is built on top of Nokogiri and Typhoeus.
115
115
  email: chad@remesch.com
@@ -160,7 +160,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
160
  version: '0'
161
161
  segments:
162
162
  - 0
163
- hash: 4062392463599958467
163
+ hash: 2410903352655737101
164
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
165
  none: false
166
166
  requirements: