Hot_100_CLI 0.1.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +9 -0
- data/Hot_100_CLI.gemspec +35 -0
- data/LICENSE.txt +21 -0
- data/NOTES.md +13 -0
- data/README.md +51 -0
- data/Rakefile +6 -0
- data/bin/HOT-100-CLI +6 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/Hot_100_CLI/artist.rb +51 -0
- data/lib/Hot_100_CLI/billboard_scraper.rb +62 -0
- data/lib/Hot_100_CLI/chart_status.rb +48 -0
- data/lib/Hot_100_CLI/cli.rb +196 -0
- data/lib/Hot_100_CLI/song.rb +69 -0
- data/lib/Hot_100_CLI/version.rb +3 -0
- data/lib/Hot_100_CLI.rb +6 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c14b2684f75020eae7794ca1a7aa2e9975e9a145
|
4
|
+
data.tar.gz: 03cb062f65d0cc6f14be368e4234bc421aad8ccc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aa2fa01b4fdb5b612d9b993a71b2468ae4e9c5fedafac34b1012cb29e699ef91e18a8a55fbafb10b6cb001614bf01fb70f3bc6379c168a5112d65d6c3461dd32
|
7
|
+
data.tar.gz: efce5efc716dcf9c97a742602b02ed876c1900c6b49bcf209421b28624a32fb99bc426064b007348a830b36353c2abc79b7bc248ceab1dae489190c46f4387e9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Hot_100_CLI.gemspec
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'Hot_100_CLI/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "Hot_100_CLI"
|
8
|
+
spec.version = Hot100CLI::VERSION
|
9
|
+
spec.authors = ["NStephenson"]
|
10
|
+
spec.email = ["nickstephenson90@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{This gem allows users to view the Billboard Top 100 in the command line.}
|
13
|
+
spec.description = %q{This gem scrapes the Billboard Top 100 webpage and displays that information in the command line.}
|
14
|
+
spec.homepage = "https://github.com/NStephenson/Hot_100_CLI"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
|
34
|
+
|
35
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 NStephenson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/NOTES.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
NOTES FOR HOT 100 CLI
|
2
|
+
|
3
|
+
|
4
|
+
This CLI should do the following:
|
5
|
+
|
6
|
+
1. Greet the user.
|
7
|
+
2. Explain what the CLI does in a sentence or two
|
8
|
+
3. Shows the user the top 10 songs for the week
|
9
|
+
4. Ask the user if they would like to view the full billboard listing or any other group of ten songs
|
10
|
+
5. Should be able to find all songs from a specified artist
|
11
|
+
6. Should be able to find songs by name
|
12
|
+
7. Asking for more info on a song should give some additional info (TBD)
|
13
|
+
8. When user is done, "exit" should close the program and dgive a goodbye message.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Hot100CLI
|
2
|
+
|
3
|
+
Welcome to your the Hot 100 CLI!. This gem scrapes the Billboard Top 100 page (http://www.billboard.com/charts/hot-100) and gives the full top 100 list, additiontional info on each song, and will allow the user to launch links to the song on spotify or vevo if available.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'Hot_100_CLI'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install Hot_100_CLI
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Upon opening, Hot 100 CLI will display the top ten songs on the chart for the current week. After this, there are a variety of inputs you can give for more information about the list.
|
24
|
+
|
25
|
+
"Hot 100" - Displays the full hot 100 listing
|
26
|
+
|
27
|
+
"Artists" - Displays a list of all the artists on the list, alphabetized.
|
28
|
+
|
29
|
+
"Song [song name]" - Displays information on the name of the song given. This will also give an option of playing the song or viewing the music video of the song.
|
30
|
+
|
31
|
+
"Artist [artist name]" - Displays a list of all the songs by the given artist that appears on the Billboard Top 100.
|
32
|
+
|
33
|
+
"Help" - Displays the list of available inputs.
|
34
|
+
|
35
|
+
- Additionally, inputting a number between 1 and 100 will display more info on the song in that position. Giving a range of numbers between 1 and 100 separated with a hyphen will show all the entires on the list between those two numbers.
|
36
|
+
|
37
|
+
## Development
|
38
|
+
|
39
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
40
|
+
|
41
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/nstephenson/Hot_100_CLI.
|
46
|
+
|
47
|
+
|
48
|
+
## License
|
49
|
+
|
50
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
51
|
+
|
data/Rakefile
ADDED
data/bin/HOT-100-CLI
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require_relative '../lib/Hot_100_CLI.rb'
|
5
|
+
# require "Hot_100_CLI"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
class Artist
|
2
|
+
|
3
|
+
attr_accessor :name, :songs
|
4
|
+
|
5
|
+
@@all = []
|
6
|
+
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
@songs = []
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.all
|
14
|
+
@@all
|
15
|
+
end
|
16
|
+
|
17
|
+
def save
|
18
|
+
@@all << self
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.find_by_name(name)
|
22
|
+
all.detect { |artist| artist.name.downcase == name.downcase }
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def self.create_by_list_name(list_name)
|
27
|
+
artists = []
|
28
|
+
list_name[:name].split(" Featuring ").map do |name|
|
29
|
+
if name.include?(" & ")
|
30
|
+
name.split(" & ").map do |name|
|
31
|
+
artists << Artist.find_or_new_by_name(name)
|
32
|
+
end
|
33
|
+
else
|
34
|
+
artists << Artist.find_or_new_by_name(name)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
artists
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.find_or_new_by_name(name)
|
41
|
+
if self.all.detect{ |song| song.name == name }
|
42
|
+
artist = self.all.detect{ |song| song.name == name }
|
43
|
+
else
|
44
|
+
artist = Artist.new(name)
|
45
|
+
artist.save
|
46
|
+
end
|
47
|
+
artist
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'pry'
|
4
|
+
class BillboardScraper
|
5
|
+
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
doc = Nokogiri::HTML(open('http://www.billboard.com/charts/hot-100'))
|
9
|
+
scrape(doc)
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
def scrape(doc)
|
16
|
+
doc.css('.chart-data .chart-row').map do |entry|
|
17
|
+
song_info = {}
|
18
|
+
song_info[:chart_status] = {
|
19
|
+
rank: entry.css('.chart-row__current-week').text,
|
20
|
+
previous_week: entry.css('.chart-row__last-week .chart-row__value').text,
|
21
|
+
peak_position: entry.css('.chart-row__top-spot .chart-row__value').text,
|
22
|
+
weeks_charted: entry.css('.chart-row__weeks-on-chart .chart-row__value').text
|
23
|
+
}
|
24
|
+
|
25
|
+
song_info[:song] = { title: entry.css('.chart-row__song').text,
|
26
|
+
spotify_link: parse_spotify_link_if_present(entry),
|
27
|
+
vevo_link: parse_vevo_link_if_present(entry) }
|
28
|
+
|
29
|
+
song_info[:artist] = { name: entry.css(".chart-row__artist").text.strip }
|
30
|
+
create_song_from_scraper(song_info)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def create_song_from_scraper(song_info)
|
36
|
+
song = Song.create(song_info[:song])
|
37
|
+
Artist.create_by_list_name(song_info[:artist]).each { |artist| song.artists << artist }
|
38
|
+
song.chart_status = ChartStatus.new(song_info[:chart_status])
|
39
|
+
|
40
|
+
song.chart_status.song = song
|
41
|
+
song.artists.each { |artist| artist.songs << song }
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def parse_spotify_link_if_present(entry)
|
46
|
+
if !entry.css('.js-spotify-play-full').empty?
|
47
|
+
entry.css('.js-spotify-play-full').attr('data-href').text
|
48
|
+
else
|
49
|
+
"error"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def parse_vevo_link_if_present(entry)
|
54
|
+
if !entry.css('.js-chart-row-vevo').empty?
|
55
|
+
entry.css('.js-chart-row-vevo').attr('data-href').text
|
56
|
+
else
|
57
|
+
"error"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class ChartStatus
|
2
|
+
|
3
|
+
attr_accessor :song, :rank, :weeks_charted, :peak_position, :previous_week
|
4
|
+
|
5
|
+
def initialize(song_info)
|
6
|
+
@rank = song_info[:rank].to_i
|
7
|
+
@previous_week = song_info[:previous_week].to_i
|
8
|
+
@peak_position = song_info[:peak_position].to_i
|
9
|
+
@weeks_charted = song_info[:weeks_charted].to_i
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
def self.new_songs
|
14
|
+
Song.all.select { | song | song.previous_week == "--" }
|
15
|
+
end
|
16
|
+
|
17
|
+
def is_new?
|
18
|
+
previous_week == "--"
|
19
|
+
end
|
20
|
+
|
21
|
+
def position_change
|
22
|
+
if previous_week > rank
|
23
|
+
puts "#{song.title} moved up from \##{previous_week} to \##{rank}!"
|
24
|
+
elsif previous_week < rank
|
25
|
+
puts "#{song.title} moved down from \##{previous_week} to \##{rank}."
|
26
|
+
elsif previous_week == rank
|
27
|
+
puts "#{song.title} remained at #{rank}."
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def peak_status
|
32
|
+
if rank == peak_position
|
33
|
+
puts "It's currently at it's peak position!!"
|
34
|
+
else
|
35
|
+
puts "It's down from it's peak position, which was number #{peak_position}."
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def weeks_status
|
40
|
+
puts "#{song.title} has been on the charts for #{weeks_charted} weeks."
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
require 'Launchy'
|
2
|
+
class Hot100::CLI
|
3
|
+
|
4
|
+
def call
|
5
|
+
puts 'Starting...'
|
6
|
+
puts ' '
|
7
|
+
BillboardScraper.new
|
8
|
+
greeting
|
9
|
+
display_songs_in_range("1-10")
|
10
|
+
puts "You may now choose to view the rest of the list or get more information on any of the songs on the list by typing the appropriate command. For a list of commands, type 'help'."
|
11
|
+
puts " "
|
12
|
+
menu
|
13
|
+
farewell
|
14
|
+
end
|
15
|
+
|
16
|
+
def greeting
|
17
|
+
puts "Hello, Welcome to the Billboard Top 100 CLI"
|
18
|
+
puts " "
|
19
|
+
puts "These are the top ten songs this week!"
|
20
|
+
puts " "
|
21
|
+
puts "For the full list type 'hot 100'!"
|
22
|
+
end
|
23
|
+
|
24
|
+
def menu
|
25
|
+
input = nil
|
26
|
+
while input != "exit" do
|
27
|
+
puts "Please enter a command:"
|
28
|
+
input = gets.chomp.downcase
|
29
|
+
case input
|
30
|
+
when "hot 100"
|
31
|
+
display_songs_in_range("1-100")
|
32
|
+
when /\A\d+\z/
|
33
|
+
chart_index_if_valid(input)
|
34
|
+
when /\A\d+-\d+\z/
|
35
|
+
chart_range_if_valid(input)
|
36
|
+
when /\Aartist\s.+/
|
37
|
+
display_artist_songs(input)
|
38
|
+
when /\Aartists\z/
|
39
|
+
display_artist_list
|
40
|
+
when /\Asong\s.+/
|
41
|
+
more_info_song(input)
|
42
|
+
when "help"
|
43
|
+
list_commands
|
44
|
+
when "exit"
|
45
|
+
puts "Aw that's it?"
|
46
|
+
else
|
47
|
+
puts "That command seems to be invalid, type 'help' for a list of commands."
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def list_commands
|
53
|
+
puts "To see the full billboard list, type hot 100. Otherwise enter a range of entries to view"
|
54
|
+
puts "For more info on a song, type 'song' followed by that song's name or chart position"
|
55
|
+
puts "To see all charted songs by a particular artist, type 'artist' followed by that artist's name"
|
56
|
+
puts "To exit, simply type exit"
|
57
|
+
puts "For help, type help, but I think you have this one figured out already."
|
58
|
+
end
|
59
|
+
|
60
|
+
def farewell
|
61
|
+
puts "See You Next Tuesday."
|
62
|
+
end
|
63
|
+
|
64
|
+
def display_artist_songs(input)
|
65
|
+
artist = Artist.find_by_name(input.split('artist ')[1])
|
66
|
+
if artist
|
67
|
+
puts ' '
|
68
|
+
puts "This week, #{artist.name} charted these songs:"
|
69
|
+
puts ' '
|
70
|
+
artist.songs.each { |song| puts "#{song.rank}. #{song.title}" }
|
71
|
+
puts ' '
|
72
|
+
else
|
73
|
+
puts ' '
|
74
|
+
puts "That artist isn't on the charts this week. Maybe next week?"
|
75
|
+
puts ' '
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def more_info_song(input)
|
80
|
+
if !input[/\Asong/]
|
81
|
+
song = Song.find_by_rank(input)
|
82
|
+
else
|
83
|
+
song = Song.find_by_title(input.split("song ")[1])
|
84
|
+
end
|
85
|
+
if song
|
86
|
+
puts ' '
|
87
|
+
puts " #{song.title}"
|
88
|
+
puts " By #{song.artist_listing}"
|
89
|
+
puts ' '
|
90
|
+
puts "This week, #{song.title} was number #{song.rank} on the Billboard Top 100 Charts."
|
91
|
+
puts ' '
|
92
|
+
song_history(song)
|
93
|
+
ask_to_play_song(song)
|
94
|
+
else
|
95
|
+
puts "That song doesn't seem to be on the charts this week."
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def valid_range?(range)
|
100
|
+
range[0].between?(1,99) && range[1].between?(2,100) && range[0] < range[1]
|
101
|
+
end
|
102
|
+
|
103
|
+
def split_input_to_range(input)
|
104
|
+
input.split("-").map { |num| num.to_i }
|
105
|
+
end
|
106
|
+
|
107
|
+
def display_songs_in_range(input)
|
108
|
+
range = split_input_to_range(input)
|
109
|
+
songs = Song.all.select do |song|
|
110
|
+
song.rank >= range[0] && range[1] >= song.rank
|
111
|
+
end
|
112
|
+
display_songs(songs)
|
113
|
+
end
|
114
|
+
|
115
|
+
def display_songs(songs)
|
116
|
+
songs.each { |song| puts "#{song.rank}. #{song.title} - #{song.artist_listing}" }
|
117
|
+
puts " "
|
118
|
+
puts "For more info on a song, please type it's rank or type 'song ' then the song's title."
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
def ask_to_play_song(song)
|
123
|
+
puts ' '
|
124
|
+
puts 'To listen to this song on spotify, type \'listen\'. To watch this song\'s music video, type \'watch\'. Otherwise, type \'exit\'.'
|
125
|
+
puts ' '
|
126
|
+
input = gets.chomp
|
127
|
+
if input == 'listen'
|
128
|
+
launch_spotify_link(song)
|
129
|
+
elsif input == 'watch'
|
130
|
+
launch_vevo_link(song)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
def launch_spotify_link(song)
|
135
|
+
if song.spotify_link != 'error'
|
136
|
+
Launchy.open(song.spotify_link)
|
137
|
+
puts ' '
|
138
|
+
puts '♪ ♪ ♪ Enjoy!♪ ♪ ♪'
|
139
|
+
puts ' '
|
140
|
+
else
|
141
|
+
puts ' '
|
142
|
+
puts 'Unfortunately, it this song is not on Spotify :('
|
143
|
+
puts ' '
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def launch_vevo_link(song)
|
148
|
+
if song.vevo_link != 'error'
|
149
|
+
Launchy.open(song.vevo_link)
|
150
|
+
puts ' '
|
151
|
+
puts '♪ ♪ ♪ Enjoy!♪ ♪ ♪'
|
152
|
+
puts ' '
|
153
|
+
else
|
154
|
+
puts ' '
|
155
|
+
puts 'Unfortunately, it this song is not on Vevo :('
|
156
|
+
puts ' '
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def song_history(song) #need to add logic for a song returning to the top 100
|
161
|
+
if song.chart_status.is_new?
|
162
|
+
puts "This is #{song.title}'s debut week on the Hot 100 charts!"
|
163
|
+
else
|
164
|
+
song.chart_status.position_change
|
165
|
+
song.chart_status.peak_status
|
166
|
+
song.chart_status.weeks_status
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def display_artist_list
|
171
|
+
Artist.all.each do |artist|
|
172
|
+
puts artist.name
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def chart_range_if_valid(input)
|
177
|
+
if valid_range?(split_input_to_range(input))
|
178
|
+
display_songs_in_range(input)
|
179
|
+
else
|
180
|
+
puts "That number range feels off. Check your numbers and format and try again."
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def chart_index_if_valid(input)
|
185
|
+
if input.to_i.between?(1,100)
|
186
|
+
more_info_song(input)
|
187
|
+
else
|
188
|
+
puts "Not a valid entry, choose a number between 1 and 100"
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'pry'
|
2
|
+
class Song
|
3
|
+
|
4
|
+
attr_accessor :title, :artists, :spotify_link, :chart_status, :vevo_link
|
5
|
+
|
6
|
+
@@all = []
|
7
|
+
|
8
|
+
def initialize(title)
|
9
|
+
@title = title
|
10
|
+
@artists = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.create(song_hash)
|
14
|
+
song = Song.new(song_hash[:title])
|
15
|
+
song.spotify_link = song_hash[:spotify_link]
|
16
|
+
song.vevo_link = song_hash[:vevo_link]
|
17
|
+
song.save
|
18
|
+
song
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.all
|
22
|
+
@@all
|
23
|
+
end
|
24
|
+
|
25
|
+
def save
|
26
|
+
@@all << self
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.find_by_title(title)
|
30
|
+
Song.all.detect { |song| song.title.downcase == title.downcase }
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.find_by_rank(int)
|
34
|
+
Song.all.detect { |song| song.rank == int.to_i }
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
#association methods
|
39
|
+
|
40
|
+
|
41
|
+
def rank
|
42
|
+
chart_status.rank
|
43
|
+
end
|
44
|
+
|
45
|
+
def weeks_charted
|
46
|
+
chart_status.weeks_charted
|
47
|
+
end
|
48
|
+
|
49
|
+
def peak_position
|
50
|
+
chart_status.peak_position
|
51
|
+
end
|
52
|
+
|
53
|
+
def previous_week
|
54
|
+
chart_status.previous_week
|
55
|
+
end
|
56
|
+
|
57
|
+
def artist_listing
|
58
|
+
if artists.length < 3
|
59
|
+
artists.map { |artist| artist.name }.join(" Featuring ")
|
60
|
+
else
|
61
|
+
listing = artists[0].name + " Featuring " + artists[1].name
|
62
|
+
artists.each_with_index do |artist, i|
|
63
|
+
listing += " & " + artist.name if i > 1
|
64
|
+
end
|
65
|
+
listing
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
data/lib/Hot_100_CLI.rb
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
require_relative "Hot_100_CLI/version.rb"
|
2
|
+
require_relative "./Hot_100_CLI/cli.rb"
|
3
|
+
require_relative "./Hot_100_CLI/artist.rb"
|
4
|
+
require_relative "./Hot_100_CLI/billboard_scraper.rb"
|
5
|
+
require_relative "./Hot_100_CLI/chart_status.rb"
|
6
|
+
require_relative "./Hot_100_CLI/song.rb"
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Hot_100_CLI
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- NStephenson
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: This gem scrapes the Billboard Top 100 webpage and displays that information
|
56
|
+
in the command line.
|
57
|
+
email:
|
58
|
+
- nickstephenson90@gmail.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- Gemfile
|
67
|
+
- Hot_100_CLI.gemspec
|
68
|
+
- LICENSE.txt
|
69
|
+
- NOTES.md
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/HOT-100-CLI
|
73
|
+
- bin/console
|
74
|
+
- bin/setup
|
75
|
+
- lib/Hot_100_CLI.rb
|
76
|
+
- lib/Hot_100_CLI/artist.rb
|
77
|
+
- lib/Hot_100_CLI/billboard_scraper.rb
|
78
|
+
- lib/Hot_100_CLI/chart_status.rb
|
79
|
+
- lib/Hot_100_CLI/cli.rb
|
80
|
+
- lib/Hot_100_CLI/song.rb
|
81
|
+
- lib/Hot_100_CLI/version.rb
|
82
|
+
homepage: https://github.com/NStephenson/Hot_100_CLI
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata:
|
86
|
+
allowed_push_host: https://rubygems.org
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.5.1
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: This gem allows users to view the Billboard Top 100 in the command line.
|
107
|
+
test_files: []
|