apprank 1.0.0 → 1.0.1
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 +4 -4
- data/lib/apprank/app.rb +51 -36
- data/spec/app_spec.rb +7 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0dc98edfdf5566cc325fe4c2b4861da11378db2
|
4
|
+
data.tar.gz: a66d02c721925e4165e7632471f4549942aa3f9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b347c8599d3aa6cc5863fd754012a8d175bc5751e750fe11fb4313c1b5cf806b6950ce5785a1874a7dd5d322a1281b44dea7a76ffb4bab436b3140927f8b93fd
|
7
|
+
data.tar.gz: 1becef818b6ddb8174ed9e9e0c6f44eab02415b2f115a2bd4971ba7f53b68ddb928b98726501d8c1647399991acdad600a1f11e7b008cad0525ea2ef36b18065
|
data/lib/apprank/app.rb
CHANGED
@@ -2,62 +2,77 @@ module Apprank
|
|
2
2
|
class App
|
3
3
|
|
4
4
|
attr_accessor :name, :icon_urls, :summary, :price, :content_type, :rights, :title,
|
5
|
-
:link, :itunes_url, :itunes_id, :bundle_id, :artist, :artist, :category, :release_date
|
5
|
+
:link, :preview, :itunes_url, :itunes_id, :bundle_id, :artist, :artist, :category, :release_date
|
6
6
|
|
7
7
|
alias_method :developer, :artist
|
8
8
|
|
9
9
|
def initialize(hash)
|
10
|
-
@name
|
11
|
-
@icon_urls =
|
12
|
-
hash
|
13
|
-
|
14
|
-
if image["attributes"]["height"] == '53'
|
15
|
-
:small
|
16
|
-
elsif image["attributes"]["height"] == '75'
|
17
|
-
:medium
|
18
|
-
else
|
19
|
-
:large
|
20
|
-
end
|
21
|
-
@icon_urls[height] = image["label"]
|
22
|
-
end
|
23
|
-
@summary = hash["summary"]["label"]
|
10
|
+
@name = App.get_label(hash, "im:name")
|
11
|
+
@icon_urls = App.get_icon_urls(hash["im:image"])
|
12
|
+
@summary = App.get_label(hash, "summary")
|
13
|
+
|
24
14
|
@price = {
|
25
|
-
:
|
26
|
-
:
|
15
|
+
amount: App.get_attributes(hash, "im:price")["amount"].to_f,
|
16
|
+
currency: App.get_attributes(hash, "im:price")["currency"],
|
27
17
|
}
|
28
|
-
@content_type = hash
|
29
|
-
@rights = hash
|
30
|
-
@title
|
31
|
-
|
32
|
-
link = hash["link"]
|
33
|
-
if link["attributes"]["title"] == "Preview"
|
34
|
-
@preview = link["attributes"]["href"]
|
35
|
-
else
|
36
|
-
@link = link["attributes"]["href"]
|
37
|
-
end
|
18
|
+
@content_type = App.get_attributes(hash, "im:contentType")["term"]
|
19
|
+
@rights = App.get_label(hash, "rights")
|
20
|
+
@title = App.get_label(hash, "title")
|
21
|
+
@link = App.get_attributes(hash, "link")["href"]
|
38
22
|
|
39
|
-
@itunes_url = hash
|
40
|
-
@itunes_id
|
41
|
-
@bundle_id
|
23
|
+
@itunes_url = App.get_label(hash, "id")
|
24
|
+
@itunes_id = App.get_attributes(hash, "id")['im:id']
|
25
|
+
@bundle_id = App.get_attributes(hash, "id")['im:bundleId']
|
42
26
|
|
43
27
|
@artist = {
|
44
|
-
:name => hash
|
45
|
-
:url => hash
|
28
|
+
:name => App.get_label(hash, "im:artist"),
|
29
|
+
:url => App.get_attributes(hash, "im:artist")["href"],
|
46
30
|
}
|
31
|
+
category = App.get_attributes(hash, "category")
|
47
32
|
@category = {
|
48
|
-
:name =>
|
49
|
-
:url =>
|
33
|
+
:name => category["term"],
|
34
|
+
:url => category["scheme"],
|
50
35
|
}
|
51
|
-
@release_date = Time.parse(hash
|
36
|
+
@release_date = Time.parse(App.get_label(hash, "im:releaseDate"))
|
52
37
|
end
|
53
38
|
|
54
39
|
def itunes_id
|
55
|
-
self.itunes_url.split(/\//).last.split(/\?/).first.gsub(/[^\d]/,'')
|
40
|
+
self.itunes_url.split(/\//).last.split(/\?/).first.gsub(/[^\d]/, '')
|
41
|
+
end
|
42
|
+
|
43
|
+
def category_id
|
44
|
+
self.category[:url].split(/\//).last.split(/\?/).first.gsub(/[^\d]/, '')
|
56
45
|
end
|
57
46
|
|
58
47
|
def is_free?
|
59
48
|
self.price[:amount].zero?
|
60
49
|
end
|
61
50
|
|
51
|
+
private
|
52
|
+
|
53
|
+
def self.get_attributes(hash, field)
|
54
|
+
hash[field]["attributes"]
|
55
|
+
end
|
56
|
+
|
57
|
+
def self.get_label(hash, field)
|
58
|
+
hash[field]["label"]
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.get_icon_urls(images)
|
62
|
+
icon_urls = {}
|
63
|
+
images.each do |image|
|
64
|
+
height =
|
65
|
+
if image["attributes"]["height"] == '53'
|
66
|
+
:small
|
67
|
+
elsif image["attributes"]["height"] == '75'
|
68
|
+
:medium
|
69
|
+
else
|
70
|
+
:large
|
71
|
+
end
|
72
|
+
icon_urls[height] = image["label"]
|
73
|
+
end
|
74
|
+
icon_urls
|
75
|
+
end
|
76
|
+
|
62
77
|
end
|
63
78
|
end
|
data/spec/app_spec.rb
CHANGED
@@ -17,9 +17,10 @@ describe App do
|
|
17
17
|
},
|
18
18
|
summary: "Tap the ball carefully through each obstacle and your ball will switch color with some powerups.\nYou must follow the color pattern on each obstacle to cross it ! \n\nBe careful not to pass through the wrong color, or you’ll have to start again.",
|
19
19
|
price: {
|
20
|
-
amount:
|
20
|
+
amount: 0.0,
|
21
21
|
currency: "USD"
|
22
22
|
},
|
23
|
+
content_type: "Application",
|
23
24
|
rights: "© 2016 Fortafy Games",
|
24
25
|
title: "Color Switch - Samuel Ratumaitavuki",
|
25
26
|
link: "https://itunes.apple.com/us/app/color-switch/id1053533457?mt=8&uo=2",
|
@@ -32,7 +33,7 @@ describe App do
|
|
32
33
|
},
|
33
34
|
category: {
|
34
35
|
name: "Games",
|
35
|
-
url:
|
36
|
+
url: "https://itunes.apple.com/us/genre/ios-games/id6014?mt=8&uo=2"
|
36
37
|
},
|
37
38
|
}
|
38
39
|
|
@@ -40,6 +41,7 @@ describe App do
|
|
40
41
|
expect(app.icon_urls).to eq(expected[:icon_urls])
|
41
42
|
expect(app.summary).to eq(expected[:summary])
|
42
43
|
expect(app.price).to eq(expected[:price])
|
44
|
+
expect(app.content_type).to eq(expected[:content_type])
|
43
45
|
expect(app.rights).to eq(expected[:rights])
|
44
46
|
expect(app.title).to eq(expected[:title])
|
45
47
|
expect(app.link).to eq(expected[:link])
|
@@ -50,6 +52,9 @@ describe App do
|
|
50
52
|
expect(app.category).to eq(expected[:category])
|
51
53
|
expect(app.release_date).to be_a(Time)
|
52
54
|
|
55
|
+
expect(app.itunes_id).to eq("1053533457")
|
56
|
+
expect(app.category_id).to eq("6014")
|
57
|
+
|
53
58
|
|
54
59
|
end
|
55
60
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apprank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hc5duke
|
@@ -28,7 +28,8 @@ files:
|
|
28
28
|
- spec/spec.opts
|
29
29
|
- spec/spec_helper.rb
|
30
30
|
homepage: https://www.github.com/hc5duke/apprank
|
31
|
-
licenses:
|
31
|
+
licenses:
|
32
|
+
- MIT
|
32
33
|
metadata: {}
|
33
34
|
post_install_message:
|
34
35
|
rdoc_options: []
|