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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3af5eefa942b5a80ab2d50d7b877eb201f1cbc6
4
- data.tar.gz: ee53d579e8d2c724eb4b07ea04b0318d6dc9b11a
3
+ metadata.gz: c98d2970570b1d901bac2179d7d92e883d1d8e35
4
+ data.tar.gz: b920d400dcd9f619dd37e81631d5c672a30ba537
5
5
  SHA512:
6
- metadata.gz: fe6a8fb850d8b257e3f5b7f625907e68456886b443e2a5a8d62ad0e5f444c0f9961be6691e2bac542fb4640b6537fe62a3c684d1daaa48a574be90272f15e0f3
7
- data.tar.gz: 6e891715c2bb8af19bacd1d16aa8331f3a1322aff9602af74863ce36fd2c1794536a58305dceb0e6c5f3eae88acabe586050827668e73eed01b0ed518867fc16
6
+ metadata.gz: 3d19906a478f8f083e64a6c72f4452584d8ceb2d0fe21156af3ed703e6b21f62ccf83318f6f2cf0a777f04af2ad33d376c2cc018728b2c926292121918d92ce9
7
+ data.tar.gz: 958ef89ef4d7647ff93664f1d2bd1996cc97dd3d7c2ec6d577c772ee40b66e1deb9fc170968d00cedb0c113a54c334441d44bd4f31d3b11a86624c39c353dff1
@@ -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/ebook-deal-info"
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} #{"and #{chosen_book.genre_two}" if chosen_book.genre_two.size > 0}"
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
- author = post.search("p.title").text.split("by")[1].strip.slice(/\A[^(,$\/]+/).split(". Kindle")[0].split("-- Kindle")[0].strip
20
- title = post.search("p.title").text.split("by").first.gsub(/[(].+[)]/,"").gsub(/\W+\z/, "").strip
21
- post.search("p.title").text.slice(/[$]\d+[.]\d+/) != nil ? price = post.search("p.title").text.slice(/[$]\d+[.]\d+/).strip : price = ""
22
- Book.create(author, title, price)
23
- puts "Loaded book ##{index+1} of #{deals.search("div.link").size}"
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).+(\S\n)/).strip #goodreads provides better titles
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
@@ -1,3 +1,3 @@
1
1
  module EbookDealInfo
2
- VERSION = "1.0.2"
2
+ VERSION = "1.0.3"
3
3
  end
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.2
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-02 00:00:00.000000000 Z
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/ebook-deal-info
95
+ homepage: https://github.com/kylekinnear/ebookdealinfo
96
96
  licenses:
97
97
  - MIT
98
98
  metadata: {}