apprank 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +5 -2
- data/README.md +20 -0
- data/lib/apprank/app.rb +17 -10
- data/spec/app_spec.rb +45 -18
- data/spec/rank_spec.rb +6 -5
- data/spec/spec_helper.rb +15 -129
- metadata +20 -44
- data/README +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 77139758135e695d99945a2ec7655de1bc05e0d0
|
4
|
+
data.tar.gz: b253389211a9491c55c6e0be4b6f052ef40ced3a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 50795ef78b574be4a12b1714b532ffd4484d2c25f385550f1e77c4c80e4a7db0f623ba23405e1f298b5691419ea6f0975fc479f70f6bb8e5b72507fc069a24c2
|
7
|
+
data.tar.gz: 61fff4e7a2e055a6e0e2674153e943da12a16b83145ee59452208cfa513110529b427dad7b0335213b573bae47911bcf7949131f0b4f5c89d5d5f167cb09269c
|
data/Gemfile
CHANGED
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Apprank
|
2
|
+
|
3
|
+
Get iOS app rank data from Apple.
|
4
|
+
|
5
|
+
# Installation
|
6
|
+
|
7
|
+
To install, add apprank to your @Gemfile@ and run `bundle install`:
|
8
|
+
|
9
|
+
```
|
10
|
+
gem 'apprank'
|
11
|
+
```
|
12
|
+
|
13
|
+
## Demo
|
14
|
+
|
15
|
+
```
|
16
|
+
require 'apprank'
|
17
|
+
json = open('http://itunes.apple.com/us/rss/topfreeapplications/limit=25/json')
|
18
|
+
rank = Apprank::Rank.new(json)
|
19
|
+
rank.apps.first.name # => "Some popular free app name"
|
20
|
+
```
|
data/lib/apprank/app.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
module Apprank
|
2
2
|
class App
|
3
3
|
|
4
|
-
attr_accessor :name, :icon_urls, :summary, :price, :rights, :
|
5
|
-
:
|
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
|
6
|
+
|
7
|
+
alias_method :developer, :artist
|
6
8
|
|
7
9
|
def initialize(hash)
|
8
10
|
@name = hash["im:name"]["label"]
|
@@ -23,17 +25,22 @@ module Apprank
|
|
23
25
|
:amount => hash["im:price"]["attributes"]["amount"].to_f,
|
24
26
|
:currency => hash["im:price"]["attributes"]["currency"]
|
25
27
|
}
|
28
|
+
@content_type = hash["rights"]["contentType"]
|
26
29
|
@rights = hash["rights"]["label"]
|
27
|
-
@
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
@title = hash["title"]["label"]
|
31
|
+
|
32
|
+
link = hash["link"]
|
33
|
+
if link["attributes"]["title"] == "Preview"
|
34
|
+
@preview = link["attributes"]["href"]
|
35
|
+
else
|
36
|
+
@link = link["attributes"]["href"]
|
34
37
|
end
|
38
|
+
|
35
39
|
@itunes_url = hash["id"]["label"]
|
36
|
-
@
|
40
|
+
@itunes_id = hash["id"]['attributes']['im:id']
|
41
|
+
@bundle_id = hash["id"]['attributes']['im:bundleId']
|
42
|
+
|
43
|
+
@artist = {
|
37
44
|
:name => hash["im:artist"]["label"],
|
38
45
|
:url => hash["im:artist"]["attributes"]["href"]
|
39
46
|
}
|
data/spec/app_spec.rb
CHANGED
@@ -5,24 +5,51 @@ describe App do
|
|
5
5
|
describe "when you load the data" do
|
6
6
|
it "should get data" do
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
8
|
+
data = JSON.load(SpecHelper.data)
|
9
|
+
app = Apprank::App.new(data['feed']['entry'][0])
|
10
|
+
|
11
|
+
expected = {
|
12
|
+
name: "Color Switch",
|
13
|
+
icon_urls: {
|
14
|
+
small: "http://is3.mzstatic.com/image/thumb/Purple69/v4/d4/70/15/d4701594-2c52-185f-766f-45fd4eab0f75/mzl.ytgnpnrv.png/53x53bb-85.png",
|
15
|
+
medium: "http://is5.mzstatic.com/image/thumb/Purple69/v4/d4/70/15/d4701594-2c52-185f-766f-45fd4eab0f75/mzl.ytgnpnrv.png/75x75bb-85.png",
|
16
|
+
large: "http://is4.mzstatic.com/image/thumb/Purple69/v4/d4/70/15/d4701594-2c52-185f-766f-45fd4eab0f75/mzl.ytgnpnrv.png/100x100bb-85.png",
|
17
|
+
},
|
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
|
+
price: {
|
20
|
+
amount: 0.0,
|
21
|
+
currency: "USD"
|
22
|
+
},
|
23
|
+
rights: "© 2016 Fortafy Games",
|
24
|
+
title: "Color Switch - Samuel Ratumaitavuki",
|
25
|
+
link: "https://itunes.apple.com/us/app/color-switch/id1053533457?mt=8&uo=2",
|
26
|
+
itunes_url: "https://itunes.apple.com/us/app/color-switch/id1053533457?mt=8&uo=2",
|
27
|
+
itunes_id: "1053533457",
|
28
|
+
bundle_id: "com.fortafygames.colorswitch",
|
29
|
+
artist: {
|
30
|
+
name: "Samuel Ratumaitavuki",
|
31
|
+
url: "https://itunes.apple.com/us/developer/samuel-ratumaitavuki/id1053533456?mt=8&uo=2"
|
32
|
+
},
|
33
|
+
category: {
|
34
|
+
name: "Games",
|
35
|
+
url: "https://itunes.apple.com/us/genre/ios-games/id6014?mt=8&uo=2"
|
36
|
+
},
|
37
|
+
}
|
38
|
+
|
39
|
+
expect(app.name).to eq(expected[:name])
|
40
|
+
expect(app.icon_urls).to eq(expected[:icon_urls])
|
41
|
+
expect(app.summary).to eq(expected[:summary])
|
42
|
+
expect(app.price).to eq(expected[:price])
|
43
|
+
expect(app.rights).to eq(expected[:rights])
|
44
|
+
expect(app.title).to eq(expected[:title])
|
45
|
+
expect(app.link).to eq(expected[:link])
|
46
|
+
expect(app.itunes_url).to eq(expected[:itunes_url])
|
47
|
+
expect(app.itunes_id).to eq(expected[:itunes_id])
|
48
|
+
expect(app.bundle_id).to eq(expected[:bundle_id])
|
49
|
+
expect(app.artist).to eq(expected[:artist])
|
50
|
+
expect(app.category).to eq(expected[:category])
|
51
|
+
expect(app.release_date).to be_a(Time)
|
52
|
+
|
26
53
|
|
27
54
|
end
|
28
55
|
end
|
data/spec/rank_spec.rb
CHANGED
@@ -5,11 +5,12 @@ describe Rank do
|
|
5
5
|
describe "when you load the data" do
|
6
6
|
it "should get data" do
|
7
7
|
|
8
|
-
|
9
|
-
rank = Rank.new(
|
10
|
-
|
11
|
-
rank.
|
12
|
-
(rank.
|
8
|
+
data = SpecHelper.data
|
9
|
+
rank = Rank.new(data)
|
10
|
+
|
11
|
+
expect(rank.apps.length).to eq(25)
|
12
|
+
expect(rank.link).to eq("https://itunes.apple.com/us/rss/topfreeapplications/limit=25/json")
|
13
|
+
expect(rank.updated.to_i).to eq(1453708166)
|
13
14
|
|
14
15
|
end
|
15
16
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,137 +1,23 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# load path for ruby 2.x
|
2
|
+
$:<< File.join(File.dirname(__FILE__), '..')
|
3
3
|
|
4
|
+
require 'lib/apprank'
|
4
5
|
include Apprank
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
:small => Faker::Internet.domain_name,
|
12
|
-
:medium => Faker::Internet.domain_name,
|
13
|
-
:large => Faker::Internet.domain_name
|
14
|
-
},
|
15
|
-
:summary => Faker::Company.catch_phrase,
|
16
|
-
:price => {
|
17
|
-
:amount => rand(1000),
|
18
|
-
:currency => Faker::Address.us_state_abbr,
|
19
|
-
},
|
20
|
-
:rights => Faker::Company.name,
|
21
|
-
:title => Faker::Company.bs + Faker::Company.name,
|
22
|
-
:link => Faker::Internet.domain_name,
|
23
|
-
:preview => Faker::Internet.domain_name,
|
24
|
-
:itunes_id => itunes_id,
|
25
|
-
:itunes_url => Faker::Internet.domain_name + '/id' + itunes_id + '?foo=bar',
|
26
|
-
:developer => {
|
27
|
-
:name => Faker::Company.name,
|
28
|
-
:url => Faker::Internet.domain_name
|
29
|
-
},
|
30
|
-
:category => {
|
31
|
-
:name => Faker::Name.last_name,
|
32
|
-
:url => Faker::Internet.domain_name
|
33
|
-
},
|
34
|
-
:release_date => Time.now
|
35
|
-
}
|
7
|
+
RSpec.configure do |config|
|
8
|
+
|
9
|
+
config.expect_with :rspec do |expectations|
|
10
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
11
|
+
end
|
36
12
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
{
|
41
|
-
"label" => expected[:icon_urls][:small],
|
42
|
-
"attributes" => { "height" => "53" }
|
43
|
-
},
|
44
|
-
{
|
45
|
-
"label" => expected[:icon_urls][:medium],
|
46
|
-
"attributes" => { "height" => "75" }
|
47
|
-
},
|
48
|
-
{
|
49
|
-
"label" => expected[:icon_urls][:large],
|
50
|
-
"attributes" => { "height" => "100" }
|
51
|
-
}
|
52
|
-
],
|
53
|
-
"summary" => { "label" => expected[:summary] },
|
54
|
-
"im:price" => {
|
55
|
-
"label" => "Free",
|
56
|
-
"attributes" => {
|
57
|
-
"amount" => expected[:price][:amount],
|
58
|
-
"currency" => expected[:price][:currency]
|
59
|
-
}
|
60
|
-
},
|
61
|
-
"im:contentType" => {
|
62
|
-
"attributes" => {
|
63
|
-
"term" => "Application",
|
64
|
-
"label" => "Application"
|
65
|
-
}
|
66
|
-
},
|
67
|
-
"rights" => { "label" => expected[:rights] },
|
68
|
-
"title" => { "label" => expected[:title] },
|
69
|
-
"link" => [
|
70
|
-
{
|
71
|
-
"attributes" => {
|
72
|
-
"rel" => "alternate",
|
73
|
-
"type" => "text/html",
|
74
|
-
"href" => expected[:link]
|
75
|
-
}
|
76
|
-
},
|
77
|
-
{
|
78
|
-
"im:duration" => { "label" => "0" },
|
79
|
-
"attributes" => {
|
80
|
-
"title" => "Preview",
|
81
|
-
"rel" => "enclosure",
|
82
|
-
"type" => "image/jpeg",
|
83
|
-
"href" => expected[:preview],
|
84
|
-
"im:assetType" => "preview"
|
85
|
-
}
|
86
|
-
}
|
87
|
-
],
|
88
|
-
"id" => { "label" => expected[:itunes_url] },
|
89
|
-
"im:artist" => {
|
90
|
-
"label" => expected[:developer][:name],
|
91
|
-
"attributes" => { "href" => expected[:developer][:url] }
|
92
|
-
},
|
93
|
-
"category" => {
|
94
|
-
"attributes" => {
|
95
|
-
"term" => expected[:category][:name],
|
96
|
-
"scheme" => expected[:category][:url],
|
97
|
-
"label" => expected[:category][:name]
|
98
|
-
}
|
99
|
-
},
|
100
|
-
"im:releaseDate" => {
|
101
|
-
"label" => expected[:release_date].strftime("%Y-%m-%dT%H:%M:%S%z"),
|
102
|
-
"attributes" => { "label" => "November 04, 2010" }
|
103
|
-
}
|
104
|
-
}
|
13
|
+
config.mock_with :rspec do |mocks|
|
14
|
+
mocks.verify_partial_doubles = true
|
15
|
+
end
|
105
16
|
|
106
|
-
[App.new(data), expected, data]
|
107
17
|
end
|
108
18
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
:uri => { :label => Faker::Internet.domain_name }
|
114
|
-
},
|
115
|
-
:entry => length.times.map{ create_fake_app[2] },
|
116
|
-
:updated => { :label => Time.now },
|
117
|
-
:rights => { :label => Faker::Company.catch_phrase },
|
118
|
-
:title => { :label => Faker::Company.bs },
|
119
|
-
:icon => { :label => Faker::Internet.domain_name },
|
120
|
-
:link => [
|
121
|
-
{
|
122
|
-
:attributes => {
|
123
|
-
:rel => "alternate",
|
124
|
-
:type => "text/html",
|
125
|
-
:href => Faker::Internet.domain_name
|
126
|
-
}
|
127
|
-
},
|
128
|
-
{
|
129
|
-
:attributes => {
|
130
|
-
:rel => "self",
|
131
|
-
:href => Faker::Internet.domain_name + "?cc=us"
|
132
|
-
}
|
133
|
-
}
|
134
|
-
],
|
135
|
-
:id => { :label => Faker::Internet.domain_name + "?cc=us" }
|
136
|
-
}
|
19
|
+
module SpecHelper
|
20
|
+
def self.data
|
21
|
+
open('./spec/fixtures/data.json')
|
22
|
+
end
|
137
23
|
end
|
metadata
CHANGED
@@ -1,36 +1,24 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: apprank
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: false
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 0
|
9
|
-
- 1
|
10
|
-
version: 0.0.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- hc5duke
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2010-12-25 00:00:00 -08:00
|
19
|
-
default_executable:
|
11
|
+
date: 2016-01-25 00:00:00.000000000 Z
|
20
12
|
dependencies: []
|
21
|
-
|
22
13
|
description: Apprank parses iOS app rank data from Apple.
|
23
14
|
email: hc5duke@gmail.com
|
24
15
|
executables: []
|
25
|
-
|
26
16
|
extensions: []
|
27
|
-
|
28
17
|
extra_rdoc_files: []
|
29
|
-
|
30
|
-
files:
|
18
|
+
files:
|
31
19
|
- Gemfile
|
32
20
|
- LICENSE
|
33
|
-
- README
|
21
|
+
- README.md
|
34
22
|
- lib/apprank.rb
|
35
23
|
- lib/apprank/app.rb
|
36
24
|
- lib/apprank/rank.rb
|
@@ -39,39 +27,27 @@ files:
|
|
39
27
|
- spec/rcov.opts
|
40
28
|
- spec/spec.opts
|
41
29
|
- spec/spec_helper.rb
|
42
|
-
has_rdoc: true
|
43
30
|
homepage: https://www.github.com/hc5duke/apprank
|
44
31
|
licenses: []
|
45
|
-
|
32
|
+
metadata: {}
|
46
33
|
post_install_message:
|
47
34
|
rdoc_options: []
|
48
|
-
|
49
|
-
require_paths:
|
35
|
+
require_paths:
|
50
36
|
- lib
|
51
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
-
|
53
|
-
requirements:
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
54
39
|
- - ">="
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
version: "0"
|
60
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
-
none: false
|
62
|
-
requirements:
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
63
44
|
- - ">="
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
66
|
-
segments:
|
67
|
-
- 0
|
68
|
-
version: "0"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
69
47
|
requirements: []
|
70
|
-
|
71
48
|
rubyforge_project:
|
72
|
-
rubygems_version:
|
49
|
+
rubygems_version: 2.5.1
|
73
50
|
signing_key:
|
74
|
-
specification_version:
|
75
|
-
summary:
|
51
|
+
specification_version: 4
|
52
|
+
summary: Parse iTunes app store data
|
76
53
|
test_files: []
|
77
|
-
|
data/README
DELETED
File without changes
|