Coffee_Hunt 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 3a49391514c16b845074b6a80ea95c7e309fec1c9508ddfdc99a1d5c23d64c82
4
+ data.tar.gz: 6f2e54160547e9c854c418d9467258090bb79fafbdc8399553edef58e4dc1f7d
5
+ SHA512:
6
+ metadata.gz: 0b7879a1cf386d8933028db0cb1517be112146b3fc122299dc8d84c7b5cb8ee85d0587c57b7afb25850dc954b7ea2b56e6a910ba6129a066b89052706a145d56
7
+ data.tar.gz: ac3b18bb6f3c82c6952cc517b485df24d6366e004071f36be9a9f577826b2ebe4667893eca59652713e2a0d1b632adc36df473c7842fdda2d7c1e1955f467cf2
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -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 [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
@@ -0,0 +1,38 @@
1
+
2
+ lib = File.expand_path("lib", __dir__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "coffee_hunt"
5
+
6
+ require_relative 'lib/coffee_hunt/version'
7
+
8
+
9
+ Gem::Specification.new do |spec|
10
+ spec.name = "Coffee_Hunt"
11
+ spec.version = CoffeeHunt::VERSION
12
+ spec.authors = ["angelastephens"]
13
+ spec.email = ["angelastephens317@gmail.com"]
14
+
15
+ spec.summary = %q{CLI Coffee shop gem}
16
+ spec.description = %q{A CLI that will help you on your hunt for the perfect cup of coffee.}
17
+ spec.homepage = "https://github.com/angelastephens/Coffee_Hunt"
18
+ spec.license = "MIT"
19
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
20
+
21
+ spec.metadata["homepage_uri"] = spec.homepage
22
+ spec.metadata["source_code_uri"] = spec.homepage
23
+
24
+
25
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+
29
+ spec.executables = ["coffee_hunt_cli"]
30
+ spec.require_paths = ["lib"]
31
+ spec.add_development_dependency "bundler", "~> 2.0"
32
+ spec.add_development_dependency "pry"
33
+ spec.add_dependency "http"
34
+ spec.add_development_dependency "rake", ">= 12.3.3"
35
+ end
36
+
37
+
38
+
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in Coffee_Hunt.gemspec
4
+ gemspec
5
+
6
+ # gem "rake", "~> 12.0"
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ Coffee_Hunt (0.1.0)
5
+ http
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.7.0)
11
+ public_suffix (>= 2.0.2, < 5.0)
12
+ coderay (1.1.3)
13
+ domain_name (0.5.20190701)
14
+ unf (>= 0.0.5, < 1.0.0)
15
+ ffi (1.13.1)
16
+ ffi-compiler (1.0.1)
17
+ ffi (>= 1.0.0)
18
+ rake
19
+ http (4.4.1)
20
+ addressable (~> 2.3)
21
+ http-cookie (~> 1.0)
22
+ http-form_data (~> 2.2)
23
+ http-parser (~> 1.2.0)
24
+ http-cookie (1.0.3)
25
+ domain_name (~> 0.5)
26
+ http-form_data (2.3.0)
27
+ http-parser (1.2.1)
28
+ ffi-compiler (>= 1.0, < 2.0)
29
+ method_source (1.0.0)
30
+ pry (0.13.1)
31
+ coderay (~> 1.1)
32
+ method_source (~> 1.0)
33
+ public_suffix (4.0.5)
34
+ rake (13.0.1)
35
+ unf (0.1.4)
36
+ unf_ext
37
+ unf_ext (0.0.7.7)
38
+
39
+ PLATFORMS
40
+ ruby
41
+
42
+ DEPENDENCIES
43
+ Coffee_Hunt!
44
+ bundler (~> 2.0)
45
+ pry
46
+ rake (>= 12.3.3)
47
+
48
+ BUNDLED WITH
49
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 <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.
@@ -0,0 +1,49 @@
1
+ # CoffeeHunt
2
+ Welcome!!!
3
+ Here is your new gem to help you find the perfect place to get coffee. This gem will help you to locate different coffee shops in a desired area and even show you ratings.
4
+ This gem is useful for finding caffinated beverages when you are struggling to function.
5
+
6
+
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'Coffee_Hunt'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle install
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install Coffee_Hunt
23
+
24
+ ## Usage
25
+
26
+ To get started using this gem simply type ./bin/coffee_hunt_cli and hit enter in your terminal.
27
+ Next you will be prompted to enter your location. This can be done by typing a City/State or zipcode.
28
+ The program will then return a list of coffee shops by location.
29
+ The user or aka coffee hunter will be promted to select a coffee shop to view further details.
30
+ Once the details have been received, the user can choose another number from the list, return back to the begining or exit.
31
+
32
+ ## Development
33
+
34
+ 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.
35
+
36
+ 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).
37
+
38
+ ## Contributing
39
+
40
+ Bug reports and pull requests are welcome on GitHub at https://github.com/<angelastephens>/Coffee_Hunt. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/<angelastephens>/Coffee_Hunt/blob/master/CODE_OF_CONDUCT.md).
41
+
42
+
43
+ ## License
44
+
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
46
+
47
+ ## Code of Conduct
48
+
49
+ Everyone interacting in the CoffeeHunt project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<angelastephens>/Coffee_Hunt/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "pry"
5
+ require_relative "../lib/coffee_hunt"
6
+
7
+ CoffeeHunt::CLI.new.start_hunt
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "coffee_hunt"
5
+
6
+ require "pry"
7
+
8
+
9
+ # You can add fixtures and/or initialization code here to make experimenting
10
+ # with your gem easier. You can also use a different console, if you like.
11
+
12
+ # (If you use this, don't forget to add pry to your Gemfile!)
13
+ # require "pry"
14
+ # Pry.start
15
+
16
+ require "irb"
17
+ IRB.start(__FILE__)
@@ -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,13 @@
1
+ require "net/http"
2
+ require "coffee_hunt/version"
3
+ require_relative "coffee_hunt/api"
4
+ require_relative "coffee_hunt/cli"
5
+ require_relative "coffee_hunt/coffee_shop"
6
+ # require "http"
7
+
8
+
9
+ module CoffeeHunt
10
+ class Error < StandardError;
11
+ end
12
+ # Your code goes here...
13
+ end
@@ -0,0 +1,41 @@
1
+ require 'open-uri'
2
+ require 'json'
3
+ require 'http'
4
+
5
+ module CoffeeHunt
6
+
7
+ class API
8
+
9
+ API_HOST = "https://api.yelp.com"
10
+ SEARCH_PATH = "/v3/businesses/search"
11
+ BUSINESS_PATH = "/v3/businesses/"
12
+
13
+ def self.api_key
14
+ begin
15
+ @@key = File.open(File.expand_path("~/.yelp-api-key")).read.strip
16
+ rescue
17
+ puts "Uh Oh! Looks like you are missing your Yelp API key! You can sign up for a new key and enter it or exit the CLI."
18
+ @@key = gets.strip
19
+ return if @@key == "exit"
20
+ File.open(File.expand_path("~/.yelp-api-key"), "w") do |file|
21
+ file.print @@key
22
+ end
23
+ end
24
+ @@key
25
+
26
+ end
27
+
28
+ def self.yelp_search(term, location)
29
+ url = "#{API_HOST}#{SEARCH_PATH}"
30
+ params = {
31
+ term: term,
32
+ location: location
33
+ }
34
+ response = HTTP.auth("Bearer #{api_key}").get(url, params: params)
35
+
36
+ JSON.parse(response)["businesses"]
37
+ end
38
+
39
+ end
40
+
41
+ end
@@ -0,0 +1,83 @@
1
+ require 'pry'
2
+ require 'colorize'
3
+
4
+ module CoffeeHunt
5
+
6
+ class CLI
7
+
8
+ def initialize
9
+ @input = " "
10
+ end
11
+
12
+ def start_hunt
13
+ puts "Welcome to Coffee Hunt CLI! ".colorize(:blue).bold
14
+ # puts "Please start by entering your location so we can give you coffee shop suggestions!"
15
+ # binding.pry
16
+ while @input != "exit"
17
+ pick_location
18
+ coffee_shop_operator unless @input == "exit"
19
+ end
20
+ farewell
21
+ end
22
+
23
+ def coffee_shop_operator
24
+ list_coffee_shops
25
+ make_a_selection
26
+ while @input != "exit" && @input != "back"
27
+ if valid?
28
+ @coffee_shop= CoffeeShop.find_by_number(@input)
29
+ puts @coffee_shop.details
30
+ puts "Smells like a great brew!".colorize(:green).bold
31
+ else
32
+ puts "That was a bad coffee bean! Please try another?".colorize(:red).bold
33
+ end
34
+ make_a_selection
35
+ end
36
+ end
37
+
38
+
39
+ def pick_location
40
+ puts "So we can help you find a tasty caffeinated beverage, please enter your location."
41
+ @input = gets.chomp
42
+ CoffeeShop.load_by_location(@input) unless @input == "exit"
43
+ if @input != "exit" && CoffeeShop.all.length == 0
44
+ puts "Please try again"
45
+ pick_location
46
+ end
47
+ end
48
+
49
+ def valid?
50
+ @input.to_i.between?(1,CoffeeShop.all.length)
51
+
52
+ end
53
+
54
+ def list_coffee_shops
55
+ CoffeeShop.all.each.with_index(1) do |coffee,index|
56
+ # binding.pry
57
+ puts "#{index}. #{coffee.name}"
58
+ end
59
+ end
60
+
61
+ def list_options
62
+ puts "Please select a coffee shop by number so you can receive more information!".colorize(:cyan)
63
+ puts "If you wish to exit please type 'exit!'"
64
+ puts "To select a different coffee shop please pick another number."
65
+ puts "Type 'back' to return to the main menu"
66
+ # puts "If you would like to return to the list of Coffee Shops then Enter 'back'."
67
+
68
+ end
69
+
70
+ def make_a_selection
71
+ list_options
72
+ @input = gets.strip
73
+ # start_hunt if @input == 'back'
74
+ end
75
+
76
+ def farewell
77
+ puts " Thanks for searching for tasty beverages! Happy coffee hunting!"
78
+ end
79
+
80
+
81
+ end
82
+
83
+ end
@@ -0,0 +1,53 @@
1
+ require 'pry'
2
+
3
+ module CoffeeHunt
4
+ class CoffeeShop
5
+
6
+ @@all = []
7
+
8
+ def self.all #access to the @@all array aka my getter method
9
+ @@all
10
+ end
11
+
12
+ def self.load_by_location(location) # returns my array of coffee shops
13
+ location_results = API.yelp_search("coffee shop", location)
14
+ if location_results != nil
15
+ @@all = self.create_from_results(location_results)
16
+ else
17
+ @@all = []
18
+ end
19
+ # binding.pry
20
+ end
21
+
22
+ def self.create_from_results(location_results) #returns the collection of coffee shops
23
+ location_results.map do |coffee_shop_hash|
24
+ self.new(coffee_shop_hash)
25
+ end
26
+ end
27
+
28
+ def self.find_by_number(n) # will return the coffee shop object
29
+ @@all[n.to_i-1]
30
+ end
31
+
32
+ def details #will display the information about the coffee shops
33
+ <<-HEREDOC
34
+ #{self.name.colorize(:yellow)}
35
+ #{self.location["display_address"].join("\n")}
36
+ #{self.phone}
37
+ Rating:#{self.rating}
38
+ HEREDOC
39
+ end
40
+
41
+ attr_accessor :name, :rating, :location, :price, :phone #defines attributes that are readable and writeable
42
+
43
+ def initialize(attributes={})
44
+ # binding.pry
45
+ attributes.each do |attribute_name,attribute_value|
46
+ if self.respond_to?("#{attribute_name}=")
47
+ self.send("#{attribute_name}=", attribute_value)
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ end
@@ -0,0 +1,3 @@
1
+ module CoffeeHunt
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Coffee_Hunt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - angelastephens
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-07-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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: http
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 12.3.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 12.3.3
69
+ description: A CLI that will help you on your hunt for the perfect cup of coffee.
70
+ email:
71
+ - angelastephens317@gmail.com
72
+ executables:
73
+ - coffee_hunt_cli
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - CODE_OF_CONDUCT.md
79
+ - Coffee_Hunt.gemspec
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/coffee_hunt_cli
86
+ - bin/console
87
+ - bin/setup
88
+ - lib/Coffee_Hunt.rb
89
+ - lib/Coffee_Hunt/api.rb
90
+ - lib/Coffee_Hunt/cli.rb
91
+ - lib/Coffee_Hunt/coffee_shop.rb
92
+ - lib/Coffee_Hunt/version.rb
93
+ homepage: https://github.com/angelastephens/Coffee_Hunt
94
+ licenses:
95
+ - MIT
96
+ metadata:
97
+ homepage_uri: https://github.com/angelastephens/Coffee_Hunt
98
+ source_code_uri: https://github.com/angelastephens/Coffee_Hunt
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: 2.3.0
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubygems_version: 3.1.4
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: CLI Coffee shop gem
118
+ test_files: []