nytimesbooks 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c54da0ec4a6adfd9d584b2eaea7b8170bf6ea3ea41fd68930ee90260bdc84844
4
- data.tar.gz: 043793852e390920fdc575d1c01b3756896b832bb03550685c54902b8822e709
3
+ metadata.gz: fb4ab69fdabb80c4fb615b6cffa35dc9bce2dbe650b46071ca62de0e23d63fb3
4
+ data.tar.gz: 7f517ae59cf7f937613e589ef6ff760a677fe77549133ab677b89f6ceae10a8f
5
5
  SHA512:
6
- metadata.gz: 1f06bf5013511056bd7f84dd02c8a292492bcb42eda7e315063fa25414922a1a5895faed8dfb7de80d72428ee214bcfa688b2368963c350dce3b1b5bc69c931c
7
- data.tar.gz: 8a698396f916339c57dd228805fa0f98981461763ed50b5415c56368a8fd98ba34d622479c1d19a3d80d6d27dc30fa208a31d80917a668d2f895c11c331902bc
6
+ metadata.gz: 43d9f578ec2c2d61fbf29fa1743a378626431104c272f89aed3c39cdf3e8081d3268ab54a4e52c2cc40a658a811a8cc2f3d822d3b6fdc4451854cb6039022038
7
+ data.tar.gz: 5292623e964d4b32d9f117fe8ba47e6c0862c76098872cdc42d5b920659e58bd878a9b14724189bb74411618ed1221fcaf66e16015d43b21cedf97546d9bf71a
@@ -1,17 +1,24 @@
1
1
  class Nytimesbooks::Book
2
2
  attr_accessor :name, :author, :bookdescription
3
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&region=Body&module=CompleteListLink&version=Fiction&pgtype=Reference"))
7
- combined_fiction_array = []
4
+
5
+ def self.new_book(doc)
6
+ new_array = []
8
7
  doc.css("div.book-body").each do |book|
9
8
  new_book = self.new
10
9
  new_book.name = book.css("h2.title").text
11
10
  new_book.author = book.css("p.author").text
12
11
  new_book.bookdescription = book.css("p.description").text
13
- combined_fiction_array << new_book
12
+ new_array << new_book
14
13
  end
14
+ new_array
15
+ end
16
+
17
+ def self.combined_fiction
18
+ puts "Combined Print & E-Book Fiction"
19
+ 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&region=Body&module=CompleteListLink&version=Fiction&pgtype=Reference"))
20
+ combined_fiction_array = []
21
+ combined_fiction_array = new_book(doc)
15
22
  combined_fiction_array
16
23
  end
17
24
 
@@ -19,13 +26,7 @@ class Nytimesbooks::Book
19
26
  puts "Hardcover Fiction"
20
27
  doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/hardcover-fiction/?module=DropDownNav&action=click&region=navbar&contentCollection=Books&version=Fiction&referrer=https%3A%2F%2Fwww.nytimes.com%2Fbooks%2Fbest-sellers%2F&pgtype=Reference"))
21
28
  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 = new_book(doc)
29
30
  hardcover_fiction_array
30
31
  end
31
32
 
@@ -33,13 +34,7 @@ class Nytimesbooks::Book
33
34
  puts "Paperback Fiction"
34
35
  doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/trade-fiction-paperback/?module=DropDownNav&action=click&region=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
36
  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
37
+ paperback_fiction_array = new_book(doc)
43
38
  paperback_fiction_array
44
39
  end
45
40
 
@@ -47,13 +42,7 @@ class Nytimesbooks::Book
47
42
  puts "Combined Print & E-Book Nonfiction"
48
43
  doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/combined-print-and-e-book-nonfiction/?module=DropDownNav&action=click&region=navbar&contentCollection=Books&version=Nonfiction&referrer=https%3A%2F%2Fwww.nytimes.com%2Fbooks%2Fbest-sellers%2Fhardcover-fiction%2F&pgtype=Reference"))
49
44
  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
45
+ combined_nonfiction_array = new_book(doc)
57
46
  combined_nonfiction_array
58
47
  end
59
48
 
