pitchfork_reviews 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +24 -0
- data/Rakefile +2 -0
- data/bin/console +7 -0
- data/bin/pitchfork-reviews +6 -0
- data/bin/setup +6 -0
- data/lib/pitchfork_reviews.rb +10 -0
- data/lib/pitchfork_reviews/album.rb +37 -0
- data/lib/pitchfork_reviews/cli.rb +63 -0
- data/lib/pitchfork_reviews/version.rb +3 -0
- data/pitchfork_reviews.gemspec +26 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 310661659dd85bcd127c9d0b820b63dee20af02e
|
4
|
+
data.tar.gz: ae633842e51199fbdf18d92aa0fb8b64b606f7cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2ab7b26e7bab56c8713db6cec61b49ded60bd6563f09c9a410747f19177f129c9a4e6b798907952ec518df86807caf0444133cdf5b923bbae8c012f8dee31ac7
|
7
|
+
data.tar.gz: 78118b6c75e210f858e1ee92dbbbc468da0dbbeb4b6dde413a3240a292c79f7bd5a921668cca079fbc4c091a8e3eea95db71e17741ccca96b70659010b7488e6
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 depippo
|
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,24 @@
|
|
1
|
+
# PitchforkReviews
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
To install this gem, go to your terminal and enter `gem install pitchfork_reviews`.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Once the gem has been installed, you can access it by entering `pitchfork-reviews` in your terminal. This will load a list of the most recent album reviews from Pitchfork.com, updated in real time. You can check which albums are the highest scoring, read album summaries, and find links to full reviews for albums you're interested in.
|
10
|
+
|
11
|
+
## Development
|
12
|
+
|
13
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
14
|
+
|
15
|
+
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).
|
16
|
+
|
17
|
+
## Contributing
|
18
|
+
|
19
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/depippo/pitchfork_reviews.
|
20
|
+
|
21
|
+
|
22
|
+
## License
|
23
|
+
|
24
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
class PitchforkReviews::Album
|
2
|
+
attr_accessor :name, :artist, :genre, :score, :summary, :best_new_album, :url
|
3
|
+
|
4
|
+
def self.scrape_pitchfork
|
5
|
+
albums = []
|
6
|
+
doc = Nokogiri::HTML(open("http://pitchfork.com/reviews/albums/"))
|
7
|
+
doc.css(".review").each do |review|
|
8
|
+
all_genres = []
|
9
|
+
all_artists = []
|
10
|
+
all_scores = []
|
11
|
+
album = self.new
|
12
|
+
album.name = review.css(".title").text
|
13
|
+
|
14
|
+
review.css("div.album-artist ul li").each do |a|
|
15
|
+
all_artists << a.text
|
16
|
+
end
|
17
|
+
album.artist = all_artists.to_s.gsub('"', "").gsub('[', "").gsub("]", "")
|
18
|
+
|
19
|
+
review.css("ul.genre-list.before.inline li").each do |g|
|
20
|
+
all_genres << g.text
|
21
|
+
end
|
22
|
+
album.genre = all_genres.to_s.gsub('"', "").gsub('[', "").gsub("]", "")
|
23
|
+
|
24
|
+
album.url = review.css(".album-link")[0]["href"]
|
25
|
+
if review.text.include?("Best New Album")
|
26
|
+
album.best_new_album = " ** Best New Album **"
|
27
|
+
end
|
28
|
+
page = Nokogiri::HTML(open("http://pitchfork.com#{album.url}"))
|
29
|
+
|
30
|
+
album.score = page.css(".score-circle").text[0..2]
|
31
|
+
album.summary = page.css("div.abstract").text.gsub("Â" , "").gsub("â" , "'")
|
32
|
+
albums << album
|
33
|
+
end
|
34
|
+
albums
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class PitchforkReviews::CLI
|
2
|
+
|
3
|
+
def call
|
4
|
+
list_reviews
|
5
|
+
menu
|
6
|
+
goodbye
|
7
|
+
end
|
8
|
+
|
9
|
+
def list_reviews
|
10
|
+
puts
|
11
|
+
puts "Welcome! Here are the most recent album reviews from Pitchfork."
|
12
|
+
puts
|
13
|
+
@albums = PitchforkReviews::Album.scrape_pitchfork
|
14
|
+
@albums.each.with_index(1) do |album, i|
|
15
|
+
puts "#{i}. #{album.name} by #{album.artist}#{album.best_new_album}"
|
16
|
+
end
|
17
|
+
puts
|
18
|
+
end
|
19
|
+
|
20
|
+
def sort_by_score
|
21
|
+
@albums = PitchforkReviews::Album.scrape_pitchfork
|
22
|
+
@albums.sort! { |a,b| b.score <=> a.score}
|
23
|
+
@albums.each.with_index(1) do |album, i|
|
24
|
+
puts "#{i}. #{album.name} by #{album.artist}#{album.best_new_album}, #{album.score}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def menu
|
29
|
+
input = nil
|
30
|
+
while input != "exit"
|
31
|
+
puts "Please enter the number of the album you would like to read more about."
|
32
|
+
puts "Enter 'sort' to sort the albums by review score."
|
33
|
+
puts "Enter 'list' to see the album list again."
|
34
|
+
puts "Enter 'exit' to exit the program."
|
35
|
+
input = gets.strip.downcase
|
36
|
+
if input.to_i.between?(1,24)
|
37
|
+
the_album = @albums[input.to_i-1]
|
38
|
+
puts
|
39
|
+
puts "#{the_album.name}"
|
40
|
+
puts "by"
|
41
|
+
puts "#{the_album.artist}"
|
42
|
+
puts "#{the_album.genre}"
|
43
|
+
puts
|
44
|
+
puts "Score: #{the_album.score} #{the_album.best_new_album}"
|
45
|
+
puts
|
46
|
+
puts "Summary:"
|
47
|
+
puts "#{the_album.summary}"
|
48
|
+
puts
|
49
|
+
puts "Read the full review at http://pitchfork.com#{the_album.url}"
|
50
|
+
puts
|
51
|
+
elsif input == "list"
|
52
|
+
list_reviews
|
53
|
+
elsif input =="sort"
|
54
|
+
sort_by_score
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def goodbye
|
60
|
+
puts "Goodbye! Check back again soon for more new albums."
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pitchfork_reviews/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pitchfork_reviews"
|
8
|
+
spec.version = PitchforkReviews::VERSION
|
9
|
+
spec.authors = ["depippo"]
|
10
|
+
spec.email = ["jdepippo@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Pitchfork reviews}
|
13
|
+
spec.description = %q{Pitchfork reviews}
|
14
|
+
spec.homepage = "https://github.com/depippo/pitchfork_reviews"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($\)
|
18
|
+
spec.bindir = "bin"
|
19
|
+
spec.executables = ["pitchfork-reviews"]
|
20
|
+
spec.require_paths = ["lib", "lib/pitchfork_reviews"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
spec.add_development_dependency "nokogiri"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pitchfork_reviews
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.8
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- depippo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-13 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.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
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: nokogiri
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Pitchfork reviews
|
70
|
+
email:
|
71
|
+
- jdepippo@gmail.com
|
72
|
+
executables:
|
73
|
+
- pitchfork-reviews
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/pitchfork-reviews
|
84
|
+
- bin/setup
|
85
|
+
- lib/pitchfork_reviews.rb
|
86
|
+
- lib/pitchfork_reviews/album.rb
|
87
|
+
- lib/pitchfork_reviews/cli.rb
|
88
|
+
- lib/pitchfork_reviews/version.rb
|
89
|
+
- pitchfork_reviews.gemspec
|
90
|
+
homepage: https://github.com/depippo/pitchfork_reviews
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
- lib/pitchfork_reviews
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.4.5.1
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Pitchfork reviews
|
115
|
+
test_files: []
|