veg_out 0.2.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f9ec04b4e397038b13b11c6380f49d6278db1464299802e3b9cd91f37da17541
4
+ data.tar.gz: b72914342548ac72cd51a0b788b2d2a46998b1e470357632a5757e845d908c55
5
+ SHA512:
6
+ metadata.gz: 60c8ad6ee65713399db758024509c6d2bbb6c659c14d9f2d3dc1aef87618c7394d415781712242e05e1107f1f68374437c60c0f3ab2dceb1e4afbdb26643cb6b
7
+ data.tar.gz: 186354c9195405a17e5d35c2f411079ec15fdd53c1f35971648ade970a1ffe8f6e23c8a841651009c3b823a17e96828921feba8b64c64085aa9b45b8c7268295
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/veg_out/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.3
5
+ before_install: gem install bundler -v 1.16.0
@@ -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 <github email address>. 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/veg_out/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/Bartekswistak/veg-out-cli-app" }
4
+
5
+ # Specify your gem's dependencies in veg_out.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 <github username>
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/veg_out/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # VegOut
2
+
3
+ Command Line Interface application to find nearby vegan and vegetarian restaurants.
4
+
5
+ This is my first application I will be building from scratch.
6
+
7
+ How it should work:
8
+
9
+ Welcome the user to Veg Out
10
+ Takes user input "zip code or city/state" and return a list of nearby restaurants that offer vegan/vegetarian options.
11
+ Asks user if they will like more info on a listed restaurant and will list details such as description, address, phone number, etc..
12
+ Source website I will be scraping from is HappyCow.com
13
+
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```ruby
20
+ gem 'veg_out'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ $ bundle
26
+
27
+ Or install it yourself as:
28
+
29
+ $ gem install veg_out
30
+
31
+ ## Usage
32
+
33
+ After being greeted, user can input either city/state location or 5 digit zip code. If there are no
34
+ restaurants in the area, user will be notified and asked for another area. Once an area has restaurants
35
+ to show, a numbered list will be displayed with the distance from the location inputted. Next user can select the number of the restaurant the user would like more information on.
36
+ User can then type 'back' to search a new area, 'list' to show the list again of nearby restaurants or
37
+ 'quit' to exit the application. These options are available the moment of showing the details of a specific restaurant.
38
+
39
+ ## Development
40
+
41
+ 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.
42
+
43
+ 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).
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Bartekswistak/veg-out-cli-app 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.
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
52
+
53
+ ## Code of Conduct
54
+
55
+ Everyone interacting in the VegOut project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<github username>/veg_out/blob/master/CODE_OF_CONDUCT.md).
data/veg_out/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "veg_out"
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/veg_out/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/enviro"
4
+
5
+ VegOut::CLI.new.call
@@ -0,0 +1,8 @@
1
+ require 'pry'
2
+ require 'nokogiri'
3
+ require 'open-uri'
4
+
5
+ require_relative './veg_out/version'
6
+ require_relative './veg_out/scraper.rb'
7
+ require_relative './veg_out/restaurant.rb'
8
+ require_relative './veg_out/cli.rb'
@@ -0,0 +1,88 @@
1
+ class VegOut::CLI
2
+
3
+ def call
4
+ puts <<~eos
5
+
6
+ ------------------
7
+ Welcome to Veg Out
8
+ ------------------
9
+
10
+ The best place to find vegan and vegetarian restaurants near you!!
11
+
12
+ eos
13
+ start
14
+ end
15
+
16
+ def start
17
+ puts ""
18
+ puts "Please enter the name of your city, or a 5 digit zip code:"
19
+
20
+ VegOut::Scraper.get_page
21
+ end
22
+
23
+ def self.create_list
24
+ puts <<~eos
25
+
26
+ ----------------------------------------------
27
+ Here are places with options to eat near you!!
28
+ ----------------------------------------------
29
+
30
+ eos
31
+
32
+ VegOut::Scraper::restaurants.each_with_index.map {|n, index| puts "#{index+1}. #{n} -- #{VegOut::Scraper::distance[index]} away" }
33
+
34
+ self.show_details
35
+ end
36
+
37
+ def self.more_info
38
+ puts <<~eos
39
+ If you would like to see the list of restaurants again type 'list'
40
+ To search a new area type 'back' or type 'quit' to exit
41
+ eos
42
+
43
+ input = gets.strip
44
+ case input
45
+ when "back"
46
+ VegOut::CLI.new.start
47
+ when "quit"
48
+ exit
49
+ when "list"
50
+ self.create_list
51
+ else
52
+ puts ""
53
+ puts "Not a valid choice!"
54
+ self.more_info
55
+ end
56
+ end
57
+
58
+ def self.show_details
59
+ puts ""
60
+ puts "Which restaurant are you interested in learning more about:"
61
+ VegOut::Scraper.find_details_page
62
+ end
63
+
64
+ def self.more_details
65
+ VegOut::Scraper.create_restaurant
66
+
67
+ VegOut::Scraper::name.size.times {print "~"}
68
+ puts ""
69
+ puts VegOut::Scraper::name
70
+ VegOut::Scraper::name.size.times {print "~"}
71
+ puts ""
72
+ puts VegOut::Scraper::description
73
+ puts ""
74
+ puts "Contact Info:"
75
+ puts VegOut::Scraper::phone
76
+ puts ""
77
+ puts "Location:"
78
+ puts VegOut::Scraper::address
79
+ puts ""
80
+ self.more_info
81
+ end
82
+
83
+ def self.retry
84
+ puts ""
85
+ puts "No nearby restaurants! Sorry!"
86
+ VegOut::CLI.new.start
87
+ end
88
+ end
@@ -0,0 +1,17 @@
1
+ class VegOut::Restaurant
2
+ attr_accessor :name, :distance, :address, :phone, :description
3
+
4
+ @@all = []
5
+
6
+ def initialize(name = nil, address = nil, phone = nil, description = nil)
7
+ @name = name
8
+ @address = address
9
+ @phone = phone
10
+ @description = description
11
+ @@all << self
12
+ end
13
+
14
+ def self.all
15
+ @@all
16
+ end
17
+ end
@@ -0,0 +1,47 @@
1
+ class VegOut::Scraper
2
+
3
+ def self.get_page
4
+ input = gets.strip.to_s
5
+ @doc = Nokogiri::HTML(open("https://www.happycow.net/searchmap?lat=&lng=&location=#{input}&vegan=true&vegetarian=true&vegfriendly=true&distance=20&distanceType=mi&limit=25"))
6
+ self.scrape_results
7
+ end
8
+
9
+ def self.create_restaurant(name = nil, address = nil, phone = nil, description = nil)
10
+ VegOut::Restaurant.new(
11
+ @name = @deets.css("h1.header__title").text,
12
+ @address = @deets.css("p.icon__text__desc").text.strip,
13
+ @phone = @deets.css("div.icon__text").children.css("span").first.text,
14
+ @description = @deets.css("div.venue__description.mb--3").children.css("p").text.gsub(/\s+/, " ").strip
15
+ )
16
+ class << self
17
+ attr_accessor :name, :address, :phone, :description
18
+ end
19
+ end
20
+
21
+ def self.scrape_results
22
+ @restaurants = @doc.css("h5").map {|name| name.text}.uniq
23
+ @distance = @doc.css("div.grid__group.js-venues").children.css("span.distance").map {|d| d.text}
24
+ class << self
25
+ attr_accessor :restaurants, :distance
26
+ end
27
+
28
+ if @restaurants != []
29
+ VegOut::CLI.create_list
30
+ else
31
+ VegOut::CLI.retry
32
+ end
33
+ end
34
+
35
+ def self.find_details_page
36
+ info = gets.strip.to_i
37
+
38
+ if info > @restaurants.size || info == 0
39
+ puts "Invalid choice. Select a number from the list above:"
40
+ self.find_details_page
41
+ else
42
+ details = @doc.css("div.thumbnail__box a").map {|link| link['href']}.uniq
43
+ @deets = Nokogiri::HTML(open("https://www.happycow.net" << details[info-1].to_s))
44
+ VegOut::CLI.more_details
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module VegOut
2
+ VERSION = "0.2.1"
3
+ end
@@ -0,0 +1,14 @@
1
+ require "bundler/setup"
2
+ require "veg_out"
3
+
4
+ RSpec.configure do |config|
5
+ # Enable flags like --only-failures and --next-failure
6
+ config.example_status_persistence_file_path = ".rspec_status"
7
+
8
+ # Disable RSpec exposing methods globally on `Module` and `main`
9
+ config.disable_monkey_patching!
10
+
11
+ config.expect_with :rspec do |c|
12
+ c.syntax = :expect
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ RSpec.describe VegOut do
2
+ it "has a version number" do
3
+ expect(VegOut::VERSION).not_to be nil
4
+ end
5
+
6
+ it "does something useful" do
7
+ expect(false).to eq(true)
8
+ end
9
+ end
data/veg_out/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
5
+ - [x] Pull data from an external source
6
+ - [x] Implement both list and detail views
@@ -0,0 +1,29 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "veg_out/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "veg_out"
8
+ spec.version = VegOut::VERSION
9
+ spec.authors = ["Bartek Swistak"]
10
+ spec.email = ["bartekswistak24@gmail.com"]
11
+
12
+ spec.summary = "Shows nearby vegan and vegetarian restaurants"
13
+ spec.description = "Takes user input and displays nearby restaurants with vegan/vegetarian options and provides more details on specific restaurants."
14
+ spec.homepage = "https://github.com/Bartekswistak/veg-out-cli-app"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.16"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "nokogiri", ">= 0"
28
+ spec.add_development_dependency "pry", ">= 0"
29
+ end
data/veg_out-0.1.0.gem ADDED
Binary file
data/veg_out-0.2.0.gem ADDED
Binary file
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: veg_out
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ platform: ruby
6
+ authors:
7
+ - Bartek Swistak
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-02-05 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: '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: nokogiri
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: pry
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
+ description: Takes user input and displays nearby restaurants with vegan/vegetarian
84
+ options and provides more details on specific restaurants.
85
+ email:
86
+ - bartekswistak24@gmail.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - veg_out-0.1.0.gem
92
+ - veg_out-0.2.0.gem
93
+ - veg_out/.gitignore
94
+ - veg_out/.rspec
95
+ - veg_out/.travis.yml
96
+ - veg_out/CODE_OF_CONDUCT.md
97
+ - veg_out/Gemfile
98
+ - veg_out/LICENSE.txt
99
+ - veg_out/README.md
100
+ - veg_out/Rakefile
101
+ - veg_out/bin/console
102
+ - veg_out/bin/setup
103
+ - veg_out/bin/veg-out
104
+ - veg_out/lib/enviro.rb
105
+ - veg_out/lib/veg_out/cli.rb
106
+ - veg_out/lib/veg_out/restaurant.rb
107
+ - veg_out/lib/veg_out/scraper.rb
108
+ - veg_out/lib/veg_out/version.rb
109
+ - veg_out/spec.md
110
+ - veg_out/spec/spec_helper.rb
111
+ - veg_out/spec/veg_out_spec.rb
112
+ - veg_out/veg_out.gemspec
113
+ homepage: https://github.com/Bartekswistak/veg-out-cli-app
114
+ licenses:
115
+ - MIT
116
+ metadata: {}
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.7.3
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Shows nearby vegan and vegetarian restaurants
137
+ test_files: []