wiser-wine 0.1.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 +7 -0
- data/.DS_Store +0 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +47 -0
- data/LICENSE.txt +21 -0
- data/README.md +28 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/wiser-wine +5 -0
- data/lib/.DS_Store +0 -0
- data/lib/wiser_wine.rb +4 -0
- data/lib/wiser_wine/cli.rb +58 -0
- data/lib/wiser_wine/grape_variety.rb +67 -0
- data/lib/wiser_wine/version.rb +3 -0
- data/spec.md +6 -0
- data/wiser_wine.gemspec +28 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fc1b10879ed637e2cc071254a40156d506539483
|
4
|
+
data.tar.gz: 3b7cb664c267c2218798e2448fb2cf26a2c7412a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a347a6c5d0d784044b180d12025bc65a83288e0bfebb7352f8eb710781592ecbf848d062547dee7c7df09b3feecbf22a35ad33f6c00c4ae87f350c7760132495
|
7
|
+
data.tar.gz: 2e2c0c4cfb70fcd1abfedce9e82177baa6e844f501107cea67b5553cc48b261e7dfc551cfdaa3368b4132fe7a5015c75dc9591cc999c701f0ba013008ac80cde
|
data/.DS_Store
ADDED
Binary file
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wiser-wine (0.1.0)
|
5
|
+
nokogiri
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.1.1)
|
11
|
+
diff-lcs (1.3)
|
12
|
+
method_source (0.8.2)
|
13
|
+
mini_portile2 (2.2.0)
|
14
|
+
nokogiri (1.8.0)
|
15
|
+
mini_portile2 (~> 2.2.0)
|
16
|
+
pry (0.10.4)
|
17
|
+
coderay (~> 1.1.0)
|
18
|
+
method_source (~> 0.8.1)
|
19
|
+
slop (~> 3.4)
|
20
|
+
rake (10.4.2)
|
21
|
+
rspec (3.6.0)
|
22
|
+
rspec-core (~> 3.6.0)
|
23
|
+
rspec-expectations (~> 3.6.0)
|
24
|
+
rspec-mocks (~> 3.6.0)
|
25
|
+
rspec-core (3.6.0)
|
26
|
+
rspec-support (~> 3.6.0)
|
27
|
+
rspec-expectations (3.6.0)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.6.0)
|
30
|
+
rspec-mocks (3.6.0)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.6.0)
|
33
|
+
rspec-support (3.6.0)
|
34
|
+
slop (3.6.0)
|
35
|
+
|
36
|
+
PLATFORMS
|
37
|
+
ruby
|
38
|
+
|
39
|
+
DEPENDENCIES
|
40
|
+
bundler (~> 1.15)
|
41
|
+
pry
|
42
|
+
rake (~> 10.0)
|
43
|
+
rspec (~> 3.0)
|
44
|
+
wiser-wine!
|
45
|
+
|
46
|
+
BUNDLED WITH
|
47
|
+
1.15.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 TODO: Write your name
|
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,28 @@
|
|
1
|
+
# WiserWine
|
2
|
+
|
3
|
+
Wiser Wine is a ruby gem that scrapes a wine grape varieties list and details from Wikipedia.
|
4
|
+
Wiser Wine provides a CLI for the user to select a grape variety and view its color, descriptors, and regions.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
$ gem install wiser-wine
|
9
|
+
|
10
|
+
## Usage
|
11
|
+
|
12
|
+
Type the command below and follow the instructions.
|
13
|
+
|
14
|
+
$ wiser-wine
|
15
|
+
|
16
|
+
## Development
|
17
|
+
|
18
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
19
|
+
|
20
|
+
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).
|
21
|
+
|
22
|
+
## Contributing
|
23
|
+
|
24
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/denisedearman/wiser_wine.
|
25
|
+
|
26
|
+
## License
|
27
|
+
|
28
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "wiser_wine"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/bin/wiser-wine
ADDED
data/lib/.DS_Store
ADDED
Binary file
|
data/lib/wiser_wine.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
class WiserWine::CLI
|
2
|
+
def initialize
|
3
|
+
@grape_varieties = []
|
4
|
+
end
|
5
|
+
|
6
|
+
def call
|
7
|
+
menu
|
8
|
+
end
|
9
|
+
|
10
|
+
def welcome
|
11
|
+
puts "Welcome to Wiser Wine!"
|
12
|
+
end
|
13
|
+
|
14
|
+
def goodbye
|
15
|
+
puts "Goodbye friend!"
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
def list_grapes
|
20
|
+
if @grape_varieties.length == 0
|
21
|
+
puts "Fetching your grape list your patience is appreciated...."
|
22
|
+
@grape_varieties = WiserWine::GrapeVariety.all
|
23
|
+
end
|
24
|
+
@grape_varieties.each.with_index(1) do |grape , index|
|
25
|
+
puts "#{index}. #{grape.name}"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def menu
|
31
|
+
welcome
|
32
|
+
input = nil
|
33
|
+
while input != "exit"
|
34
|
+
puts "Enter the number for a wine grape variety to get more info or type exit to quit."
|
35
|
+
list_grapes
|
36
|
+
input = gets.strip.downcase
|
37
|
+
if input.to_i != 0 && input.to_i <= @grape_varieties.length
|
38
|
+
grape = @grape_varieties[input.to_i-1]
|
39
|
+
grape.print_details
|
40
|
+
puts "Would you like information about a different wine? Hit enter to continue or type 'no' to quit."
|
41
|
+
again = gets.strip.downcase
|
42
|
+
if again == "no"
|
43
|
+
input = "exit"
|
44
|
+
goodbye
|
45
|
+
end
|
46
|
+
elsif input == "exit"
|
47
|
+
goodbye
|
48
|
+
else
|
49
|
+
puts "I didn't understand what you wanted."
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
class WiserWine::GrapeVariety
|
2
|
+
require 'open-uri'
|
3
|
+
require 'openssl'
|
4
|
+
attr_accessor :name, :descriptors, :color, :url, :regions
|
5
|
+
def initialize
|
6
|
+
@descriptors = []
|
7
|
+
@regions = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def print_details
|
11
|
+
puts "#{self.name}\n\n"
|
12
|
+
if self.color
|
13
|
+
puts "Color: #{self.color}\n\n"
|
14
|
+
end
|
15
|
+
puts "Common descriptors for #{self.name} include: #{self.descriptors.join(", ")}\n\n"
|
16
|
+
if self.regions.length > 0
|
17
|
+
puts "Notable regions include: #{self.regions.join(", ")}\n\n"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.all
|
22
|
+
scrape_grapes
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
def self.scrape_grapes
|
27
|
+
scraped_grapes = []
|
28
|
+
url = "https://en.wikipedia.org/wiki/Wine_tasting"
|
29
|
+
doc = Nokogiri::HTML open(url)
|
30
|
+
tables = doc.css("table.multicol table.wikitable")
|
31
|
+
tables.each do |table|
|
32
|
+
rows = table.css("tr")
|
33
|
+
rows.each do |row|
|
34
|
+
name = row.css("td:first").text
|
35
|
+
descriptors = row.css("td:nth-child(2)").text
|
36
|
+
if name != ""
|
37
|
+
grape = self.new
|
38
|
+
grape.name = name
|
39
|
+
grape.descriptors = descriptors.split(", ")
|
40
|
+
grape.url = "https://en.wikipedia.org" << row.css("td:first a").attribute("href").text
|
41
|
+
scrape_grape_details(grape)
|
42
|
+
scraped_grapes << grape
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
scraped_grapes
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.scrape_grape_details(grape)
|
50
|
+
doc = Nokogiri::HTML open(grape.url)
|
51
|
+
table = doc.css("table.infobox")
|
52
|
+
rows = table.css("tr")
|
53
|
+
rows.each do |row|
|
54
|
+
if row.css("th").text.downcase.include?("color") || row.css("th").text.downcase.include?("colour")
|
55
|
+
grape.color = row.css("td").text
|
56
|
+
end
|
57
|
+
if row.css("th").text.downcase.include?("region")
|
58
|
+
grape.regions = row.css("td").text.split(", ")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
end
|
data/spec.md
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
# Specifications for the CLI Assessment
|
2
|
+
|
3
|
+
Specs:
|
4
|
+
- [x] Have a CLI for interfacing with the application - My CLI class provides menu options and instructions for the user
|
5
|
+
- [X] Pull data from an external source - I pull data from the Wikipedia wine tasting page and the pages for 36 different grape varieties.
|
6
|
+
- [X] Implement both list and detail views - The list view only includes the wine grapes list. The details view includes the tasting descriptors (also from the main wine tasting page), the grape color and regions (which both come from the individual grape's wikipedia page)
|
data/wiser_wine.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "wiser_wine/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "wiser-wine"
|
8
|
+
spec.version = WiserWine::VERSION
|
9
|
+
spec.authors = ["Denise Dearman"]
|
10
|
+
spec.email = "dearmandenise@gmail.com"
|
11
|
+
|
12
|
+
spec.summary = %q{This gem allows users to get a list of wine grape varieties and find out more information including descriptors, color, and regions.}
|
13
|
+
spec.homepage = "https://github.com/denisedearman/wiser-wine-cli-app"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
18
|
+
end
|
19
|
+
spec.executables << 'wiser-wine' #= spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
spec.add_development_dependency "pry"
|
26
|
+
|
27
|
+
spec.add_dependency "nokogiri"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wiser-wine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Denise Dearman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-06-25 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.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
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: nokogiri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description:
|
84
|
+
email: dearmandenise@gmail.com
|
85
|
+
executables:
|
86
|
+
- wiser-wine
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".DS_Store"
|
91
|
+
- Gemfile
|
92
|
+
- Gemfile.lock
|
93
|
+
- LICENSE.txt
|
94
|
+
- README.md
|
95
|
+
- Rakefile
|
96
|
+
- bin/console
|
97
|
+
- bin/setup
|
98
|
+
- bin/wiser-wine
|
99
|
+
- lib/.DS_Store
|
100
|
+
- lib/wiser_wine.rb
|
101
|
+
- lib/wiser_wine/cli.rb
|
102
|
+
- lib/wiser_wine/grape_variety.rb
|
103
|
+
- lib/wiser_wine/version.rb
|
104
|
+
- spec.md
|
105
|
+
- wiser_wine.gemspec
|
106
|
+
homepage: https://github.com/denisedearman/wiser-wine-cli-app
|
107
|
+
licenses:
|
108
|
+
- MIT
|
109
|
+
metadata: {}
|
110
|
+
post_install_message:
|
111
|
+
rdoc_options: []
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 2.6.12
|
127
|
+
signing_key:
|
128
|
+
specification_version: 4
|
129
|
+
summary: This gem allows users to get a list of wine grape varieties and find out
|
130
|
+
more information including descriptors, color, and regions.
|
131
|
+
test_files: []
|