newegg_scraper_chsbr 0.1.3 → 0.1.4
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 +4 -4
- data/lib/environment.rb +2 -0
- data/lib/newegg_scraper_chsbr/cli.rb +68 -14
- data/lib/newegg_scraper_chsbr/cpu.rb +2 -2
- data/lib/newegg_scraper_chsbr/user.rb +4 -3
- data/lib/newegg_scraper_chsbr/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11059b9bceeeef9708cfe6a2c5f3580382d6d3bc433912236ab994f9bb6f32d5
|
4
|
+
data.tar.gz: b59fb69c6336168d4298e3c844ac53e3cc53dd8494a9e3d9a06f770e8ee61399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c0c58f08256a1122cdcf3de9ad9db3ebb0df98a1dd046d5e18f9a7ba66b0516c2b64c7ac3f4a92fc4cdf4147ed326fd924c3f7d3327337679eb84b553561d40
|
7
|
+
data.tar.gz: e7b300cbd9a4e0410e0d91888bb268ecaa4cb7d35b10b49caf19feec47e4c707ad3f10e7d8d26d036dfe0c342781617f477e7cbda486f22491dddf14e3647c07
|
data/lib/environment.rb
CHANGED
@@ -6,26 +6,51 @@ class NeweggScraperChsbr::CLI
|
|
6
6
|
end
|
7
7
|
def call
|
8
8
|
puts "Were you interested in purchasing some CPU's?"
|
9
|
-
puts "Please enter y to do so."
|
9
|
+
puts "Please enter y to do so."
|
10
10
|
@counter = gets.strip
|
11
|
-
|
11
|
+
corr_input = control_bool
|
12
|
+
while corr_input
|
13
|
+
puts "Were you interested in purchasing some CPU's?"
|
14
|
+
puts "Please enter y to do so.\nPlease enter n or exit to quit."
|
15
|
+
@counter = gets.strip
|
16
|
+
corr_input = control_bool
|
17
|
+
end
|
18
|
+
while @counter == 'y'
|
19
|
+
get_price_range
|
12
20
|
get_init_data_for_user
|
13
21
|
NeweggScraperChsbr::Cpu.display_cpu(@user)
|
14
22
|
@user.choose_cpu
|
15
23
|
NeweggScraperChsbr::Cpu.display_cpu_with_extras(@user)
|
16
|
-
puts "If you would like to continue please enter : #{@counter}"
|
24
|
+
puts "If you would like to continue please enter : #{@counter}.\nTo exit type n or exit."
|
17
25
|
@counter = gets.strip
|
26
|
+
corr_input = control_bool
|
27
|
+
while corr_input
|
28
|
+
puts "Were you interested in purchasing some CPU's?"
|
29
|
+
puts "Please enter y to do so.\nPlease enter n or exit to quit."
|
30
|
+
@counter = gets.strip
|
31
|
+
corr_input = control_bool
|
32
|
+
end
|
33
|
+
|
18
34
|
end
|
19
35
|
puts "Thanks for using Chesbro's Scraper!"
|
20
36
|
end
|
21
37
|
def get_init_data_for_user
|
22
38
|
|
23
39
|
if @counter == 'y'
|
24
|
-
|
40
|
+
|
25
41
|
puts "Are you searching for Intel or AMD?"
|
26
42
|
puts "Please put i for Intel, or a for AMD."
|
27
43
|
puts "Please put x for either."
|
28
44
|
@cpu_make = gets.strip
|
45
|
+
not_found = cpu_make_bool
|
46
|
+
while not_found
|
47
|
+
puts "\n\n\n\n THIS IS CPU_MAKE: #{@cpu_make}\n\n\n IS THIS TRUE?: #{!@cpu_make.include?("x") || !@cpu_make.include?("a") || !@cpu_make.include?("i") || @cpu_make == nil }\n"
|
48
|
+
puts "Are you searching for Intel or AMD?"
|
49
|
+
puts "Please put i for Intel, or a for AMD."
|
50
|
+
puts "Please put x for either."
|
51
|
+
@cpu_make = gets.strip
|
52
|
+
not_found = cpu_make_bool
|
53
|
+
end
|
29
54
|
puts "\n\nYou want to search for (an) #{NeweggScraperChsbr::Cpu.cpu_maker(@cpu_make)} CPU."
|
30
55
|
if @max_price.to_i != 0 && @min_price.to_i != 0
|
31
56
|
puts "You entered a maximum price of $#{@max_price}, and a minimum price of $#{@min_price}."
|
@@ -40,28 +65,57 @@ class NeweggScraperChsbr::CLI
|
|
40
65
|
end
|
41
66
|
end
|
42
67
|
def if_correct_info
|
43
|
-
puts "\nIf you're satisfied with your selection, the computer will print\na list of CPUs that satisfy the criteria. Enter y to continue."
|
68
|
+
puts "\nIf you're satisfied with your selection, the computer will print\na list of CPUs that satisfy the criteria. Enter y to continue. Enter n to choose again."
|
44
69
|
@counter = gets.strip
|
45
70
|
if @counter == 'y'
|
46
71
|
@user = NeweggScraperChsbr::User.new(@cpu_make, @min_price, @max_price)
|
47
72
|
else
|
48
|
-
|
73
|
+
@counter = 'y'
|
74
|
+
call
|
49
75
|
end
|
50
76
|
end
|
51
77
|
def get_price_range
|
52
78
|
puts "Welcome. Would you like to set a budget? If no, set your maximum budget to 0"
|
79
|
+
puts "Please enter the integer value of your maximum price."
|
80
|
+
puts "$500.50, please enter as 501, or 500 to stay below budget."
|
81
|
+
@max_price = gets.strip
|
82
|
+
while @max_price.to_i < 0 || @max_price.to_i > 10000 || @max_price.include?("$") || @max_price.include?(".") || @max_price == nil
|
83
|
+
puts "Welcome. Would you like to set a budget? If no, set your maximum budget to 0"
|
53
84
|
puts "Please enter the integer value of your maximum price."
|
54
85
|
puts "$500.50, please enter as 501, or 500 to stay below budget."
|
55
86
|
@max_price = gets.strip
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
87
|
+
end
|
88
|
+
puts "Please enter the minimum you would spend on a CPU."
|
89
|
+
puts "Please use the same format as above."
|
90
|
+
@min_price = gets.strip
|
91
|
+
while @min_price.to_i <= 0 || @min_price.to_i >= @max_price.to_i || @min_price.include?("$") || @min_price.include?(".") || @min_price == nil
|
92
|
+
puts "Please enter the minimum you would spend on a CPU."
|
93
|
+
puts "Please use the same format as above."
|
94
|
+
@min_price = gets.strip
|
95
|
+
end
|
63
96
|
|
64
97
|
end
|
98
|
+
def control_bool
|
99
|
+
if @counter.include?("y")
|
100
|
+
false
|
101
|
+
elsif @counter.include?("exit")
|
102
|
+
false
|
103
|
+
elsif @counter.include?("n")
|
104
|
+
false
|
105
|
+
else
|
106
|
+
true
|
107
|
+
end
|
108
|
+
end
|
109
|
+
def cpu_make_bool
|
110
|
+
if @cpu_make.include?("x")
|
111
|
+
false
|
112
|
+
elsif @cpu_make.include?("a")
|
113
|
+
false
|
114
|
+
elsif @cpu_make.include?("i")
|
115
|
+
false
|
116
|
+
else
|
117
|
+
true
|
118
|
+
end
|
65
119
|
|
66
|
-
|
120
|
+
end
|
67
121
|
end
|
@@ -6,7 +6,7 @@ class NeweggScraperChsbr::Cpu
|
|
6
6
|
@name = NeweggScraperChsbr::Name.new(name)
|
7
7
|
@price = NeweggScraperChsbr::Price.new(price)
|
8
8
|
@desc = NeweggScraperChsbr::Descriptors.new(desc)
|
9
|
-
@shipping =
|
9
|
+
@shipping = NeweggScraperChsbr::Shipping.new(shipping)
|
10
10
|
@@all << self
|
11
11
|
end
|
12
12
|
def self.all
|
@@ -25,7 +25,7 @@ class NeweggScraperChsbr::Cpu
|
|
25
25
|
counter = 1
|
26
26
|
@@all.each do | computer |
|
27
27
|
if user.max_price.to_i != 0 && user.min_price.to_i == 0
|
28
|
-
|
28
|
+
|
29
29
|
|
30
30
|
user.min_price = "1"
|
31
31
|
end
|
@@ -8,11 +8,12 @@ class NeweggScraperChsbr::User
|
|
8
8
|
@chosen_cpu = []
|
9
9
|
end
|
10
10
|
def choose_cpu
|
11
|
-
puts "Please enter the number of the CPU you'd like to
|
11
|
+
puts "Please enter the number of the CPU you'd like to see more about."
|
12
12
|
chosen = gets.strip.to_i
|
13
13
|
@chosen_cpu << chosen
|
14
|
-
puts "Would you like to
|
15
|
-
|
14
|
+
puts "Would you like to see more about another CPU?\nEnter y to do so.\nEnter n to see details about the chosen CPU(s)"
|
15
|
+
input = gets.strip
|
16
|
+
if input == 'y'
|
16
17
|
choose_cpu
|
17
18
|
end
|
18
19
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: newegg_scraper_chsbr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lrd134
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|