billboard_hot_100 0.1.1

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
+ SHA1:
3
+ metadata.gz: 997e94fa9974dbeebb5b3801a887f12464b99dba
4
+ data.tar.gz: fa94cfdaae4a47a90c6baea84f13c7179788b8fa
5
+ SHA512:
6
+ metadata.gz: ad73d2c2a31a1dea3fc4eceae8a989505c9c52321664237c8f660b893ac1b0ede1974c611bdaa92e2461c8ba45b52fe6940d03ee1746df5b82b4a91bd911a6a7
7
+ data.tar.gz: 2a9da1d2837cfda2d99f1833f2f2df6a82cc00c0bebd33f8e1d0da7a5af5c907933cc472543d7a4cb2f555bce1ea83d376f612db8ea63a6e11a24a725feed5c6
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.16.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at villicana.i@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/ivillicana/billboard_hot_100" }
4
+
5
+ # Specify your gem's dependencies in billboard_chart.gemspec
6
+ gemspec
7
+
data/Gemfile.lock ADDED
@@ -0,0 +1,41 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ billboard_hot_100 (0.1.1)
5
+ nokogiri (~> 1.8)
6
+ require_all (~> 2.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ diff-lcs (1.2.5)
12
+ mini_portile2 (2.3.0)
13
+ nokogiri (1.8.2)
14
+ mini_portile2 (~> 2.3.0)
15
+ rake (10.4.2)
16
+ require_all (2.0.0)
17
+ rspec (3.4.0)
18
+ rspec-core (~> 3.4.0)
19
+ rspec-expectations (~> 3.4.0)
20
+ rspec-mocks (~> 3.4.0)
21
+ rspec-core (3.4.1)
22
+ rspec-support (~> 3.4.0)
23
+ rspec-expectations (3.4.0)
24
+ diff-lcs (>= 1.2.0, < 2.0)
25
+ rspec-support (~> 3.4.0)
26
+ rspec-mocks (3.4.0)
27
+ diff-lcs (>= 1.2.0, < 2.0)
28
+ rspec-support (~> 3.4.0)
29
+ rspec-support (3.4.1)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ billboard_hot_100!
36
+ bundler (~> 1.16)
37
+ rake (~> 10.0)
38
+ rspec (~> 3.0)
39
+
40
+ BUNDLED WITH
41
+ 1.16.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 TODO: Write your name
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
+ BillboardHot100 is a command-line interface applications that scrapes and displays the 'Billboard Hot 100' songs from https://www.billboard.com/charts/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/billboard_hot_100` 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/ivillicana/billboard_hot_100. 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 BillboardChart project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ivillicana/billboard_chart/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,32 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "billboard_hot_100/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "billboard_hot_100"
8
+ spec.version = BillboardHot100::VERSION
9
+ spec.authors = ["Isaac Villicana"]
10
+ spec.email = ["villicana.i@gmail.com"]
11
+
12
+ spec.summary = %q{This gem (billboard_hot_100) includes a CLI shows a user the 'Billboard Hot 100' list.}
13
+ spec.description = %q{Scrapes data from https://www.billboard.com/charts/hot-100 and allows a user to see the chart in an organized manner. Selecting a song from the list will display the user with additional information about that song.}
14
+ spec.homepage = "https://github.com/ivillicana/billboard_hot_100"
15
+ spec.license = "MIT"
16
+
17
+
18
+ # Specify which files should be added to the gem when it is released.
19
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
20
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.16"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_dependency "nokogiri", "~> 1.8"
31
+ spec.add_dependency "require_all", "~> 2.0"
32
+ end
data/bin/.DS_Store ADDED
Binary file
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/billboard_hot_100.rb'
4
+
5
+ BillboardHot100::CLI.new.run
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 'bundler/setup'
2
+ require 'require_all'
3
+ require 'open-uri'
4
+ require 'nokogiri'
5
+
6
+
7
+ Bundler.require(:default)
8
+
9
+ require_all './lib/billboard_hot_100'
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,88 @@
1
+ class BillboardHot100::CLI
2
+
3
+ # Main instance method
4
+ def run
5
+ main_menu
6
+ select_song
7
+ end
8
+
9
+ # main menu selection and builds songs from scraper
10
+ def main_menu
11
+ puts "-----Welcome to the Billboard Hot 100 app-----"
12
+ puts ""
13
+ puts "Which chart range would you like to see?"
14
+ display_range
15
+ select_range
16
+ display_songs
17
+ end
18
+
19
+ #displays range of songs
20
+ def display_range
21
+ i = 1
22
+ r= 1
23
+ puts ""
24
+ 10.times do
25
+ puts "#{i}. Ranks #{r}-#{r+9}"
26
+ i += 1
27
+ r += 10
28
+ end
29
+ puts ""
30
+ end
31
+
32
+ #allows selection of range of songs
33
+ def select_range
34
+ puts "Enter the number of the range you would like to see?"
35
+ input = gets.strip.downcase
36
+ if input.to_i.between?(1, 10)
37
+ create_songs(input.to_i)
38
+ else
39
+ puts "Please enter a valid value:"
40
+ select_range
41
+ end
42
+ end
43
+
44
+ #prints out 10 songs in selected range
45
+ def display_songs
46
+
47
+ puts ""
48
+ @songs.each.with_index(1) do |song, i|
49
+ puts "#{i}. #{song.title} - #{song.artist}"
50
+ end
51
+ puts ""
52
+ end
53
+
54
+ #create Song objects
55
+ def create_songs(range)
56
+ @songs = BillboardHot100::Song.this_week(range)
57
+ end
58
+
59
+ # displays song info and asks for user input
60
+ def select_song
61
+ input = nil
62
+ while input != "exit"
63
+ puts "Please enter the song number to see more information:"
64
+ puts "(You can also type 'exit', 'see list', or 'main menu')"
65
+ input = gets.strip.downcase
66
+
67
+ #if/elseif/else depending on user input
68
+ if input.to_i.between?(1, @songs.length)
69
+ song = @songs[input.to_i - 1]
70
+ song.print_info
71
+ elsif input == "see list"
72
+ display_songs
73
+ elsif input == "main menu"
74
+ main_menu
75
+ elsif input == "exit"
76
+ close_app
77
+ else
78
+ puts ""
79
+ puts "Please enter a valid value..."
80
+ end
81
+ end
82
+ end
83
+
84
+ # ends the application
85
+ def close_app
86
+ puts "Thank you for using the Billboard Hot 100 CLI Application!"
87
+ end
88
+ end
@@ -0,0 +1,47 @@
1
+ class BillboardHot100::Song
2
+ # set up attributes for each instance
3
+ attr_accessor :title, :artist, :current_rank, :last_week_rank, :peak_position, :weeks
4
+
5
+ # Return this week's Billboard Hot 100 based on scraped data
6
+ def self.this_week(range)
7
+ @@all ||= self.scrape_songs
8
+ if range == 1
9
+ @@all[0, 10]
10
+ else
11
+ @@all["#{range-1}0".to_i, 10]
12
+ end
13
+ end
14
+
15
+ # Scrape songs from https://www.billboard.com/charts/hot-100
16
+ def self.scrape_songs
17
+ page_html = Nokogiri::HTML(open("https://www.billboard.com/charts/hot-100"))
18
+ chart = page_html.css(".chart-data .container")
19
+
20
+ #Iterate through the first 100 rows of the billboard chart
21
+ #Create instances of the Song class during each iteration
22
+ rows = chart.css(".chart-row")
23
+ songs = []
24
+ rows.collect do |row|
25
+ song = self.new
26
+ song.title = row.css(".chart-row__song").text
27
+ song.artist = row.css(".chart-row__artist").text.strip
28
+ song.current_rank = row.css(".chart-row__current-week").text
29
+ song.last_week_rank = row.css(".chart-row__secondary .chart-row__last-week .chart-row__value").text
30
+ song.peak_position = row.css(".chart-row__secondary .chart-row__top-spot .chart-row__value").text
31
+ song.weeks = row.css(".chart-row__secondary .chart-row__weeks-on-chart .chart-row__value").text
32
+ song
33
+ end
34
+ end
35
+
36
+ # Print info for chosen song
37
+ def print_info
38
+ puts ""
39
+ puts "Title: #{self.title}"
40
+ puts "Artist: #{self.artist}"
41
+ puts "Current Rank: #{self.current_rank}"
42
+ puts "Previous Rank: #{self.last_week_rank}"
43
+ puts "Peak Rank: #{self.peak_position}"
44
+ puts "Total Weeks: #{self.weeks}"
45
+ puts ""
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module BillboardHot100
2
+ VERSION = "0.1.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ module BillboardHot100
2
+ end
3
+
4
+ require_relative '../config/environment'
data/spec.md ADDED
@@ -0,0 +1,7 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [x] Have a CLI for interfacing with the application
5
+ - [x] Pull data from an external source
6
+ - [x] Implement both list and detail views
7
+
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: billboard_hot_100
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Isaac Villicana
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-06-14 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: 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
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: require_all
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ description: Scrapes data from https://www.billboard.com/charts/hot-100 and allows
84
+ a user to see the chart in an organized manner. Selecting a song from the list will
85
+ display the user with additional information about that song.
86
+ email:
87
+ - villicana.i@gmail.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".DS_Store"
93
+ - ".gitignore"
94
+ - ".rspec"
95
+ - ".travis.yml"
96
+ - CODE_OF_CONDUCT.md
97
+ - Gemfile
98
+ - Gemfile.lock
99
+ - LICENSE.txt
100
+ - README.md
101
+ - Rakefile
102
+ - billboard_hot_100.gemspec
103
+ - bin/.DS_Store
104
+ - bin/billboard_hot_100
105
+ - bin/setup
106
+ - config/environment.rb
107
+ - lib/.DS_Store
108
+ - lib/billboard_hot_100.rb
109
+ - lib/billboard_hot_100/cli.rb
110
+ - lib/billboard_hot_100/song.rb
111
+ - lib/billboard_hot_100/version.rb
112
+ - spec.md
113
+ homepage: https://github.com/ivillicana/billboard_hot_100
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.5.2
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: This gem (billboard_hot_100) includes a CLI shows a user the 'Billboard Hot
137
+ 100' list.
138
+ test_files: []