market_bot 1.2.0 → 1.3.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
- SHA1:
3
- metadata.gz: e192bf589108f929cb2ab6f9324c9353050c6155
4
- data.tar.gz: eb312e9370107cd0df21e089472c34e91f696380
2
+ SHA256:
3
+ metadata.gz: b69851827593453db81b7f914d288d76587b61c3cd110cc5278abc60e3d65e62
4
+ data.tar.gz: 1cf502f15dac6a0fcac41f342416874c6b9ff4a1ed7747b1c2c435c534d450e1
5
5
  SHA512:
6
- metadata.gz: da09d7316ebaead76056bfad1ba53834be37ba77d3372a3cf5d7d6482ecf20983ab49d48bf7957d44a199a33ab721171ec3b679f477e776b9e6fd589100686ea
7
- data.tar.gz: a2f451312c0b3c7ff9aa5e7753948587af0772e70a818520b5db0e339dcc558e5c51c30bda19312be0880aa59c143ad098eea85a4bcb698ec438dcdc875a0f9b
6
+ metadata.gz: 873aadfacea67683ddf4e8b404c25bb7c888e20e4b4b35f3513fb794089452b666f0036888b431e96fb719fd4f48404536b0808a27b400aeaa21a6f3aca4a208
7
+ data.tar.gz: 248f43a7d5298f3c8fa7726d10b41f9f390da6307c3cd0244691f538edc135ead99d7a835af9a6f1771e9cd6b8d10f2e4cd5bf16d7b9d9e608d1ab2e8d048b75
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.4.0
4
- - 2.3.3
5
- - 2.2.6
3
+ - 2.5.0
4
+ - 2.4.3
5
+ - 2.3.5
6
+ - 2.2.8
6
7
  - 2.1.10
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## [1.3.0] - 2017-09-26
4
+ ### Added
5
+ - in_app_products_price to the app class from @lightalloy.
6
+ - physical_address to the app class from @lightalloy.
7
+ - contains_ads to the app class from @lightalloy.
8
+ - multiple app categories (categories, categories_urls) added to the app class from @lightalloy.
9
+ - privacy_url to the app class from @antonyr.
10
+ - updated test data from @chadrem.
11
+ ### Fixed
12
+ - website_url for app class from @antonyr.
13
+ - tweak tests to work with latest test data from @chadrem.
14
+
3
15
  ## [1.2.0] - 2017-09-26
4
16
  ### Added
5
17
  - Reviews now have a review_id from @tom-wolters.
data/bin/update_test_data CHANGED
@@ -19,6 +19,7 @@ end
19
19
 
20
20
  download('https://play.google.com/store/apps/details?id=com.bluefroggaming.popdat', 'app-com.bluefroggaming.popdat.txt')
21
21
  download('https://play.google.com/store/apps/details?id=com.mg.android', 'app-com.mg.android.txt')
22
+ download('https://play.google.com/store/apps/details?id=com.hasbro.mlpcoreAPPSTORE', 'app-com.hasbro.mlpcoreAPPSTORE.txt')
22
23
  download('https://play.google.com/store/apps/category/GAME_ARCADE/collection/topselling_paid?start=0&gl=us&num=100&hl=en', 'chart-topselling_paid-GAME_ARCADE-0.txt')
23
24
  download('https://play.google.com/store/apps/category/GAME_ARCADE/collection/topselling_paid?start=100&gl=us&num=100&hl=en', 'chart-topselling_paid-GAME_ARCADE-1.txt')
24
25
  download('https://play.google.com/store/apps/category/GAME_ARCADE/collection/topselling_paid?start=200&gl=us&num=100&hl=en', 'chart-topselling_paid-GAME_ARCADE-2.txt')
