shoe_scraper 0.0.5 → 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 (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -1
  3. data/lib/shoe_scraper.rb +74 -44
  4. metadata +23 -12
  5. data/LICENSE.txt +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c6cb88eda4ec7d557f17e96f7091b4a73f4c384069dd9eadaa5a1ad61ec041b
4
- data.tar.gz: 31f3c55a503ead108c0336d77252c9d1742902e90a3379c1e3b3c7c3c61d70c6
3
+ metadata.gz: e13f4f497c0df4344d5070de9cd9632e64da9cbfb3aee2e67066b3999ddea492
4
+ data.tar.gz: f9598d73ccbeaae8be8fdf2e05202c2b1545dee02af1fef7bf23db8aa18cddaf
5
5
  SHA512:
6
- metadata.gz: 2d5938a4a925edb080d59a2ec53d348cfd58c7fa081bfa337807bac656c0845ebba9ea852717ee3ef19a141c92fd3f1cabfe9af0694c976db8adfb4630a6d513
7
- data.tar.gz: 478fa2623df6177af0aa3e59ccc2a9d5b6d0b7fdecdfbe25e5f0a77ea6dc6433047e27379d0bad05c6c35230223d8eec6caae99a47662fbe4d62e7fae9fa2ec2
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
@@ -42,7 +54,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
42
54
 
43
55
  ## Contributing
44
56
 
45
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/shoe_scraper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/shoe_scraper/blob/master/CODE_OF_CONDUCT.md).
57
+ Bug reports and pull requests are welcome on GitHub at https://github.com/uharston/shoe_scraper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/shoe_scraper/blob/master/CODE_OF_CONDUCT.md).
46
58
 
47
59
 
48
60
  ## License
@@ -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.5
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uriah Harston
@@ -11,47 +11,59 @@ cert_chain: []
11
11
  date: 2020-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rake
14
+ name: colorize
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '12.0'
19
+ version: '0.8'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.8.1
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '12.0'
29
+ version: '0.8'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.8.1
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: nokogiri
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
- - - '='
37
+ - - "~>"
32
38
  - !ruby/object:Gem::Version
33
39
  version: '1.10'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.10.8
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
37
46
  requirements:
38
- - - '='
47
+ - - "~>"
39
48
  - !ruby/object:Gem::Version
40
49
  version: '1.10'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.10.8
41
53
  - !ruby/object:Gem::Dependency
42
- name: colorize
54
+ name: rake
43
55
  requirement: !ruby/object:Gem::Requirement
44
56
  requirements:
45
- - - ">="
57
+ - - "~>"
46
58
  - !ruby/object:Gem::Version
47
- version: 0.8.1
59
+ version: '12.0'
48
60
  type: :runtime
49
61
  prerelease: false
50
62
  version_requirements: !ruby/object:Gem::Requirement
51
63
  requirements:
52
- - - ">="
64
+ - - "~>"
53
65
  - !ruby/object:Gem::Version
54
- version: 0.8.1
66
+ version: '12.0'
55
67
  description: A gem that scrapes available sneaker inventory from the indexpdx.com
56
68
  website for sneaker collectors.
57
69
  email: uharston@gmail.com
@@ -60,7 +72,6 @@ extensions: []
60
72
  extra_rdoc_files:
61
73
  - README.md
62
74
  files:
63
- - LICENSE.txt
64
75
  - README.md
65
76
  - lib/Jordan_Edition.rb
66
77
  - lib/brand.rb
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2020 uharston
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.