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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52f7eb81c26eb1e547b1fe1a5d9f928b3f78f82b98869084bc6d3ae6c1e6e32e
4
- data.tar.gz: e2a84eb386ed1b38f79064598f6e703fbdadd1fd897f7c6bf8e99c05a70ee0c6
3
+ metadata.gz: d1dabc03503b81ea81f0673e2570f7125183d140948c9f05e20b30361f7129e5
4
+ data.tar.gz: 8bf8158dcb4175100db1b3529cd08345b6391e2c2a7c8d747bbd8212bb67ad0e
5
5
  SHA512:
6
- metadata.gz: 0cd1a68651176ee5fd38c1bed00b9c5b6f54f86feb9fa9e81c8e22004642539d6a00671d943b79e573675aa2f4dc006f53ce20af717e3c5c344f47eed7ee7041
7
- data.tar.gz: 07a167edf306b9d6bc043e0467c8ff142c889cda70bd868c5bac248a69ce57db67cc3193e7b91a094791e84393be883259b64df198217b1c835ffde65cc70d3c
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
- doc = Nokogiri::HTML(open("https://www.billboard.com/charts/hot-100"))
5
- doc.css("div.chart-list-item").each do |song|
6
- BillboardHot100::Song.new(
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
- end
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 initialize(rank=nil, title=nil, artist=nil, last_week=nil, peak_position=nil, weeks_on_chart=nil, lyrics=nil, award=nil)
8
- @rank = rank
9
- @title = title
10
- @artist = artist
11
- @last_week = last_week
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
@@ -1,3 +1,3 @@
1
1
  module BillboardHot100
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  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.1.3
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-16 00:00:00.000000000 Z
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