run-swim-hike-nyc 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/NOTES.markdown +10 -0
- data/README.md +45 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/run-swim-hike +5 -0
- data/bin/setup +8 -0
- data/lib/run-swim-hike-nyc.rb +11 -0
- data/lib/run-swim-hike-nyc/cli.rb +231 -0
- data/lib/run-swim-hike-nyc/hike.rb +113 -0
- data/lib/run-swim-hike-nyc/hike_scraper.rb +142 -0
- data/lib/run-swim-hike-nyc/run.rb +114 -0
- data/lib/run-swim-hike-nyc/run_scraper.rb +197 -0
- data/lib/run-swim-hike-nyc/swim.rb +138 -0
- data/lib/run-swim-hike-nyc/swim_scraper.rb +169 -0
- data/lib/run-swim-hike-nyc/version.rb +3 -0
- data/run-swim-hike-nyc.gemspec +35 -0
- metadata +164 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 14bc9ff9c15f69897486080615711da65502bea3
|
4
|
+
data.tar.gz: 860ad250a91904ae4729971f34ab42d9517fd772
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fce93725803513c1f5726a460fd02679c454b38dc68dbb76e27d8f9b15901bf9f9d96d64cea6dd5ce19ae9c1553765f01c8698910a9f069b567d0d84177270d5
|
7
|
+
data.tar.gz: 66e08b30bd60be4f4f54ba3e8ce24a542a9b87c1506d71381836c065288522221533dfbeb9703f8bd781d50c50f80431fe19e1837dd3116233aa36e517ec6ef0
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at brennenawana108ny@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 the-widget
|
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/NOTES.markdown
ADDED
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# RunSwimHikeNYC
|
2
|
+
|
3
|
+
Welcome to RunSwimHikeNYC! This is a simple CLI Gem allowing you to discover all the places to Run, Swim or Hike in all five boroughs of NYC. All information is provided by and scraped from http://www.nycgovparks.org/
|
4
|
+
|
5
|
+
Enjoy, contribute and comment!
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'run-swim-hike-nyc'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install run-swim-hike-nyc
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Type 'run-swim-hike' in your command line to run gem.
|
26
|
+
|
27
|
+
Use the numbered menus to navigate:
|
28
|
+
- Type 'exit' at anytime to quit the program.
|
29
|
+
- Type 'reset' at anytime to return to the main menu.
|
30
|
+
|
31
|
+
## Development
|
32
|
+
|
33
|
+
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.
|
34
|
+
|
35
|
+
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).
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/run-swim-hike-nyc. 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.
|
40
|
+
|
41
|
+
|
42
|
+
## License
|
43
|
+
|
44
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
45
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "run-swim-hike-nyc"
|
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
|
data/bin/run-swim-hike
ADDED
data/bin/setup
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require_relative "./run-swim-hike-nyc/version"
|
2
|
+
require_relative "./run-swim-hike-nyc/cli"
|
3
|
+
require_relative "./run-swim-hike-nyc/run_scraper"
|
4
|
+
require_relative "./run-swim-hike-nyc/run"
|
5
|
+
require_relative "./run-swim-hike-nyc/swim_scraper"
|
6
|
+
require_relative "./run-swim-hike-nyc/swim"
|
7
|
+
require_relative "./run-swim-hike-nyc/hike_scraper"
|
8
|
+
require_relative "./run-swim-hike-nyc/hike"
|
9
|
+
|
10
|
+
module RunSwimHike
|
11
|
+
end
|
@@ -0,0 +1,231 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
class RunSwimHike::CLI
|
4
|
+
@@farewell = ["Have a nice day!", "Take care of yourself!", "You'll never regret some good excercise!", "Have fun!", "Thanks for checking us out!", "Keep running, swimming and hiking!", ":)"]
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
opening_greeting
|
8
|
+
end
|
9
|
+
|
10
|
+
def opening_greeting
|
11
|
+
puts " \n*** Welcome to RunSwimHike NYC! ***\n "
|
12
|
+
spinny
|
13
|
+
first_menu
|
14
|
+
end
|
15
|
+
|
16
|
+
def first_menu
|
17
|
+
puts "What would you like to do?"
|
18
|
+
puts "1. Run\n2. Swim\n3. Hike"
|
19
|
+
menu
|
20
|
+
end
|
21
|
+
|
22
|
+
def menu
|
23
|
+
input = gets.strip
|
24
|
+
if input.to_s == "1"
|
25
|
+
run_boroughs
|
26
|
+
elsif input.to_s == "2"
|
27
|
+
swim_boroughs
|
28
|
+
elsif input.to_s == "3"
|
29
|
+
hike_boroughs
|
30
|
+
elsif input == "exit"
|
31
|
+
quit
|
32
|
+
else
|
33
|
+
clear
|
34
|
+
puts " \n--------------------------------------\nPlease choose a number from the menu:\n--------------------------------------"
|
35
|
+
opening_greeting
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
####### RUN #######
|
40
|
+
def run_boroughs
|
41
|
+
RunScraper.new.call
|
42
|
+
run_menu
|
43
|
+
end
|
44
|
+
|
45
|
+
def run_menu
|
46
|
+
puts " \nWhere would you like to Run?"
|
47
|
+
puts " \n1. Bronx\n2. Brooklyn\n3. Manhattan\n4. Queens\n5. Staten Island"
|
48
|
+
spinny
|
49
|
+
borough = gets.strip
|
50
|
+
if borough.to_s == "1"
|
51
|
+
run_bronx
|
52
|
+
elsif borough.to_s == "2"
|
53
|
+
run_brooklyn
|
54
|
+
elsif borough.to_s == "3"
|
55
|
+
run_manhattan
|
56
|
+
elsif borough.to_s == "4"
|
57
|
+
run_queens
|
58
|
+
elsif borough.to_s == "5"
|
59
|
+
run_staten_island
|
60
|
+
elsif borough == "exit"
|
61
|
+
abort("Have a nice day!")
|
62
|
+
else
|
63
|
+
clear
|
64
|
+
puts " \n--------------------------------------\nPlease choose a number from the menu:\n--------------------------------------"
|
65
|
+
run_menu
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def run_bronx
|
71
|
+
puts " \n"
|
72
|
+
Run.load_borough("Bronx")
|
73
|
+
end
|
74
|
+
|
75
|
+
def run_brooklyn
|
76
|
+
puts " \n"
|
77
|
+
Run.load_borough("Brooklyn")
|
78
|
+
end
|
79
|
+
|
80
|
+
def run_manhattan
|
81
|
+
puts " \n"
|
82
|
+
Run.load_borough("Manhattan")
|
83
|
+
end
|
84
|
+
|
85
|
+
def run_queens
|
86
|
+
puts " \n"
|
87
|
+
Run.load_borough("Queens")
|
88
|
+
end
|
89
|
+
|
90
|
+
def run_staten_island
|
91
|
+
puts " \n"
|
92
|
+
Run.load_borough("Staten Island")
|
93
|
+
end
|
94
|
+
|
95
|
+
####### SWIM #######
|
96
|
+
|
97
|
+
def swim_boroughs
|
98
|
+
SwimScraper.new.call
|
99
|
+
swim_menu
|
100
|
+
end
|
101
|
+
|
102
|
+
def swim_menu
|
103
|
+
puts " \nWhere would you like to Swim?"
|
104
|
+
puts " \n1. Bronx\n2. Brooklyn\n3. Manhattan\n4. Queens\n5. Staten Island"
|
105
|
+
spinny
|
106
|
+
borough = gets.strip
|
107
|
+
if borough.to_s == "1"
|
108
|
+
swim_bronx
|
109
|
+
elsif borough.to_s == "2"
|
110
|
+
swim_brooklyn
|
111
|
+
elsif borough.to_s == "3"
|
112
|
+
swim_manhattan
|
113
|
+
elsif borough.to_s == "4"
|
114
|
+
swim_queens
|
115
|
+
elsif borough.to_s == "5"
|
116
|
+
swim_staten_island
|
117
|
+
elsif borough == "exit"
|
118
|
+
abort("Have a nice day!")
|
119
|
+
else
|
120
|
+
clear
|
121
|
+
puts " \n--------------------------------------\nPlease choose a number from the menu:\n--------------------------------------"
|
122
|
+
swim_menu
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
def swim_bronx
|
128
|
+
puts " \n"
|
129
|
+
Swim.load_borough("Bronx")
|
130
|
+
end
|
131
|
+
|
132
|
+
def swim_brooklyn
|
133
|
+
puts " \n"
|
134
|
+
Swim.load_borough("Brooklyn")
|
135
|
+
end
|
136
|
+
|
137
|
+
def swim_manhattan
|
138
|
+
puts " \n"
|
139
|
+
Swim.load_borough("Manhattan")
|
140
|
+
end
|
141
|
+
|
142
|
+
def swim_queens
|
143
|
+
puts " \n"
|
144
|
+
Swim.load_borough("Queens")
|
145
|
+
end
|
146
|
+
|
147
|
+
def swim_staten_island
|
148
|
+
puts " \n"
|
149
|
+
Swim.load_borough("Staten Island")
|
150
|
+
end
|
151
|
+
|
152
|
+
####### Hike #######
|
153
|
+
|
154
|
+
def hike_boroughs
|
155
|
+
HikeScraper.new.call
|
156
|
+
hike_menu
|
157
|
+
end
|
158
|
+
|
159
|
+
def hike_menu
|
160
|
+
puts " \nWhere would you like to Hike?"
|
161
|
+
puts " \n1. Bronx\n2. Brooklyn\n3. Manhattan\n4. Queens\n5. Staten Island"
|
162
|
+
spinny
|
163
|
+
borough = gets.strip
|
164
|
+
if borough.to_s == "1"
|
165
|
+
hike_bronx
|
166
|
+
elsif borough.to_s == "2"
|
167
|
+
hike_brooklyn
|
168
|
+
elsif borough.to_s == "3"
|
169
|
+
hike_manhattan
|
170
|
+
elsif borough.to_s == "4"
|
171
|
+
hike_queens
|
172
|
+
elsif borough.to_s == "5"
|
173
|
+
hike_staten_island
|
174
|
+
elsif borough == "exit"
|
175
|
+
abort("Have a nice day!")
|
176
|
+
else
|
177
|
+
clear
|
178
|
+
puts " \n--------------------------------------\nPlease choose a number from the menu:\n--------------------------------------"
|
179
|
+
swim_menu
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
|
184
|
+
def hike_bronx
|
185
|
+
puts " \n"
|
186
|
+
Hike.load_borough("Bronx")
|
187
|
+
end
|
188
|
+
|
189
|
+
def hike_brooklyn
|
190
|
+
puts " \n"
|
191
|
+
Hike.load_borough("Brooklyn")
|
192
|
+
end
|
193
|
+
|
194
|
+
def hike_manhattan
|
195
|
+
puts " \n"
|
196
|
+
Hike.load_borough("Manhattan")
|
197
|
+
end
|
198
|
+
|
199
|
+
def hike_queens
|
200
|
+
puts " \n"
|
201
|
+
Hike.load_borough("Queens")
|
202
|
+
end
|
203
|
+
|
204
|
+
def hike_staten_island
|
205
|
+
puts " \n"
|
206
|
+
Hike.load_borough("Staten Island")
|
207
|
+
end
|
208
|
+
|
209
|
+
####### EXTRA FEATURES #######
|
210
|
+
|
211
|
+
def clear
|
212
|
+
print "\e[2J\e[f"
|
213
|
+
end
|
214
|
+
|
215
|
+
def quit
|
216
|
+
puts " \n"
|
217
|
+
abort("#{@@farewell.sample} \n ")
|
218
|
+
end
|
219
|
+
|
220
|
+
def spinny
|
221
|
+
n=0
|
222
|
+
a=["-","\\","|","/"].cycle do |a|
|
223
|
+
print a
|
224
|
+
print "\b"
|
225
|
+
n+=1
|
226
|
+
sleep 0.1
|
227
|
+
break if (n % 6).zero?
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
require 'pry'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'launchy'
|
4
|
+
|
5
|
+
class Hike
|
6
|
+
attr_accessor :prop_id, :name, :location, :park_name, :length, :difficulty, :other_details, :accessible, :borough
|
7
|
+
@@farewell = ["Have a nice day!", "Take care of yourself!", "You'll never regret some good excercise!", "Have fun!", "Thanks for checking us out!", "Keep running, swimming and hiking!", ":)"]
|
8
|
+
@@all = []
|
9
|
+
@@parks = []
|
10
|
+
|
11
|
+
def initialize(name)
|
12
|
+
@name = name
|
13
|
+
@@all << self
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.all
|
17
|
+
@@all
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.parks
|
21
|
+
@@parks
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.reset
|
25
|
+
clear
|
26
|
+
@@all = []
|
27
|
+
@@parks = []
|
28
|
+
RunSwimHike::CLI.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.clear
|
32
|
+
print "\e[2J\e[f"
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.spinny
|
36
|
+
n=0
|
37
|
+
a=["-","\\","|","/"].cycle do |a|
|
38
|
+
print a
|
39
|
+
print "\b"
|
40
|
+
n+=1
|
41
|
+
sleep 0.1
|
42
|
+
break if (n % 6).zero?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.quit
|
47
|
+
puts " \n"
|
48
|
+
abort("#{@@farewell.sample} \n ")
|
49
|
+
end
|
50
|
+
|
51
|
+
####### HIKE LOGIC ######
|
52
|
+
|
53
|
+
def self.load_borough(cli_input)
|
54
|
+
self.all.each do |hike|
|
55
|
+
if hike.borough == cli_input
|
56
|
+
self.parks << hike unless self.parks.include?(hike)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
display_borough("#{self.parks[0].borough}")
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.display_borough(borough)
|
63
|
+
spinny
|
64
|
+
index = 0
|
65
|
+
puts " \nHere are the Hiking Paths in #{borough}: \n "
|
66
|
+
spinny
|
67
|
+
self.parks.each do |hike|
|
68
|
+
if hike.borough == borough
|
69
|
+
self.parks << hike unless self.parks.include?(hike)
|
70
|
+
puts "#{index+1}. #{hike.name} - #{hike.location}"
|
71
|
+
index += 1
|
72
|
+
sleep(0.04)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
spinny
|
76
|
+
puts " \nSelect a number for more information:"
|
77
|
+
spinny
|
78
|
+
input = gets.strip
|
79
|
+
if input.to_i != 0 && input.to_i <= self.parks.size
|
80
|
+
park_select(input)
|
81
|
+
elsif input == "exit"
|
82
|
+
quit
|
83
|
+
elsif input == "reset"
|
84
|
+
reset
|
85
|
+
else
|
86
|
+
clear
|
87
|
+
puts " \n--------------------------------------\nPlease choose a number from the menu:\n--------------------------------------"
|
88
|
+
display_borough("#{self.park_select[0].borough}")
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def self.park_select(cli_input)
|
93
|
+
clear
|
94
|
+
display = @@parks[cli_input.to_i-1]
|
95
|
+
puts " \n#{display.name}: \n \nBorough: #{display.borough} \nLocation: #{display.location} \nPark Name: #{display.park_name} \nLength: #{display.length} \nDifficulty: #{display.difficulty} \nOther Details: #{display.other_details} \nWheelchair Accessible: #{display.accessible} "
|
96
|
+
puts " \nOptions:\n'open' to display in Google Maps\n'back' to see search results in #{display.borough}\n'reset' to return to main menu"
|
97
|
+
input = gets.strip
|
98
|
+
if input == "open"
|
99
|
+
Launchy.open("https://www.google.com/maps/place/#{display.park_name}")
|
100
|
+
self.park_select(cli_input)
|
101
|
+
elsif input == "back"
|
102
|
+
clear
|
103
|
+
display_borough("#{display.borough}")
|
104
|
+
elsif input == "reset"
|
105
|
+
reset
|
106
|
+
elsif input == "exit"
|
107
|
+
quit
|
108
|
+
else
|
109
|
+
park_select(cli_input)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|