billboard_hot_100_CLI 0.1.3 → 0.2.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 +4 -4
- data/billboard_hot_100_CLI-0.1.3.gem +0 -0
- data/lib/billboard_hot_100/scraper.rb +15 -14
- data/lib/billboard_hot_100/song.rb +10 -10
- data/lib/billboard_hot_100/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d1dabc03503b81ea81f0673e2570f7125183d140948c9f05e20b30361f7129e5
|
|
4
|
+
data.tar.gz: 8bf8158dcb4175100db1b3529cd08345b6391e2c2a7c8d747bbd8212bb67ad0e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 29e8f4105aeadf770e1055346629b59c6f060fb880999434e1a696e8a1e4bf19cc146c61fad506235698f2a2509d127e599860d8f68d54971ff1ff70b07a2bf1
|
|
7
|
+
data.tar.gz: 2b2154ccb9256650eae582540d3200b7a756403ccc8b401239230ffa637a621246c96a2da7c0c0ccea4093df051489253f6fc5096975f49f6cf26e182d45daa1
|
|
Binary file
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
class BillboardHot100::Scraper
|
|
2
|
-
|
|
3
2
|
def self.scrape_songs
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
songs = []
|
|
4
|
+
index = Nokogiri::HTML(open("https://www.billboard.com/charts/hot-100"))
|
|
5
|
+
index.css("div.chart-list-item").each do |song|
|
|
6
|
+
songs << {
|
|
7
|
+
rank: song.css(".chart-list-item__rank").text.strip,
|
|
8
|
+
title: song.css(".chart-list-item__title-text").text.strip,
|
|
9
|
+
artist: song.css(".chart-list-item__artist").text.strip,
|
|
10
|
+
last_week: song.css(".chart-list-item__last-week").text.strip,
|
|
11
|
+
peak_position: song.css(".chart-list-item__weeks-at-one").text.strip,
|
|
12
|
+
weeks_on_chart: song.css(".chart-list-item__weeks-on-chart").text.strip,
|
|
13
|
+
lyrics: song.css('div.chart-list-item__lyrics a').map { |link| link['href'] }.join,
|
|
14
|
+
award: song.css(".chart-list-item__award-icon").text.strip
|
|
15
|
+
}
|
|
16
|
+
end
|
|
17
|
+
BillboardHot100::Song.create(songs)
|
|
16
18
|
end
|
|
17
|
-
|
|
18
19
|
end
|
|
@@ -4,16 +4,16 @@ class BillboardHot100::Song
|
|
|
4
4
|
|
|
5
5
|
@@all = []
|
|
6
6
|
|
|
7
|
-
def
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
@peak_position = peak_position
|
|
13
|
-
@weeks_on_chart = weeks_on_chart
|
|
14
|
-
@lyrics = lyrics
|
|
15
|
-
@award = award
|
|
7
|
+
def self.create(songs)
|
|
8
|
+
songs.each do |song|
|
|
9
|
+
self.new(song)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
16
12
|
|
|
13
|
+
def initialize(song_hash)
|
|
14
|
+
song_hash.each do |key, value|
|
|
15
|
+
self.send(:"#{key}=", value)
|
|
16
|
+
end
|
|
17
17
|
@@all << self
|
|
18
18
|
end
|
|
19
19
|
|
|
@@ -21,4 +21,4 @@ class BillboardHot100::Song
|
|
|
21
21
|
@@all
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
-
end
|
|
24
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: billboard_hot_100_CLI
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stephen Olson
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-04-
|
|
11
|
+
date: 2019-04-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -93,6 +93,7 @@ files:
|
|
|
93
93
|
- Gemfile
|
|
94
94
|
- LICENSE.md
|
|
95
95
|
- README.md
|
|
96
|
+
- billboard_hot_100_CLI-0.1.3.gem
|
|
96
97
|
- billboard_hot_100_CLI.gemspec
|
|
97
98
|
- bin/billboard_hot_100
|
|
98
99
|
- bin/console
|