hot_songs 1.0.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/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +35 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/hot-songs +5 -0
- data/bin/setup +7 -0
- data/hot_songs.gemspec +29 -0
- data/lib/hot_songs/cli.rb +73 -0
- data/lib/hot_songs/songs.rb +35 -0
- data/lib/hot_songs/version.rb +3 -0
- data/lib/hot_songs.rb +8 -0
- metadata +134 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 663f9a7b9c35360be272dd667e2dacc54eab4314
|
|
4
|
+
data.tar.gz: 8c257eafaf9432710645e0383eb5e17c3425feab
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 722fc1401083af7c744980d4490f90ffcfeb9bf9b0015a6c6def26d5aef8d5700de2dc8006c0e4f5def7ffd609292b6412ae5daf19bb806e478a39373622a921
|
|
7
|
+
data.tar.gz: cf4934084f4483a9bf2a4f114fed65fe7c30cb54901e4f15766d74f8f85db8a06e9538a7ec9124b928b996cb6c9db36708c2ea8832939ad4e28d93c8c3105bce
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Contributor Code of Conduct
|
|
2
|
+
|
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
|
4
|
+
|
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
|
6
|
+
|
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
|
8
|
+
|
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
|
10
|
+
|
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
|
12
|
+
|
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 KhalilC
|
|
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/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# HotSongs
|
|
2
|
+
|
|
3
|
+
HotSongs is a gem that utitlizes Billboard data to provide the week's most popular songs by genre. A little confusing, but after installing type hot-songs not hot_songs in the terminal to run.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'hot_songs'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install hot_songs
|
|
20
|
+
|
|
21
|
+
## Development
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
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).
|
|
26
|
+
|
|
27
|
+
## Contributing
|
|
28
|
+
|
|
29
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/hot_songs. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
35
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "hot_songs"
|
|
5
|
+
|
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
8
|
+
|
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
10
|
+
# require "pry"
|
|
11
|
+
# Pry.start
|
|
12
|
+
|
|
13
|
+
require "irb"
|
|
14
|
+
IRB.start
|
data/bin/hot-songs
ADDED
data/bin/setup
ADDED
data/hot_songs.gemspec
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'hot_songs/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "hot_songs"
|
|
8
|
+
spec.version = HotSongs::VERSION
|
|
9
|
+
spec.authors = ["KhalilC"]
|
|
10
|
+
spec.email = ["klcrumpler@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Retrive popular songs for user specifed genre}
|
|
13
|
+
spec.description = %q{Retrieves most popular artist and song data from Billboard.}
|
|
14
|
+
spec.homepage = "https://github.com/KhalilC/hot-songs-cli-gem"
|
|
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
|
+
|
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
22
|
+
spec.require_paths = ["lib", "lib/hot_songs"]
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency 'nokogiri'
|
|
25
|
+
spec.add_development_dependency 'rspec'
|
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
28
|
+
spec.add_development_dependency 'pry'
|
|
29
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
class HotSongs::CLI
|
|
2
|
+
|
|
3
|
+
attr_accessor :genres
|
|
4
|
+
|
|
5
|
+
def initialize
|
|
6
|
+
@genres = %w{ Pop Country Rock R&B/Rap Dance/Electronic Latin Christian/Gospel }
|
|
7
|
+
end
|
|
8
|
+
def about
|
|
9
|
+
system 'clear'
|
|
10
|
+
puts "Hot Songs v1.0".center(125)
|
|
11
|
+
puts ""
|
|
12
|
+
puts "The week's most popular songs, based on radio airplay audience impressions as measured by Nielsen Music, sales data
|
|
13
|
+
as compiled by Nielsen Music and streaming activity data from online music sources tracked by Nielsen Music.
|
|
14
|
+
Songs are defined as current if they are newly-released titles, or songs receiving widespread airplay and/or
|
|
15
|
+
sales activity for the first time.".center(421)
|
|
16
|
+
3.times {puts}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def display_menu
|
|
20
|
+
genres.each.with_index(1) { |genre, index| puts "#{index}. #{genre}".center(125)}
|
|
21
|
+
puts
|
|
22
|
+
user_input
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def user_input
|
|
26
|
+
begin
|
|
27
|
+
print "Please pick a genre to see the week's hottest songs(1-7)('q' or quit to exit): ".center(125)
|
|
28
|
+
choice = gets.chomp.downcase
|
|
29
|
+
return choice if choice == 'q' || choice == 'quit'
|
|
30
|
+
end until ('1'..'7').to_a.include?(choice)
|
|
31
|
+
display_songs(choice)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def display_songs(genre)
|
|
35
|
+
puts
|
|
36
|
+
songs, artists, title, week, chart_history = HotSongs::Songs.scrape_songs_artists(genre)
|
|
37
|
+
system 'clear'
|
|
38
|
+
puts "Hottest #{genres[genre.to_i-1]} songs for the week of #{week}".center(125)
|
|
39
|
+
puts
|
|
40
|
+
songs.each.with_index(1) { |song, index| puts "#{index}. #{song} -- #{artists[index-1]}".center(125)}
|
|
41
|
+
2.times {puts}
|
|
42
|
+
puts "Press enter to return to return or enter a number to see the song's chart history".center(125)
|
|
43
|
+
answer = gets.chomp
|
|
44
|
+
display_chart_history(songs[answer.to_i-1], artists[answer.to_i-1], chart_history[answer.to_i-1], genre) if ('1'..songs.count.to_s).include?(answer)
|
|
45
|
+
system 'clear'
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def display_chart_history(song, artist, chart_history, genre)
|
|
49
|
+
system 'clear'
|
|
50
|
+
puts "#{song} - #{artist}".center(125)
|
|
51
|
+
puts
|
|
52
|
+
puts "*****Chart History******".center(125)
|
|
53
|
+
puts
|
|
54
|
+
chart_history.each_with_index do |stat, index|
|
|
55
|
+
next if index.odd?
|
|
56
|
+
puts "#{stat} -- #{chart_history[index+1]}".center(125)
|
|
57
|
+
puts
|
|
58
|
+
end
|
|
59
|
+
puts "Press enter to return to song list".center(125)
|
|
60
|
+
gets.chomp
|
|
61
|
+
display_songs(genre)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def main_loop
|
|
65
|
+
about
|
|
66
|
+
loop do
|
|
67
|
+
break if %w{q quit}.include?(display_menu)
|
|
68
|
+
end
|
|
69
|
+
system 'clear'
|
|
70
|
+
puts "Goodbye!".center(125)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
class HotSongs::Songs
|
|
2
|
+
|
|
3
|
+
attr_accessor :stats
|
|
4
|
+
|
|
5
|
+
def self.scrape_songs_artists(genre)
|
|
6
|
+
genres = ['http://www.billboard.com/charts/pop-songs',
|
|
7
|
+
'http://www.billboard.com/charts/country-songs',
|
|
8
|
+
'http://www.billboard.com/charts/rock-songs',
|
|
9
|
+
'http://www.billboard.com/charts/r-b-hip-hop-songs',
|
|
10
|
+
'http://www.billboard.com/charts/dance-electronic-songs',
|
|
11
|
+
'http://www.billboard.com/charts/latin-songs',
|
|
12
|
+
'http://www.billboard.com/charts/christian-songs']
|
|
13
|
+
html = open(genres[genre.to_i-1])
|
|
14
|
+
doc = Nokogiri::HTML(html)
|
|
15
|
+
songs = []
|
|
16
|
+
artists = []
|
|
17
|
+
title = doc.css('.chart-header-headline span').text
|
|
18
|
+
week = doc.css('time').text
|
|
19
|
+
doc.css('.row-title h2').each {|song| songs << song.text.strip}
|
|
20
|
+
doc.css('.row-title h3').each {|artist| artists << artist.text.strip}
|
|
21
|
+
return songs, artists, title, week, self.song_chart_history(doc)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.song_chart_history(doc)
|
|
25
|
+
stats = []
|
|
26
|
+
doc.css('.stats').each { |song| stats << song.children.text.split("\n")}
|
|
27
|
+
chart_history = stats.map do |stat|
|
|
28
|
+
stats = stat.map {|history_stat| history_stat.strip}.select {|word| word != "" }
|
|
29
|
+
end
|
|
30
|
+
chart_history
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
data/lib/hot_songs.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: hot_songs
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- KhalilC
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-12-04 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: nokogiri
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rspec
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: bundler
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.10'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '1.10'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rake
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '10.0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '10.0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: pry
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
description: Retrieves most popular artist and song data from Billboard.
|
|
84
|
+
email:
|
|
85
|
+
- klcrumpler@gmail.com
|
|
86
|
+
executables:
|
|
87
|
+
- console
|
|
88
|
+
- hot-songs
|
|
89
|
+
- setup
|
|
90
|
+
extensions: []
|
|
91
|
+
extra_rdoc_files: []
|
|
92
|
+
files:
|
|
93
|
+
- ".gitignore"
|
|
94
|
+
- ".rspec"
|
|
95
|
+
- ".travis.yml"
|
|
96
|
+
- CODE_OF_CONDUCT.md
|
|
97
|
+
- Gemfile
|
|
98
|
+
- LICENSE.txt
|
|
99
|
+
- README.md
|
|
100
|
+
- Rakefile
|
|
101
|
+
- bin/console
|
|
102
|
+
- bin/hot-songs
|
|
103
|
+
- bin/setup
|
|
104
|
+
- hot_songs.gemspec
|
|
105
|
+
- lib/hot_songs.rb
|
|
106
|
+
- lib/hot_songs/cli.rb
|
|
107
|
+
- lib/hot_songs/songs.rb
|
|
108
|
+
- lib/hot_songs/version.rb
|
|
109
|
+
homepage: https://github.com/KhalilC/hot-songs-cli-gem
|
|
110
|
+
licenses:
|
|
111
|
+
- MIT
|
|
112
|
+
metadata: {}
|
|
113
|
+
post_install_message:
|
|
114
|
+
rdoc_options: []
|
|
115
|
+
require_paths:
|
|
116
|
+
- lib
|
|
117
|
+
- lib/hot_songs
|
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
120
|
+
- - ">="
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: '0'
|
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
|
+
requirements:
|
|
125
|
+
- - ">="
|
|
126
|
+
- !ruby/object:Gem::Version
|
|
127
|
+
version: '0'
|
|
128
|
+
requirements: []
|
|
129
|
+
rubyforge_project:
|
|
130
|
+
rubygems_version: 2.4.5.1
|
|
131
|
+
signing_key:
|
|
132
|
+
specification_version: 4
|
|
133
|
+
summary: Retrive popular songs for user specifed genre
|
|
134
|
+
test_files: []
|