sommeligem 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/sommeligem +7 -0
- data/lib/sommeligem.rb +9 -0
- data/lib/sommeligem/som_cli.rb +234 -0
- data/lib/sommeligem/version.rb +3 -0
- data/lib/sommeligem/wine_scraper.rb +81 -0
- data/sommeligem.gemspec +29 -0
- data/sommeligem_outline +27 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ad023e26115423d68f3436a056978363e5acbdd7
|
4
|
+
data.tar.gz: 2deeaa69861d9af712e840bc8c830562fa46c04e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 90f49003aa2295787153dbfe300025c3531aee1fb935d235d082061b995312c8ede74f73ea719fc66478103d82592eac1eaef9c3ad199ef3b9d7cd5ae2c073c3
|
7
|
+
data.tar.gz: e0769d7820d33bf658bdaebc87e18fb339767830acc4d8c5df2fa4f9db6aeb16d316d2d081bea9a278194c58aea2f2f2bf42549e953e83a4320d8006d1b4684a
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at donedesign1@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 febbraiod
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# Sommeligem
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/sommeligem`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'sommeligem'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install sommeligem
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sommeligem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sommeligem"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/bin/sommeligem
ADDED
data/lib/sommeligem.rb
ADDED
@@ -0,0 +1,234 @@
|
|
1
|
+
require 'launchy'
|
2
|
+
require_relative './wine_scraper.rb'
|
3
|
+
|
4
|
+
class Som_cli
|
5
|
+
|
6
|
+
attr_accessor :wine, :list
|
7
|
+
|
8
|
+
def initialize(wine)
|
9
|
+
@wine = wine
|
10
|
+
@list = wine.scrape
|
11
|
+
self.add_foods
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_foods
|
15
|
+
food_pairs = {"Cabernet Sauvignon" => "red meats, especially short ribs and rare steaks, and dishes with mushroom sauces. It also goes well with strong cheese and lamb",
|
16
|
+
"Other Red Blend" => "roasted white meats, hamburger, veal, or risotto",
|
17
|
+
"Chardonnay" => "fatty fish or lean fish in a rich sauce, lobster, sushi rolls with mayo, ripe fruit and hard cheeses",
|
18
|
+
"Non-Vintage Sparkling Wine" => "salty foods, oysters, chinese food, smoked fish and lean fish",
|
19
|
+
"Sauvignon Blanc" => "lean fish, nigiri sushi, lobster, fresh fruits and veggies or light cheeses",
|
20
|
+
"Malbec" => "steak, roast beef or venison, barbecued lamb, beef or pork with smokey, chili-based rubs. Also goes nicely with Chili con Carne",
|
21
|
+
"Pinot Noir" => "glazed ham, pork tenderloin, roasted vegatables, poutry and fowl, duck, rabbit, and dishes with light flavorful sauces",
|
22
|
+
"Tempranillo" => "cured ham, tapas, rabbit, Lasagna, Pizza and dishes with tomato-based sauces, tacos, nachos, mole sauces",
|
23
|
+
"Bordeaux Red Blend" => "braised lamb, mussels, quiche, beef stew and smoked duck",
|
24
|
+
"Pinot Gris/Grigio" => "fatty fish, tuna, salmon, shellfish, lobster, light chicken dishes, fresh veggies, pasta with light sauces or olive oil and fresh herbs, as well as mild Asian dishes",
|
25
|
+
"Rhone Red Blend" => "pizza, pork belly, sausages, charcuterrie, stir fry, and pork chops",
|
26
|
+
"Sangiovese" => "lasagna, pizza, tomatos, tomato sauce, any acidic Italian dish",
|
27
|
+
"RosÃ" => "artisinal grilled cheese sandwiches, aparagus, cheese souflet, goat cheese, lobster, roasted beets and summer salads",
|
28
|
+
"Syrah/Shiraz" => "lamb chops, sausages, steak, spicy chicken dishes, paella, barbecued meats, and venison",
|
29
|
+
"Zinfandel" => "Indian food especially curries, chocolate, duck, chili, pork, hard cheese, bacon, and spicy BBQ",
|
30
|
+
"Chenin Blanc" => "sweet and sour chicken or pork, most Chinese foods, soft cheeses, smoked fish, fowl and fresh veggies",
|
31
|
+
"Grenache" => "skirt steak, charcuterrie, stuffed mushrooms, young hard cheese, dark chocolate, stews, braises and ratatouille",
|
32
|
+
"Muscat" => "blue cheese, melon with prosciutto, fresh fruit, dried fruit, desserts",
|
33
|
+
"Other White Blend" => "mild to strong cheese, chicken, seafood, fresh veggies",
|
34
|
+
"Petite Sirah" => "roasted or grill beef and pork, lamb, barbeque, hard and strong cheeses, Mexican food",
|
35
|
+
"Riesling" => "risotto, grilled fish, nigiri sushi, spicy dishes, Mexican, Indian, Chinese foods",
|
36
|
+
"Vintage Sparkling Wine" => "salty foods, oysters, chinese food, smoked fish, and lean fish"}
|
37
|
+
|
38
|
+
|
39
|
+
list.each do |wine|
|
40
|
+
wine[:pairing] = food_pairs[wine[:varietal]]
|
41
|
+
end
|
42
|
+
|
43
|
+
list
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def welcome
|
48
|
+
puts ""
|
49
|
+
puts " _________"
|
50
|
+
puts " | |"
|
51
|
+
puts " % %"
|
52
|
+
puts " \\ /"
|
53
|
+
puts " '. .'"
|
54
|
+
puts " \\ /"
|
55
|
+
puts " ( )"
|
56
|
+
puts " |"
|
57
|
+
puts " ===^=== " #ascii art credit: hjw
|
58
|
+
puts "Good evening and welcome to the Sommeligem."
|
59
|
+
puts ""
|
60
|
+
end
|
61
|
+
|
62
|
+
def wine_list #should only happen at request
|
63
|
+
|
64
|
+
puts ""
|
65
|
+
puts "You like to see the wine list?"
|
66
|
+
response = gets.chomp.downcase
|
67
|
+
|
68
|
+
if response == "yes" || response == "y"
|
69
|
+
puts "For tonight's wine list we have:"
|
70
|
+
sleep(1)
|
71
|
+
|
72
|
+
list.each do |bottle|
|
73
|
+
puts "#{bottle[:ranking]}. #{bottle[:name]} from #{bottle[:region]}"
|
74
|
+
sleep(1/8.to_f)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
def interface
|
81
|
+
|
82
|
+
puts ""
|
83
|
+
puts "How may I assist you? If you are unfamiliar with Sommeligem, please ask for 'help'."
|
84
|
+
|
85
|
+
guest_choice = gets.chomp
|
86
|
+
if guest_choice.downcase == 'help'
|
87
|
+
puts ""
|
88
|
+
sleep(1.to_f)
|
89
|
+
puts "You may ask to see the wine list by typing 'list'."
|
90
|
+
sleep(3/2.to_f)
|
91
|
+
puts "You may choose a number 1-100 for more details on the corresponding wine of your choice."
|
92
|
+
sleep(3/2.to_f)
|
93
|
+
puts "Or if you'd like, I could suggest wines from our list to pair with your meal by typing 'pairing'."
|
94
|
+
sleep(2.to_f)
|
95
|
+
puts "If you no longer need my assistance you may type 'exit.'"
|
96
|
+
puts ""
|
97
|
+
sleep(3/4.to_f)
|
98
|
+
interface
|
99
|
+
elsif (1..100).include?(guest_choice.to_i)
|
100
|
+
if details(guest_choice) == exit
|
101
|
+
puts "Have a good evening!"
|
102
|
+
return
|
103
|
+
end
|
104
|
+
elsif guest_choice.downcase == 'list'
|
105
|
+
wine_list
|
106
|
+
interface
|
107
|
+
elsif guest_choice.downcase == 'pairing'
|
108
|
+
if pairing_food_to_wine == "exit"
|
109
|
+
puts "Have a nice night!"
|
110
|
+
return
|
111
|
+
end
|
112
|
+
puts "For more information on any of these wines please enter the wine number."
|
113
|
+
wine_num = gets.chomp
|
114
|
+
if wine_num == "exit"
|
115
|
+
puts "Have a nice night!"
|
116
|
+
return
|
117
|
+
end
|
118
|
+
details(wine_num)
|
119
|
+
elsif guest_choice.downcase == 'exit'
|
120
|
+
puts "Please come again!"
|
121
|
+
return
|
122
|
+
else
|
123
|
+
puts "Im sorry I do not understand your request, please try again"
|
124
|
+
interface
|
125
|
+
end
|
126
|
+
|
127
|
+
end
|
128
|
+
|
129
|
+
def details(user_input)
|
130
|
+
wine = user_input.to_i - 1
|
131
|
+
puts "A very fine selection, the #{list[wine][:name]}"
|
132
|
+
puts "The #{list[wine][:name]} is a #{list[wine][:varietal]} from #{list[wine][:region]}"
|
133
|
+
puts "This wine will pair well with #{list[wine][:pairing]}."
|
134
|
+
|
135
|
+
if list[wine][:price] == "Price not available"
|
136
|
+
puts "I'm sorry to inform you that the price on the #{list[wine][:name]} is not available. Please check the details link for more information."
|
137
|
+
else
|
138
|
+
puts "The cost of this bottle will be #{list[wine][:price]}"
|
139
|
+
end
|
140
|
+
|
141
|
+
puts "Would you like more information?"
|
142
|
+
|
143
|
+
response = gets.chomp
|
144
|
+
|
145
|
+
while true
|
146
|
+
if response.downcase == "yes" || response.downcase == "y"
|
147
|
+
Launchy.open("#{list[wine][:detail_link]}")
|
148
|
+
interface
|
149
|
+
break
|
150
|
+
elsif response.downcase == "no" || response.downcase == "n"
|
151
|
+
interface
|
152
|
+
break
|
153
|
+
elsif response.downcase == "exit"
|
154
|
+
puts "Good Evening."
|
155
|
+
return
|
156
|
+
else
|
157
|
+
puts "Im sorry I do not understand your request, please try again"
|
158
|
+
response = gets.chomp
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
=begin
|
165
|
+
I wonder if this should be done with a Food class,
|
166
|
+
where foods belong to wines and vice versa,
|
167
|
+
but I'm not sure how I'd get all this info assigned properly.
|
168
|
+
Ask at assessment.
|
169
|
+
=end
|
170
|
+
|
171
|
+
def pairing_food_to_wine
|
172
|
+
food_to_wine =
|
173
|
+
{"beef" => ["Cabernet Sauvignon", "Other Red Blend", "Malbec", "Bordeaux Red Blend", "Syrah/Shiraz", "Grenache", "Petite Sirah"],
|
174
|
+
"chicken" => ["Pinot Gris/Grigio", "Syrah/Shiraz", "Chenin Blanc", "Other Red Blend", "Other White Blend"],
|
175
|
+
"pork" => ["Malbec", "Pinot Noir", "Zinfandel", "Petite Sirah", "Other Red Blend", "Tempranillo"],
|
176
|
+
"veggies" => ["Pinot Noir", "Other White Blend", "Pinot Gris/Grigio", "Chenin Blanc", "Sauvignon Blanc", "RosÃ"],
|
177
|
+
"fruit" => ["Chardonnay", "Sauvignon Blanc", "Muscat"],
|
178
|
+
"bbq" => ["Zinfandel", "Malbec", "Syrah/Shiraz", "Petite Sirah"],
|
179
|
+
"mexican" => ["Petite Sirah", "Riesling", "Syrah/Shiraz", "Tempranillo"],
|
180
|
+
"indian" => ["Riesling", "Zinfandel"],
|
181
|
+
"chinese" => ["Non-Vintage Sparkling Wine", "Chenin Blanc", "Riesling", "Vintage Sparkling Wine"],
|
182
|
+
"roasted" => ["Other Red Blend", "Malbec", "RosÃ", "Petite Sirah", "Sangiovese"],
|
183
|
+
"hard cheese" => ["Chardonnay", "Zinfandel", "Grenache", "Petite Sirah", "Rhone Red Blend"],
|
184
|
+
"soft cheese" => ["Chenin Blanc", "Rhone Red Blend", "Grenache"],
|
185
|
+
"dessert" => ["Muscat", "Zinfandel", "Grenache"],
|
186
|
+
"sweets" => ["Muscat", "Zinfandel", "Grenache"],
|
187
|
+
"italian" => ["Sangiovese", "Other Red Blend"],
|
188
|
+
"pizza" => ["Tempranillo", "Rhone Red Blend", "Sangiovese"],
|
189
|
+
"fatty fish" => ["Chardonnay", "Pinot Gris/Grigio"],
|
190
|
+
"lean fish" => ["Sauvignon Blanc", "Non-Vintage Sparkling Wine", "Vintage Sparkling Wine", "Riesling"],
|
191
|
+
"sushi rolls" => ["Chardonnay"],
|
192
|
+
"nigiri sushi" => ["Sauvignon Blanc", "Riesling"],
|
193
|
+
"lamb" => ["Malbec", "Bordeaux Red Blend", "Syrah/Shiraz", "Petite Sirah"],
|
194
|
+
"duck" => ["Pinot Noir", "Zinfandel", "Bordeaux Red Blend"],
|
195
|
+
"fowl" => ["Pinot Noir", "Chenin Blanc"],
|
196
|
+
"venison" => ["Malbec", "Syrah/Shiraz"],
|
197
|
+
"lobster" => ["Vintage Sparkling Wine", "Non-Vintage Sparkling Wine", "Chardonnay", "Sauvignon Blanc", "Pinot Gris/Grigio", "RosÃ", "Bordeaux Red Blend"],
|
198
|
+
"shellfish" => ["Vintage Sparkling Wine", "Non-Vintage Sparkling Wine", "Chardonnay", "Sauvignon Blanc", "Pinot Gris/Grigio", "RosÃ", "Bordeaux Red Blend"],
|
199
|
+
"spicy" => ["Syrah/Shiraz", "Zinfandel", "Riesling"],
|
200
|
+
"salty" => ["Non-Vintage Sparkling Wine", "Vintage Sparkling Wine"]
|
201
|
+
}
|
202
|
+
|
203
|
+
while true
|
204
|
+
puts "What are you considering for dinner? For a list of foods and flavors I can pair please enter 'foods'" # use in CLI not in hash(lobster, shellfish ect)
|
205
|
+
|
206
|
+
input = gets.chomp.downcase
|
207
|
+
if input == "foods"
|
208
|
+
food_to_wine.each do |food, wine|
|
209
|
+
puts food
|
210
|
+
end
|
211
|
+
elsif input == "exit"
|
212
|
+
return "exit"
|
213
|
+
elsif food_to_wine.has_key?(input)
|
214
|
+
list.each do |bottle|
|
215
|
+
if food_to_wine[input].include?(bottle[:varietal]) && input != "sushi"
|
216
|
+
puts "#{bottle[:ranking]}. #{bottle[:name]} from #{bottle[:region]}"
|
217
|
+
sleep(1/8.to_f)
|
218
|
+
end
|
219
|
+
end
|
220
|
+
break
|
221
|
+
else
|
222
|
+
puts "I'm sorry I'm not familar with that dish."
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
end
|
234
|
+
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'launchy'
|
4
|
+
|
5
|
+
|
6
|
+
class Wine
|
7
|
+
|
8
|
+
WINE_URL = "http://www.wine.com/v6/winemarketinglist.aspx?N=490%201251&pagelength=100&s=100&cid=100"
|
9
|
+
|
10
|
+
@@wines = []
|
11
|
+
|
12
|
+
attr_accessor :wine_url
|
13
|
+
|
14
|
+
|
15
|
+
def initialize(wine_url = WINE_URL)
|
16
|
+
@wine_url = WINE_URL
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def scrape
|
21
|
+
|
22
|
+
html = Nokogiri::HTML(open(wine_url))
|
23
|
+
doc = html.css(".detailsBlock")
|
24
|
+
|
25
|
+
names_and_links = doc.css(".listProductName")
|
26
|
+
prices = html.css(".priceBoxHeader")
|
27
|
+
regions = doc.css(".productAbstract").css("span + span [href]")
|
28
|
+
varietals = doc.css("div.productAbstract").css("span:first-child [href]")
|
29
|
+
|
30
|
+
idx = 1
|
31
|
+
names_and_links.each do |wine|
|
32
|
+
wine_hash = {}
|
33
|
+
wine_hash[:ranking] = idx
|
34
|
+
wine_hash[:name] = wine.text
|
35
|
+
wine_hash[:detail_link] = "wine.com" + wine.attribute("href").value
|
36
|
+
@@wines << wine_hash
|
37
|
+
idx += 1 #for ranking
|
38
|
+
end
|
39
|
+
|
40
|
+
idx2 = 0
|
41
|
+
prices.each do |price|
|
42
|
+
if price.css(".soldOutPrice").text != ""
|
43
|
+
@@wines[idx2][:price] = price.css(".soldOutPrice").text
|
44
|
+
elsif price.css(".salesPrice").text != ""
|
45
|
+
@@wines[idx2][:price] = price.css(".salesPrice").text
|
46
|
+
else
|
47
|
+
@@wines[idx2][:price] = "Price not available"
|
48
|
+
end
|
49
|
+
idx2 += 1
|
50
|
+
end
|
51
|
+
|
52
|
+
idx3 = 0
|
53
|
+
regions.each do |region|
|
54
|
+
@@wines[idx3][:region] = region.text
|
55
|
+
idx3 += 1
|
56
|
+
end
|
57
|
+
|
58
|
+
idx4 = 0
|
59
|
+
varietals.each do |grape|
|
60
|
+
@@wines[idx4][:varietal] = grape.text.chomp("s")
|
61
|
+
idx4 += 1
|
62
|
+
end
|
63
|
+
|
64
|
+
@@wines
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def self.all
|
69
|
+
@@wines
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
data/sommeligem.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sommeligem/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sommeligem"
|
8
|
+
spec.version = Sommeligem::VERSION
|
9
|
+
spec.authors = ["febbraiod"]
|
10
|
+
spec.email = ["donedesign1@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{a CLI gem that provides information about the top 100 wines on Wine.com including suggested pairings}
|
13
|
+
spec.homepage = "https://github.com/febbraiod/sommeligem.git"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.executables = ["sommeligem"]
|
18
|
+
spec.require_paths = ["lib", "lib/sommeligem"]
|
19
|
+
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "pry"
|
24
|
+
spec.add_development_dependency "json"
|
25
|
+
spec.add_development_dependency "open-uri"
|
26
|
+
spec.add_development_dependency "nokogiri"
|
27
|
+
spec.add_development_dependency "launchy"
|
28
|
+
|
29
|
+
end
|
data/sommeligem_outline
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
TopWinesGem or SomGem
|
2
|
+
|
3
|
+
|
4
|
+
It scrapes the Wine.com site for the info needed to perform the following:
|
5
|
+
|
6
|
+
It displays all the different wines on the list in order from 1 - 100.
|
7
|
+
|
8
|
+
It isolates the name from the grape.
|
9
|
+
|
10
|
+
choosing a wine will provide a description(might have to just provide a link as the description for each wine is on it's own page) where grown and price.
|
11
|
+
|
12
|
+
Alternatively the user can choose the pairing option where they can pare down the list by a food group. Say if they choose "red meat" or "Beef" The list will redisplay with the wines that match the varietal I associate it with.
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
Don => Draw out a Hash?, array? hashes? that will help:
|
20
|
+
|
21
|
+
{}
|
22
|
+
|
23
|
+
[{:rank => 2, :name => "Black Box", :varietal => "Red Blend" :details => [price, rating, vinatge]},{}]
|
24
|
+
|
25
|
+
[{:rank => 2, :name => "Black Box", :varietal => "Red Blend" :details => {:price => $5, :rating => 80, :vinatage => 2014}},{}]
|
26
|
+
|
27
|
+
[{:rank => 2, :name => "Black Box", :varietal => "Red Blend", :price => $5, :rating => 80, :vinatage => 2014},{}]
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sommeligem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- febbraiod
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: open-uri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: nokogiri
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: launchy
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- donedesign1@gmail.com
|
114
|
+
executables:
|
115
|
+
- sommeligem
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- CODE_OF_CONDUCT.md
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/console
|
126
|
+
- bin/setup
|
127
|
+
- bin/sommeligem
|
128
|
+
- lib/sommeligem.rb
|
129
|
+
- lib/sommeligem/som_cli.rb
|
130
|
+
- lib/sommeligem/version.rb
|
131
|
+
- lib/sommeligem/wine_scraper.rb
|
132
|
+
- sommeligem.gemspec
|
133
|
+
- sommeligem_outline
|
134
|
+
homepage: https://github.com/febbraiod/sommeligem.git
|
135
|
+
licenses:
|
136
|
+
- MIT
|
137
|
+
metadata: {}
|
138
|
+
post_install_message:
|
139
|
+
rdoc_options: []
|
140
|
+
require_paths:
|
141
|
+
- lib
|
142
|
+
- lib/sommeligem
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.4.5.1
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: a CLI gem that provides information about the top 100 wines on Wine.com including
|
159
|
+
suggested pairings
|
160
|
+
test_files: []
|