@@ -4,6 +4,9 @@ module MarketBot
4
4
  ATTRIBUTES = [
5
5
  :category,
6
6
  :category_url,
7
+ :categories,
8
+ :categories_urls,
9
+ :contains_ads,
7
10
  :content_rating,
8
11
  :cover_image_url,
9
12
  :current_version,
@@ -13,6 +16,8 @@ module MarketBot
13
16
  :email,
14
17
  :full_screenshot_urls,
15
18
  :html,
19
+ :in_app_products_price,
20
+ :physical_address,
16
21
  :installs,
17
22
  :more_from_developer,
18
23
  :price,
@@ -27,6 +32,7 @@ module MarketBot
27
32
  :updated,
28
33
  :votes,
29
34
  :website_url,
35
+ :privacy_url,
30
36
  :whats_new,
31
37
  ]
32
38
  end
@@ -25,20 +25,29 @@ module MarketBot
25
25
  result[:current_version] = info.at_css('.content').text.strip
26
26
  when 'Requires Android'
27
27
  result[:requires_android] = info.at_css('.content').text.strip
28
+ when 'In-app Products'
29
+ result[:in_app_products_price] = info.at_css('.content').text.strip
28
30
  when 'Contact Developer', 'Developer'
29
- info.css('.dev-link').each do |node|
30
- node_href = node[:href]
31
- if node_href =~ /^mailto:/
32
- result[:email] = node_href.gsub(/^mailto:/,'')
33
- else
34
- if q_param = URI(node_href).query.split('&').select{ |p| p =~ /q=/ }.first
35
- actual_url = q_param.gsub('q=', '')
36
- end
37
-
38
- result[:website_url] = actual_url
39
- end
31
+ dev_links = info.css('.dev-link')
32
+
33
+ if website = dev_links.css(':contains("Visit")').first
34
+ href = website.attr('href')
35
+ q_param = URI(href).query.split('&').select{ |p| p =~ /q=/ }.first
36
+ result[:website_url] = q_param.gsub('q=', '')
37
+ end
38
+
39
+ if email = dev_links.css(':contains("Email")').first
40
+ email = email.attr('href')
41
+ result[:email] = email.gsub(/^mailto:/,'')
42
+ end
43
+
44
+ if privacy = dev_links.css(':contains("Privacy")').first
45
+ href = privacy.attr('href')
46
+ q_param = URI(href).query.split('&').select{ |p| p =~ /q=/ }.first
47
+ result[:privacy_url] = q_param.gsub('q=', '')
40
48
  end
41
49
 
50
+ result[:physical_address] = info.at_css('.physical-address').text.strip if info.at_css('.physical-address')
42
51
  end
43
52
  end
44
53
 
@@ -46,9 +55,15 @@ module MarketBot
46
55
 
47
56
  result[:price] = doc.at_css('meta[itemprop="price"]')[:content] if doc.at_css('meta[itemprop="price"]')
48
57
 
49
- category_div = doc.at_css('.category')
50
- result[:category] = category_div.text.strip
51
- result[:category_url] = File.split(category_div["href"])[1]
58
+ result[:contains_ads] = !!doc.at_css('.ads-supported-label-msg')
59
+
60
+ category_divs = doc.css('.category')
61
+
62
+ result[:categories] = category_divs.map { |d| d.text.strip }
63
+ result[:categories_urls] = category_divs.map { |d| File.split(d["href"])[1] }
64
+
65
+ result[:category] = result[:categories].first
66
+ result[:category_url] = result[:categories_urls].first
52
67
 
53
68
  result[:description] = doc.at_css('div[itemprop="description"]').inner_html.strip
54
69
  result[:title] = doc.at_css('div.id-app-title').text
@@ -1,3 +1,3 @@
1
1
  module MarketBot
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
@@ -3,11 +3,19 @@ require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
3
3
  describe MarketBot::Play::App do
4
4
  shared_context('parsing an app') do
5
5
  it 'should parse the category attribute' do
6
- expect(@parsed[:category]).to eq('Arcade').or eq('Weather')
6
+ expect(@parsed[:category]).to eq('Arcade').or eq('Weather').or eq('Simulation')
7
7
  end
8
8
 
9
9
  it 'should parse the category_url attribute' do
