best_selling_books 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 +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/NOTES.md +25 -0
- data/README.md +44 -0
- data/Rakefile +2 -0
- data/best_selling_books.gemspec +33 -0
- data/bin/best_selling_books +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/best_selling_books.rb +10 -0
- data/lib/best_selling_books/books.rb +5 -0
- data/lib/best_selling_books/cli.rb +96 -0
- data/lib/best_selling_books/collectable.rb +24 -0
- data/lib/best_selling_books/site_scrapers/amazon.rb +35 -0
- data/lib/best_selling_books/site_scrapers/barnes_n_noble.rb +37 -0
- data/lib/best_selling_books/version.rb +3 -0
- data/spec.md +9 -0
- metadata +135 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 354092ee7ea51615edda55a60438d7411dae56ff7dae6c82f8d4312b8ea4c9b4
|
|
4
|
+
data.tar.gz: cc59ae22b66b61065e8f256ef5280021cfd09758c10b47e975762b1d48191377
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9422463838c3dde0ae0dc3e9960bfdadd6b74e0fd1fe9c5f12e645515fda19586fd41f1eed0610e807c2f852c018357de319d12fa7f6911e4a78e438f85470b5
|
|
7
|
+
data.tar.gz: b5fef6c753d8fda30e3aaaeb4df6bef176f57ba445ba71a1e05f56512c8f3e98dd9034b0d6fe999da1d09075d1882b9ed6e780d02a9961e08c515eab0b9dc806
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -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 'yahyal0v3@yahoo.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
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 'Khaya Ramcharita-Dillon'
|
|
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/NOTES.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
|
|
2
|
+
Command Line Interface for best_selling_books
|
|
3
|
+
|
|
4
|
+
Prompts user to choose between B&N, and Amazon best sellers
|
|
5
|
+
|
|
6
|
+
Shows a list of best selling books from that site
|
|
7
|
+
(ex of Amazon list)
|
|
8
|
+
1. Milk and Honey by Rupi Kaur
|
|
9
|
+
2. Hillbilly Elegy: A Memoir of a Family and Culture in Crisis by J. D. Vance
|
|
10
|
+
|
|
11
|
+
Prompts user to choose listing for more info
|
|
12
|
+
Asks user what they would like to know
|
|
13
|
+
Genre
|
|
14
|
+
Plot Summary
|
|
15
|
+
Author Bio
|
|
16
|
+
Prices & Formats
|
|
17
|
+
Link
|
|
18
|
+
|
|
19
|
+
Class Responsibilities
|
|
20
|
+
CLI - displays best sellers and related information
|
|
21
|
+
Site Scraper - scraps book lists and related information, has many books
|
|
22
|
+
Collect Module - has self.list_best_sellers
|
|
23
|
+
Books - belongs to a site, has characteristics (takes info from site scraper to assign characteristics)
|
|
24
|
+
|
|
25
|
+
-Don't have 2017 hard coded
|
data/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# BestSellingBooks
|
|
2
|
+
|
|
3
|
+
This Ruby Gem provides a CLI to view the top 20 best selling books of the year according to Amazon's and Barnes & Noble's website.
|
|
4
|
+
The user can also select book listings to view additional details about them.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
Add this line to your application's Gemfile:
|
|
9
|
+
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'best_selling_books'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
And then execute:
|
|
15
|
+
|
|
16
|
+
$ bundle
|
|
17
|
+
|
|
18
|
+
Or install it yourself as:
|
|
19
|
+
|
|
20
|
+
$ gem install best_selling_books
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
Type the below and follow the on screen prompts.
|
|
25
|
+
|
|
26
|
+
$ best-selling-books
|
|
27
|
+
|
|
28
|
+
## Development
|
|
29
|
+
|
|
30
|
+
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.
|
|
31
|
+
|
|
32
|
+
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).
|
|
33
|
+
|
|
34
|
+
## Contributing
|
|
35
|
+
|
|
36
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/'yahyal0v3'/best_selling_books. 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.
|
|
37
|
+
|
|
38
|
+
## License
|
|
39
|
+
|
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
|
41
|
+
|
|
42
|
+
## Code of Conduct
|
|
43
|
+
|
|
44
|
+
Everyone interacting in the BestSellingBooks project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/'yahyal0v3'/best_selling_books/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "best_selling_books/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "best_selling_books"
|
|
8
|
+
spec.version = BestSellingBooks::VERSION
|
|
9
|
+
spec.authors = ["'Khaya Ramcharita-Dillon'"]
|
|
10
|
+
spec.email = ["'yahyal0v3@yahoo.com'"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Best Selling Books Lister}
|
|
13
|
+
spec.description = %q{Lists the best selling books from Amazon and B&N and provides information about each book.}
|
|
14
|
+
spec.homepage = ""
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
+
|
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
21
|
+
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.15"
|
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
29
|
+
spec.add_development_dependency "rspec"
|
|
30
|
+
spec.add_development_dependency "pry"
|
|
31
|
+
|
|
32
|
+
spec.add_dependency "nokogiri"
|
|
33
|
+
end
|
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "best_selling_books"
|
|
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,10 @@
|
|
|
1
|
+
require 'nokogiri'
|
|
2
|
+
require 'open-uri'
|
|
3
|
+
|
|
4
|
+
require_relative "./best_selling_books/version"
|
|
5
|
+
require_relative "./best_selling_books/cli"
|
|
6
|
+
require_relative "./best_selling_books/collectable"
|
|
7
|
+
require_relative "./best_selling_books/books"
|
|
8
|
+
|
|
9
|
+
require_relative "./best_selling_books/site_scrapers/amazon"
|
|
10
|
+
require_relative "./best_selling_books/site_scrapers/barnes_n_noble"
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
|
|
2
|
+
class BestSellingBooks::CLI
|
|
3
|
+
|
|
4
|
+
def call
|
|
5
|
+
choose_best_sellers_list
|
|
6
|
+
choose_listing
|
|
7
|
+
choose_info
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def choose_best_sellers_list
|
|
11
|
+
puts ">> Would you like to see Barnes & Noble's or Amazon's best sellers of #{Time.now.year}?"
|
|
12
|
+
site = gets.strip
|
|
13
|
+
case site.downcase
|
|
14
|
+
when "amazon", "amazon's"
|
|
15
|
+
@site = BestSellingBooks::Amazon
|
|
16
|
+
create_and_display_book_list
|
|
17
|
+
when "barnes & noble", "barnes & noble's", "barnes and noble", "barnes and noble's", "b&n"
|
|
18
|
+
@site = BestSellingBooks::BarnesAndNoble
|
|
19
|
+
create_and_display_book_list
|
|
20
|
+
when "exit"
|
|
21
|
+
exit
|
|
22
|
+
else
|
|
23
|
+
puts "Invalid input. Please type the name of the best sellers list you would like to view."
|
|
24
|
+
choose_best_sellers_list
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def create_and_display_book_list
|
|
29
|
+
@site.create_and_collect_books if @site.all_books == []
|
|
30
|
+
@site.list_best_sellers
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def display_other_options
|
|
34
|
+
puts "> Or type 'List' to return to the list, 'Best Sellers' to pick a different top 20 list, or 'Exit' to leave."
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def choose_listing
|
|
38
|
+
puts ">> Please type a listing number for more information."
|
|
39
|
+
display_other_options
|
|
40
|
+
input = gets.strip
|
|
41
|
+
if input.downcase == "exit"
|
|
42
|
+
exit
|
|
43
|
+
elsif input.to_i != 0
|
|
44
|
+
@book = @site.all_books.detect {|instance| instance.rank == input }
|
|
45
|
+
elsif input.downcase == "list"
|
|
46
|
+
create_and_display_book_list
|
|
47
|
+
choose_listing
|
|
48
|
+
elsif input.downcase == "best sellers"
|
|
49
|
+
call
|
|
50
|
+
else
|
|
51
|
+
puts "Invalid input."
|
|
52
|
+
choose_listing
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def display_book_info_options
|
|
57
|
+
puts @book.title
|
|
58
|
+
puts "A. Author Bio"
|
|
59
|
+
puts "B. Price"
|
|
60
|
+
puts "C. Available Format"
|
|
61
|
+
puts "D. Site Rating"
|
|
62
|
+
puts "E. #{@site.name} Link"
|
|
63
|
+
puts ">> What would you like to know about this listing? Please select a letter."
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def choose_info
|
|
67
|
+
display_book_info_options
|
|
68
|
+
loop do
|
|
69
|
+
input = gets.strip
|
|
70
|
+
case input.downcase
|
|
71
|
+
when "a"
|
|
72
|
+
puts "About " + @book.author
|
|
73
|
+
puts @book.author_bio
|
|
74
|
+
when "b"
|
|
75
|
+
puts @book.price
|
|
76
|
+
when "c"
|
|
77
|
+
puts @book.format
|
|
78
|
+
when "d"
|
|
79
|
+
puts @book.rating
|
|
80
|
+
when "e"
|
|
81
|
+
puts @book.link
|
|
82
|
+
when "list"
|
|
83
|
+
@site.list_best_sellers
|
|
84
|
+
choose_listing
|
|
85
|
+
choose_info
|
|
86
|
+
when "best sellers"
|
|
87
|
+
call
|
|
88
|
+
when "exit"
|
|
89
|
+
exit
|
|
90
|
+
else
|
|
91
|
+
puts "Invalid input."
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'pry'
|
|
2
|
+
|
|
3
|
+
module BestSellingBooks::Collectable
|
|
4
|
+
|
|
5
|
+
def create_and_collect_books
|
|
6
|
+
self::Scraper.scrape_book_list.each do |hash|
|
|
7
|
+
instance = BestSellingBooks::Books.new
|
|
8
|
+
instance.title = hash[:Title]
|
|
9
|
+
instance.author = hash[:Author]
|
|
10
|
+
instance.author_bio = hash[:Author_Bio]
|
|
11
|
+
instance.price = hash[:Price]
|
|
12
|
+
instance.format = hash[:Format]
|
|
13
|
+
instance.rating = hash[:Rating]
|
|
14
|
+
instance.link = hash[:Link]
|
|
15
|
+
instance.rank = hash[:Rank]
|
|
16
|
+
self.all_books << instance
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def list_best_sellers
|
|
21
|
+
puts self.name + "'s Top 20"
|
|
22
|
+
self.all_books.each {|instance| puts "#{instance.rank}. #{instance.title} by #{instance.author}"}
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
|
|
2
|
+
class BestSellingBooks::Amazon
|
|
3
|
+
extend BestSellingBooks::Collectable
|
|
4
|
+
|
|
5
|
+
@@all_books = []
|
|
6
|
+
|
|
7
|
+
def self.all_books
|
|
8
|
+
@@all_books
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.name
|
|
12
|
+
"Amazon"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Scraper
|
|
16
|
+
def self.get_book_list
|
|
17
|
+
Nokogiri::HTML(open("https://www.amazon.com/gp/bestsellers/#{Time.now.year}/books"))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.scrape_book_list
|
|
21
|
+
homepage = "https://www.amazon.com"
|
|
22
|
+
get_book_list.css('div.zg_itemImmersion').collect do |book_listing|
|
|
23
|
+
{Rank: book_listing.css('span.zg_rankNumber').text.strip.chop,
|
|
24
|
+
Title: book_listing.css('div.p13n-sc-truncated-hyphen').text.strip,
|
|
25
|
+
Author: book_listing.css('a.a-size-small.a-link-child').text.strip,
|
|
26
|
+
Author_Bio: homepage + book_listing.css('a.a-size-small.a-link-child').attr('href').value.strip,
|
|
27
|
+
Price: book_listing.css('span.p13n-sc-price').text.strip,
|
|
28
|
+
Format: book_listing.css('span.a-size-small.a-color-secondary').text.strip,
|
|
29
|
+
Rating: book_listing.css('i.a-icon-star').text.strip,
|
|
30
|
+
Link: homepage + book_listing.css('a.a-link-normal').attr('href').value.strip}
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
class BestSellingBooks::BarnesAndNoble
|
|
3
|
+
extend BestSellingBooks::Collectable
|
|
4
|
+
|
|
5
|
+
@@all_books = []
|
|
6
|
+
|
|
7
|
+
def self.all_books
|
|
8
|
+
@@all_books
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.name
|
|
12
|
+
"B&N"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Scraper
|
|
16
|
+
def self.get_book_list
|
|
17
|
+
doc = Nokogiri::HTML(open("https://www.barnesandnoble.com/b/books/_/N-1fZ29Z8q8"))
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.scrape_book_list
|
|
21
|
+
homepage = "https://www.barnesandnoble.com"
|
|
22
|
+
get_book_list.css('div.pb-m.mt-m.bd-bottom-disabled-gray.record').collect do |book_listing|
|
|
23
|
+
author_bio = homepage + book_listing.css('div.product-shelf-author.contributors a:first-child').attr('href').value.strip
|
|
24
|
+
|
|
25
|
+
{Rank: book_listing.css('div.col-lg-1.count').text.strip,
|
|
26
|
+
Title: book_listing.css('h3.product-info-title a').text.strip,
|
|
27
|
+
Author: book_listing.css('div.product-shelf-author.contributors a:first-child').text.strip,
|
|
28
|
+
Author_Bio: author_bio.gsub!(' ', '%20'),
|
|
29
|
+
Price: book_listing.css('a.current.link').text.strip,
|
|
30
|
+
Format: book_listing.css('a.format').text.strip,
|
|
31
|
+
Rating: book_listing.css('div.product-shelf-ratings').attr('aria-label').value,
|
|
32
|
+
Link: homepage + book_listing.css('div.product-shelf-image.product-image a').attr('href').value}
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
data/spec.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
Scrapes the best sellers list data from websites (Barnes & Noble and Amazon) to create book instances.
|
|
7
|
+
- [x] Implement both list and detail views
|
|
8
|
+
Displays a list of the top 20 books and asks the user to select a listing. If a listing is selected, the
|
|
9
|
+
program then displays a list of additional details about the book, which the user can select to view..
|
metadata
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: best_selling_books
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- "'Khaya Ramcharita-Dillon'"
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-11-16 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.15'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.15'
|
|
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: '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: pry
|
|
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
|
+
- !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: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
description: Lists the best selling books from Amazon and B&N and provides information
|
|
84
|
+
about each book.
|
|
85
|
+
email:
|
|
86
|
+
- "'yahyal0v3@yahoo.com'"
|
|
87
|
+
executables: []
|
|
88
|
+
extensions: []
|
|
89
|
+
extra_rdoc_files: []
|
|
90
|
+
files:
|
|
91
|
+
- ".gitignore"
|
|
92
|
+
- CODE_OF_CONDUCT.md
|
|
93
|
+
- Gemfile
|
|
94
|
+
- Gemfile.lock
|
|
95
|
+
- LICENSE.txt
|
|
96
|
+
- NOTES.md
|
|
97
|
+
- README.md
|
|
98
|
+
- Rakefile
|
|
99
|
+
- best_selling_books.gemspec
|
|
100
|
+
- bin/best_selling_books
|
|
101
|
+
- bin/console
|
|
102
|
+
- bin/setup
|
|
103
|
+
- lib/best_selling_books.rb
|
|
104
|
+
- lib/best_selling_books/books.rb
|
|
105
|
+
- lib/best_selling_books/cli.rb
|
|
106
|
+
- lib/best_selling_books/collectable.rb
|
|
107
|
+
- lib/best_selling_books/site_scrapers/amazon.rb
|
|
108
|
+
- lib/best_selling_books/site_scrapers/barnes_n_noble.rb
|
|
109
|
+
- lib/best_selling_books/version.rb
|
|
110
|
+
- spec.md
|
|
111
|
+
homepage: ''
|
|
112
|
+
licenses:
|
|
113
|
+
- MIT
|
|
114
|
+
metadata: {}
|
|
115
|
+
post_install_message:
|
|
116
|
+
rdoc_options: []
|
|
117
|
+
require_paths:
|
|
118
|
+
- lib
|
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0'
|
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
|
+
requirements:
|
|
126
|
+
- - ">="
|
|
127
|
+
- !ruby/object:Gem::Version
|
|
128
|
+
version: '0'
|
|
129
|
+
requirements: []
|
|
130
|
+
rubyforge_project:
|
|
131
|
+
rubygems_version: 2.7.2
|
|
132
|
+
signing_key:
|
|
133
|
+
specification_version: 4
|
|
134
|
+
summary: Best Selling Books Lister
|
|
135
|
+
test_files: []
|