pawesome_parks 0.1.2
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/bin/pawesome_parks +8 -0
- data/config/environment.rb +9 -0
- data/lib/pawesome_parks/api.rb +32 -0
- data/lib/pawesome_parks/cli.rb +149 -0
- data/lib/pawesome_parks/park.rb +51 -0
- data/lib/pawesome_parks.rb +8 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5b30e7f4c423b63566e93c01a62984a36c924cc9582e40647aae22957fcdd632
|
4
|
+
data.tar.gz: eaae4b9c6d2685705f7a50a6458fd8e89c6c9289c11351900d1cb3834d5169ea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 836c9c54900e541358c75533ad8f4c855bad871589041a65dc7bbf3b6ae923a0b8c0328400d174cfc0802e97c9a6bb0f6cee34e15f8c80f106388fcdf9ddcecc
|
7
|
+
data.tar.gz: c7cc5a210322d9bd1628b51091cbb8f509518072cd82c33c6e494f406d48f7ad37bbd5e1cf7cc2ee895bd2d72e01e0595780693ee9a5443802f5393f19387d3b
|
data/bin/pawesome_parks
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'json'
|
4
|
+
require 'colorize'
|
5
|
+
|
6
|
+
require_relative '../lib/pawesome_parks'
|
7
|
+
require_relative '../lib/pawesome_parks/cli'
|
8
|
+
require_relative '../lib/pawesome_parks/api'
|
9
|
+
require_relative '../lib/pawesome_parks/park'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
class PawesomeParks::API
|
3
|
+
def get_parks
|
4
|
+
# request to postman mock server to mimic error
|
5
|
+
# uri = URI.parse("https://2c64e826-c4ff-400d-b87c-edb154f6e8f6.mock.pstmn.io/mockdogparks")
|
6
|
+
|
7
|
+
uri = URI.parse("https://services1.arcgis.com/cNVyNtjGVZybOQWZ/arcgis/rest/services/Dog_off_leash_parks/FeatureServer/0/query?outFields=*&where=1%3D1&f=geojson")
|
8
|
+
response = Net::HTTP.get_response(uri)
|
9
|
+
if response.code == "200"
|
10
|
+
response.body
|
11
|
+
else
|
12
|
+
"error"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def make_parks
|
18
|
+
parks = JSON.parse(self.get_parks)
|
19
|
+
parks["features"].each do |park|
|
20
|
+
name = park["properties"]["ParkName"]
|
21
|
+
off_leash_description = park["properties"]["OffLeashDescription"]
|
22
|
+
off_leash_time = park["properties"]["OffLeashTime"]
|
23
|
+
street_address = park["properties"]["Street"]
|
24
|
+
suburb = park["properties"]["Suburb"]
|
25
|
+
postcode = park["properties"]["Postcode"]
|
26
|
+
PawesomeParks::Park.new name, off_leash_description, off_leash_time, street_address, suburb, postcode
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,149 @@
|
|
1
|
+
|
2
|
+
class PawesomeParks::CLI
|
3
|
+
def call
|
4
|
+
puts "\n\n
|
5
|
+
██████╗ █████╗ ██╗ ██╗███████╗███████╗ ██████╗ ███╗ ███╗███████╗ ██████╗ █████╗ ██████╗ ██╗ ██╗███████╗
|
6
|
+
██╔══██╗██╔══██╗██║ ██║██╔════╝██╔════╝██╔═══██╗████╗ ████║██╔════╝ ██╔══██╗██╔══██╗██╔══██╗██║ ██╔╝██╔════╝
|
7
|
+
██████╔╝███████║██║ █╗ ██║█████╗ ███████╗██║ ██║██╔████╔██║█████╗ ██████╔╝███████║██████╔╝█████╔╝ ███████╗
|
8
|
+
██╔═══╝ ██╔══██║██║███╗██║██╔══╝ ╚════██║██║ ██║██║╚██╔╝██║██╔══╝ ██╔═══╝ ██╔══██║██╔══██╗██╔═██╗ ╚════██║
|
9
|
+
██║ ██║ ██║╚███╔███╔╝███████╗███████║╚██████╔╝██║ ╚═╝ ██║███████╗ ██║ ██║ ██║██║ ██║██║ ██╗███████║
|
10
|
+
╚═╝ ╚═╝ ╚═╝ ╚══╝╚══╝ ╚══════╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝
|
11
|
+
\n".light_green
|
12
|
+
puts "\nWelcome to Pawesome Parks!\n\n"
|
13
|
+
puts "There are currently 51 dog-friendly parks within the City of Sydney council region in NSW, Australia. With a range of off-leash hours and other restrictions, this app will let you explore the most suitable park to take your furry friend!"
|
14
|
+
retrieve_dog_parks
|
15
|
+
end
|
16
|
+
|
17
|
+
def retrieve_dog_parks
|
18
|
+
num_of_retries = 0
|
19
|
+
until num_of_retries == 3 do
|
20
|
+
parks = PawesomeParks::API.new
|
21
|
+
if parks.get_parks == "error"
|
22
|
+
puts "\nSorry, there has been an error accessing City of Sydney's dog park information. Reattempting for you now... (reattempt #{num_of_retries + 1} / 3)".red
|
23
|
+
else
|
24
|
+
parks.make_parks
|
25
|
+
menu_selection
|
26
|
+
end
|
27
|
+
num_of_retries += 1
|
28
|
+
end
|
29
|
+
puts "\nUnfortunately we have been unable to access the information needed for this program to run and it will now be terminated.\n\n".red
|
30
|
+
exit
|
31
|
+
end
|
32
|
+
|
33
|
+
def menu_selection
|
34
|
+
|
35
|
+
loop do
|
36
|
+
choice = display_options
|
37
|
+
if choice == "1"
|
38
|
+
list_dog_parks
|
39
|
+
elsif choice == "2"
|
40
|
+
search_for_park
|
41
|
+
elsif choice == "3"
|
42
|
+
off_leash_hours
|
43
|
+
elsif choice.downcase == "exit"
|
44
|
+
exit_app
|
45
|
+
else
|
46
|
+
puts "\nSorry, that is an invalid selection, please enter another option:".light_green
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def display_options
|
52
|
+
puts "\nMenu:"
|
53
|
+
puts "1 - List all dog parks"
|
54
|
+
puts "2 - Search for dog parks by suburb or postcode"
|
55
|
+
puts "3 - View parks with unrestricted off-leash hours\n"
|
56
|
+
puts "\nPlease select an option from the menu above by entering '1', '2', or '3' below. You can also enter 'exit' to leave the application and 'menu' to bring up this menu at any time:".light_green
|
57
|
+
gets.strip.downcase
|
58
|
+
end
|
59
|
+
|
60
|
+
def list_dog_parks
|
61
|
+
puts "\nAll Dog Parks:\n"
|
62
|
+
PawesomeParks::Park.park_names.each { |park| puts park }
|
63
|
+
puts "\nEnter one of the above park names to see more details, or enter 'menu' to return to the main menu:".light_green
|
64
|
+
get_park_details_by_name
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_park_details_by_name
|
68
|
+
loop do
|
69
|
+
choice = gets.strip.downcase
|
70
|
+
names = PawesomeParks::Park.park_names.map { |name| name.downcase }
|
71
|
+
if names.include? choice
|
72
|
+
puts ""
|
73
|
+
chosen_park_instance = PawesomeParks::Park.find_by_name choice
|
74
|
+
print_park chosen_park_instance
|
75
|
+
puts "\nPlease enter another park name for more details or enter 'menu' to return to the main menu:".light_green
|
76
|
+
elsif choice == "exit"
|
77
|
+
exit_app
|
78
|
+
elsif choice == "menu"
|
79
|
+
menu_selection
|
80
|
+
else
|
81
|
+
puts "\nInvalid park name. Please enter a park name included in the list above:".light_green
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def search_for_park
|
87
|
+
puts "\nPlease enter a suburb name or postcode within the City of Sydney:".light_green
|
88
|
+
loop do
|
89
|
+
location = gets.strip.downcase
|
90
|
+
if location.to_i != 0
|
91
|
+
search_by_postcode location
|
92
|
+
puts "\nPlease enter another postcode or suburb name for park details, enter 'menu' to return to the main menu:".light_green
|
93
|
+
elsif location == "exit"
|
94
|
+
exit_app
|
95
|
+
elsif location == "menu"
|
96
|
+
menu_selection
|
97
|
+
else
|
98
|
+
search_by_suburb location
|
99
|
+
puts "\nPlease enter another suburb name or postcode for park details, enter 'menu' to return to the main menu:".light_green
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def search_by_postcode location
|
105
|
+
if PawesomeParks::Park.postcodes.include? location.to_i
|
106
|
+
parks = PawesomeParks::Park.find_by_postcode location.to_i
|
107
|
+
puts "\nDog parks at postcode #{location} include:\n\n"
|
108
|
+
parks.each { |park| print_park park }
|
109
|
+
else
|
110
|
+
puts "\nUnable to locate a dog park at that postcode. Postcodes with a dog park include:\n".light_green
|
111
|
+
puts PawesomeParks::Park.postcodes.each { |postcode| postcode }
|
112
|
+
puts ""
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def search_by_suburb location
|
117
|
+
if PawesomeParks::Park.suburbs.include? location
|
118
|
+
parks = PawesomeParks::Park.find_by_suburb location
|
119
|
+
puts "\nDog parks in #{location.capitalize} include:\n\n"
|
120
|
+
parks.each { |park| print_park park }
|
121
|
+
else
|
122
|
+
puts "\nUnable to locate a dog park at that suburb name. Suburbs with a dog park include:\n".light_green
|
123
|
+
PawesomeParks::Park.suburbs.each { |suburb| puts suburb.capitalize }
|
124
|
+
puts ""
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def off_leash_hours
|
129
|
+
puts "\nParks with unrestricted off-leash hours include:\n\n"
|
130
|
+
parks = PawesomeParks::Park.unrestricted_off_leash_hours
|
131
|
+
parks.each { |park| puts park.name }
|
132
|
+
puts "\nEnter one of the above parks name's to see more details, or enter 'menu' to return to the main menu:".light_green
|
133
|
+
get_park_details_by_name
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
def print_park park
|
138
|
+
puts "#{park.name}:
|
139
|
+
#{park.off_leash_description}
|
140
|
+
Address: #{park.street_address}, #{park.suburb}, #{park.postcode}\n\n"
|
141
|
+
end
|
142
|
+
|
143
|
+
def exit_app
|
144
|
+
puts "\nThank you for using Sydney's Pawesome Parks! Goodbye!\n\n"
|
145
|
+
exit
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
class PawesomeParks::Park
|
3
|
+
attr_reader :name, :off_leash_description, :off_leash_time, :street_address, :suburb, :postcode
|
4
|
+
|
5
|
+
@@all = []
|
6
|
+
|
7
|
+
def initialize name="Information unavailable", off_leash_description="Information unavailable", off_leash_time="Information unavailable", street_address="Information unavailable", suburb="Information unavailable", postcode="Information unavailable"
|
8
|
+
@name=name
|
9
|
+
@off_leash_description = off_leash_description
|
10
|
+
@off_leash_time = off_leash_time
|
11
|
+
@street_address = street_address
|
12
|
+
@suburb = suburb
|
13
|
+
@postcode = postcode
|
14
|
+
@@all << self
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.all
|
18
|
+
@@all
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.find_by_suburb suburb
|
22
|
+
self.all.select { |park| park.suburb.downcase == suburb }
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.find_by_postcode postcode
|
26
|
+
self.all.select { |park| park.postcode == postcode }
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.find_by_name name
|
30
|
+
self.all.find { |park| park.name.downcase == name }
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.unrestricted_off_leash_hours
|
34
|
+
self.all.select { |park| park.off_leash_time == "At all times"}
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.suburbs
|
38
|
+
suburbs = self.all.map { |park| park.suburb.downcase }
|
39
|
+
suburbs.uniq
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.postcodes
|
43
|
+
postcodes = self.all.map { |park| park.postcode }
|
44
|
+
postcodes.uniq
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.park_names
|
48
|
+
park_names = self.all.map { |park| park.name }
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pawesome_parks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Lauren Giordano
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-06-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: colorize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.1
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.1
|
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
|
+
description: Users can use Pawesome Parks to access information about dog-friendly
|
42
|
+
parks within the City of Sydney council region in Sydney, Australia. They can view
|
43
|
+
all parks and then select a park to access detailed park information such as location,
|
44
|
+
off-leash hours, and any other off-leash resitrctions. Users can also search for
|
45
|
+
parks by either postcode or suburb, and can access a list of dog parks that are
|
46
|
+
off-leash friendly 24 hours a day.
|
47
|
+
email:
|
48
|
+
- laurengiordano94@gmail.com
|
49
|
+
executables:
|
50
|
+
- pawesome_parks
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- bin/pawesome_parks
|
55
|
+
- config/environment.rb
|
56
|
+
- lib/pawesome_parks.rb
|
57
|
+
- lib/pawesome_parks/api.rb
|
58
|
+
- lib/pawesome_parks/cli.rb
|
59
|
+
- lib/pawesome_parks/park.rb
|
60
|
+
homepage: https://github.com/lagiordano/pawesome-parks
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.6.0
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubygems_version: 3.4.12
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Provides information about dog parks within the City of Sydney council area
|
83
|
+
in Sydney, Australia.
|
84
|
+
test_files: []
|