10
- expect(@parsed[:category_url]).to eq('GAME_ARCADE').or eq('WEATHER')
10
+ expect(@parsed[:category_url]).to eq('GAME_ARCADE').or eq('WEATHER').or eq('GAME_SIMULATION')
11
+ end
12
+
13
+ it 'should parse the categories attribute' do
14
+ expect(@parsed[:categories]).to eq(['Arcade']).or eq(['Weather']).or eq(['Simulation', 'Pretend Play'])
15
+ end
16
+
17
+ it 'should parse the categories_urls attribute' do
18
+ expect(@parsed[:categories_urls]).to eq(['GAME_ARCADE']).or eq(['WEATHER']).or eq(%w[GAME_SIMULATION FAMILY_PRETEND])
11
19
  end
12
20
 
13
21
  it 'should parse the content_rating attribute' do
@@ -83,7 +91,7 @@ describe MarketBot::Play::App do
83
91
 
84
92
  it 'should parse the requires_android attribute' do
85
93
  expect(@parsed[:requires_android]).to \
86
- be_kind_of(String).and match(/\A\d\.\d and up\z/)
94
+ be_kind_of(String).and match(/\A\d(\.\d)* and up\z/)
87
95
  end
88
96
 
89
97
  it 'should parse the reviews attribute' do
@@ -99,7 +107,7 @@ describe MarketBot::Play::App do
99
107
  end
100
108
 
101
109
  it 'should parse the similar attribute' do
102
- expect(@parsed[:similar].length).to be > 0
110
+ expect(@parsed[:similar].length).to be >= 0
103
111
  expect(@parsed[:similar]).to all(be_kind_of(Hash)).and \
104
112
  all(have_key(:package))
105
113
  end
@@ -126,12 +134,33 @@ describe MarketBot::Play::App do
126
134
  it 'should parse the website_url attribute' do
127
135
  expect(@parsed[:website_url]).to be_kind_of(String).and \
128
136
  match(/\Ahttps?:\/\//)
137
+ expect(@parsed[:website_url]).not_to match(/privacy/)
138
+ end
139
+
140
+ it 'should parse the privacy_url attribute' do
141
+ expect(@parsed[:privacy_url]).to match(/\Ahttps?:\/\//).and \
142
+ be_kind_of(String) if @parsed[:privacy_url]
129
143
  end
130
144
 
131
- it 'shoud parse the whats_new attribute' do
145
+ it 'should parse the whats_new attribute' do
132
146
  expect(@parsed[:whats_new]).to be_kind_of(String).or \
133
147
  be_kind_of(NilClass)
134
148
  end
149
+
150
+ it 'should parse the contains_ads attribute' do
151
+ expect(@parsed[:contains_ads]).to eq(true).or \
152
+ eq(false)
153
+ end
154
+
155
+ it 'should parse the in_app_products_price attribute' do
156
+ expect(@parsed[:in_app_products_price]).to eq(nil).or(
157
+ be_kind_of(String).and match(/(.+(\d|.){1,}\ )\-(.+(\d|.){1,})\ per\ item/))
158
+ end
159
+
160
+ it 'should parse the physical_address attribute' do
161
+ expect(@parsed[:physical_address]).to eq(nil).or(
162
+ be_kind_of(String))
163
+ end
135
164
  end
136
165
 
137
166
  context '(app-com.bluefroggaming.popdat)' do
@@ -154,6 +183,16 @@ describe MarketBot::Play::App do
154
183
  end
155
184
  end
156
185
 
186
+ context '(app-com.hasbro.mlpcoreAPPSTORE)' do
187
+ include_context 'parsing an app'
188
+
189
+ before(:all) do
190
+ @package = 'com.hasbro.mlpcoreAPPSTORE'
191
+ @html = read_play_data('app-com.hasbro.mlpcoreAPPSTORE.txt')
192
+ @parsed = MarketBot::Play::App.parse(@html)
193
+ end
194
+ end
195
+
157
196
  it 'should populate the attribute getters' do
158
197
  package = 'app-com.bluefroggaming.popdat'
159
198
  html = read_play_data('app-com.bluefroggaming.popdat.txt')