compare_supermarkets 0.1.4 → 0.1.9
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/config/environment.rb +13 -0
- data/lib/compare_supermarkets/cli.rb +9 -6
- data/lib/compare_supermarkets/product.rb +2 -2
- data/lib/compare_supermarkets/version.rb +1 -1
- metadata +12 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21d751bb1877f2aec5c1b3f80dcf680b41006b4e2be969d0fc31f9d6c1ae390d
|
4
|
+
data.tar.gz: b0daf658c23f131b73f159af94b50de565e210e6e91b71e69bc495ac1dd1a36f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94187db55938eaca84e23d48616391e182f64d90d3c148911a68db6de43076c6d7afb108474c77f2e83cb1bf7b8ae7f76374d68108a1c393758ab6774b39f67a
|
7
|
+
data.tar.gz: cbd9fbb88dfcafb951950ca7b5be1739be62849e2247a739d8d00eb2f1c950733d3a0d8f00f2b5bbcb527ec0dab28d6798cc5926bc40286c5b1abf5f741c3b94
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'nokogiri'
|
3
|
+
require 'watir'
|
4
|
+
|
5
|
+
#gem install selenium-webdriver - required for watir to work
|
6
|
+
#brew install --cask chromedriver - required for watir to work
|
7
|
+
|
8
|
+
require_relative '../lib/compare_supermarkets/scraper'
|
9
|
+
require_relative '../lib/compare_supermarkets/product'
|
10
|
+
require_relative '../lib/compare_supermarkets/cli'
|
11
|
+
require_relative '../lib/compare_supermarkets/version'
|
12
|
+
|
13
|
+
Watir.default_timeout = 0
|
@@ -42,15 +42,15 @@ class CompareSupermarkets::CLI
|
|
42
42
|
self.search_supermarkets(input)
|
43
43
|
puts ""
|
44
44
|
puts ""
|
45
|
-
if CompareSupermarkets::Product.
|
45
|
+
if CompareSupermarkets::Product.count > 10
|
46
46
|
puts ""
|
47
47
|
puts "Ooo, jeez, seems like we have a lot of results."
|
48
|
-
puts "We have #{CompareSupermarkets::Product.
|
48
|
+
puts "We have #{CompareSupermarkets::Product.count} results for you."
|
49
49
|
puts "If you were a little more specific with your search"
|
50
50
|
puts "term, we would have less to sort through..."
|
51
51
|
puts ""
|
52
52
|
change_search_term
|
53
|
-
elsif CompareSupermarkets::Product.
|
53
|
+
elsif CompareSupermarkets::Product.count == 0
|
54
54
|
puts ""
|
55
55
|
puts "Ohhh man! Doesn't seem like either supermarket carry"
|
56
56
|
puts "that product."
|
@@ -58,7 +58,7 @@ class CompareSupermarkets::CLI
|
|
58
58
|
change_search_term
|
59
59
|
else
|
60
60
|
puts ""
|
61
|
-
puts "Great! We have #{CompareSupermarkets::Product.
|
61
|
+
puts "Great! We have #{CompareSupermarkets::Product.count} items for you."
|
62
62
|
puts ""
|
63
63
|
puts ""
|
64
64
|
puts ""
|
@@ -79,7 +79,7 @@ class CompareSupermarkets::CLI
|
|
79
79
|
puts ""
|
80
80
|
puts "No worries"
|
81
81
|
puts ""
|
82
|
-
if CompareSupermarkets::Product.
|
82
|
+
if CompareSupermarkets::Product.count > 0
|
83
83
|
how_to_display
|
84
84
|
else
|
85
85
|
puts ""
|
@@ -113,6 +113,10 @@ class CompareSupermarkets::CLI
|
|
113
113
|
puts ""
|
114
114
|
input = gets.strip
|
115
115
|
puts ""
|
116
|
+
choice(input)
|
117
|
+
end
|
118
|
+
|
119
|
+
def choice(input)
|
116
120
|
if input == "1"
|
117
121
|
choice = CompareSupermarkets::Product.all_top_10_sorted_by_price
|
118
122
|
print_items(choice, "asc")
|
@@ -140,7 +144,6 @@ class CompareSupermarkets::CLI
|
|
140
144
|
invalid_input
|
141
145
|
how_to_display
|
142
146
|
end
|
143
|
-
|
144
147
|
end
|
145
148
|
|
146
149
|
def finished
|
@@ -26,7 +26,7 @@ class CompareSupermarkets::Product
|
|
26
26
|
@all
|
27
27
|
end
|
28
28
|
|
29
|
-
def self.
|
29
|
+
def self.count
|
30
30
|
@@all.count
|
31
31
|
end
|
32
32
|
|
@@ -54,7 +54,7 @@ class CompareSupermarkets::Product
|
|
54
54
|
sorted = @@all.sort_by! do |s|
|
55
55
|
price_to_sort = s.dollar_value + '.' + s.cent_value
|
56
56
|
price_to_sort.to_f
|
57
|
-
|
57
|
+
end
|
58
58
|
end
|
59
59
|
|
60
60
|
def self.all_top_10_sorted_by_price
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compare_supermarkets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Berger Howes
|
@@ -84,7 +84,9 @@ description: |
|
|
84
84
|
Will search Woolworths and Coles online stores for prices based on an input search parameter
|
85
85
|
# CompareSupermarkets
|
86
86
|
|
87
|
-
Ever wondered 'I wonder if my shampoo is cheaper at Coles or Woolworths...?' ? But can't be
|
87
|
+
Ever wondered 'I wonder if my shampoo is cheaper at Coles or Woolworths...?' ? But can't be
|
88
|
+
bothered searching both websites and comparing? Well that's what this gem does for you. Simply
|
89
|
+
install and follow the prompts.
|
88
90
|
|
89
91
|
## Installation
|
90
92
|
|
@@ -104,18 +106,19 @@ description: |
|
|
104
106
|
|
105
107
|
## Usage
|
106
108
|
|
107
|
-
To use compare_supermarkets call $
|
109
|
+
To use compare_supermarkets call $ 'compare_supermarkets'
|
108
110
|
and follow the prompts. The more specific you are the faster the search results appear
|
109
111
|
and there will be less items to compare.
|
110
112
|
|
111
113
|
|
112
114
|
## Contributing
|
113
115
|
|
114
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
116
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/happymelonbox/compare_supermarkets
|
115
117
|
|
116
118
|
## License
|
117
119
|
|
118
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org
|
120
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org
|
121
|
+
/licenses/MIT).
|
119
122
|
email:
|
120
123
|
- howes.j.j@gmail.com
|
121
124
|
executables:
|
@@ -126,6 +129,7 @@ files:
|
|
126
129
|
- bin/compare_supermarkets
|
127
130
|
- bin/console
|
128
131
|
- bin/setup
|
132
|
+
- config/environment.rb
|
129
133
|
- lib/compare_supermarkets.rb
|
130
134
|
- lib/compare_supermarkets/cli.rb
|
131
135
|
- lib/compare_supermarkets/product.rb
|
@@ -136,12 +140,13 @@ licenses:
|
|
136
140
|
- MIT
|
137
141
|
metadata:
|
138
142
|
homepage_uri: http://rubygems.org/gems/compare_supermarkets
|
139
|
-
source_code_uri: https://github.com/happymelonbox/
|
140
|
-
changelog_uri: https://github.com/happymelonbox/
|
143
|
+
source_code_uri: https://github.com/happymelonbox/compare_supermarkets
|
144
|
+
changelog_uri: https://github.com/happymelonbox/compare_supermarkets/blob/main/CHANGELOG.md
|
141
145
|
post_install_message:
|
142
146
|
rdoc_options: []
|
143
147
|
require_paths:
|
144
148
|
- lib
|
149
|
+
- config
|
145
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
146
151
|
requirements:
|
147
152
|
- - ">="
|