@@ -61,13 +50,7 @@ class Nytimesbooks::Book
61
50
  puts "Hardcover Nonfiction"
62
51
  doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/hardcover-nonfiction/?module=DropDownNav&action=click&region=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
52
  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
53
+ hardcover_nonfiction_array = new_book(doc)
71
54
  hardcover_nonfiction_array
72
55
  end
73
56
 
@@ -75,13 +58,7 @@ class Nytimesbooks::Book
75
58
  puts "Paperback Nonfiction"
76
59
  doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/paperback-nonfiction/?module=DropDownNav&action=click&region=navbar&contentCollection=Books&version=Nonfiction&referrer=https%3A%2F%2Fwww.nytimes.com%2Fsection%2Fbooks&pgtype=Reference"))
77
60
  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
61
+ paperback_nonfiction_array = new_book(doc)
85
62
  paperback_nonfiction_array
86
63
  end
87
64
 
@@ -89,13 +66,7 @@ class Nytimesbooks::Book
89
66
  puts "Children's Middle Grade"
90
67
  doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/childrens-middle-grade-hardcover/?module=DropDownNav&action=click&region=navbar&contentCollection=Books&version=Childrens&referrer=https%3A%2F%2Fwww.nytimes.com%2Fbooks%2Fbest-sellers%2Fchildrens-middle-grade-hardcover%2F&pgtype=Reference"))
91
68
  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
69
+ childrens_middle_array = new_book(doc)
99
70
  childrens_middle_array
100
71
  end
101
72
 
@@ -103,13 +74,7 @@ class Nytimesbooks::Book
103
74
  puts "Children's Picture Books"
104
75
  doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/picture-books/?module=DropDownNav&action=click&region=navbar&contentCollection=Books&version=Childrens&referrer=https%3A%2F%2Fwww.nytimes.com%2Fbooks%2Fbest-sellers%2Fchildrens-middle-grade-hardcover%2F&pgtype=Reference"))
105
76
  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
77
+ children_picture_array = new_book(doc)
113
78
  children_picture_array
114
79
  end
115
80
 
@@ -117,13 +82,7 @@ class Nytimesbooks::Book
117
82
  puts "Children's Series"
118
83
  doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/series-books/?module=DropDownNav&action=click&region=navbar&contentCollection=Books&version=Childrens&referrer=https%3A%2F%2Fwww.nytimes.com%2Fsection%2Fbooks&pgtype=Reference"))
119
84
  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
85
+ children_series_array = new_book(doc)
127
86
  children_series_array
128
87
  end
129
88
 
@@ -131,15 +90,8 @@ class Nytimesbooks::Book
131
90
  puts "Young Adult Hardcover"
132
91
  doc = Nokogiri::HTML(open("https://www.nytimes.com/books/best-sellers/young-adult-hardcover/?module=DropDownNav&action=click&region=navbar&contentCollection=Books&version=More&referrer=https%3A%2F%2Fwww.nytimes.com%2Fbooks%2Fbest-sellers%2F&pgtype=Reference"))
133
92
  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
93
+ young_adult_array = new_book(doc)
141
94
  young_adult_array
142
95
  end
143
96
 
144
-
145
97
  end
@@ -99,7 +99,6 @@ end
99
99
  puts "#{i+1}. #{book.name} #{book.author}"
100
100
  end
101
101
  childrens_middle
102
- goodbye
103
102
  when "2"
104
103
  @childrens_picture = Nytimesbooks::Book.childrens_picture
105
104
  @childrens_picture.each_with_index do |book, i|
@@ -1,3 +1,3 @@
1
1
  module Nytimesbooks
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nytimesbooks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'Alexandra Fren'"
@@ -57,6 +57,7 @@ files:
57
57
  - lib/nytimesbooks/books.rb
58
58
  - lib/nytimesbooks/cli.rb
59
59
  - lib/nytimesbooks/version.rb
60
+ - nytimesbooks-0.1.0.gem
60
61
  - nytimesbooks.gemspec
61
62
  homepage: https://github.com/alexandrafren/nytimesbooks-cli-app
62
63
  licenses: []