nyc_greenthumb_gardens 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +87 -0
- data/Gemfile +13 -0
- data/Gemfile.lock +68 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/Rakefile +4 -0
- data/bin/run.rb +4 -0
- data/config/environment.rb +9 -0
- data/lib/command_line_interface.rb +249 -0
- data/lib/garden.rb +74 -0
- data/lib/gardens.rb +8 -0
- data/lib/scraper.rb +26 -0
- data/lib/version.rb +5 -0
- data/nyc_greenthumb_gardens-0.1.0.gem +0 -0
- data/nyc_greenthumb_gardens.gemspec +36 -0
- metadata +63 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8a74cdfacfa0a205078141faf9036a000cab984800ed0d9797625ff8a60cebd4
|
4
|
+
data.tar.gz: 5c273e83cfac8545fe916a2892b861f1ce312ba85b491b081219729050dc348f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b805b486eb3f6844fd5a4c017b765365ec2ccd3ab188764308d8c6e45eb7f4fe8ba54edba991f589d5544b2301b9e2ad026bcfb6e45f1e3cfea6ef685afb70a8
|
7
|
+
data.tar.gz: 473c931c1ecedf1187b1adb8009a18e2155d661ae8239f3e0f08bc99612047e3506d484ab0e24d03aaca0d32193ee43b307fdbed9eb86751fe51184e866ec1d0
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Land Acknowledgement
|
4
|
+
We acknowledge that the land and data gathered are on the unceded land of the Lenape and Canarsie peoples. We acknowledge the Lenape and Canarsie communities, their elders both past and present, as well as future generations. This acknowledgement demonstrates a commitment to beginning the process of working to dismantle the ongoing legacies of settler colonialism.
|
5
|
+
|
6
|
+
## Our Pledge
|
7
|
+
|
8
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
9
|
+
|
10
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
15
|
+
|
16
|
+
* Demonstrating empathy and kindness toward other people
|
17
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
18
|
+
* Giving and gracefully accepting constructive feedback
|
19
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
20
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
21
|
+
|
22
|
+
Examples of unacceptable behavior include:
|
23
|
+
|
24
|
+
* The use of sexualized language or imagery, and sexual attention or
|
25
|
+
advances of any kind
|
26
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
27
|
+
* Public or private harassment
|
28
|
+
* Publishing others' private information, such as a physical or email
|
29
|
+
address, without their explicit permission
|
30
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
31
|
+
professional setting
|
32
|
+
|
33
|
+
## Enforcement Responsibilities
|
34
|
+
|
35
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
36
|
+
|
37
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
38
|
+
|
39
|
+
## Scope
|
40
|
+
|
41
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
42
|
+
|
43
|
+
## Enforcement
|
44
|
+
|
45
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at rachel.a.levinson@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
|
46
|
+
|
47
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
48
|
+
|
49
|
+
## Enforcement Guidelines
|
50
|
+
|
51
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
52
|
+
|
53
|
+
### 1. Correction
|
54
|
+
|
55
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
56
|
+
|
57
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
58
|
+
|
59
|
+
### 2. Warning
|
60
|
+
|
61
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
62
|
+
|
63
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
64
|
+
|
65
|
+
### 3. Temporary Ban
|
66
|
+
|
67
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
68
|
+
|
69
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
70
|
+
|
71
|
+
### 4. Permanent Ban
|
72
|
+
|
73
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
74
|
+
|
75
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
76
|
+
|
77
|
+
## Attribution
|
78
|
+
|
79
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
80
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
81
|
+
|
82
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
83
|
+
|
84
|
+
[homepage]: https://www.contributor-covenant.org
|
85
|
+
|
86
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
87
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in nyc-greenthumb-gardens.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "rake", "~> 13.0"
|
9
|
+
gem 'pry'
|
10
|
+
gem 'nokogiri', '1.10.8'
|
11
|
+
gem 'rspec'
|
12
|
+
gem 'httparty'
|
13
|
+
gem 'inkjet'
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
nyc_greenthumb_gardens (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activesupport (6.1.3.1)
|
10
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
11
|
+
i18n (>= 1.6, < 2)
|
12
|
+
minitest (>= 5.1)
|
13
|
+
tzinfo (~> 2.0)
|
14
|
+
zeitwerk (~> 2.3)
|
15
|
+
coderay (1.1.3)
|
16
|
+
concurrent-ruby (1.1.8)
|
17
|
+
diff-lcs (1.4.4)
|
18
|
+
httparty (0.18.1)
|
19
|
+
mime-types (~> 3.0)
|
20
|
+
multi_xml (>= 0.5.2)
|
21
|
+
i18n (1.8.10)
|
22
|
+
concurrent-ruby (~> 1.0)
|
23
|
+
inkjet (0.0.6)
|
24
|
+
activesupport
|
25
|
+
method_source (1.0.0)
|
26
|
+
mime-types (3.3.1)
|
27
|
+
mime-types-data (~> 3.2015)
|
28
|
+
mime-types-data (3.2021.0225)
|
29
|
+
mini_portile2 (2.4.0)
|
30
|
+
minitest (5.14.4)
|
31
|
+
multi_xml (0.6.0)
|
32
|
+
nokogiri (1.10.8)
|
33
|
+
mini_portile2 (~> 2.4.0)
|
34
|
+
pry (0.14.1)
|
35
|
+
coderay (~> 1.1)
|
36
|
+
method_source (~> 1.0)
|
37
|
+
rake (13.0.3)
|
38
|
+
rspec (3.10.0)
|
39
|
+
rspec-core (~> 3.10.0)
|
40
|
+
rspec-expectations (~> 3.10.0)
|
41
|
+
rspec-mocks (~> 3.10.0)
|
42
|
+
rspec-core (3.10.1)
|
43
|
+
rspec-support (~> 3.10.0)
|
44
|
+
rspec-expectations (3.10.1)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.10.0)
|
47
|
+
rspec-mocks (3.10.2)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.10.0)
|
50
|
+
rspec-support (3.10.2)
|
51
|
+
tzinfo (2.0.4)
|
52
|
+
concurrent-ruby (~> 1.0)
|
53
|
+
zeitwerk (2.4.2)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
x86_64-darwin-20
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
httparty
|
60
|
+
inkjet
|
61
|
+
nokogiri (= 1.10.8)
|
62
|
+
nyc_greenthumb_gardens!
|
63
|
+
pry
|
64
|
+
rake (~> 13.0)
|
65
|
+
rspec
|
66
|
+
|
67
|
+
BUNDLED WITH
|
68
|
+
2.2.16
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 minirachel
|
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/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# NycGreenthumbGardens
|
2
|
+
|
3
|
+
An app to learn about the GreenThumb gardens in New York City.
|
4
|
+
|
5
|
+
Current Features:
|
6
|
+
- Filter by borough
|
7
|
+
- Filter by ZIP code
|
8
|
+
- Run "reports" of park names and their ID numbers
|
9
|
+
- Run "report" of most populated zipcodes by borough or overall city
|
10
|
+
- Randomly pull one up a park to learn more
|
11
|
+
- Search by park name or ID number
|
12
|
+
- Data pulled from the City of New York's NYC Open Data API.
|
13
|
+
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'nyc_greenthumb_gardens'
|
21
|
+
```
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle install
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
$ gem install nyc-greenthumb-gardens
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
Run `bin/run.rb` in your console for an interactive CLI menu.
|
34
|
+
|
35
|
+
## Development
|
36
|
+
|
37
|
+
After checking out the repo, run `bundle install` to install dependencies. You can also run `bin/run.rb` for an interactive prompt that will allow you to experiment.
|
38
|
+
|
39
|
+
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).
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/minirachel/nyc-greenthumb-gardens. 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/minirachel/nyc-greenthumb-gardens/blob/master/CODE_OF_CONDUCT.md).
|
44
|
+
|
45
|
+
## License
|
46
|
+
|
47
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
48
|
+
|
49
|
+
## Code of Conduct
|
50
|
+
|
51
|
+
Everyone interacting in the NycGreenthumbGardens project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/minirachel/nyc-greenthumb-gardens/blob/master/CODE_OF_CONDUCT.md).
|
52
|
+
|
53
|
+
## Land Acknowledgement
|
54
|
+
|
55
|
+
We (the app creators and users) acknowledge that the land used for these gardens are on the unceded land of the Lenape and Canarsie peoples. We acknowledge the Lenape and Canarsie communities, their elders both past and present, as well as future generations. This acknowledgement demonstrates a commitment to beginning the process of working to dismantle the ongoing legacies of settler colonialism.
|
data/Rakefile
ADDED
data/bin/run.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.require
|
3
|
+
#requires all gems in gem file
|
4
|
+
|
5
|
+
require_relative '../lib/scraper.rb'
|
6
|
+
require_relative '../lib/garden.rb'
|
7
|
+
require_relative '../lib/command_line_interface.rb'
|
8
|
+
require_relative '../lib/version.rb'
|
9
|
+
# require_relative '../bin/run.rb'
|
@@ -0,0 +1,249 @@
|
|
1
|
+
require_relative '../config/environment.rb'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
class CommandLineInterface
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
Scraper.gardens_api
|
8
|
+
Scraper.garden_hashes
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
menu
|
13
|
+
end
|
14
|
+
|
15
|
+
def menu
|
16
|
+
input = ""
|
17
|
+
|
18
|
+
puts " "
|
19
|
+
puts "Welcome to the unofficial NYC Parks GreenThumb app".cyan.invert
|
20
|
+
puts "What are you interested in learning about today?".cyan.invert
|
21
|
+
puts " "
|
22
|
+
|
23
|
+
while input != "9"
|
24
|
+
puts "~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~"
|
25
|
+
puts " "
|
26
|
+
puts "[enter a number]".blue
|
27
|
+
puts "#{"[1]".cyan} #{"How many".cyan} gardens are there?"
|
28
|
+
puts "#{"[2]".cyan} Show me a (long) list of #{"all gardens".cyan} in the city, please."
|
29
|
+
puts "#{"[3]".cyan} Show me a list of the gardens #{"in my borough".cyan}."
|
30
|
+
puts "#{"[4]".cyan} Show me a list of the gardens #{"in my ZIP code".cyan}."
|
31
|
+
puts "#{"[5]".cyan} I'd like to see #{"a random garden".cyan}. Now."
|
32
|
+
puts "#{"[6]".cyan} I know my garden's name or ID number, can I #{"search for it".cyan}?"
|
33
|
+
puts "#{"[9]".cyan} Please, let me #{"exit".cyan}."
|
34
|
+
puts " "
|
35
|
+
|
36
|
+
input = gets.strip
|
37
|
+
case input
|
38
|
+
|
39
|
+
#How many?
|
40
|
+
when "1"
|
41
|
+
puts " "
|
42
|
+
puts "Great question! How would you like me to pull the report?"
|
43
|
+
puts " "
|
44
|
+
puts "#{"[1]".cyan} in all of New York City"
|
45
|
+
puts "#{"[2]".cyan} in my borough"
|
46
|
+
puts "#{"[3]".cyan} in my ZIP"
|
47
|
+
|
48
|
+
input = gets.strip
|
49
|
+
|
50
|
+
case input
|
51
|
+
#citywide count
|
52
|
+
when "1"
|
53
|
+
citywide_garden_count_report
|
54
|
+
|
55
|
+
#borough count
|
56
|
+
when "2"
|
57
|
+
puts " "
|
58
|
+
puts "Ok! Which borough are you in?"
|
59
|
+
puts "#{"[X]".cyan} Bronx"
|
60
|
+
puts "#{"[Q]".cyan} Queens"
|
61
|
+
puts "#{"[M]".cyan} Manhattan"
|
62
|
+
puts "#{"[B]".cyan} Brooklyn"
|
63
|
+
puts "#{"[R]".cyan} Staten Island"
|
64
|
+
|
65
|
+
input = gets.strip
|
66
|
+
|
67
|
+
until Garden.all.detect {|g| input == g.borough}
|
68
|
+
puts "That's not a borough. Please try again (maybe without brackets and capitalized?)."
|
69
|
+
input = gets.strip
|
70
|
+
end
|
71
|
+
|
72
|
+
puts "There are #{"#{Garden.filter_by_borough(input).count}".magenta} in #{"#{Garden.translate_borough(input)}".yellow}."
|
73
|
+
puts "The most vegetative ZIP codes in your borough are:"
|
74
|
+
puts " "
|
75
|
+
Garden.print_top_zipcodes(input)
|
76
|
+
|
77
|
+
puts " "
|
78
|
+
puts "~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~"
|
79
|
+
|
80
|
+
#zip count
|
81
|
+
when "3"
|
82
|
+
puts " "
|
83
|
+
puts "Ok! What is your ZIP code?"
|
84
|
+
|
85
|
+
input = gets.strip
|
86
|
+
|
87
|
+
until Garden.all.detect {|g| input == g.zipcode}
|
88
|
+
puts "I'm not finding that ZIP code in my system. Please try again. (stuck in a loop? 10031 has some good gardens)."
|
89
|
+
input = gets.strip
|
90
|
+
end
|
91
|
+
|
92
|
+
puts "There are #{"#{Garden.filter_by_zip(input).count}".magenta} GreenThumb Gardens in #{"#{input}".yellow}."
|
93
|
+
puts ""
|
94
|
+
puts "~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~"
|
95
|
+
zip_one_liner(input)
|
96
|
+
end
|
97
|
+
|
98
|
+
#all gardens
|
99
|
+
when "2"
|
100
|
+
all_gardens_detail
|
101
|
+
puts "this is a long report! scroll up to see all of the gardens in New York City #{":)".yellow}"
|
102
|
+
puts ""
|
103
|
+
|
104
|
+
#borough report
|
105
|
+
when "3"
|
106
|
+
puts " "
|
107
|
+
puts "Ok! Which borough are you in?"
|
108
|
+
puts "#{"[X]".cyan} Bronx"
|
109
|
+
puts "#{"[Q]".cyan} Queens"
|
110
|
+
puts "#{"[M]".cyan} Manhattan"
|
111
|
+
puts "#{"[B]".cyan} Brooklyn"
|
112
|
+
puts "#{"[R]".cyan} Staten Island"
|
113
|
+
|
114
|
+
|
115
|
+
input = gets.strip
|
116
|
+
|
117
|
+
until Garden.all.detect {|g| input == g.borough}
|
118
|
+
puts "That's not a borough. Please try again (maybe without brackets and capitalized?)."
|
119
|
+
input = gets.strip
|
120
|
+
end
|
121
|
+
|
122
|
+
puts "~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~"
|
123
|
+
puts " "
|
124
|
+
puts "Here is a list of garden names in your borough."
|
125
|
+
borough_one_liner(input)
|
126
|
+
|
127
|
+
puts "#{"this is a long report!".yellow} scroll up to see all of the gardens in #{Garden.translate_borough(input)} #{":)".yellow}"
|
128
|
+
puts ""
|
129
|
+
puts ""
|
130
|
+
puts ""
|
131
|
+
|
132
|
+
puts "#{"Type in the #{"garden ID".magenta} to learn more about a specific location:".cyan}"
|
133
|
+
puts ""
|
134
|
+
input = gets.strip
|
135
|
+
|
136
|
+
drill_down = find_by_parksid(input)
|
137
|
+
index_card(drill_down)
|
138
|
+
|
139
|
+
#zip report
|
140
|
+
when "4"
|
141
|
+
puts " "
|
142
|
+
puts "Ok! What is your ZIP code?"
|
143
|
+
input = gets.strip
|
144
|
+
|
145
|
+
until Garden.all.detect {|g| input == g.zipcode}
|
146
|
+
puts "I'm not finding that ZIP code in my system. Please try again. (stuck in a loop? 10031 has some good gardens)."
|
147
|
+
input = gets.strip
|
148
|
+
end
|
149
|
+
|
150
|
+
puts "~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~ * ~"
|
151
|
+
puts ""
|
152
|
+
puts "Here's a list of garden names in your borough."
|
153
|
+
zip_one_liner(input)
|
154
|
+
puts "#{"Type in the #{"garden ID".magenta} to learn more about a specific location:".cyan}"
|
155
|
+
input = gets.strip
|
156
|
+
|
157
|
+
drill_down = find_by_parksid(input)
|
158
|
+
index_card(drill_down)
|
159
|
+
|
160
|
+
#random report
|
161
|
+
when "5"
|
162
|
+
random_garden
|
163
|
+
|
164
|
+
#search
|
165
|
+
when "6"
|
166
|
+
puts "Type in the garden name or ID to pull up more info:"
|
167
|
+
input = gets.strip
|
168
|
+
search_function(input)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def search_function(input)
|
174
|
+
if find_by_gardenname(input)
|
175
|
+
found_garden = find_by_gardenname(input)
|
176
|
+
index_card(found_garden)
|
177
|
+
elsif find_by_parksid(input)
|
178
|
+
found_garden = find_by_parksid(input)
|
179
|
+
index_card(found_garden)
|
180
|
+
else
|
181
|
+
puts "Sorry, I can't find that park. Are you sure you're spelling it correctly? Try again:"
|
182
|
+
input = gets.strip
|
183
|
+
search_function(input)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
def all_gardens_detail
|
189
|
+
Garden.all.map {|g| index_card(g)}
|
190
|
+
end
|
191
|
+
|
192
|
+
def random_garden
|
193
|
+
index_card(Garden.all.sample)
|
194
|
+
end
|
195
|
+
|
196
|
+
def index_card(garden)
|
197
|
+
garden.tap do |g|
|
198
|
+
puts "- - - - - - - - - - - - - - - - - - - - - - - - - - "
|
199
|
+
puts ""
|
200
|
+
puts " ~*~ #{"#{g.gardenname}".blue} ~*~"
|
201
|
+
puts " #{"#{g.parksid}".magenta} (#{g.status})"
|
202
|
+
puts " #{Garden.translate_borough(g.borough)} - ZIP Code: #{"#{g.zipcode}".yellow}"
|
203
|
+
puts ""
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def borough_one_liner(input)
|
208
|
+
alphabatized_boroughs = Garden.filter_by_borough(input).sort_by {|g| g.gardenname}
|
209
|
+
|
210
|
+
alphabatized_boroughs.each do |g|
|
211
|
+
puts "~*~ #{"#{g.gardenname}".blue} - #{"#{g.parksid}".magenta}"
|
212
|
+
puts " "
|
213
|
+
end
|
214
|
+
|
215
|
+
end
|
216
|
+
|
217
|
+
def zip_one_liner(input)
|
218
|
+
Garden.filter_by_zip(input).map do |g|
|
219
|
+
puts "~*~ #{"#{g.gardenname}".blue} - #{"#{g.parksid}".magenta}"
|
220
|
+
puts " "
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def citywide_garden_count_report
|
225
|
+
puts " "
|
226
|
+
puts "There are a total of #{"#{Garden.all.count} gardens".magenta} in New York City."
|
227
|
+
puts " "
|
228
|
+
puts "Bronx: #{"#{Garden.filter_by_borough("X").count}".magenta}"
|
229
|
+
puts "Queens: #{"#{Garden.filter_by_borough("Q").count}".magenta}"
|
230
|
+
puts "Manhattan: #{"#{Garden.filter_by_borough("M").count}".magenta}"
|
231
|
+
puts "Brooklyn: #{"#{Garden.filter_by_borough("B").count}".magenta}"
|
232
|
+
puts "Staten Island: #{"#{Garden.filter_by_borough("M").count}".magenta}"
|
233
|
+
puts " "
|
234
|
+
puts "The most vegetative ZIP codes are:"
|
235
|
+
puts " "
|
236
|
+
Garden.print_top_zipcodes("all")
|
237
|
+
puts " "
|
238
|
+
end
|
239
|
+
|
240
|
+
def find_by_parksid(input)
|
241
|
+
Garden.all.detect {|g| g.parksid == input}
|
242
|
+
end
|
243
|
+
|
244
|
+
def find_by_gardenname(input)
|
245
|
+
Garden.all.detect {|g| g.gardenname == input}
|
246
|
+
end
|
247
|
+
|
248
|
+
|
249
|
+
end
|
data/lib/garden.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require_relative '../config/environment.rb'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
class Garden
|
5
|
+
attr_reader :borough, :gardenname, :multipolygon, :parksid, :status, :zipcode
|
6
|
+
|
7
|
+
@@all = []
|
8
|
+
|
9
|
+
def initialize (borough, gardenname, multipolygon, parksid, status, zipcode)
|
10
|
+
@borough = borough
|
11
|
+
@gardenname = gardenname
|
12
|
+
@multipolygon = multipolygon
|
13
|
+
@parksid = parksid
|
14
|
+
@status = status
|
15
|
+
@zipcode = zipcode
|
16
|
+
@@all << self
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.all
|
20
|
+
@@all
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def self.translate_borough(borough)
|
25
|
+
if borough == "B"
|
26
|
+
"Brooklyn"
|
27
|
+
elsif borough == "X"
|
28
|
+
"the Bronx"
|
29
|
+
elsif borough == "M"
|
30
|
+
"Manhattan"
|
31
|
+
elsif borough == "Q"
|
32
|
+
"Queens"
|
33
|
+
elsif borough == "R"
|
34
|
+
"Staten Island"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def self.filter_by_borough(borough)
|
40
|
+
if borough == "all"
|
41
|
+
@@all
|
42
|
+
else
|
43
|
+
@@all.select {|g| g.borough == borough}
|
44
|
+
end
|
45
|
+
|
46
|
+
#select creates a new array with all gardens (object IDs) that match it
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.filter_by_zip(zipcode)
|
50
|
+
@@all.select {|g| g.zipcode == zipcode}
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.filter_by_status(status)
|
54
|
+
@@all.select {|g| g.status == status}
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def self.zipcode_hash(borough)
|
59
|
+
zipcode_count = {}
|
60
|
+
|
61
|
+
self.filter_by_borough(borough).map do |g|
|
62
|
+
zipcode_count[g.zipcode] = self.filter_by_zip(g.zipcode).count
|
63
|
+
end
|
64
|
+
|
65
|
+
zipcode_count
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.print_top_zipcodes(borough)
|
69
|
+
highest_sorted_zipcodes = self.zipcode_hash(borough).sort_by{|k,v| v}.reverse
|
70
|
+
highest_sorted_zipcodes.first(5).map {|k,v| puts "#{"#{v}".magenta} gardens in #{"#{k}".yellow}".indent(4)}
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
end
|
data/lib/gardens.rb
ADDED
data/lib/scraper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative '../config/environment.rb'
|
2
|
+
require 'pry'
|
3
|
+
require 'httparty'
|
4
|
+
|
5
|
+
class Scraper
|
6
|
+
|
7
|
+
def self.gardens_api
|
8
|
+
site = 'https://data.cityofnewyork.us/resource/p78i-pat6.json'
|
9
|
+
page = HTTParty.get(site)
|
10
|
+
greenthumb_gardens = page.to_a
|
11
|
+
greenthumb_gardens
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.create_symbols
|
15
|
+
self.gardens_api.map do |gardens_hash|
|
16
|
+
gardens_hash.transform_keys(&:to_sym)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.garden_hashes
|
21
|
+
self.create_symbols.map do |g|
|
22
|
+
Garden.new(g[:borough], g[:gardenname], g[:multipolygon], g[:parksid], g[:status], g[:zipcode])
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
data/lib/version.rb
ADDED
Binary file
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "nyc_greenthumb_gardens"
|
7
|
+
spec.version = NycGreenthumbGardens::VERSION
|
8
|
+
spec.authors = ["minirachel"]
|
9
|
+
spec.email = ["rachelscodingemail@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "A CLI gem to explore NYC's GreenThumb gardens."
|
12
|
+
spec.description = "Filter through NYC's GreenThumb gardens by borough, ZIP code, parkname, or ID number. Pull reports or search at random."
|
13
|
+
spec.homepage = "https://github.com/minirachel/nyc-greenthumb-gardens"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
|
16
|
+
|
17
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
18
|
+
|
19
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
20
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
21
|
+
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
25
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
26
|
+
end
|
27
|
+
spec.bindir = "exe"
|
28
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
# Uncomment to register a new dependency of your gem
|
32
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
33
|
+
|
34
|
+
# For more information and examples about making a new gem, checkout our
|
35
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nyc_greenthumb_gardens
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- minirachel
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-05-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Filter through NYC's GreenThumb gardens by borough, ZIP code, parkname,
|
14
|
+
or ID number. Pull reports or search at random.
|
15
|
+
email:
|
16
|
+
- rachelscodingemail@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- CODE_OF_CONDUCT.md
|
23
|
+
- Gemfile
|
24
|
+
- Gemfile.lock
|
25
|
+
- LICENSE.txt
|
26
|
+
- README.md
|
27
|
+
- Rakefile
|
28
|
+
- bin/run.rb
|
29
|
+
- config/environment.rb
|
30
|
+
- lib/command_line_interface.rb
|
31
|
+
- lib/garden.rb
|
32
|
+
- lib/gardens.rb
|
33
|
+
- lib/scraper.rb
|
34
|
+
- lib/version.rb
|
35
|
+
- nyc_greenthumb_gardens-0.1.0.gem
|
36
|
+
- nyc_greenthumb_gardens.gemspec
|
37
|
+
homepage: https://github.com/minirachel/nyc-greenthumb-gardens
|
38
|
+
licenses:
|
39
|
+
- MIT
|
40
|
+
metadata:
|
41
|
+
allowed_push_host: https://rubygems.org
|
42
|
+
homepage_uri: https://github.com/minirachel/nyc-greenthumb-gardens
|
43
|
+
source_code_uri: https://github.com/minirachel/nyc-greenthumb-gardens
|
44
|
+
post_install_message:
|
45
|
+
rdoc_options: []
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 2.4.0
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubygems_version: 3.2.16
|
60
|
+
signing_key:
|
61
|
+
specification_version: 4
|
62
|
+
summary: A CLI gem to explore NYC's GreenThumb gardens.
|
63
|
+
test_files: []
|