shoe_scraper 0.0.9 → 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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -0
  3. data/lib/shoe_scraper.rb +74 -44
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3234206832fec0ac82aa061bfd89e092f89d936a6fb564a10a89353e0dc1f623
4
- data.tar.gz: 3af9b3aded0d11dbcc4870b6393193f051d63dbe9735f9e7f9363604a5a36a13
3
+ metadata.gz: e13f4f497c0df4344d5070de9cd9632e64da9cbfb3aee2e67066b3999ddea492
4
+ data.tar.gz: f9598d73ccbeaae8be8fdf2e05202c2b1545dee02af1fef7bf23db8aa18cddaf
5
5
  SHA512:
6
- metadata.gz: 44d84f8d4913d89196d98fccb5e9e9c9fc8000287de12aab970cc17a5f0402dd51f4ce75db0f75f96808a28c6afd5d832d8647f27168a6922c08591598edad0b
7
- data.tar.gz: a8c1702cf588b390db19232797f7ad5becea9c20f35dd59231a32a458bcdbe54ff900f8c049704c958c9c6fc97325d188d5795b92b8a0ee2060364c4c120519c
6
+ metadata.gz: 1e7e5a83288adabcd00b6c576c8b4fe9e0832be8fb427e621f90600e448a2ff65e814601ea82434a7433ba0353ec9fc41844413fe3071be704b7e1c44c876cd1
7
+ data.tar.gz: a8ce197c3712b28a8b8b2e89e89a88b7f20d420f7d132cf6bb1b9395a1c5610679a07b623701e1d44dadc4725806d769753df30a5138a2daf7be1b9bdad86e7f
data/README.md CHANGED
@@ -18,6 +18,18 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install shoe_scraper
20
20
 
21
+ ## Dependencies
22
+
23
+ Please note the following dependencies are needed in order for ShoeScraper to work properly.
24
+
25
+
26
+ 'colorize', '>= 0.8.1'
27
+
28
+ 'nokogiri', '>= 1.10.8'
29
+
30
+ 'rake', '>= 12.0'
31
+
32
+
21
33
  ## Usage
22
34
 
23
35
  Open up a session of irb
@@ -12,31 +12,38 @@ class ShoeScraper
12
12
  @@saved = []
13
13
 
14
14
  def run
15
- first_selection
15
+ first_message
16
16
  end
17
17
 
18
- def first_selection
18
+ def first_message
19
19
  # a = AsciiArt.new("https://www.indexpdx.com/content/images/logo.jpeg")
20
20
  # print "#{a.to_ascii_art(width: 50)}"
21
21
  puts ''
22
22
  puts "Welcome to The Sneaker Finder! Are you ready to find your next pair of kicks?".colorize(:green)
23
23
  puts ''
24
- puts "Type yes or any other key to exit"
25
-
26
- input = gets.chomp.downcase
27
- if input == 'y'
28
- # Saved_Shoe.new
29
- puts ''
30
- puts "Great!! Let's get you started with our list of brands".colorize(:green)
31
- puts ''
32
- scrape_brand
33
- else
34
- puts "Goodbye!".colorize(:green)
35
- end
24
+ puts "YES or EXIT ?"
25
+ first_selection('first_message')
26
+ end
27
+
28
+ def first_selection(selection)
29
+ if selection == 'wrong_input'
30
+ puts 'That is not a selection...'
36
31
  end
32
+ input = gets.chomp.downcase
33
+ if input == 'y' || input == 'yes'
34
+ # Saved_Shoe.new
35
+ puts ''
36
+ puts "Great!! Let's get you started with our list of brands".colorize(:green)
37
+ puts ''
38
+ scrape_brand
39
+ elsif input == 'e' || input == 'exit'
40
+ puts "Goodbye!".colorize(:green)
41
+ else
42
+ first_selection('wrong_input')
43
+ end
44
+ end
37
45
 
38
46
  def scrape_brand
39
-
40
47
  Brand.create_from_collection(IndexPDX_Scraper.brand_list(BASE_PATH))
41
48
  display_brand
42
49
  end
@@ -53,25 +60,25 @@ class ShoeScraper
53
60
  puts "Enter a number..."
54
61
  input = gets.chomp
55
62
 
56
- if !input.to_i.between?(1, Brand.all.size) #1.Repeat select_brand function if input an index in the length of Brand.all
63
+ if !input.to_i.between?(1, Brand.all.size) #1.Repeat select_brand function if input is an index in the length of Brand.all
57
64
  puts ""
58
65
  puts "That is not a valid option."
59
66
  puts ""
60
67
  select_brand
61
68
  else
