mobile_stores 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +32 -0
- data/Gemfile.lock +155 -0
- data/Guardfile +14 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +65 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/lib/.DS_Store +0 -0
- data/lib/mobile_stores.rb +24 -0
- data/lib/mobile_stores/amazon_marketplace.rb +70 -0
- data/lib/mobile_stores/app.rb +60 -0
- data/lib/mobile_stores/app_store.rb +56 -0
- data/lib/mobile_stores/black_berry_world.rb +55 -0
- data/lib/mobile_stores/google_play.rb +61 -0
- data/lib/mobile_stores/mobile_store.rb +176 -0
- data/lib/mobile_stores/windows_store.rb +72 -0
- data/spec/amazon_marketplace_spec.rb +53 -0
- data/spec/app_spec.rb +64 -0
- data/spec/app_store_spec.rb +65 -0
- data/spec/blackberry_world_spec.rb +53 -0
- data/spec/google_play_spec.rb +53 -0
- data/spec/mobile_store_spec.rb +56 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/windows_store_spec.rb +63 -0
- data/test/helper.rb +18 -0
- data/test/test_mobile_stores.rb +7 -0
- metadata +272 -0
@@ -0,0 +1,53 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module MobileStores
|
4
|
+
describe "AmazonMarketplace" do
|
5
|
+
describe ".find" do
|
6
|
+
it "should select single app by ID" do
|
7
|
+
app = AmazonMarketplace.new.find("B004SBQGHS")
|
8
|
+
app.should_not be_nil
|
9
|
+
|
10
|
+
[:title, :application_id, :creator_name, :creator_id, :version, :rating, :description, :category, :icon_url, :view_url, :price, :compatibility, :screenshot_urls].each do |field|
|
11
|
+
app.send(field).should_not be_nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return correct information for single app by application id" do
|
16
|
+
# find Angry birds app (http://www.amazon.com/gp/product/B004SBQGHS)
|
17
|
+
app = App.in(:amazon_marketplace).find("B004SBQGHS")
|
18
|
+
app.should_not be_nil
|
19
|
+
app.title.should eq("Angry Birds (Ad-Free)")
|
20
|
+
app.application_id.should eq("B004SBQGHS")
|
21
|
+
app.creator_name.should eq("Rovio Entertainment Ltd.")
|
22
|
+
app.creator_id.should eq("Rovio Entertainment Ltd.")
|
23
|
+
app.version.should match(/\d+\.\d+\.\d+/)
|
24
|
+
app.rating.to_i.should eq(4)
|
25
|
+
app.description.should match /^It's Birds vs. Pigs!/
|
26
|
+
app.category.should eq("Games")
|
27
|
+
app.icon_url.should eq("http://ecx.images-amazon.com/images/I/61bZ2vhn4kL._SL512_AA512_.png")
|
28
|
+
app.view_url.should eq("http://www.amazon.com/gp/product/B004SBQGHS")
|
29
|
+
app.price.should eq(0.99)
|
30
|
+
app.compatibility.should eq("Android 2.3")
|
31
|
+
app.screenshot_urls.should include("http://ecx.images-amazon.com/images/I/71DxlUnAJ0L._SL1024_AA1024_.jpg")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".search" do
|
36
|
+
it "should select multiple apps by query" do
|
37
|
+
apps = AmazonMarketplace.new.search("angry")
|
38
|
+
apps.should_not be_empty
|
39
|
+
apps.first.title.should match /Angry Birds/
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should respect small count argument" do
|
43
|
+
apps = AmazonMarketplace.new.search("angry", 3)
|
44
|
+
apps.size.should eq(3)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should respect large count argument" do
|
48
|
+
apps = AmazonMarketplace.new.search("angry", 200)
|
49
|
+
apps.size.should eq(200)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/spec/app_spec.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module MobileStores
|
4
|
+
describe "App" do
|
5
|
+
describe "#in" do
|
6
|
+
it "should accept symbol as argument" do
|
7
|
+
stores = {
|
8
|
+
app_store: AppStore,
|
9
|
+
google_play: GooglePlay,
|
10
|
+
windows_store: WindowsStore,
|
11
|
+
blackberry_world: BlackBerryWorld,
|
12
|
+
amazon_marketplace: AmazonMarketplace
|
13
|
+
}
|
14
|
+
|
15
|
+
stores.each_pair do |store, klass|
|
16
|
+
App.in(store).should be_a klass
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should accept string as argument" do
|
21
|
+
stores = [AppStore, GooglePlay, WindowsStore, BlackBerryWorld, AmazonMarketplace]
|
22
|
+
|
23
|
+
stores.each do |store|
|
24
|
+
App.in(store.to_s).should be_a store
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should raise not found error for unknown store" do
|
29
|
+
expect{ App.in("UnknownStore") }.to raise_error
|
30
|
+
expect{ App.in(:unknown_store) }.to raise_error
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#app_store" do
|
35
|
+
it "should return AppStore class" do
|
36
|
+
App.app_store.should be_an AppStore
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#google_play" do
|
41
|
+
it "should return GooglePlay class" do
|
42
|
+
App.google_play.should be_a GooglePlay
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#windows_store" do
|
47
|
+
it "should return WindowsStore class" do
|
48
|
+
App.windows_store.should be_a WindowsStore
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#blackberry_world" do
|
53
|
+
it "should return BlackBerryWorld class" do
|
54
|
+
App.blackberry_world.should be_a BlackBerryWorld
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe "#amazon_marketplace" do
|
59
|
+
it "should return AmazonMarketplace class" do
|
60
|
+
App.amazon_marketplace.should be_a AmazonMarketplace
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module MobileStores
|
4
|
+
describe "AppStore" do
|
5
|
+
describe ".find" do
|
6
|
+
it "should select single app by ID" do
|
7
|
+
app = AppStore.new.find("343200656")
|
8
|
+
app.should_not be_nil
|
9
|
+
|
10
|
+
[:title, :application_id, :creator_name, :creator_id, :version, :rating, :description, :category, :icon_url, :view_url, :price, :compatibility, :screenshot_urls].each do |field|
|
11
|
+
app.send(field).should_not be_nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should raise error if store is not specified" do
|
16
|
+
expect{ App.find("unknown id") }.to raise_error(NoMethodError)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should return correct information for single app by application id" do
|
20
|
+
# find Angry birds app (https://itunes.apple.com/us/app/angry-birds/id343200656)
|
21
|
+
app = App.in(:app_store).find("343200656")
|
22
|
+
app.should_not be_nil
|
23
|
+
app.title.should eq("Angry Birds")
|
24
|
+
app.application_id.should eq("343200656")
|
25
|
+
app.creator_name.should eq("Rovio Entertainment Ltd")
|
26
|
+
app.creator_id.should eq("298910979")
|
27
|
+
app.version.should match(/\d+\.\d+\.\d+/)
|
28
|
+
app.rating.should eq(4.5)
|
29
|
+
app.description.should match /^Use the unique powers/
|
30
|
+
app.category.should eq("Games")
|
31
|
+
app.icon_url.should eq("http://a1974.phobos.apple.com/us/r30/Purple/v4/fd/dc/91/fddc91e7-c6b2-2552-bf24-d0dce3ef72b6/mzl.onvampds.png")
|
32
|
+
app.view_url.should eq("https://itunes.apple.com/us/app/angry-birds/id343200656?mt=8&uo=4")
|
33
|
+
app.price.should eq(0.99)
|
34
|
+
app.compatibility.should eq(["iPadWifi", "iPodTouchFifthGen", "iPadThirdGen4G", "iPadFourthGen", "iPad3G", "iPadMini", "iPhone4", "iPodTouchourthGen", "iPhone5c", "iPhone-3GS", "iPadFourthGen4G", "iPadMini4G", "iPad23G", "iPadThirdGen", "iPad2Wifi", "iPhone4S", "iPhone5", "iPodTouchThirdGen", "iPhone5s"].sort)
|
35
|
+
app.screenshot_urls.should include("http://a5.mzstatic.com/us/r30/Purple/v4/9b/48/67/9b48678d-39e2-026f-7fdb-410cfdfa7a8d/screen1136x1136.jpeg")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should not raise error if app exists for specified store and country" do
|
39
|
+
expect{ App.in(:app_store).country(:ru).find!("724254877") }.not_to raise_error
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should raise error if app doesn't exist for specified store and country" do
|
43
|
+
expect{ App.in(:app_store).country(:in).find!("724254877") }.to raise_error
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe ".search" do
|
48
|
+
it "should select multiple apps by query" do
|
49
|
+
apps = AppStore.new.search("angry")
|
50
|
+
apps.should_not be_empty
|
51
|
+
apps.first.title.should match /Angry Birds/
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should respect small count argument" do
|
55
|
+
apps = AppStore.new.search("angry", 3)
|
56
|
+
apps.size.should eq(3)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should respect large count argument" do
|
60
|
+
apps = AppStore.new.search("angry", 200)
|
61
|
+
apps.size.should eq(200)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module MobileStores
|
4
|
+
describe "BlackBerryWorld" do
|
5
|
+
describe ".find" do
|
6
|
+
it "should select single app by ID" do
|
7
|
+
app = BlackBerryWorld.new.find("21717683")
|
8
|
+
app.should_not be_nil
|
9
|
+
|
10
|
+
[:title, :application_id, :creator_name, :creator_id, :version, :rating, :description, :category, :icon_url, :view_url, :price, :compatibility, :screenshot_urls].each do |field|
|
11
|
+
app.send(field).should_not be_nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return correct information for single app by application id" do
|
16
|
+
# find Angry birds app (https://play.google.com/store/apps/details?id=com.rovio.angrybirds)
|
17
|
+
app = App.in(:blackberry_world).find("85455")
|
18
|
+
app.should_not be_nil
|
19
|
+
app.title.should eq("Viber")
|
20
|
+
app.application_id.should eq(85455)
|
21
|
+
app.creator_name.should eq("Viber Media Inc")
|
22
|
+
app.creator_id.should eq(20886)
|
23
|
+
app.version.should match(/\d+\.\d+\.\d+/)
|
24
|
+
app.rating.should be_nil
|
25
|
+
app.description.should match /^Send free messages and make free calls/
|
26
|
+
app.category.should eq("Social Networking")
|
27
|
+
app.icon_url.should eq("http://appworld.blackberry.com/webstore/servedimages/2506685.png/?t=2")
|
28
|
+
app.view_url.should eq("http://appworld.blackberry.com/webstore/content/85455")
|
29
|
+
app.price.should eq(0)
|
30
|
+
app.compatibility.should include("8100")
|
31
|
+
app.screenshot_urls.should include("http://appworld.blackberry.com/webstore/servedimages/18254169.png/?t=11")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".search" do
|
36
|
+
it "should select multiple apps by query" do
|
37
|
+
apps = BlackBerryWorld.new.search("viber")
|
38
|
+
apps.should_not be_empty
|
39
|
+
apps.first.title.should match /Viber/
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should respect small count argument" do
|
43
|
+
apps = BlackBerryWorld.new.search("game", 3)
|
44
|
+
apps.size.should eq(3)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should respect large count argument" do
|
48
|
+
apps = BlackBerryWorld.new.search("game", 200)
|
49
|
+
apps.size.should eq(200)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module MobileStores
|
4
|
+
describe "GooglePlay" do
|
5
|
+
describe ".find" do
|
6
|
+
it "should select single app by ID" do
|
7
|
+
app = GooglePlay.new.find("com.rovio.angrybirds")
|
8
|
+
app.should_not be_nil
|
9
|
+
|
10
|
+
[:title, :application_id, :creator_name, :creator_id, :version, :rating, :description, :category, :icon_url, :view_url, :price, :compatibility, :screenshot_urls].each do |field|
|
11
|
+
app.send(field).should_not be_nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should return correct information for single app by application id" do
|
16
|
+
# find Angry birds app (https://play.google.com/store/apps/details?id=com.rovio.angrybirds)
|
17
|
+
app = App.in(:google_play).find("com.rovio.angrybirds")
|
18
|
+
app.should_not be_nil
|
19
|
+
app.title.should eq("Angry Birds")
|
20
|
+
app.application_id.should eq("com.rovio.angrybirds")
|
21
|
+
app.creator_name.should eq("Rovio Mobile Ltd.")
|
22
|
+
app.creator_id.should eq("Rovio Mobile Ltd.")
|
23
|
+
app.version.should match(/\d+\.\d+\.\d+/)
|
24
|
+
app.rating.to_i.should eq(4)
|
25
|
+
app.description.should match /^The survival of the Angry Birds/
|
26
|
+
app.category.should eq("Arcade & Action")
|
27
|
+
app.icon_url.should eq("https://lh6.ggpht.com/M9q_Zs_CRt2rbA41nTMhrPqiBxhUEUN8Z1f_mn9m89_TiHbIbUF8hjnc_zwevvLsRIJy=w300")
|
28
|
+
app.view_url.should eq("https://play.google.com/store/apps/details?hl=en&id=com.rovio.angrybirds")
|
29
|
+
app.price.should eq(0)
|
30
|
+
app.compatibility.should eq("2.3 and up")
|
31
|
+
app.screenshot_urls.should include("https://lh3.ggpht.com/nt7lisvneE-S-W1SP8hjfLD-JVrX_cuWLJaT2eKKn4LmvpzscqwXS1vnl_GSN95JCm2P=h900")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe ".search" do
|
36
|
+
it "should select multiple apps by query" do
|
37
|
+
apps = GooglePlay.new.search("angry")
|
38
|
+
apps.should_not be_empty
|
39
|
+
apps.first.title.should match /Angry Birds/
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should respect small count argument" do
|
43
|
+
apps = GooglePlay.new.search("angry", 3)
|
44
|
+
apps.size.should eq(3)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should respect large count argument" do
|
48
|
+
apps = GooglePlay.new.search("angry", 200)
|
49
|
+
apps.size.should eq(200)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module MobileStores
|
4
|
+
describe "MobileStore" do
|
5
|
+
describe ".initialize" do
|
6
|
+
it "should select United States as default country" do
|
7
|
+
App.in(:app_store).country.alpha2.should eq('US')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe ".country" do
|
12
|
+
it "should return MobileStore object with country selected" do
|
13
|
+
App.in(:app_store).country(:in).country.name.should eq('India')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".find" do
|
18
|
+
it "should raise error if store is not specified" do
|
19
|
+
expect{ App.find("unknown id") }.to raise_error(NoMethodError)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return nil if app was not found" do
|
23
|
+
App.in(:app_store).find("unknown id").should be_nil
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe ".find!" do
|
28
|
+
it "should raise error if store is not specified" do
|
29
|
+
expect{ App.find!("unknown id") }.to raise_error(NoMethodError)
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should raise error if app was not found" do
|
33
|
+
expect{ App.in(:app_store).find!("unknown id") }.to raise_error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe ".exists?" do
|
38
|
+
it "should return true if app exists for specified store and country" do
|
39
|
+
App.in(:app_store).exists?("343200656").should be_true
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return false if app doesn't exist for specified store and country" do
|
43
|
+
App.in(:app_store).exists?("unknown id").should be_false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#find_app" do
|
48
|
+
it "should return single app by application id" do
|
49
|
+
# find Angry birds app (https://itunes.apple.com/us/app/angry-birds/id343200656)
|
50
|
+
app = AppStore.find_app("343200656", Country.new('US'))
|
51
|
+
app.should_not be_nil
|
52
|
+
app.title.should eq("Angry Birds")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
module MobileStores
|
6
|
+
describe "WindowsStore" do
|
7
|
+
describe ".find" do
|
8
|
+
it "should select single app by ID" do
|
9
|
+
app = WindowsStore.new.find("angry-birds/9168c4f3-217b-4a29-b543-7513bb4ae2ed")
|
10
|
+
app.should_not be_nil
|
11
|
+
|
12
|
+
[:title, :application_id, :creator_name, :creator_id, :version, :rating, :description, :category, :icon_url, :view_url, :price, :compatibility, :screenshot_urls].each do |field|
|
13
|
+
app.send(field).should_not be_nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should return correct information for single app by application id" do
|
18
|
+
# find Angry birds app (https://play.google.com/store/apps/details?id=com.rovio.angrybirds)
|
19
|
+
app = App.in(:windows_store).find("angry-birds/9168c4f3-217b-4a29-b543-7513bb4ae2ed")
|
20
|
+
app.should_not be_nil
|
21
|
+
app.title.should eq("Angry Birds")
|
22
|
+
app.application_id.should eq("angry-birds/9168c4f3-217b-4a29-b543-7513bb4ae2ed")
|
23
|
+
app.creator_name.should eq("Rovio Entertainment Ltd")
|
24
|
+
app.creator_id.should eq("Rovio Entertainment Ltd")
|
25
|
+
app.version.should match(/\d+\.\d+\.\d+\.\d+/)
|
26
|
+
app.rating.to_i.should_not be_nil
|
27
|
+
app.description.should match /^Use the unique powers of the Angry Birds/
|
28
|
+
app.category.should eq("Games")
|
29
|
+
app.icon_url.should eq("http://cdn.marketplaceimages.windowsphone.com/v8/images/5f34c7c6-63f6-4113-bfa0-5d3380601252?imageType=ws_icon_large")
|
30
|
+
app.view_url.should eq("http://www.windowsphone.com/en-us/store/app/angry-birds/9168c4f3-217b-4a29-b543-7513bb4ae2ed")
|
31
|
+
app.price.should eq(0.99)
|
32
|
+
app.compatibility.should include("Windows Phone 8")
|
33
|
+
app.screenshot_urls.should_not be_empty
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should not raise error if app exists for specified store and country" do
|
37
|
+
expect{ App.in(:windows_store).country(:ru).find!("женский-календарь/1475828d-8d46-e011-854c-00237de2db9e") }.not_to raise_error
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should raise error if app doesn't exist for specified store and country" do
|
41
|
+
expect{ App.in(:windows_store).country(:in).find!("женский-календарь") }.to raise_error
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe ".search" do
|
46
|
+
it "should select multiple apps by query" do
|
47
|
+
apps = WindowsStore.new.search("angry")
|
48
|
+
apps.should_not be_empty
|
49
|
+
apps.first.title.should match /Angry Birds/
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should respect small count argument" do
|
53
|
+
apps = WindowsStore.new.search("angry", 3)
|
54
|
+
apps.size.should eq(3)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should respect large count argument" do
|
58
|
+
apps = WindowsStore.new.search("angry", 200)
|
59
|
+
apps.size.should eq(200)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'mobile_stores'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|