best_music 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/README.md +4 -4
- data/best_music-0.1.0.gem +0 -0
- data/bin/.DS_Store +0 -0
- data/bin/best-music +0 -1
- data/bin/setup +0 -2
- data/lib/{album.rb → best_music/album.rb} +1 -1
- data/lib/best_music/cli.rb +89 -0
- data/lib/{genre.rb → best_music/genre.rb} +0 -0
- data/lib/{scraper.rb → best_music/scraper.rb} +3 -9
- data/lib/best_music/version.rb +1 -1
- data/lib/environment.rb +9 -89
- metadata +9 -6
- data/bin/console +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f68ceff34e38f99e007c5f610dc9cb1fa56fadd2667c2fe25ae400565285be70
|
4
|
+
data.tar.gz: 48e6ed2d37dbaeddcdfc2f24961e407a0496a6b2adc536a1845e45343ac2fe27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8b2bf303217dd2ee72a01831eeb3fe253a8f310f8e735d51793d7d872585ceb41484d64d63aad9c1e963b1d92f64c1fca15060f195ac5432ce02c0126337ade
|
7
|
+
data.tar.gz: d62d07379dde05ade6c1f7f8c5b1272e07ce595aedf45c020f227b2ca70036ad1b913327d694d4ff62aa8bb98fd03b5cfd2d4fda293ad833128aea6237f1ca68
|
data/.DS_Store
ADDED
Binary file
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Best Music
|
2
2
|
|
3
|
-
_Best Music_ is a CLI app that returns Pitchfork.com's
|
3
|
+
_Best Music_ is a CLI app that returns Pitchfork.com's "Best New Albums" in realtime. It allows easy browsability by genre and score and provides a brief album description and link to the full review online.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -26,10 +26,10 @@ Once you've installed/cloned/downloaded the Gem, run `bin/setup` to install depe
|
|
26
26
|
|
27
27
|
To launch _Best Music_, simply run `bin/best-music`. The app returns live data from more than a dozen webpages, so it may take a few seconds to launch. Thanks for your patience!
|
28
28
|
|
29
|
-
Once _Best Music_ has loaded, you will have access to this week's
|
29
|
+
Once _Best Music_ has loaded, you will have access to this week's "Best New Album" along with a number of options for browsing the past 12 weeks' worth of "Best New Albums." You can:
|
30
30
|
|
31
|
-
1. Browse through a list of previous
|
32
|
-
2. Explore
|
31
|
+
1. Browse through a list of previous albums by typing `list`.
|
32
|
+
2. Explore albums by genre. Just type `genre`.
|
33
33
|
3. Type `score` to check out the highest scoring albums.
|
34
34
|
|
35
35
|
If at any point you need a refresher on your options, simply type `help` to access a list of instructions.
|
Binary file
|
data/bin/.DS_Store
ADDED
Binary file
|
data/bin/best-music
CHANGED
data/bin/setup
CHANGED
@@ -0,0 +1,89 @@
|
|
1
|
+
require_relative '../environment.rb'
|
2
|
+
|
3
|
+
module BestMusic
|
4
|
+
class CLI
|
5
|
+
@@path = 'https://pitchfork.com/reviews/best/albums/'
|
6
|
+
|
7
|
+
def call
|
8
|
+
puts "Welcome to Best Music!".colorize( :background => :green)
|
9
|
+
puts "Please wait while we bring you the best new albums according to Pitchfork.com...".red
|
10
|
+
|
11
|
+
Scraper.album_list(@@path)
|
12
|
+
Scraper.album_score
|
13
|
+
Scraper.album_description
|
14
|
+
|
15
|
+
puts "The 'Best New Album' is:"
|
16
|
+
puts "*#{Album.all[0].name}* by #{Album.all[0].artist}".colorize(:background => :red)
|
17
|
+
puts "It has a score of #{Album.all[0].rating}".yellow
|
18
|
+
puts "Pitchfork says: \"#{Album.all[0].description}\""
|
19
|
+
puts "To read the full review and/or to learn more visit:"
|
20
|
+
puts "https://pitchfork.com#{Album.all[0].url}".green
|
21
|
+
puts "______________________".red
|
22
|
+
puts "Check out more great music!".yellow
|
23
|
+
instructions
|
24
|
+
|
25
|
+
input = ""
|
26
|
+
while input != "exit"
|
27
|
+
|
28
|
+
puts "What would you like to do?".green
|
29
|
+
|
30
|
+
input = gets.downcase.chomp
|
31
|
+
|
32
|
+
case input
|
33
|
+
when "list"
|
34
|
+
album_list
|
35
|
+
when "genre"
|
36
|
+
albums_by_genre
|
37
|
+
when "score"
|
38
|
+
albums_by_rating
|
39
|
+
when "help"
|
40
|
+
instructions
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def album_list
|
46
|
+
puts "Below are the 12 most recent 'Best New Albums.'"
|
47
|
+
Album.all.each do |a|
|
48
|
+
puts "*#{a.name}* by #{a.artist}".colorize(:background => :red)
|
49
|
+
puts "It has a score of #{a.rating}".yellow
|
50
|
+
puts "Pitchfork says: \"#{a.description}\""
|
51
|
+
puts "To read the full review and/or to learn more visit:"
|
52
|
+
puts "https://pitchfork.com#{a.url}".green
|
53
|
+
puts "______________________".yellow
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def albums_by_genre
|
58
|
+
Genre.all.each do |g|
|
59
|
+
puts "// #{g.name} //".upcase.yellow
|
60
|
+
g.albums.each do |a|
|
61
|
+
puts "*#{a.name}* by #{a.artist}".colorize(:background => :red)
|
62
|
+
puts "It has a score of #{a.rating}".yellow
|
63
|
+
puts "Pitchfork says: \"#{a.description}\""
|
64
|
+
puts "To read the full review and/or to learn more visit:"
|
65
|
+
puts "https://pitchfork.com#{a.url}".green
|
66
|
+
puts "----".red
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def albums_by_rating
|
72
|
+
Album.albums_by_rating.each do |a|
|
73
|
+
puts "*#{a.name}* by #{a.artist}".colorize(:background => :red)
|
74
|
+
puts "It has a score of #{a.rating}".yellow
|
75
|
+
puts "Pitchfork says: \"#{a.description}\""
|
76
|
+
puts "To read the full review and/or to learn more visit:"
|
77
|
+
puts "https://pitchfork.com#{a.url}".green
|
78
|
+
puts "______________________".yellow
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def instructions
|
83
|
+
puts "To list all recent 'Best New Albums,' type 'list'."
|
84
|
+
puts "To browse by genre, type 'genre'."
|
85
|
+
puts "To browse by album score, type 'score'."
|
86
|
+
puts "To quit, type 'exit'."
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
File without changes
|
@@ -1,9 +1,4 @@
|
|
1
|
-
|
2
|
-
require 'nokogiri'
|
3
|
-
require 'pry'
|
4
|
-
require_relative './album.rb'
|
5
|
-
|
6
|
-
#album_list_url = https://pitchfork.com/reviews/best/albums/
|
1
|
+
require_relative '../environment.rb'
|
7
2
|
|
8
3
|
class Scraper
|
9
4
|
def self.scrape_pitchfork(index_url)
|
@@ -14,7 +9,7 @@ class Scraper
|
|
14
9
|
a_list = scrape_pitchfork(index_url).css(".fragment-list").css(".review")
|
15
10
|
a_list.each do |a|
|
16
11
|
album = a.css(".review__title-album").text
|
17
|
-
artist = a.css("li")[0].text.gsub("Ã", "ü").gsub("¼", "")
|
12
|
+
artist = a.css("li")[0].text.gsub("Ã", "ü").gsub("¼", "").gsub("ü©", "é")
|
18
13
|
genre = a.css("li")[1].text
|
19
14
|
url = a.css("a").attr("href").value
|
20
15
|
Genre.new(genre) if !Genre.all.collect {|g| g.name}.include?(genre)
|
@@ -32,8 +27,7 @@ class Scraper
|
|
32
27
|
def self.album_description
|
33
28
|
Album.all.each do |a|
|
34
29
|
url = "https://pitchfork.com#{a.url}"
|
35
|
-
description = scrape_pitchfork(url).css(".review-detail__abstract").text.gsub(/\u0099\u0080/, "").gsub(/â(?=\Ss)/, "'")
|
36
|
-
a.description = description.gsub("â", "--").chomp
|
30
|
+
a.description = scrape_pitchfork(url).css(".review-detail__abstract").text.gsub(/\u0099\u0080/, "").gsub(/â(?=\Ss)/, "'").gsub("â", "--").gsub("é", "é").chomp
|
37
31
|
end
|
38
32
|
end
|
39
33
|
end
|
data/lib/best_music/version.rb
CHANGED
data/lib/environment.rb
CHANGED
@@ -1,90 +1,10 @@
|
|
1
1
|
require 'colorize'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Scraper.album_list(@@path)
|
13
|
-
Scraper.album_score
|
14
|
-
Scraper.album_description
|
15
|
-
|
16
|
-
puts "The 'Best New Album' is:"
|
17
|
-
puts "*#{Album.all[0].name}* by #{Album.all[0].artist}".colorize(:background => :red)
|
18
|
-
puts "It has a score of #{Album.all[0].rating}".yellow
|
19
|
-
puts "Pitchfork says: \"#{Album.all[0].description}\""
|
20
|
-
puts "To read the full review and/or to learn more visit:"
|
21
|
-
puts "https://pitchfork.com#{Album.all[0].url}".green
|
22
|
-
puts "______________________".red
|
23
|
-
puts "Check out more great music!".yellow
|
24
|
-
instructions
|
25
|
-
|
26
|
-
input = ""
|
27
|
-
while input != "exit"
|
28
|
-
|
29
|
-
puts "What would you like to do?".green
|
30
|
-
|
31
|
-
input = gets.downcase.chomp
|
32
|
-
|
33
|
-
case input
|
34
|
-
when "list"
|
35
|
-
album_list
|
36
|
-
when "genre"
|
37
|
-
albums_by_genre
|
38
|
-
when "score"
|
39
|
-
albums_by_rating
|
40
|
-
when "help"
|
41
|
-
instructions
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def album_list
|
47
|
-
puts "Below are the 'Best New Albums' for the past 12 weeks."
|
48
|
-
Album.all.each do |a|
|
49
|
-
puts "*#{a.name}* by #{a.artist}".colorize(:background => :red)
|
50
|
-
puts "It has a score of #{a.rating}".yellow
|
51
|
-
puts "Pitchfork says: \"#{a.description}\""
|
52
|
-
puts "To read the full review and/or to learn more visit:"
|
53
|
-
puts "https://pitchfork.com#{a.url}".green
|
54
|
-
puts "______________________".yellow
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def albums_by_genre
|
59
|
-
Genre.all.each do |g|
|
60
|
-
puts "// #{g.name} //".upcase.yellow
|
61
|
-
g.albums.each do |a|
|
62
|
-
puts "*#{a.name}* by #{a.artist}".colorize(:background => :red)
|
63
|
-
puts "It has a score of #{a.rating}".yellow
|
64
|
-
puts "Pitchfork says: \"#{a.description}\""
|
65
|
-
puts "To read the full review and/or to learn more visit:"
|
66
|
-
puts "https://pitchfork.com#{a.url}".green
|
67
|
-
puts "----".red
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def albums_by_rating
|
73
|
-
Album.albums_by_rating.each do |a|
|
74
|
-
puts "*#{a.name}* by #{a.artist}".colorize(:background => :red)
|
75
|
-
puts "It has a score of #{a.rating}".yellow
|
76
|
-
puts "Pitchfork says: \"#{a.description}\""
|
77
|
-
puts "To read the full review and/or to learn more visit:"
|
78
|
-
puts "https://pitchfork.com#{a.url}".green
|
79
|
-
puts "______________________".yellow
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def instructions
|
84
|
-
puts "To list all recent 'Best New Albums,' type 'list'."
|
85
|
-
puts "To browse by genre, type 'genre'."
|
86
|
-
puts "To browse by album score, type 'score'."
|
87
|
-
puts "To quit, type 'exit'."
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
2
|
+
require 'open-uri'
|
3
|
+
require 'nokogiri'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
require_relative './best_music/album.rb'
|
7
|
+
require_relative './best_music/cli.rb'
|
8
|
+
require_relative './best_music/genre.rb'
|
9
|
+
require_relative './best_music/scraper.rb'
|
10
|
+
require_relative './best_music/version.rb'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: best_music
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cyantis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -47,6 +47,7 @@ executables: []
|
|
47
47
|
extensions: []
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
|
+
- ".DS_Store"
|
50
51
|
- ".Rhistory"
|
51
52
|
- ".gitignore"
|
52
53
|
- Gemfile
|
@@ -54,15 +55,17 @@ files:
|
|
54
55
|
- LICENSE.txt
|
55
56
|
- README.md
|
56
57
|
- Rakefile
|
58
|
+
- best_music-0.1.0.gem
|
57
59
|
- best_music.gemspec
|
60
|
+
- bin/.DS_Store
|
58
61
|
- bin/best-music
|
59
|
-
- bin/console
|
60
62
|
- bin/setup
|
61
|
-
- lib/album.rb
|
63
|
+
- lib/best_music/album.rb
|
64
|
+
- lib/best_music/cli.rb
|
65
|
+
- lib/best_music/genre.rb
|
66
|
+
- lib/best_music/scraper.rb
|
62
67
|
- lib/best_music/version.rb
|
63
68
|
- lib/environment.rb
|
64
|
-
- lib/genre.rb
|
65
|
-
- lib/scraper.rb
|
66
69
|
homepage: https://github.com/cyantis/best_music
|
67
70
|
licenses:
|
68
71
|
- MIT
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "best_music"
|
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__)
|