ebookdealinfo 1.0.2 → 1.0.3
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 +4 -4
- data/ebookdealinfo.gemspec +1 -1
- data/lib/ebookdealinfo/controller.rb +1 -1
- data/lib/ebookdealinfo/deal_scraper.rb +10 -5
- data/lib/ebookdealinfo/info_scraper.rb +1 -1
- data/lib/ebookdealinfo/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c98d2970570b1d901bac2179d7d92e883d1d8e35
|
|
4
|
+
data.tar.gz: b920d400dcd9f619dd37e81631d5c672a30ba537
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3d19906a478f8f083e64a6c72f4452584d8ceb2d0fe21156af3ed703e6b21f62ccf83318f6f2cf0a777f04af2ad33d376c2cc018728b2c926292121918d92ce9
|
|
7
|
+
data.tar.gz: 958ef89ef4d7647ff93664f1d2bd1996cc97dd3d7c2ec6d577c772ee40b66e1deb9fc170968d00cedb0c113a54c334441d44bd4f31d3b11a86624c39c353dff1
|
data/ebookdealinfo.gemspec
CHANGED
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
|
10
10
|
spec.email = ["27875726+kylekinnear@users.noreply.github.com"]
|
|
11
11
|
|
|
12
12
|
spec.summary = "Grabs daily ebook deals and gets goodreads info about them."
|
|
13
|
-
spec.homepage = "https://github.com/kylekinnear/
|
|
13
|
+
spec.homepage = "https://github.com/kylekinnear/ebookdealinfo"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
|
|
16
16
|
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
@@ -53,7 +53,7 @@ class Controller
|
|
|
53
53
|
elsif chosen_book.genre_one == "No genre listed"
|
|
54
54
|
puts "This book doesn't have a genre listing"
|
|
55
55
|
else
|
|
56
|
-
puts "Shelved as #{chosen_book.genre_one}
|
|
56
|
+
puts "Shelved as #{chosen_book.genre_one}#{"and #{chosen_book.genre_two}" if chosen_book.genre_two.size > 0}"
|
|
57
57
|
end
|
|
58
58
|
puts "#{chosen_book.rates} people gave this book an average rating of #{chosen_book.rating}"
|
|
59
59
|
puts "----------------------------------------------------------------------------\n#{chosen_book.wrap_blurb}" #line wrap our blurb
|
|
@@ -16,11 +16,16 @@ class DealScraper
|
|
|
16
16
|
puts "Loaded book ##{index+1} of #{deals.search("div.link").size}"
|
|
17
17
|
else #for posts formatted "~Title~ by ~author~ (~Price~)"
|
|
18
18
|
if post.search("p.title").text.slice(/[,.-[ ]]([Bb]y)/) != nil #ignore wacky formatted posts
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
if post.search("p.title").text.scan(/(\s[Bb][Yy]\s)/).size > 1 #count instances of "by"; if the title includes a "by" we can't parse it
|
|
20
|
+
puts "Unable to load book ##{index+1} of #{deals.search("div.link").size}. Probably a bad post name."
|
|
21
|
+
Book.create("","","",0)
|
|
22
|
+
else
|
|
23
|
+
author = post.search("p.title").text.gsub(/(\s[Bb][Yy]\s)/, " by ").split("by")[1].strip.slice(/\A[^(,$\/]+/).split(". Kindle")[0].split("-- Kindle")[0].strip
|
|
24
|
+
title = post.search("p.title").text.gsub(/(\s[Bb][Yy]\s)/, " by ").split("by").first.gsub(/[(].+[)]/,"").gsub(/\W+\z/, "").strip
|
|
25
|
+
post.search("p.title").text.slice(/[$]\d+[.]\d+/) != nil ? price = post.search("p.title").text.slice(/[$]\d+[.]\d+/).strip : price = ""
|
|
26
|
+
Book.create(author, title, price)
|
|
27
|
+
puts "Loaded book ##{index+1} of #{deals.search("div.link").size}"
|
|
28
|
+
end
|
|
24
29
|
else
|
|
25
30
|
puts "Unable to load book ##{index+1} of #{deals.search("div.link").size}. Probably a bad post name."
|
|
26
31
|
Book.create("","","",0)
|
|
@@ -10,7 +10,7 @@ class InfoScraper
|
|
|
10
10
|
determinant = search_page.css("span.minirating").map.with_index {|i,index| [index, i.text.strip.slice(/\s(\d|,)+/).strip.gsub(",","").to_i]}.sort! {|x,y| x[1].to_i <=> y[1].to_i}.last #the search result with the most rates (and presumably most legitimate) is an array [result_index, #rates]
|
|
11
11
|
item_page = Nokogiri::HTML(open("https://goodreads.com/#{search_page.css("table a.bookTitle")[determinant[0]].attribute("href").value}",'User-Agent' => 'Ruby').read)
|
|
12
12
|
book.author = item_page.search("div#bookAuthors.stacked span :not(.greyText) :not(.smallText)").text #gets the complete author name since reddit might not provide it
|
|
13
|
-
book.title = item_page.search("h1#bookTitle.bookTitle").text.slice(/^(\n).+(
|
|
13
|
+
book.title = item_page.search("h1#bookTitle.bookTitle").text.slice(/^(\n).+(.\n)/).strip #goodreads provides better titles
|
|
14
14
|
book.series = item_page.search("h1#bookTitle.bookTitle :first-child").text.strip.gsub(/[()]/, "") #provides series
|
|
15
15
|
book.rating = item_page.search("span.average").text #average rating
|
|
16
16
|
book.rates = item_page.search("span.votes.value-title").text.strip #number of ratings
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ebookdealinfo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kylek
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-09-
|
|
11
|
+
date: 2017-09-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -92,7 +92,7 @@ files:
|
|
|
92
92
|
- lib/ebookdealinfo/info_scraper.rb
|
|
93
93
|
- lib/ebookdealinfo/version.rb
|
|
94
94
|
- spec.md
|
|
95
|
-
homepage: https://github.com/kylekinnear/
|
|
95
|
+
homepage: https://github.com/kylekinnear/ebookdealinfo
|
|
96
96
|
licenses:
|
|
97
97
|
- MIT
|
|
98
98
|
metadata: {}
|