nytimesbooks 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +6 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/nytimesbooks +5 -0
- data/bin/setup +8 -0
- data/lib/nytimesbooks/books.rb +145 -0
- data/lib/nytimesbooks/cli.rb +292 -0
- data/lib/nytimesbooks/version.rb +3 -0
- data/lib/nytimesbooks.rb +6 -0
- data/nytimesbooks.gemspec +28 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c54da0ec4a6adfd9d584b2eaea7b8170bf6ea3ea41fd68930ee90260bdc84844
|
4
|
+
data.tar.gz: 043793852e390920fdc575d1c01b3756896b832bb03550685c54902b8822e709
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f06bf5013511056bd7f84dd02c8a292492bcb42eda7e315063fa25414922a1a5895faed8dfb7de80d72428ee214bcfa688b2368963c350dce3b1b5bc69c931c
|
7
|
+
data.tar.gz: 8a698396f916339c57dd228805fa0f98981461763ed50b5415c56368a8fd98ba34d622479c1d19a3d80d6d27dc30fa208a31d80917a668d2f895c11c331902bc
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "nytimesbooks"
|
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/nytimesbooks
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
class Nytimesbooks::Book
|
2
|
+
attr_accessor :name, :author, :bookdescription
|
3
|
+
|
4
|
+
def self.combined_fiction
|
5
|
+
puts "Combined Print & E-Book Fiction"
|
6
|
+
doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/combined-print-and-e-book-fiction/?action=click&contentCollection=Books&referrer=https%3A%2F%2Fwww.nytimes.com%2Fsection%2Fbooks®ion=Body&module=CompleteListLink&version=Fiction&pgtype=Reference"))
|
7
|
+
combined_fiction_array = []
|
8
|
+
doc.css("div.book-body").each do |book|
|
9
|
+
new_book = self.new
|
10
|
+
new_book.name = book.css("h2.title").text
|
11
|
+
new_book.author = book.css("p.author").text
|
12
|
+
new_book.bookdescription = book.css("p.description").text
|
13
|
+
combined_fiction_array << new_book
|
14
|
+
end
|
15
|
+
combined_fiction_array
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.hardcover_fiction
|
19
|
+
puts "Hardcover Fiction"
|
20
|
+
doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/hardcover-fiction/?module=DropDownNav&action=click®ion=navbar&contentCollection=Books&version=Fiction&referrer=https%3A%2F%2Fwww.nytimes.com%2Fbooks%2Fbest-sellers%2F&pgtype=Reference"))
|
21
|
+
hardcover_fiction_array = []
|
22
|
+
doc.css("div.book-body").each do |book|
|
23
|
+
new_book = self.new
|
24
|
+
new_book.name = book.css("h2.title").text
|
25
|
+
new_book.author = book.css("p.author").text
|
26
|
+
new_book.bookdescription = book.css("p.description").text
|
27
|
+
hardcover_fiction_array << new_book
|
28
|
+
end
|
29
|
+
hardcover_fiction_array
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.paperback_fiction
|
33
|
+
puts "Paperback Fiction"
|
34
|
+
doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/trade-fiction-paperback/?module=DropDownNav&action=click®ion=navbar&contentCollection=Books&version=Fiction&referrer=https%3A%2F%2Fwww.nytimes.com%2Fbooks%2Fbest-sellers%2Fcombined-print-and-e-book-fiction%2F&pgtype=Reference"))
|
35
|
+
paperback_fiction_array = []
|
36
|
+
doc.css("div.book-body").each do |book|
|
37
|
+
new_book = self.new
|
38
|
+
new_book.name = book.css("h2.title").text
|
39
|
+
new_book.author = book.css("p.author").text
|
40
|
+
new_book.bookdescription = book.css("p.description").text
|
41
|
+
paperback_fiction_array << new_book
|
42
|
+
end
|
43
|
+
paperback_fiction_array
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.combined_nonfiction
|
47
|
+
puts "Combined Print & E-Book Nonfiction"
|
48
|
+
doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/combined-print-and-e-book-nonfiction/?module=DropDownNav&action=click®ion=navbar&contentCollection=Books&version=Nonfiction&referrer=https%3A%2F%2Fwww.nytimes.com%2Fbooks%2Fbest-sellers%2Fhardcover-fiction%2F&pgtype=Reference"))
|
49
|
+
combined_nonfiction_array = []
|
50
|
+
doc.css("div.book-body").each do |book|
|
51
|
+
new_book = self.new
|
52
|
+
new_book.name = book.css("h2.title").text
|
53
|
+
new_book.author = book.css("p.author").text
|
54
|
+
new_book.bookdescription = book.css("p.description").text
|
55
|
+
combined_nonfiction_array << new_book
|
56
|
+
end
|
57
|
+
combined_nonfiction_array
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.hardcover_nonfiction
|
61
|
+
puts "Hardcover Nonfiction"
|
62
|
+
doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/hardcover-nonfiction/?module=DropDownNav&action=click®ion=navbar&contentCollection=Books&version=Nonfiction&referrer=https%3A%2F%2Fwww.nytimes.com%2Fbooks%2Fbest-sellers%2Ftrade-fiction-paperback%2F&pgtype=Reference&mtrref=www.nytimes.com&gwh=631EB713B46E9B6EEA11D9D78A6A73A3&gwt=pay"))
|
63
|
+
hardcover_nonfiction_array = []
|
64
|
+
doc.css("div.book-body").each do |book|
|
65
|
+
new_book = self.new
|
66
|
+
new_book.name = book.css("h2.title").text
|
67
|
+
new_book.author = book.css("p.author").text
|
68
|
+
new_book.bookdescription = book.css("p.description").text
|
69
|
+
hardcover_nonfiction_array << new_book
|
70
|
+
end
|
71
|
+
hardcover_nonfiction_array
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.paperback_nonfiction
|
75
|
+
puts "Paperback Nonfiction"
|
76
|
+
doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/paperback-nonfiction/?module=DropDownNav&action=click®ion=navbar&contentCollection=Books&version=Nonfiction&referrer=https%3A%2F%2Fwww.nytimes.com%2Fsection%2Fbooks&pgtype=Reference"))
|
77
|
+
paperback_nonfiction_array = []
|
78
|
+
doc.css("div.book-body").each do |book|
|
79
|
+
new_book = self.new
|
80
|
+
new_book.name = book.css("h2.title").text
|
81
|
+
new_book.author = book.css("p.author").text
|
82
|
+
new_book.bookdescription = book.css("p.description").text
|
83
|
+
paperback_nonfiction_array << new_book
|
84
|
+
end
|
85
|
+
paperback_nonfiction_array
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.childrens_middle
|
89
|
+
puts "Children's Middle Grade"
|
90
|
+
doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/childrens-middle-grade-hardcover/?module=DropDownNav&action=click®ion=navbar&contentCollection=Books&version=Childrens&referrer=https%3A%2F%2Fwww.nytimes.com%2Fbooks%2Fbest-sellers%2Fchildrens-middle-grade-hardcover%2F&pgtype=Reference"))
|
91
|
+
childrens_middle_array = []
|
92
|
+
doc.css("div.book-body").each do |book|
|
93
|
+
new_book = self.new
|
94
|
+
new_book.name = book.css("h2.title").text
|
95
|
+
new_book.author = book.css("p.author").text
|
96
|
+
new_book.bookdescription = book.css("p.description").text
|
97
|
+
childrens_middle_array << new_book
|
98
|
+
end
|
99
|
+
childrens_middle_array
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.childrens_picture
|
103
|
+
puts "Children's Picture Books"
|
104
|
+
doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/picture-books/?module=DropDownNav&action=click®ion=navbar&contentCollection=Books&version=Childrens&referrer=https%3A%2F%2Fwww.nytimes.com%2Fbooks%2Fbest-sellers%2Fchildrens-middle-grade-hardcover%2F&pgtype=Reference"))
|
105
|
+
children_picture_array = []
|
106
|
+
doc.css("div.book-body").each do |book|
|
107
|
+
new_book = self.new
|
108
|
+
new_book.name = book.css("h2.title").text
|
109
|
+
new_book.author = book.css("p.author").text
|
110
|
+
new_book.bookdescription = book.css("p.description").text
|
111
|
+
children_picture_array << new_book
|
112
|
+
end
|
113
|
+
children_picture_array
|
114
|
+
end
|
115
|
+
|
116
|
+
def self.childrens_series
|
117
|
+
puts "Children's Series"
|
118
|
+
doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/series-books/?module=DropDownNav&action=click®ion=navbar&contentCollection=Books&version=Childrens&referrer=https%3A%2F%2Fwww.nytimes.com%2Fsection%2Fbooks&pgtype=Reference"))
|
119
|
+
children_series_array = []
|
120
|
+
doc.css("div.book-body").each do |book|
|
121
|
+
new_book = self.new
|
122
|
+
new_book.name = book.css("h2.title").text
|
123
|
+
new_book.author = book.css("p.author").text
|
124
|
+
new_book.bookdescription = book.css("p.description").text
|
125
|
+
children_series_array << new_book
|
126
|
+
end
|
127
|
+
children_series_array
|
128
|
+
end
|
129
|
+
|
130
|
+
def self.young_adult
|
131
|
+
puts "Young Adult Hardcover"
|
132
|
+
doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/young-adult-hardcover/?module=DropDownNav&action=click®ion=navbar&contentCollection=Books&version=More&referrer=https%3A%2F%2Fwww.nytimes.com%2Fbooks%2Fbest-sellers%2F&pgtype=Reference"))
|
133
|
+
young_adult_array = []
|
134
|
+
doc.css("div.book-body").each do |book|
|
135
|
+
new_book = self.new
|
136
|
+
new_book.name = book.css("h2.title").text
|
137
|
+
new_book.author = book.css("p.author").text
|
138
|
+
new_book.bookdescription = book.css("p.description").text
|
139
|
+
young_adult_array << new_book
|
140
|
+
end
|
141
|
+
young_adult_array
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
end
|
@@ -0,0 +1,292 @@
|
|
1
|
+
class Nytimesbooks::CLI
|
2
|
+
attr_reader :combined_fiction, :hardcover_fiction, :paperback_fiction, :combined_nonfiction, :hardcover_nonfiction, :paperback_nonfiction, :paperback_howto, :childrens_middle, :childrens_picture, :childrens_series, :young_adult
|
3
|
+
|
4
|
+
def call
|
5
|
+
puts "Welcome to the New York Times Best Selling Books list!"
|
6
|
+
main_categories
|
7
|
+
end
|
8
|
+
|
9
|
+
def main_categories
|
10
|
+
puts "Are you interested in seeing Fiction, Nonfiction, or Childrens Best Sellers lists?"
|
11
|
+
puts "(Type exit to leave program)"
|
12
|
+
input = gets.chomp.downcase
|
13
|
+
case input
|
14
|
+
when "fiction"
|
15
|
+
fiction_menu
|
16
|
+
when "nonfiction"
|
17
|
+
nonfiction_menu
|
18
|
+
when "childrens"
|
19
|
+
childrens_menu
|
20
|
+
when "exit"
|
21
|
+
goodbye
|
22
|
+
else
|
23
|
+
puts "I don't understand your input. Please try again."
|
24
|
+
main_categories
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def fiction_menu
|
29
|
+
puts "There are 3 Fiction categories:"
|
30
|
+
puts "1. Combined Print & E-Book Fiction 2. Hardcover Fiction 3. Paperback Trade Fiction"
|
31
|
+
puts "Which are you interested in? Type 1-3 or exit to leave the program."
|
32
|
+
input = gets.chomp.downcase
|
33
|
+
case input
|
34
|
+
when "1"
|
35
|
+
@combined_fiction = Nytimesbooks::Book.combined_fiction
|
36
|
+
@combined_fiction.each_with_index do |book, i|
|
37
|
+
puts "#{i+1}. #{book.name} #{book.author}"
|
38
|
+
end
|
39
|
+
combined_fiction
|
40
|
+
when "2"
|
41
|
+
@hardcover_fiction = Nytimesbooks::Book.hardcover_fiction
|
42
|
+
@hardcover_fiction.each_with_index do |book, i|
|
43
|
+
puts "#{i+1}. #{book.name} #{book.author}"
|
44
|
+
end
|
45
|
+
hardcover_fiction
|
46
|
+
when "3"
|
47
|
+
@paperback_fiction = Nytimesbooks::Book.paperback_fiction
|
48
|
+
@paperback_fiction.each_with_index do |book, i|
|
49
|
+
puts "#{i+1}. #{book.name} #{book.author}"
|
50
|
+
end
|
51
|
+
paperback_fiction
|
52
|
+
when "exit"
|
53
|
+
goodbye
|
54
|
+
else
|
55
|
+
puts "I don't understand your input. Please try again."
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def nonfiction_menu
|
60
|
+
puts "There are 3 Nonfiction categories:"
|
61
|
+
puts "1. Combined Print & E-Book Nonfiction 2. Hardcover Nonfiction 3. Paperback Nonfiction"
|
62
|
+
puts "Which are you interested in? Type 1-3 or exit to leave the program."
|
63
|
+
input = gets.chomp.downcase
|
64
|
+
case input
|
65
|
+
when "1"
|
66
|
+
@combined_nonfiction = Nytimesbooks::Book.combined_nonfiction
|
67
|
+
@combined_nonfiction.each_with_index do |book, i|
|
68
|
+
puts "#{i+1}. #{book.name} #{book.author}"
|
69
|
+
end
|
70
|
+
combined_nonfiction
|
71
|
+
when "2"
|
72
|
+
@hardcover_nonfiction = Nytimesbooks::Book.hardcover_nonfiction
|
73
|
+
@hardcover_nonfiction.each_with_index do |book, i|
|
74
|
+
puts "#{i+1}. #{book.name} #{book.author}"
|
75
|
+
end
|
76
|
+
hardcover_nonfiction
|
77
|
+
when "3"
|
78
|
+
@paperback_nonfiction = Nytimesbooks::Book.paperback_nonfiction
|
79
|
+
@paperback_nonfiction.each_with_index do |book, i|
|
80
|
+
puts "#{i+1}. #{book.name} #{book.author}"
|
81
|
+
end
|
82
|
+
paperback_nonfiction
|
83
|
+
when "exit"
|
84
|
+
goodbye
|
85
|
+
else
|
86
|
+
puts "I don't understand your input. Please try again."
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def childrens_menu
|
91
|
+
puts "There are 4 Childrens categories:"
|
92
|
+
puts "1. Childrens Middle Grade Hardcover 2. Children's Picture Books 3. Children's Series 4. Young Adult Hardcover"
|
93
|
+
puts "Which are you interested in? Type 1-4 or exit to leave the program."
|
94
|
+
input = gets.chomp.downcase
|
95
|
+
case input
|
96
|
+
when "1"
|
97
|
+
@childrens_middle = Nytimesbooks::Book.childrens_middle
|
98
|
+
@childrens_middle.each_with_index do |book, i|
|
99
|
+
puts "#{i+1}. #{book.name} #{book.author}"
|
100
|
+
end
|
101
|
+
childrens_middle
|
102
|
+
goodbye
|
103
|
+
when "2"
|
104
|
+
@childrens_picture = Nytimesbooks::Book.childrens_picture
|
105
|
+
@childrens_picture.each_with_index do |book, i|
|
106
|
+
puts "#{i+1}. #{book.name} #{book.author}"
|
107
|
+
end
|
108
|
+
childrens_picture
|
109
|
+
when "3"
|
110
|
+
@childrens_series = Nytimesbooks::Book.childrens_series
|
111
|
+
@childrens_series.each_with_index do |book, i|
|
112
|
+
puts "#{i+1}. #{book.name} #{book.author}"
|
113
|
+
end
|
114
|
+
childrens_series
|
115
|
+
when "4"
|
116
|
+
@young_adult = Nytimesbooks::Book.young_adult
|
117
|
+
@young_adult.each_with_index do |book, i|
|
118
|
+
puts "#{i+1}. #{book.name} #{book.author}"
|
119
|
+
end
|
120
|
+
young_adult
|
121
|
+
when "exit"
|
122
|
+
goodbye
|
123
|
+
else
|
124
|
+
puts "I don't understand your input. Please try again."
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def combined_fiction
|
129
|
+
puts "Which of these books would you like to see a description of? Enter 1 - 15, or exit to leave."
|
130
|
+
input = gets.chomp
|
131
|
+
if input == "exit"
|
132
|
+
goodbye
|
133
|
+
elsif input.to_i < 16 && input.to_i > 0
|
134
|
+
input = input.to_i
|
135
|
+
puts "#{@combined_fiction[input - 1].name} #{@combined_fiction[input -1].author}."
|
136
|
+
puts "#{@combined_fiction[input - 1].bookdescription}"
|
137
|
+
goodbye
|
138
|
+
else
|
139
|
+
puts "I don't understand your input. Please try again."
|
140
|
+
combined_fiction
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def hardcover_fiction
|
145
|
+
puts "Which of these books would you like to see a description of? Enter 1 - 15, or exit to leave."
|
146
|
+
input = gets.chomp
|
147
|
+
if input == "exit"
|
148
|
+
goodbye
|
149
|
+
elsif input.to_i < 16 && input.to_i > 0
|
150
|
+
input = input.to_i
|
151
|
+
puts "#{@hardcover_fiction[input - 1].name} #{@hardcover_fiction[input -1].author}."
|
152
|
+
puts "#{@hardcover_fiction[input - 1].bookdescription}"
|
153
|
+
goodbye
|
154
|
+
else
|
155
|
+
puts "I don't understand your input. Please try again."
|
156
|
+
hardcover_fiction
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def paperback_fiction
|
161
|
+
puts "Which of these books would you like to see a description of? Enter 1 - 15, or exit to leave."
|
162
|
+
input = gets.chomp
|
163
|
+
if input == "exit"
|
164
|
+
goodbye
|
165
|
+
elsif input.to_i < 16 && input.to_i > 0
|
166
|
+
input = input.to_i
|
167
|
+
puts "#{@paperback_fiction[input - 1].name} #{@paperback_fiction[input -1].author}."
|
168
|
+
puts "#{@paperback_fiction[input - 1].bookdescription}"
|
169
|
+
goodbye
|
170
|
+
else
|
171
|
+
puts "I don't understand your input. Please try again."
|
172
|
+
paperback_fiction
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def combined_nonfiction
|
177
|
+
puts "Which of these books would you like to see a description of? Enter 1 - 15, or exit to leave."
|
178
|
+
input = gets.chomp
|
179
|
+
if input == "exit"
|
180
|
+
goodbye
|
181
|
+
elsif input.to_i < 16 && input.to_i > 0
|
182
|
+
input = input.to_i
|
183
|
+
puts "#{@combined_nonfiction[input - 1].name} #{@combined_nonfiction[input -1].author}."
|
184
|
+
puts "#{@combined_nonfiction[input - 1].bookdescription}"
|
185
|
+
goodbye
|
186
|
+
else
|
187
|
+
puts "I don't understand your input. Please try again."
|
188
|
+
combined_nonfiction
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def hardcover_nonfiction
|
193
|
+
puts "Which of these books would you like to see a description of? Enter 1 - 15, or exit to leave."
|
194
|
+
input = gets.chomp
|
195
|
+
if input == "exit"
|
196
|
+
goodbye
|
197
|
+
elsif input.to_i < 16 && input.to_i > 0
|
198
|
+
input = input.to_i
|
199
|
+
puts "#{@hardcover_nonfiction[input - 1].name} #{@hardcover_nonfiction[input -1].author}."
|
200
|
+
puts "#{@hardcover_nonfiction[input - 1].bookdescription}"
|
201
|
+
goodbye
|
202
|
+
else
|
203
|
+
puts "I don't understand your input. Please try again."
|
204
|
+
hardcover_nonfiction
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
def paperback_nonfiction
|
209
|
+
puts "Which of these books would you like to see a description of? Enter 1 - 15, or exit to leave."
|
210
|
+
input = gets.chomp
|
211
|
+
if input == "exit"
|
212
|
+
goodbye
|
213
|
+
elsif input.to_i < 16 && input.to_i > 0
|
214
|
+
input = input.to_i
|
215
|
+
puts "#{@paperback_nonfiction[input - 1].name} #{@paperback_nonfiction[input -1].author}."
|
216
|
+
puts "#{@paperback_nonfiction[input - 1].bookdescription}"
|
217
|
+
goodbye
|
218
|
+
else
|
219
|
+
puts "I don't understand your input. Please try again."
|
220
|
+
paperback_nonfiction
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def childrens_middle
|
225
|
+
puts "Which of these books would you like to see a description of? Enter 1 - 10, or exit to leave."
|
226
|
+
input = gets.chomp
|
227
|
+
if input == "exit"
|
228
|
+
goodbye
|
229
|
+
elsif input.to_i < 16 && input.to_i > 0
|
230
|
+
input.to_i
|
231
|
+
puts "#{@childrens_middle[input - 1].name} #{@childrens_middle[input -1].author}."
|
232
|
+
puts "#{@childrens_middle[input - 1].bookdescription}"
|
233
|
+
goodbye
|
234
|
+
else
|
235
|
+
puts "I don't understand your input. Please try again."
|
236
|
+
childrens_middle
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
def childrens_picture
|
241
|
+
puts "Which of these books would you like to see a description of? Enter 1 - 10, or exit to leave."
|
242
|
+
input = gets.chomp
|
243
|
+
if input == "exit"
|
244
|
+
goodbye
|
245
|
+
elsif input.to_i < 16 && input.to_i > 0
|
246
|
+
input.to_i
|
247
|
+
puts "#{@childrens_picture[input - 1].name} #{@childrens_picture[input -1].author}."
|
248
|
+
puts "#{@childrens_picture[input - 1].bookdescription}"
|
249
|
+
goodbye
|
250
|
+
else
|
251
|
+
puts "I don't understand your input. Please try again."
|
252
|
+
childrens_picture
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
def childrens_series
|
257
|
+
puts "Which of these books would you like to see a description of? Enter 1 - 10, or exit to leave."
|
258
|
+
input = gets.chomp
|
259
|
+
if input == "exit"
|
260
|
+
goodbye
|
261
|
+
elsif input.to_i < 16 && input.to_i > 0
|
262
|
+
input.to_i
|
263
|
+
puts "#{@childrens_series[input - 1].name} #{@childrens_series[input -1].author}."
|
264
|
+
puts "#{@childrens_series[input - 1].bookdescription}"
|
265
|
+
goodbye
|
266
|
+
else
|
267
|
+
puts "I don't understand your input. Please try again."
|
268
|
+
childrens_series
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
def young_adult
|
273
|
+
puts "Which of these books would you like to see a description of? Enter 1 - 10, or exit to leave."
|
274
|
+
input = gets.chomp
|
275
|
+
if input == "exit"
|
276
|
+
goodbye
|
277
|
+
elsif input.to_t < 16 && input.to_i > 0
|
278
|
+
input.to_i
|
279
|
+
puts "#{@young_adult[input - 1].name} #{@young_adult[input -1].author}."
|
280
|
+
puts "#{@young_adult[input - 1].bookdescription}"
|
281
|
+
goodbye
|
282
|
+
else
|
283
|
+
puts "I don't understand your input. Please try again."
|
284
|
+
young_adult
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
def goodbye
|
289
|
+
puts "Enjoy your reading!"
|
290
|
+
end
|
291
|
+
|
292
|
+
end
|
data/lib/nytimesbooks.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "nytimesbooks/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "nytimesbooks"
|
8
|
+
spec.version = Nytimesbooks::VERSION
|
9
|
+
spec.authors = ["'Alexandra Fren'"]
|
10
|
+
spec.email = ["'alexandra.fren@gmail.com'"]
|
11
|
+
|
12
|
+
spec.summary = %q{This gem pulls the bestseller lists from NYT. It has a CLI that allows users to drill down further through each list.}
|
13
|
+
spec.description = %q{This gem pulls the bestseller lists from NYT. It has a CLI that allows users to drill down further through each list, showing all of the books on each list and allowing users to select a book to see its description.}
|
14
|
+
spec.homepage = "https://github.com/alexandrafren/nytimesbooks-cli-app"
|
15
|
+
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nytimesbooks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "'Alexandra Fren'"
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-07-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
|
+
description: This gem pulls the bestseller lists from NYT. It has a CLI that allows
|
42
|
+
users to drill down further through each list, showing all of the books on each
|
43
|
+
list and allowing users to select a book to see its description.
|
44
|
+
email:
|
45
|
+
- "'alexandra.fren@gmail.com'"
|
46
|
+
executables: []
|
47
|
+
extensions: []
|
48
|
+
extra_rdoc_files: []
|
49
|
+
files:
|
50
|
+
- ".gitignore"
|
51
|
+
- Gemfile
|
52
|
+
- Rakefile
|
53
|
+
- bin/console
|
54
|
+
- bin/nytimesbooks
|
55
|
+
- bin/setup
|
56
|
+
- lib/nytimesbooks.rb
|
57
|
+
- lib/nytimesbooks/books.rb
|
58
|
+
- lib/nytimesbooks/cli.rb
|
59
|
+
- lib/nytimesbooks/version.rb
|
60
|
+
- nytimesbooks.gemspec
|
61
|
+
homepage: https://github.com/alexandrafren/nytimesbooks-cli-app
|
62
|
+
licenses: []
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.7.7
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: This gem pulls the bestseller lists from NYT. It has a CLI that allows users
|
84
|
+
to drill down further through each list.
|
85
|
+
test_files: []
|