newegg_scraper_chsbr 0.1.4 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11059b9bceeeef9708cfe6a2c5f3580382d6d3bc433912236ab994f9bb6f32d5
4
- data.tar.gz: b59fb69c6336168d4298e3c844ac53e3cc53dd8494a9e3d9a06f770e8ee61399
3
+ metadata.gz: dbfd1d76149f6e24674933978bc42dfed9c4793b07ede185dd890a9624ac8259
4
+ data.tar.gz: dcf10106484e843c95d888d267725e8d3cee154a78ae8014c141baf9a160495b
5
5
  SHA512:
6
- metadata.gz: 0c0c58f08256a1122cdcf3de9ad9db3ebb0df98a1dd046d5e18f9a7ba66b0516c2b64c7ac3f4a92fc4cdf4147ed326fd924c3f7d3327337679eb84b553561d40
7
- data.tar.gz: e7b300cbd9a4e0410e0d91888bb268ecaa4cb7d35b10b49caf19feec47e4c707ad3f10e7d8d26d036dfe0c342781617f477e7cbda486f22491dddf14e3647c07
6
+ metadata.gz: 6eedd9aae8b3c008bb8485e882e24322d7b76ac61245f4690dd43772816f72e5a1b5be2ab7538be22c6fc643ab096a4f6530db673c0a04c2611e74fd5eaaec5b
7
+ data.tar.gz: d4d473f51c977978959b4dd7e32a91938cb626bd90b2cb8cd4d83e9e6ea08136747b658ce45f9beefab02aa73445683ef177274f1ab30c659136f42637791388
@@ -21,7 +21,7 @@ class NeweggScraperChsbr::CLI
21
21
  NeweggScraperChsbr::Cpu.display_cpu(@user)
22
22
  @user.choose_cpu
23
23
  NeweggScraperChsbr::Cpu.display_cpu_with_extras(@user)
24
- puts "If you would like to continue please enter : #{@counter}.\nTo exit type n or exit."
24
+ puts "If you would like to restart the program please enter : #{@counter}.\nTo exit type n or exit."
25
25
  @counter = gets.strip
26
26
  corr_input = control_bool
27
27
  while corr_input
@@ -44,7 +44,6 @@ class NeweggScraperChsbr::CLI
44
44
  @cpu_make = gets.strip
45
45
  not_found = cpu_make_bool
46
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
47
  puts "Are you searching for Intel or AMD?"
49
48
  puts "Please put i for Intel, or a for AMD."
50
49
  puts "Please put x for either."
@@ -85,15 +84,17 @@ class NeweggScraperChsbr::CLI
85
84
  puts "$500.50, please enter as 501, or 500 to stay below budget."
86
85
  @max_price = gets.strip
87
86
  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
87
+ if @max_price.to_i != 0
92
88
  puts "Please enter the minimum you would spend on a CPU."
93
89
  puts "Please use the same format as above."
94
90
  @min_price = gets.strip
91
+
92
+ while @min_price.to_i <= 0 || @min_price.to_i >= @max_price.to_i || @min_price.include?("$") || @min_price.include?(".") || @min_price == nil
93
+ puts "Please enter the minimum you would spend on a CPU."
94
+ puts "Please use the same format as above."
95
+ @min_price = gets.strip
96
+ end
95
97
  end
96
-
97
98
  end
98
99
  def control_bool
99
100
  if @counter.include?("y")
@@ -4,7 +4,7 @@ class NeweggScraperChsbr::Scraper
4
4
 
5
5
  URL = "https://www.newegg.com/p/pl?d=cpu"
6
6
  def initialize(url = URL)
7
- @xml_obj = Nokogiri::HTML(open(url)) # This opens the URL with open-uri, then parses it as an XML Object
7
+ @xml_obj = Nokogiri::HTML(URI.open(url)) # This opens the URL with open-uri, then parses it as an XML Object
8
8
  end
9
9
 
10
10
 
@@ -9,13 +9,21 @@ class NeweggScraperChsbr::User
9
9
  end
10
10
  def choose_cpu
11
11
  puts "Please enter the number of the CPU you'd like to see more about."
12
- chosen = gets.strip.to_i
13
- @chosen_cpu << chosen
12
+ chosen = gets.strip
13
+ while !is_numeric?(chosen)
14
+ puts "Please enter the number of the CPU you'd like to see more about."
15
+ chosen = gets.strip
16
+ end
17
+ @chosen_cpu << chosen.to_i
14
18
  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
19
  input = gets.strip
20
+
16
21
  if input == 'y'
17
22
  choose_cpu
18
23
  end
19
24
 
20
25
  end
26
+ def is_numeric?(obj)
27
+ obj.match(/\A[^+-]?\d+?(\^.\d+)?\Z/) == nil ? false : true
28
+ end
21
29
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NeweggScraperChsbr
4
- VERSION = "0.1.4"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newegg_scraper_chsbr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lrd134