billboard_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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5f6116ef8a034199c9ef48c307feca6a131709f54f90dd502109ca054d92ca66
4
+ data.tar.gz: 0426f8c95c1be5b4467cd881f7be1402eca542e6e660cb3439d52bc643bd77da
5
+ SHA512:
6
+ metadata.gz: c3ac6acf15970343ce10ead1946589fd319bf2439672ab770430abe2f6b7d04d51e75e8354129652b6d33bb0a5c6221db1bf00a64db31fc40678a851dfaf4518
7
+ data.tar.gz: 61f0d8f2080f57aa2f8973381fe2bca8f1d312df7a3a36c95e668b60bff64af9160230257d762a6876460c5416be7f488b1a652944da21d8c9821c487f4c24f2
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,37 @@
1
+ # Contributing to Learn.co Curriculum
2
+
3
+ We're really exited that you're about to contribute to the [open curriculum](https://learn.co/content-license) on [Learn.co](https://learn.co). If this is your first time contributing, please continue reading to learn how to make the most meaningful and useful impact possible.
4
+
5
+ ## Raising an Issue to Encourage a Contribution
6
+
7
+ If you notice a problem with the curriculum that you believe needs improvement
8
+ but you're unable to make the change yourself, you should raise a Github issue
9
+ containing a clear description of the problem. Include relevant snippets of
10
+ the content and/or screenshots if applicable. Curriculum owners regularly review
11
+ issue lists and your issue will be prioritized and addressed as appropriate.
12
+
13
+ ## Submitting a Pull Request to Suggest an Improvement
14
+
15
+ If you see an opportunity for improvement and can make the change yourself go
16
+ ahead and use a typical git workflow to make it happen:
17
+
18
+ * Fork this curriculum repository
19
+ * Make the change on your fork, with descriptive commits in the standard format
20
+ * Open a Pull Request against this repo
21
+
22
+ A curriculum owner will review your change and approve or comment on it in due
23
+ course.
24
+
25
+ # Why Contribute?
26
+
27
+ Curriculum on Learn is publicly and freely available under Learn's
28
+ [Educational Content License](https://learn.co/content-license). By
29
+ embracing an open-source contribution model, our goal is for the curriculum
30
+ on Learn to become, in time, the best educational content the world has
31
+ ever seen.
32
+
33
+ We need help from the community of Learners to maintain and improve the
34
+ educational content. Everything from fixing typos, to correcting
35
+ out-dated information, to improving exposition, to adding better examples,
36
+ to fixing tests—all contributions to making the curriculum more effective are
37
+ welcome.
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/stephenolson/billboard_hot_100" }
4
+
5
+ # Specify your gem's dependencies in billboard_hot_100.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,11 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+
5
+ PLATFORMS
6
+ ruby
7
+
8
+ DEPENDENCIES
9
+
10
+ BUNDLED WITH
11
+ 1.17.3
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 dannyd4315
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,41 @@
1
+ # BillboardHot100
2
+
3
+ This gem allows users to access the current weeks Billboard Hot 100.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'billboard_hot_100'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install billboard_hot_100
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/<github username>/nj_fishing_report. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
38
+
39
+ ## Code of Conduct
40
+
41
+ Everyone interacting in the NjFishingReport project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<github username>/nj_fishing_report/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/billboard_hot_100.rb"
4
+
5
+ BillboardHot100::CommandLineInteface.new.run
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "billboard_hot_100"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,9 @@
1
+ require 'pry'
2
+ require 'nokogiri'
3
+ require 'open-uri'
4
+ require 'colorize'
5
+
6
+ require_relative '../lib/billboard_hot_100/scraper.rb'
7
+ require_relative '../lib/billboard_hot_100/song.rb'
8
+ require_relative '../lib/billboard_hot_100/command_line_interface.rb'
9
+ require_relative '../lib/billboard_hot_100/version.rb'
data/config.rb ADDED
@@ -0,0 +1 @@
1
+ require 'nokogiri'
@@ -0,0 +1,95 @@
1
+ class BillboardHot100::CommandLineInteface
2
+
3
+ def run
4
+ BillboardHot100::Scraper.scrape_songs
5
+ welcome
6
+ list_ranges
7
+ more_info
8
+ goodbye
9
+ end
10
+
11
+ def welcome
12
+ puts "\nWelcome to the this weeks Billboard Hot 100!\n"
13
+ end
14
+
15
+ def list_ranges
16
+ puts "\nPlease enter the rankings you wish to see...\n"
17
+ puts "\nEnter 1-10, 11-20, 21-30, 31-40, 41-50, 51-60, 61-70, 71-80, 81-90 or 91-100\n"
18
+ input = gets.strip.to_i
19
+ display_songs(input)
20
+ end
21
+
22
+ def display_songs(input)
23
+ case input
24
+ when 1..100
25
+ increment = 10
26
+ quantize(input, increment)
27
+ else
28
+ invalid_choice
29
+ end
30
+ end
31
+
32
+ def quantize(input, increment)
33
+ low_num = ((input-1)/increment).floor*increment
34
+ display_ten_songs(low_num)
35
+ end
36
+
37
+ def display_ten_songs(low_num)
38
+ puts "\nDisplaying songs #{low_num+1} through #{low_num+10}\n\n"
39
+ BillboardHot100::Song.all[low_num,10].each do |song|
40
+ puts "#{song.rank}. #{song.title} by #{song.artist}"
41
+ end
42
+ end
43
+
44
+ def more_info
45
+ puts "\nPlease enter the song you want more information on.\n"
46
+ input = gets.strip
47
+
48
+ song = BillboardHot100::Song.all[input.to_i-1]
49
+
50
+ display_song(song)
51
+
52
+ puts "\nWould you like information on another song? Enter Y or N\n"
53
+
54
+ input = gets.strip.downcase
55
+ if input == "y"
56
+ run
57
+ elsif input == "n"
58
+ goodbye
59
+ else
60
+ invalid_choice
61
+ end
62
+ end
63
+
64
+ def display_song(song)
65
+ puts "\n#{song.rank}. #{song.title} by #{song.artist}"
66
+ if song.last_week.length > 0 && !song.last_week.include?("-")
67
+ puts "Last Week: #{song.last_week}"
68
+ else
69
+ puts "New To Chart!".colorize(:red)
70
+ end
71
+ if song.peak_position.length > 0
72
+ puts "Peak Position: #{song.peak_position}"
73
+ end
74
+ if song.weeks_on_chart.length > 0
75
+ puts "Weeks On Chart: #{song.weeks_on_chart}"
76
+ end
77
+ if song.lyrics.length > 0
78
+ puts "Lyrics: #{song.lyrics}"
79
+ end
80
+ if song.award.length > 0
81
+ puts "Award: #{song.award}".colorize(:red)
82
+ end
83
+ end
84
+
85
+ def goodbye
86
+ puts "\nCheck back next week for the latest Billboard Hot 100!"
87
+ exit
88
+ end
89
+
90
+ def invalid_choice
91
+ puts "\nInvalid Choice!"
92
+ run
93
+ end
94
+
95
+ end
@@ -0,0 +1,18 @@
1
+ class BillboardHot100::Scraper
2
+
3
+ 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
16
+ end
17
+
18
+ end
@@ -0,0 +1,24 @@
1
+ class BillboardHot100::Song
2
+
3
+ attr_accessor :rank, :title, :artist, :last_week, :peak_position, :weeks_on_chart, :lyrics, :award
4
+
5
+ @@all = []
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
16
+
17
+ @@all << self
18
+ end
19
+
20
+ def self.all
21
+ @@all
22
+ end
23
+
24
+ end
@@ -0,0 +1,3 @@
1
+ module BillboardHot100
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,4 @@
1
+ module BillboardHot100
2
+ end
3
+
4
+ require_relative "../config/environment.rb"
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: billboard_hot_100_CLI
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Olson
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-04-10 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.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
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: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: nokogiri
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: Access the current weeks Billboard Hot 100. Select a song to see additional
84
+ information.
85
+ email:
86
+ - stephenolson@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - CONTRIBUTING.md
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.md
95
+ - README.md
96
+ - bin/billboard_hot_100
97
+ - bin/console
98
+ - bin/setup
99
+ - config.rb
100
+ - config/environment.rb
101
+ - lib/billboard_hot_100.rb
102
+ - lib/billboard_hot_100/command_line_interface.rb
103
+ - lib/billboard_hot_100/scraper.rb
104
+ - lib/billboard_hot_100/song.rb
105
+ - lib/billboard_hot_100/version.rb
106
+ homepage: https://github.com/stephenolson/billboard_hot_100
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubygems_version: 3.0.3
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: '"This gem allows users to access the current weeks Billboard Hot 100."'
129
+ test_files: []