daily-trending-apps 0.1.7 → 0.1.8
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/daily_trending/app.rb +7 -25
- data/lib/daily_trending/cli.rb +41 -34
- data/lib/daily_trending/scraper.rb +24 -10
- data/lib/daily_trending/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d64862a39481fe7803dbc67e92bf17d1430e955308530bc5785c36d42d8b4ef
|
4
|
+
data.tar.gz: 179567ec2b353889b6cac6468a7d68b56d718672f18d064977e947c67a1d468f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c076c5c33ebd88ffee0ca7ee20811ddf39c8afa45ee46a0ccdd00bd111aa046e523ff255f2a9f3408be119b26aee586b42f3598ef609c4ae206e9e1d90a1ae31
|
7
|
+
data.tar.gz: 2888a2fc353c1d7fef7331bd15069d058854028c259f4a6f787ead460928bed88238e2b54df0de64a499bdeadefcac1f3ee5c076e652d96728106bb68908e67a
|
data/lib/daily_trending/app.rb
CHANGED
@@ -3,22 +3,13 @@ class DailyTrending::App
|
|
3
3
|
@@all = []
|
4
4
|
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def self.all
|
7
|
+
@@all
|
8
|
+
end
|
10
9
|
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
app = self.new
|
15
|
-
app.title = a.css('a.title').attribute('title').value
|
16
|
-
app.dev = a.css('a.subtitle').attribute('title').value
|
17
|
-
app.dev_url = ("https://play.google.com" + a.css('a.subtitle').attribute('href').value)
|
18
|
-
app.app_url = ("https://play.google.com" + a.css('a.title').attribute('href').value)
|
19
|
-
app.rating = a.css('div.tiny-star').attribute('aria-label').value.strip.slice(/\d.\S/)<<"/5 Stars"
|
20
|
-
app.price = a.at_css('span.display-price').text
|
21
|
-
app.exist? ? all.freeze : app.save
|
11
|
+
def self.find(input)
|
12
|
+
@@all[input.to_i-1]
|
22
13
|
end
|
23
14
|
|
24
15
|
|
@@ -31,16 +22,7 @@ class DailyTrending::App
|
|
31
22
|
@@all << self
|
32
23
|
end
|
33
24
|
|
34
|
-
def
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
|
39
|
-
def make_app(xml_info)
|
40
|
-
page = xml_info
|
41
|
-
self.genre = page.css('a.document-subtitle.category').text
|
42
|
-
self.description = page.css('div.show-more-content.text-body').text
|
43
|
-
self.con_rating = page.css('span.document-subtitle.content-rating-title').text
|
44
|
-
self.rate_cnt = page.css('span.rating-count').text
|
25
|
+
def open_in_browser
|
26
|
+
system("open '#{app_url}'")
|
45
27
|
end
|
46
28
|
end
|
data/lib/daily_trending/cli.rb
CHANGED
@@ -3,7 +3,6 @@ class DailyTrending::Cli
|
|
3
3
|
def call
|
4
4
|
list_apps
|
5
5
|
menu
|
6
|
-
goodbye
|
7
6
|
end
|
8
7
|
|
9
8
|
def list_apps
|
@@ -11,9 +10,8 @@ class DailyTrending::Cli
|
|
11
10
|
puts ""
|
12
11
|
puts " #{s}"+"New And Updated Apps!"+s
|
13
12
|
puts ""
|
14
|
-
|
15
|
-
|
16
|
-
@apps.each.with_index(1) do |app, i|
|
13
|
+
DailyTrending::Scraper.new.scrape_index_page
|
14
|
+
DailyTrending::App.all.each.with_index(1) do |app, i|
|
17
15
|
puts <<-DOC
|
18
16
|
#{i}. #{app.title.colorize(:blue)}
|
19
17
|
#{app.rating} Cost: #{app.price}
|
@@ -21,27 +19,31 @@ class DailyTrending::Cli
|
|
21
19
|
DOC
|
22
20
|
end
|
23
21
|
puts ""
|
22
|
+
puts "Enter the number of the app you'd like more info on, or type exit"
|
24
23
|
end
|
25
24
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
25
|
+
|
26
|
+
def menu
|
27
|
+
input = nil
|
28
|
+
until input == 'exit'
|
29
|
+
input = gets.strip.downcase
|
30
|
+
|
31
|
+
if input.to_i > 0 && input.to_i <= DailyTrending::App.all.size
|
32
|
+
app_info(DailyTrending::App.find(input))
|
33
|
+
elsif input == 'list'
|
34
|
+
list_apps
|
35
|
+
elsif input == 'exit'
|
36
|
+
goodbye
|
37
|
+
else
|
38
|
+
puts " #{input} not an option, type list or exit" unless input == 'exit'
|
39
39
|
end
|
40
40
|
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
41
44
|
|
42
45
|
def app_info(app)
|
43
|
-
|
44
|
-
app.make_app(xml_info)
|
46
|
+
DailyTrending::Scraper.new.scrape_app(app)
|
45
47
|
puts <<-DOC
|
46
48
|
#{app.title.upcase.colorize(:blue)}
|
47
49
|
Developers: #{app.dev}
|
@@ -58,23 +60,28 @@ class DailyTrending::Cli
|
|
58
60
|
More Apps By #{app.dev}: #{app.dev_url.colorize(:red)}
|
59
61
|
|
60
62
|
DOC
|
61
|
-
|
63
|
+
# open_browser(app)
|
64
|
+
|
62
65
|
puts " Type 'list' to see apps again or 'exit' to leave"
|
63
|
-
|
64
|
-
input = gets.strip.downcase
|
65
|
-
if input == 'list'
|
66
|
-
list_apps
|
67
|
-
elsif input == 'exit'
|
68
|
-
goodbye
|
69
|
-
exit
|
70
|
-
else
|
71
|
-
puts " #{input} not an option, type list or exit" unless input == 'exit'
|
72
|
-
end
|
73
|
-
end
|
66
|
+
menu
|
74
67
|
end
|
75
68
|
|
76
69
|
|
77
|
-
|
78
|
-
|
79
|
-
|
70
|
+
def goodbye
|
71
|
+
puts "See you next time!!"
|
72
|
+
exit
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# def open_browser(app)
|
77
|
+
# puts "Would you like to visit this App page?? (y/n)"
|
78
|
+
# input = gets.strip.downcase
|
79
|
+
#
|
80
|
+
# if input == 'y'
|
81
|
+
# app.open_in_browser
|
82
|
+
# else
|
83
|
+
# list_apps
|
84
|
+
# end
|
85
|
+
# end
|
86
|
+
|
80
87
|
end
|
@@ -1,19 +1,33 @@
|
|
1
1
|
class DailyTrending::Scraper
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
|
4
|
+
def initialize
|
5
|
+
@base_link = "https://play.google.com"
|
6
6
|
end
|
7
|
+
# Why was instance variable @base_link not available in #scrape_app before I made #initialize??
|
8
|
+
# Didn't work in #scrape_app when I assigned it in #scrape_index_page
|
7
9
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
10
|
+
def scrape_index_page
|
11
|
+
index_page = Nokogiri::HTML(open("#{@base_link}/store/apps/collection/promotion_3000792_new_releases_apps?clp=SpEBCikKI3Byb21vdGlvbl8zMDAwNzkyX25ld19yZWxlYXNlc19hcHBzEAcYAxpkCl5uZXdfaG9tZV9kZXZpY2VfZmVhdHVyZWRfcmVjczJfdG9waWNfdjFfbGF1bmNoX2FwcHNfVVNfXzE1MTQ0NDgwMDAwMDBfNl9wcm9tb18xNTE0NDkxNzcwMTgwMDAwEAwYAw%3D%3D%3AS%3AANO1ljLrBj0&hl=en"))
|
12
|
+
index_page.css('div.card-content.id-track-click.id-track-impression').each do |a|
|
13
|
+
app = DailyTrending::App.new
|
14
|
+
app.title = a.css('a.title').attribute('title').value
|
15
|
+
app.app_url = (@base_link + a.css('a.title').attribute('href').value)
|
16
|
+
app.rating = a.css('div.tiny-star').attribute('aria-label').value.strip.slice(/\d.\S/)<<"/5 Stars"
|
17
|
+
app.price = a.at_css('span.display-price').text
|
18
|
+
app.exist? ? DailyTrending::App.all.freeze : app.save
|
11
19
|
end
|
12
|
-
DailyTrending::App.all
|
13
20
|
end
|
14
21
|
|
15
|
-
def self.scrape_app(app_url)
|
16
|
-
Nokogiri::HTML(open(app_url))
|
17
|
-
end
|
18
22
|
|
23
|
+
def scrape_app(app)
|
24
|
+
page = Nokogiri::HTML(open(app.app_url))
|
25
|
+
app.dev = page.css('a.document-subtitle.primary').text.strip
|
26
|
+
app.dev_url = (@base_link + page.css('a.document-subtitle.primary').attribute('href').value)
|
27
|
+
app.genre = page.css('a.document-subtitle.category').text.strip
|
28
|
+
app.description = page.css('div.show-more-content.text-body').text
|
29
|
+
app.con_rating = page.css('span.document-subtitle.content-rating-title').text
|
30
|
+
app.rate_cnt = page.css('span.rating-count').text
|
31
|
+
app
|
32
|
+
end
|
19
33
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daily-trending-apps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "'Chad Montoya'"
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|