62
- href = Brand.all[input.to_i - 1].brand_href
63
- if input == '1' #1.If they are Jordans, check if they have been scraped before
64
- if Brand.all[input.to_i - 1].editions == nil
65
- scrape_jordan_editions(href, input)
69
+ href = Brand.all[input.to_i - 1].brand_href
70
+ if input == '1' #1.If they are Jordans, check if they have been scraped before
71
+ if Brand.all[input.to_i - 1].editions == nil
72
+ scrape_jordan_editions(href, input)
73
+ else
74
+ display_jordan_editions
75
+ end
76
+ elsif Brand.all[input.to_i - 1].shoe_collection == nil #1.If they are other shoes, check if they have been scraped before
77
+ scrape_shoe_collection(href, input)
66
78
  else
67
- display_jordan_editions
68
- end
69
- elsif Brand.all[input.to_i - 1].shoe_collection == nil #1.If they are other shoes, check if they have been scraped before
70
- scrape_shoe_collection(href, input)
71
- else
72
- display_shoe_collection(Brand.all[input.to_i - 1].shoe_collection)
79
+ display_shoe_collection(Brand.all[input.to_i - 1].shoe_collection)
80
+ end
73
81
  end
74
- end
75
82
  end
76
83
 
77
84
  #---------------------------------------------------------------------------
@@ -84,12 +91,16 @@ class ShoeScraper
84
91
  end
85
92
 
86
93
  def display_shoe_collection(brand)
94
+
87
95
  puts ''
88
96
  brand.each.with_index(1) do |shoe_obj, index|
89
97
  puts "#{index}. Model: #{shoe_obj.shoe_name.colorize(:cyan)}" + " Price: #{shoe_obj.price.colorize(:cyan)}".gsub("+", " ")
90
98
  puts ""
91
99
  end
92
- select_shoe_collection
100
+ puts "Gotta love some fresh kicks!! Pick a shoe and I can show you more info.".colorize(:green)
101
+ puts ""
102
+ puts "Type a number or 'b' for back"
103
+ select_shoe_collection(brand)
93
104
  end
94
105
 
95
106
  def scrape_edition_collection(href, input)
@@ -99,18 +110,22 @@ class ShoeScraper
99
110
  display_shoe_collection(Brand.all[0].editions[input.to_i - 1].shoe_collection)
100
111
  end
101
112
 
102
- def select_shoe_collection
103
- puts "Gotta love some fresh kicks!! Pick a shoe and I can show you more info.".colorize(:green)
104
- puts ""
105
- puts "Type a number or 'b' for back"
113
+ def select_shoe_collection(brand, bad_input = false)
114
+ # BAD INPUT CONDITION
115
+ if bad_input
116
+ puts 'That is not a selection...'
117
+ end
118
+
106
119
  input = gets.chomp.downcase
107
120
 
108
- if input == "b"
121
+ if input == "b" || input == 'back'
109
122
  display_brand
110
- else
123
+ elsif input.to_i.between?(1, brand.size)
111
124
  puts "Good Choice!".colorize(:green)
112
125
  puts ''
113
126
  scrape_shoe(input)
127
+ else
128
+ select_shoe_collection(brand, true)
114
129
  end
115
130
  end
116
131
 
@@ -167,35 +182,50 @@ class ShoeScraper
167
182
  save(input)
168
183
  end
169
184
 
170
- def save(input)
171
- puts ''
172
- puts "Would you like to save this shoe?".colorize(:yellow)
185
+ def save(input, bad_input = false)
186
+ if !bad_input
187
+ puts ''
188
+ puts "Would you like to save this shoe?".colorize(:yellow)
189
+ puts ''
190
+ puts 'YES or NO'
191
+ else
192
+ puts 'That is not a selection...'
193
+ end
173
194
  choice = gets.chomp.downcase
174
- if choice == 'y'
195
+ if choice == 'y' || choice == 'yes'
175
196
  @@saved << Shoe.all[input.to_i - 1]
176
197
  puts ''
177
198
  puts "SHOE SAVED!!!!".colorize(:yellow)
178
199
  puts ''
179
200
  go_back
201
+ elsif choice == 'n' || choice == 'no'
202
+ go_back
180
203
  else
181
- go_back
204
+ save(input, true)
182
205
  end
183
206
  end
184
207
 
185
- def go_back
208
+ def go_back(bad_input = false)
209
+ if !bad_input
186
210
  puts ''
187
211
  puts "Would you like to check out more? Type yes, cart, or exit".colorize(:green)
188
212
  puts ''
189
- input = gets.chomp.downcase
190
- if input == 'y'
213
+ else
214
+ puts 'That is not a selection...'
215
+ end
216
+
217
+ input = gets.chomp.downcase
218
+ if input == 'y' || input == 'yes'
191
219
  puts ''
192
220
  display_brand
193
- elsif input == 'c'
221
+ elsif input == 'c' || input == 'cart'
194
222
  view_saved
195
- elsif input == 'e'
223
+ elsif input == 'e' || input == 'exit'
196
224
  puts ''
197
225
  puts 'Goodbye!!'.colorize(:green)
198
226
  puts ''
227
+ else
228
+ go_back(true)
199
229
  end
200
230
  end
201
231
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shoe_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uriah Harston