book_club_picks 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb4a91e7daec460dfc4ca7eeaf1f894e770fa1ef
4
- data.tar.gz: 66c227ebc9d915f1841ef830878c77e6559f5d59
3
+ metadata.gz: 899aabdb83a02e72048f285f683943e63d14c6d4
4
+ data.tar.gz: 3c4df535d7c8ebbfd8869af35ed7c0afb2adfa73
5
5
  SHA512:
6
- metadata.gz: fde772755fee67aacda0fa790df8f37ac8f184015c9da16d422bb8ddf4dcbc8d9681a38c15f8d074b941957b46bbb5b43a8993881f0ec98717d2ced0960091d9
7
- data.tar.gz: 1afc5998af5367a7449005f12411bad5ff3b50ec492dd44f8333e56d71e5a2501baf858f7c26c408c138694ceec076460240c20c5cf0782f7f2eb531cd0e0972
6
+ metadata.gz: c61ede32b9405256f7b0b98e3c42f39adc7c7995308377c81175afd07a6def8658e8b07e8e618da7928a469f418b30837c82b3478503ffd9efe312cb50de1c4f
7
+ data.tar.gz: 01e8376197976a26f029165aa4f2d8aad81828153ff45bcbee3c69d0f0614a66e779379a47e259fbdce83d119b7b513ea4a056aab7d0b070ebbb1e0c64c24ed6
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # BookClubPicks
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/book_club_picks`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Welcome to book club picks! This gem will help you find the next best book for your club to read. Browse popular titles from the bookmovement.com website. You can see the current top ten list and read more about each title. Follow the directions below to get started.
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,7 +20,7 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- TODO: Write usage instructions here
23
+ Simply type the number of the top 10 book that you would like to learn more about. You can keep entering numbers for as many books as you would like to browse. When finished, type exit to leave the program.
26
24
 
27
25
  ## Development
28
26
 
@@ -32,7 +30,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
30
 
33
31
  ## Contributing
34
32
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/book_club_picks. 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.
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sensei100/book_club_picks. 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.
36
34
 
37
35
 
38
36
  ## License
data/bin/book_club_picks CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
 
4
- require './lib/book_club_picks'
4
+ require_relative'../lib/book_club_picks'
5
5
 
6
- BookClubPicks::CLI.new.call
6
+ BookClubPicks::CLI.new.call
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
22
22
  end
23
23
 
24
24
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
- spec.bindir = "exe"
26
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.bindir = "bin"
26
+ spec.executables = ["book_club_picks"]
27
27
  spec.require_paths = ["lib"]
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 1.11"
@@ -1,6 +1,8 @@
1
- class BookClubPicks::Book
1
+ class BookClubPicks::Book
2
2
 
3
3
  attr_accessor :name, :author, :published, :clubs, :summary
4
+
5
+ DOC = Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
4
6
 
5
7
  def initialize(name = nil, author = nil, published = nil, clubs = nil, summary = nil)
6
8
  @name = name
@@ -9,127 +11,18 @@ class BookClubPicks::Book
9
11
  @clubs = clubs
10
12
  @summary = summary
11
13
  end
12
-
13
- def self.scrape_details_1
14
- doc = Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
15
-
16
- individual_details = self.new
17
- individual_details.name = doc.search("h2")[0].text.strip
18
- individual_details.published = doc.search("div.midd .omatter")[0].text.strip.split('Paperback').first.split('Hardcover').first.split('Kindle').first
19
- individual_details.clubs = doc.css(".recomnd")[0].text.strip
20
- individual_details.summary = doc.css(".midd .statement")[0].text.strip.gsub('â', "\'").gsub('Â', " ")
21
-
22
- individual_details
23
- end
24
-
25
- def self.scrape_details_2
26
- doc = Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
27
-
28
- individual_details = self.new
29
- individual_details.name = doc.search("h2")[1].text.strip
30
- individual_details.published = doc.search("div.midd .omatter")[1].text.strip.split('Paperback').first.split('Hardcover').first.split('Kindle').first
31
- individual_details.clubs = doc.css(".recomnd")[1].text.strip
32
- individual_details.summary = doc.css(".midd .statement")[1].text.strip.gsub('â', "\'").gsub('Â', " ")
33
-
34
- individual_details
35
- end
36
-
37
- def self.scrape_details_3
38
- doc = Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
39
-
40
- individual_details = self.new
41
- individual_details.name = doc.search("h2")[2].text.strip
42
- individual_details.published = doc.search("div.midd .omatter")[2].text.strip.split('Paperback').first.split('Hardcover').first.split('Kindle').first
43
- individual_details.clubs = doc.css(".recomnd")[2].text.strip
44
- individual_details.summary = doc.css(".midd .statement")[2].text.strip.gsub('â', "\'").gsub('Â', " ")
45
-
46
- individual_details
47
- end
48
-
49
- def self.scrape_details_4
50
- doc = Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
51
-
52
- individual_details = self.new
53
- individual_details.name = doc.search("h2")[3].text.strip
54
- individual_details.published = doc.search("div.midd .omatter")[3].text.strip.split('Paperback').first.split('Hardcover').first.split('Kindle').first
55
- individual_details.clubs = doc.css(".recomnd")[3].text.strip
56
- individual_details.summary = doc.css(".midd .statement")[3].text.strip.gsub('â', "\'").gsub('Â', " ")
57
-
58
- individual_details
59
- end
60
-
61
- def self.scrape_details_5
62
- doc = Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
63
-
64
- individual_details = self.new
65
- individual_details.name = doc.search("h2")[4].text.strip
66
- individual_details.published = doc.search("div.midd .omatter")[4].text.strip.split('Paperback').first.split('Hardcover').first.split('Kindle').first
67
- individual_details.clubs = doc.css(".recomnd")[4].text.strip
68
- individual_details.summary = doc.css(".midd .statement")[4].text.strip.gsub('â', "\'").gsub('Â', " ")
69
-
70
- individual_details
71
- end
72
-
73
- def self.scrape_details_6
74
- doc = Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
75
-
76
- individual_details = self.new
77
- individual_details.name = doc.search("h2")[5].text.strip
78
- individual_details.published = doc.search("div.midd .omatter")[5].text.strip.split('Paperback').first.split('Hardcover').first.split('Kindle').first
79
- individual_details.clubs = doc.css(".recomnd")[5].text.strip
80
- individual_details.summary = doc.css(".midd .statement")[5].text.strip.gsub('â', "\'").gsub('Â', " ")
81
-
82
- individual_details
83
- end
84
-
85
- def self.scrape_details_7
86
- doc = Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
87
-
88
- individual_details = self.new
89
- individual_details.name = doc.search("h2")[6].text.strip
90
- individual_details.published = doc.search("div.midd .omatter")[6].text.strip.split('Paperback').first.split('Hardcover').first.split('Kindle').first
91
- individual_details.clubs = doc.css(".recomnd")[6].text.strip
92
- individual_details.summary = doc.css(".midd .statement")[6].text.strip.gsub('â', "\'").gsub('Â', " ")
93
-
94
- individual_details
95
- end
96
-
97
- def self.scrape_details_8
98
- doc = Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
99
-
100
- individual_details = self.new
101
- individual_details.name = doc.search("h2")[7].text.strip
102
- individual_details.published = doc.search("div.midd .omatter")[7].text.strip.split('Paperback').first.split('Hardcover').first.split('Kindle').first
103
- individual_details.clubs = doc.css(".recomnd")[7].text.strip
104
- individual_details.summary = doc.css(".midd .statement")[7].text.strip.gsub('â', "\'").gsub('Â', " ")
105
-
106
- individual_details
107
- end
108
-
109
- def self.scrape_details_9
110
- doc = Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
111
-
112
- individual_details = self.new
113
- individual_details.name = doc.search("h2")[8].text.strip
114
- individual_details.published = doc.search("div.midd .omatter")[8].text.strip.split('Paperback').first.split('Hardcover').first.split('Kindle').first
115
- individual_details.clubs = doc.css(".recomnd")[8].text.strip
116
- individual_details.summary = doc.css(".midd .statement")[8].text.strip.gsub('â', "\'").gsub('Â', " ")
117
-
118
- individual_details
119
- end
120
-
121
- def self.scrape_details_ten
122
- doc = Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
123
-
124
- individual_details = self.new
125
- individual_details.name = doc.search("h2")[9].text.strip
126
- individual_details.published = doc.search("div.midd .omatter")[9].text.strip.split('Paperback').first.split('Hardcover').first.split('Kindle').first
127
- individual_details.clubs = doc.css(".recomnd")[8].text
128
- individual_details.summary = doc.css(".midd .statement")[9].text.strip.gsub('â', "\'").gsub('Â', " ")
129
-
130
- individual_details
131
- end
132
14
 
15
+ def self.scrape_details(num)
16
+ DOC
17
+
18
+ individual_details = self.new
19
+ individual_details.name = DOC.search("h2")[num].text.strip
20
+ individual_details.published = DOC.search("div.midd .omatter")[num].text.strip.split('Paperback').first.split('Hardcover').first.split('Kindle').first
21
+ individual_details.clubs = DOC.css(".recomnd")[num].text.strip
22
+ individual_details.summary = DOC.css(".midd .statement")[num].text.strip.gsub('â', "\'").gsub('Â', " ")
23
+
24
+ individual_details
25
+ end
133
26
  end
134
27
 
135
28
 
@@ -7,16 +7,16 @@ class BookClubPicks::CLI
7
7
  puts ""
8
8
  puts "------------------------------"
9
9
  puts ""
10
- book_range
10
+ top_ten
11
11
  end
12
12
 
13
- def book_range
13
+ def top_ten
14
14
  puts "Here are this week's top 10 books."
15
15
  puts "They are ranked in order of their current popularity on the Book Movement website."
16
16
  puts ""
17
17
  puts "------------------------------"
18
18
  puts ""
19
- BookClubPicks::Scraper.today
19
+ puts_books
20
20
  puts ""
21
21
  puts "------------------------------"
22
22
  puts ""
@@ -29,6 +29,13 @@ class BookClubPicks::CLI
29
29
  menu
30
30
  end
31
31
 
32
+ def puts_books
33
+ current_books = BookClubPicks::Scraper.today
34
+ current_books.each_with_index do |book, index|
35
+ puts "#{index+1}. #{book}"
36
+ end
37
+ end
38
+
32
39
  def menu
33
40
  input = nil
34
41
  while input != "exit"
@@ -41,43 +48,43 @@ class BookClubPicks::CLI
41
48
  case input
42
49
  when "1"
43
50
  puts ""
44
- @individual_details = BookClubPicks::Book.scrape_details_1
51
+ @individual_details = BookClubPicks::Book.scrape_details(0)
45
52
  book_details
46
53
  when "2"
47
54
  puts ""
48
- @individual_details = BookClubPicks::Book.scrape_details_2
55
+ @individual_details = BookClubPicks::Book.scrape_details(1)
49
56
  book_details
50
57
  when "3"
51
58
  puts ""
52
- @individual_details = BookClubPicks::Book.scrape_details_3
59
+ @individual_details = BookClubPicks::Book.scrape_details(2)
53
60
  book_details
54
61
  when "4"
55
62
  puts ""
56
- @individual_details = BookClubPicks::Book.scrape_details_4
63
+ @individual_details = BookClubPicks::Book.scrape_details(3)
57
64
  book_details
58
65
  when "5"
59
66
  puts ""
60
- @individual_details = BookClubPicks::Book.scrape_details_5
67
+ @individual_details = BookClubPicks::Book.scrape_details(4)
61
68
  book_details
62
69
  when "6"
63
70
  puts ""
64
- @individual_details = BookClubPicks::Book.scrape_details_6
71
+ @individual_details = BookClubPicks::Book.scrape_details(5)
65
72
  book_details
66
73
  when "7"
67
74
  puts ""
68
- @individual_details = BookClubPicks::Book.scrape_details_7
75
+ @individual_details = BookClubPicks::Book.scrape_details(6)
69
76
  book_details
70
77
  when "8"
71
78
  puts ""
72
- @individual_details = BookClubPicks::Book.scrape_details_8
79
+ @individual_details = BookClubPicks::Book.scrape_details(7)
73
80
  book_details
74
81
  when "9"
75
82
  puts ""
76
- @individual_details = BookClubPicks::Book.scrape_details_9
83
+ @individual_details = BookClubPicks::Book.scrape_details(8)
77
84
  book_details
78
85
  when "10"
79
86
  puts ""
80
- @individual_details = BookClubPicks::Book.scrape_details_ten
87
+ @individual_details = BookClubPicks::Book.scrape_details(9)
81
88
  book_details
82
89
  end
83
90
  elsif input == "exit"
@@ -101,8 +108,7 @@ class BookClubPicks::CLI
101
108
  puts ""
102
109
  puts "#{@individual_details.summary}"
103
110
  puts ""
104
- puts "------------------------------"
105
-
111
+ puts "------------------------------"
106
112
  end
107
113
 
108
114
  def goodbye
@@ -114,5 +120,4 @@ class BookClubPicks::CLI
114
120
  puts "------------------------------"
115
121
  puts ""
116
122
  end
117
-
118
123
  end
@@ -1,22 +1,14 @@
1
1
  class BookClubPicks::Scraper
2
2
 
3
3
  def self.today
4
- self.scrape_books
5
- end
6
-
7
- def self.scrape_books
8
- self.scrape_book_movement
4
+ self.scrape_book_movement
9
5
  end
10
6
 
11
7
  def self.scrape_book_movement
12
8
  doc = Nokogiri::HTML(open("http://www.bookmovement.com/topClubPicks"))
13
- current_books = []
14
9
 
15
- doc.search("div.midd").each do |book|
16
- current_books << book.search("h2").text
17
- end
18
- current_books.each_with_index do |book, index|
19
- puts "#{index+1}. #{book}"
20
- end
10
+ doc.search("div.midd").collect do |book|
11
+ book.search("h2").text
12
+ end
21
13
  end
22
14
  end
@@ -1,3 +1,3 @@
1
1
  module BookClubPicks
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: book_club_picks
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
  - Jennifer Anton
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-23 00:00:00.000000000 Z
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -69,7 +69,8 @@ dependencies:
69
69
  description:
70
70
  email:
71
71
  - jenanton01@gmail.com
72
- executables: []
72
+ executables:
73
+ - book_club_picks
73
74
  extensions: []
74
75
  extra_rdoc_files: []
75
76
  files: