vegan-restaurant-finder 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 821366206ca6b656a33c963f402dcd92d41a79b7
|
4
|
+
data.tar.gz: 4ec48686e3f2aadeb1bc4ea0aeaf61271404509d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 52a65e7673ec0f1d65b6278cb2afef907ea6ee174d3d54c63463ef688313b9529a5721bd908503e43dced7961a845946a6460fbbb5c08a606b2360201d4351fd
|
7
|
+
data.tar.gz: a5fd34e2f9036cc6ae4149e6681756c099afc9cc29390c88619fdb0529e0c4696f73908d21c77159052d7fd765b239d5776bba2441797e8764a76681ddeff8f1
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class VeganRestaurantFinder
|
2
|
+
|
3
|
+
attr_accessor :postcode
|
4
|
+
|
5
|
+
def initialize(postcode = nil)
|
6
|
+
@postcode = postcode
|
7
|
+
call
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(postcode = nil)
|
11
|
+
puts "Welcome to Vegan Restaurant Finder!"
|
12
|
+
puts "Please enter your zip code. We will list your local vegan restaurants!"
|
13
|
+
|
14
|
+
postcode = gets.strip.to_i
|
15
|
+
|
16
|
+
|
17
|
+
@restaurants = VeganRestaurant.find_by_postcode(postcode)
|
18
|
+
list_restaurants(postcode)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
def list_restaurants(postcode)
|
24
|
+
@postcode = postcode
|
25
|
+
puts "************* Good news! The Following Establishments in #{@postcode} are 100% Vegan! *************"
|
26
|
+
|
27
|
+
puts ""
|
28
|
+
@restaurants.each_with_index do |restaurant, index| puts "#{index+1}. #{restaurant.name}"
|
29
|
+
end
|
30
|
+
more_information
|
31
|
+
end
|
32
|
+
|
33
|
+
def more_information
|
34
|
+
puts ""
|
35
|
+
puts "Want more information? Enter the index number of the restaurant you wish to see."
|
36
|
+
index = gets.strip.to_i-1
|
37
|
+
puts ""
|
38
|
+
|
39
|
+
if restaurant = @restaurants[index]
|
40
|
+
puts "Name: #{restaurant.name}"
|
41
|
+
puts "Address: #{restaurant.address1}"
|
42
|
+
puts "City: #{restaurant.city}"
|
43
|
+
puts "Region: #{restaurant.region}"
|
44
|
+
puts "Phone: #{restaurant.phone}"
|
45
|
+
puts "Description: #{restaurant.short_description}"
|
46
|
+
puts "Website: #{restaurant.website}"
|
47
|
+
else
|
48
|
+
puts "That's an invalid entry!"
|
49
|
+
end
|
50
|
+
|
51
|
+
puts ""
|
52
|
+
puts "Type 'back' to return to the list of restaurants. Enter any key to end this program."
|
53
|
+
|
54
|
+
input = gets.strip.downcase
|
55
|
+
|
56
|
+
if input == "back"
|
57
|
+
list_restaurants(postcode)
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
|
5
|
+
class VeganRestaurant
|
6
|
+
attr_accessor :name, :address1, :city, :region, :phone, :short_description, :website
|
7
|
+
|
8
|
+
def self.find_by_postcode(postcode)
|
9
|
+
# 1. constructs a request url
|
10
|
+
url = "http://www.vegguide.org/search/by-address/#{postcode}/filter/veg_level=5"
|
11
|
+
|
12
|
+
# 2. performs the request, get a string
|
13
|
+
json_response = open(url).read
|
14
|
+
|
15
|
+
# 3. parses the string into data the application can understand
|
16
|
+
vegan_data = JSON.parse(json_response)
|
17
|
+
|
18
|
+
vegan_data["entries"].map{|hash| self.new_from_hash(hash)}
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.new_from_hash(hash)
|
22
|
+
r = self.new
|
23
|
+
|
24
|
+
r.name = hash["name"]
|
25
|
+
r.address1 = hash["address1"]
|
26
|
+
r.city = hash["city"]
|
27
|
+
r.region = hash["region"]
|
28
|
+
r.phone = hash["phone"]
|
29
|
+
r.short_description = hash["short_description"]
|
30
|
+
r.website = hash["website"]
|
31
|
+
|
32
|
+
r
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vegan-restaurant-finder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shana Moore
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
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: open-uri
|
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
|
+
description: This gem finds local vegan restaurants.
|
56
|
+
email: shana.lavina.moore@gmail.com
|
57
|
+
executables:
|
58
|
+
- vegan-restaurant-finder
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- bin/vegan-restaurant-finder
|
63
|
+
- config/environment.rb
|
64
|
+
- lib/vegan-restaurant-finder.rb
|
65
|
+
- lib/vegan-restaurant-finder/cli.rb
|
66
|
+
- lib/vegan-restaurant-finder/vegan_restaurant.rb
|
67
|
+
homepage: http://rubygems.org/gems/vegan-restaurant-finder
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.4.8
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Enter your zip code to find local vegan restaurant options!
|
91
|
+
test_files: []
|