nyt-bestsellers 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nytimes/cli.rb +23 -13
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dde1d8da6a957133ddcfcaf3958afaa6c2c684cf
4
- data.tar.gz: fbac5bfe18ed7f0118969a35f0bf42f4afda17ab
3
+ metadata.gz: ada07f12703db76eac60fe562660c08c1e1af02d
4
+ data.tar.gz: 68d508bebc12879e83c6a499dead3c3a6dedb60f
5
5
  SHA512:
6
- metadata.gz: 2e9985ef36a159d93856faba0cb499eb2487fab82d516afe1bf47e28b5b1b7614222a4e0b5109bf291c5be4645aa9d0dd09091f0272bb95125c257f140599235
7
- data.tar.gz: d1d9605341e715ece07266d62c01050e7dbcec79f33b21e7d43c501552c89ba2d66af2a9657b795877cdfebd1298bdc85fdab0b9b4b000434a43c64f546b95dd
6
+ metadata.gz: e85bab7360689bc3a5e6de860632ba750e3883ee49abce441e8ca3ce70fdf11c7b67d37b63717d83957cacde5691660395eb2945e1ff5713449e07eec23ff71a
7
+ data.tar.gz: 5e4a13554a4c1cc1b1349593fb9a0b7a3acd55ca5d1d50d19e12a34db78a3f28f2dcc7676c76823908fa254e833659e97268c3b3463e23200cb7fcbffca9b72a
data/lib/nytimes/cli.rb CHANGED
@@ -21,9 +21,9 @@ class NYTBestsellers::CLI
21
21
 
22
22
  response = ""
23
23
  while response != "exit"
24
- puts "Select a category by number: " + "[exit]".light_red
24
+ puts "Select a category by number or type " + "'exit'".light_red + " to close the CLI."
25
25
  response = gets.strip
26
- if (1..5).to_a.include?(response.to_i)
26
+ if (1..genre_count).to_a.include?(response.to_i)
27
27
  genre_books(response.to_i)
28
28
  elsif response == "exit"
29
29
  puts "Goodbye!~".bold.red
@@ -33,6 +33,10 @@ class NYTBestsellers::CLI
33
33
  end
34
34
  end
35
35
 
36
+ def genre_count
37
+ NYTBestsellers::Genre.all.count
38
+ end
39
+
36
40
  def display_genres
37
41
  NYTBestsellers::Genre.all.each_with_index do |genre, index|
38
42
  puts "#{index+1} - #{genre.name}"
@@ -57,18 +61,22 @@ class NYTBestsellers::CLI
57
61
  puts ""
58
62
  puts "(^refers to the current position on the bestseller's list)"
59
63
  puts ""
60
- puts "Select a book by rank number to get more info: " + "[back][exit]".light_red
61
- puts ""
62
64
 
63
- book_input = gets.strip
64
- puts ""
65
- display_book_info(response, book_input)
66
- if book_input == "back"
67
- run
68
- elsif book_input == "exit"
69
- puts "Goodbye!~".bold.red
65
+ book_input = ""
66
+ while book_input != "exit"
67
+ puts "Select a book by rank number to get more info."
68
+ puts "You may type" + " 'back'".light_red + " to return to the categories or " + "'exit'".light_red + " to close the CLI."
69
+ book_input = gets.strip
70
70
  puts ""
71
- exit
71
+ if (1..genre.books.count).include?(book_input.to_i)
72
+ display_book_info(response, book_input)
73
+ elsif book_input == "back"
74
+ run
75
+ elsif book_input == "exit"
76
+ puts "Goodbye!~".bold.red
77
+ puts ""
78
+ exit
79
+ end
72
80
  end
73
81
  end
74
82
 
@@ -87,7 +95,7 @@ class NYTBestsellers::CLI
87
95
  puts "---------Summary---------".bold
88
96
  puts "#{book.summary}"
89
97
  puts ""
90
- puts "[back][menu][exit]".light_red
98
+ puts "Type" + " 'back'".light_red + "," + " 'menu',".light_red + " or" + " 'exit'".light_red + "."
91
99
  puts ""
92
100
 
93
101
  input = gets.strip
@@ -101,6 +109,8 @@ class NYTBestsellers::CLI
101
109
  elsif input == "menu"
102
110
  run
103
111
  puts ""
112
+ else
113
+ display_book_info(response, book_input)
104
114
  end #second if
105
115
  end #first if
106
116
  end #each
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nyt-bestsellers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amy Back
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-19 00:00:00.000000000 Z
11
+ date: 2016-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler