halliday_wine_list 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/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +45 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/halliday_wine_list +6 -0
- data/bin/setup +8 -0
- data/config/environment.rb +9 -0
- data/halliday_wine_list.gemspec +41 -0
- data/lib/halliday_wine_list/category.rb +37 -0
- data/lib/halliday_wine_list/cli.rb +92 -0
- data/lib/halliday_wine_list/scraper.rb +26 -0
- data/lib/halliday_wine_list/version.rb +3 -0
- data/lib/halliday_wine_list/wine.rb +28 -0
- data/lib/halliday_wine_list.rb +1 -0
- data/spec.md +11 -0
- metadata +136 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: d7d4c1e7d25c0d49b9077750422bee6a4ceb7e553d20e3320a94f6c4f47e13ee
|
|
4
|
+
data.tar.gz: 60deb9d1493b2d3d5b8f2904dec632640131ba3d15887be50413e9e7f3979941
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 65b150b8c0db408c79415cecc4815299bdb7527667d1e8ebc2763dffef4e4e66f497e2ed6bb9956d59b06e2a5af6632d4763effebb5d9c0a9b488ad1245731b2
|
|
7
|
+
data.tar.gz: 714cc1a702b1d82ada23ae6ea4fdb299074660d3cf35e3a5a6d7dec929c1c9f124f381cd661740565549bfebca2b61ad0738b6a8f16ab80eda6f8334fd162e01
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at 'remmy.lauren@gmail.com'. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
halliday_wine_list (0.1.0)
|
|
5
|
+
nokogiri
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: https://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
coderay (1.1.2)
|
|
11
|
+
diff-lcs (1.3)
|
|
12
|
+
method_source (0.9.0)
|
|
13
|
+
mini_portile2 (2.3.0)
|
|
14
|
+
nokogiri (1.8.1)
|
|
15
|
+
mini_portile2 (~> 2.3.0)
|
|
16
|
+
pry (0.11.3)
|
|
17
|
+
coderay (~> 1.1.0)
|
|
18
|
+
method_source (~> 0.9.0)
|
|
19
|
+
rake (10.4.2)
|
|
20
|
+
rspec (3.7.0)
|
|
21
|
+
rspec-core (~> 3.7.0)
|
|
22
|
+
rspec-expectations (~> 3.7.0)
|
|
23
|
+
rspec-mocks (~> 3.7.0)
|
|
24
|
+
rspec-core (3.7.0)
|
|
25
|
+
rspec-support (~> 3.7.0)
|
|
26
|
+
rspec-expectations (3.7.0)
|
|
27
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
28
|
+
rspec-support (~> 3.7.0)
|
|
29
|
+
rspec-mocks (3.7.0)
|
|
30
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
31
|
+
rspec-support (~> 3.7.0)
|
|
32
|
+
rspec-support (3.7.0)
|
|
33
|
+
|
|
34
|
+
PLATFORMS
|
|
35
|
+
ruby
|
|
36
|
+
|
|
37
|
+
DEPENDENCIES
|
|
38
|
+
bundler (~> 1.16)
|
|
39
|
+
halliday_wine_list!
|
|
40
|
+
pry
|
|
41
|
+
rake (~> 10.0)
|
|
42
|
+
rspec
|
|
43
|
+
|
|
44
|
+
BUNDLED WITH
|
|
45
|
+
1.16.0
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 Remmy Clay and Contributors
|
|
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
|
+
# HallidayWineList
|
|
2
|
+
|
|
3
|
+
This Ruby gem provides a CLI to view the red and white wines selected as part of the James Halliday Top 100 Wines of 2017. Users can select to view all wines, or view wines via category.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'halliday_wine_list'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install halliday_wine_list
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
Run halliday_wine_list after installing the gem
|
|
24
|
+
|
|
25
|
+
## Development
|
|
26
|
+
|
|
27
|
+
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.
|
|
28
|
+
|
|
29
|
+
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).
|
|
30
|
+
|
|
31
|
+
## Contributing
|
|
32
|
+
|
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/'remclay'/halliday_wine_list. 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.
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
38
|
+
|
|
39
|
+
## Code of Conduct
|
|
40
|
+
|
|
41
|
+
Everyone interacting in the HallidayWineList project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/'remclay'/halliday_wine_list/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "./config/environment"
|
|
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
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
require 'nokogiri'
|
|
3
|
+
#require 'pry'
|
|
4
|
+
|
|
5
|
+
require_relative '../lib/halliday_wine_list/version'
|
|
6
|
+
require_relative '../lib/halliday_wine_list/cli'
|
|
7
|
+
require_relative '../lib/halliday_wine_list/category'
|
|
8
|
+
require_relative '../lib/halliday_wine_list/wine'
|
|
9
|
+
require_relative '../lib/halliday_wine_list/scraper'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "halliday_wine_list/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "halliday_wine_list"
|
|
8
|
+
spec.version = HallidayWineList::VERSION
|
|
9
|
+
spec.authors = ["'Remmy Clay'"]
|
|
10
|
+
spec.email = ["'remmy.lauren@gmail.com'"]
|
|
11
|
+
|
|
12
|
+
spec.summary = "A gem that displays the red and white wines in the James Halliday Top 100 Wines of 2017."
|
|
13
|
+
spec.description = "A gem that retreives all red and white wines selected in the James Halliday Top 100 Wines of 2017 and displays those wines via category or lists all selections."
|
|
14
|
+
spec.homepage = "https://github.com/remclay/halliday_wine_list"
|
|
15
|
+
#Update to gem's website or public repo URL here.
|
|
16
|
+
spec.license = "MIT"
|
|
17
|
+
|
|
18
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
19
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
20
|
+
#if spec.respond_to?(:metadata)
|
|
21
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
|
22
|
+
#else
|
|
23
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
|
24
|
+
# "public gem pushes."
|
|
25
|
+
#end
|
|
26
|
+
|
|
27
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
28
|
+
f.match(%r{^(test|spec|features)/})
|
|
29
|
+
end
|
|
30
|
+
#spec.bindir = "exe"
|
|
31
|
+
spec.executables << "halliday_wine_list"
|
|
32
|
+
spec.require_paths = ["lib"]
|
|
33
|
+
|
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
36
|
+
spec.add_development_dependency "rspec"
|
|
37
|
+
spec.add_development_dependency "pry"
|
|
38
|
+
|
|
39
|
+
spec.add_dependency "nokogiri"
|
|
40
|
+
|
|
41
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
class HallidayWineList::Category
|
|
2
|
+
|
|
3
|
+
attr_reader :name, :url
|
|
4
|
+
|
|
5
|
+
@@all_categories = []
|
|
6
|
+
|
|
7
|
+
def self.all_categories
|
|
8
|
+
@@all_categories
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.print_categories
|
|
12
|
+
@@all_categories.each.with_index(1) {|c, i| puts "#{i} - #{c.name}"}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def initialize(name= nil, url= nil)
|
|
16
|
+
@wines = []
|
|
17
|
+
@name = name
|
|
18
|
+
@url = url
|
|
19
|
+
@@all_categories << self
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.new_from_scraper(name, url)
|
|
23
|
+
self.new(name, url)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.create_categories
|
|
27
|
+
HallidayWineList::Scraper.new.scrape_categories
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def add_wine(wine)
|
|
31
|
+
@wines << wine
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def print_wines
|
|
35
|
+
@wines.each.with_index(1) {|w, i| puts "#{i} #{w.winery} - #{w.variety} - #{w.location}."}
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
class HallidayWineList::CLI
|
|
2
|
+
|
|
3
|
+
def start
|
|
4
|
+
puts ""
|
|
5
|
+
puts "James Halliday's Top Wines for 2017"
|
|
6
|
+
puts "--------------------------------------------"
|
|
7
|
+
puts "Retrieving all red and white varieties from the 2017 selection.."
|
|
8
|
+
collect_data
|
|
9
|
+
choose_category
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def choose_category
|
|
13
|
+
categories = HallidayWineList::Category.all_categories
|
|
14
|
+
if categories.count == 0
|
|
15
|
+
site_error
|
|
16
|
+
else
|
|
17
|
+
puts ""
|
|
18
|
+
puts "Categories:"
|
|
19
|
+
list_categories
|
|
20
|
+
puts ""
|
|
21
|
+
puts "Select a category (1-#{categories.count}) to view the wines from that category, type 'list' to see all wines or type exit to leave."
|
|
22
|
+
@input = gets.strip.downcase
|
|
23
|
+
if users_choice >= 0 && users_choice < (categories.count)
|
|
24
|
+
puts ""
|
|
25
|
+
puts "Current selection: #{categories[users_choice].name}."
|
|
26
|
+
puts "--------------------------------------------"
|
|
27
|
+
print_category_wines
|
|
28
|
+
elsif @input == "exit"
|
|
29
|
+
goodbye
|
|
30
|
+
elsif @input == "list"
|
|
31
|
+
puts ""
|
|
32
|
+
puts "Current selection: all red and white wines from the 2017 selection."
|
|
33
|
+
puts "--------------------------------------------"
|
|
34
|
+
print_all_wines
|
|
35
|
+
else
|
|
36
|
+
puts ""
|
|
37
|
+
puts "Sorry, that input is not valid. Here are your options again."
|
|
38
|
+
choose_category
|
|
39
|
+
end
|
|
40
|
+
next_steps
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def next_steps
|
|
45
|
+
puts ""
|
|
46
|
+
puts "--------------------------------------------"
|
|
47
|
+
puts "What would you like to do next? (1-2)"
|
|
48
|
+
puts "1 View main menu"
|
|
49
|
+
puts "2 Exit"
|
|
50
|
+
input = gets.strip.to_i
|
|
51
|
+
if input == 1
|
|
52
|
+
choose_category
|
|
53
|
+
elsif input == 2
|
|
54
|
+
goodbye
|
|
55
|
+
else
|
|
56
|
+
puts ""
|
|
57
|
+
puts "Sorry, that input is not valid. Please enter a valid input (1-2)."
|
|
58
|
+
next_steps
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def site_error
|
|
63
|
+
puts ""
|
|
64
|
+
puts "We're sorry. There seems to be an issue with the James Halliday Top Wines 2017 website at this time. Please check back again later."
|
|
65
|
+
exit
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def print_category_wines
|
|
69
|
+
HallidayWineList::Category.all_categories[users_choice].print_wines
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def users_choice
|
|
73
|
+
@input.to_i - 1
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def goodbye
|
|
77
|
+
puts "We hope you found a wine to your liking! Enjoy often, enjoy responsibly."
|
|
78
|
+
exit
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def collect_data
|
|
82
|
+
HallidayWineList::Category.create_categories
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def list_categories
|
|
86
|
+
HallidayWineList::Category.print_categories
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def print_all_wines
|
|
90
|
+
HallidayWineList::Wine.print_wines
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class HallidayWineList::Scraper
|
|
2
|
+
|
|
3
|
+
def scrape_categories
|
|
4
|
+
doc = Nokogiri::HTML(open("https://www.winecompanion.com.au/wines/james-hallidays-top-100-wines-of-2017"))
|
|
5
|
+
doc.css("div.clearfix.bestofbest ul.listing-items h3.sub-title").each do |item|
|
|
6
|
+
name = item.css("a").text
|
|
7
|
+
@url = item.css("a").attr("href").value
|
|
8
|
+
if name.include?("red") || name.include?("white")
|
|
9
|
+
@current_category = HallidayWineList::Category.new_from_scraper(name, @url)
|
|
10
|
+
scrape_wines
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def scrape_wines
|
|
16
|
+
category_url = "https://www.winecompanion.com.au" + "#{@url}"
|
|
17
|
+
doc = Nokogiri::HTML(open(category_url))
|
|
18
|
+
doc.css("div.clearfix ul.listing-items div.info").each do |item|
|
|
19
|
+
winery = item.css("p.winery").text
|
|
20
|
+
variety = item.css("p.variety").text
|
|
21
|
+
location = item.css("p.location").text
|
|
22
|
+
category = @current_category
|
|
23
|
+
HallidayWineList::Wine.new_from_scraper(winery, variety, location, category)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class HallidayWineList::Wine
|
|
2
|
+
|
|
3
|
+
attr_accessor :category
|
|
4
|
+
attr_reader :winery, :variety, :location
|
|
5
|
+
|
|
6
|
+
@@all_wines = []
|
|
7
|
+
|
|
8
|
+
def self.all_wines
|
|
9
|
+
@@all_wines
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.print_wines
|
|
13
|
+
@@all_wines.each.with_index(1) {|w, i| puts "#{i} #{w.winery} - #{w.variety} - #{w.location}."}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def initialize(winery= nil, variety= nil, location= nil, category)
|
|
17
|
+
@winery = winery
|
|
18
|
+
@variety = variety
|
|
19
|
+
@location = location
|
|
20
|
+
@@all_wines << self
|
|
21
|
+
self.category = category
|
|
22
|
+
category.add_wine(self)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.new_from_scraper(winery, variety, location, category)
|
|
26
|
+
self.new(winery, variety, location, category)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require_relative '../config/environment'
|
data/spec.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Specifications for the CLI Assessment
|
|
2
|
+
|
|
3
|
+
Specs:
|
|
4
|
+
- [x] Have a CLI for interfacing with the application
|
|
5
|
+
HallidayWineList::CLI class encapsulates the CLI. The CLI class displays messages to the user (including welcome message, main menu, next steps menu and farewell message), receives user input in response to those messages (via gets) and calls the method(s) applicable to the user input.
|
|
6
|
+
|
|
7
|
+
- [x] Pull data from an external source
|
|
8
|
+
The HallidayWineList::Scraper class is responsible for scraping the 'Wine Companion' website to retrieve the applicable categories of red and white wines. Each category has a unique URL path, which is then used to scrape the wines within that category.
|
|
9
|
+
|
|
10
|
+
- [x] Implement both list and detail views
|
|
11
|
+
The categories are displayed in a list (via HallidayWineList::Categories.print_categories). Once the user selects a category, or opts to view all wines, the applicable wines are displayed in detail (winery - variety} - location).
|
metadata
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: halliday_wine_list
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- "'Remmy Clay'"
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-01-24 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.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
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: '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: 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: A gem that retreives all red and white wines selected in the James Halliday
|
|
84
|
+
Top 100 Wines of 2017 and displays those wines via category or lists all selections.
|
|
85
|
+
email:
|
|
86
|
+
- "'remmy.lauren@gmail.com'"
|
|
87
|
+
executables:
|
|
88
|
+
- halliday_wine_list
|
|
89
|
+
extensions: []
|
|
90
|
+
extra_rdoc_files: []
|
|
91
|
+
files:
|
|
92
|
+
- ".gitignore"
|
|
93
|
+
- CODE_OF_CONDUCT.md
|
|
94
|
+
- Gemfile
|
|
95
|
+
- Gemfile.lock
|
|
96
|
+
- LICENSE.txt
|
|
97
|
+
- README.md
|
|
98
|
+
- Rakefile
|
|
99
|
+
- bin/console
|
|
100
|
+
- bin/halliday_wine_list
|
|
101
|
+
- bin/setup
|
|
102
|
+
- config/environment.rb
|
|
103
|
+
- halliday_wine_list.gemspec
|
|
104
|
+
- lib/halliday_wine_list.rb
|
|
105
|
+
- lib/halliday_wine_list/category.rb
|
|
106
|
+
- lib/halliday_wine_list/cli.rb
|
|
107
|
+
- lib/halliday_wine_list/scraper.rb
|
|
108
|
+
- lib/halliday_wine_list/version.rb
|
|
109
|
+
- lib/halliday_wine_list/wine.rb
|
|
110
|
+
- spec.md
|
|
111
|
+
homepage: https://github.com/remclay/halliday_wine_list
|
|
112
|
+
licenses:
|
|
113
|
+
- MIT
|
|
114
|
+
metadata: {}
|
|
115
|
+
post_install_message:
|
|
116
|
+
rdoc_options: []
|
|
117
|
+
require_paths:
|
|
118
|
+
- lib
|
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
|
+
requirements:
|
|
121
|
+
- - ">="
|
|
122
|
+
- !ruby/object:Gem::Version
|
|
123
|
+
version: '0'
|
|
124
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
|
+
requirements:
|
|
126
|
+
- - ">="
|
|
127
|
+
- !ruby/object:Gem::Version
|
|
128
|
+
version: '0'
|
|
129
|
+
requirements: []
|
|
130
|
+
rubyforge_project:
|
|
131
|
+
rubygems_version: 2.7.4
|
|
132
|
+
signing_key:
|
|
133
|
+
specification_version: 4
|
|
134
|
+
summary: A gem that displays the red and white wines in the James Halliday Top 100
|
|
135
|
+
Wines of 2017.
|
|
136
|
+
test_files: []
|