FreeWiFiNYC 0.1.10
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/.gitignore +8 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/FreeWiFiNYC-0.1.0.gem +0 -0
- data/FreeWiFiNYC-0.1.1.gem +0 -0
- data/FreeWiFiNYC-0.1.2.gem +0 -0
- data/FreeWiFiNYC-0.1.3.gem +0 -0
- data/FreeWiFiNYC-0.1.4.gem +0 -0
- data/FreeWiFiNYC-0.1.5.gem +0 -0
- data/FreeWiFiNYC-0.1.6.gem +0 -0
- data/FreeWiFiNYC-0.1.7.gem +0 -0
- data/FreeWiFiNYC-0.1.8.gem +0 -0
- data/FreeWiFiNYC-0.1.9.gem +0 -0
- data/FreeWiFiNYC.gemspec +27 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +45 -0
- data/Rakefile +2 -0
- data/bin/console +13 -0
- data/bin/freewifinyc +5 -0
- data/bin/setup +8 -0
- data/config/environment.rb +9 -0
- data/lib/FreeWiFiNYC/FreeWiFiNYC.rb +17 -0
- data/lib/FreeWiFiNYC/api.rb +70 -0
- data/lib/FreeWiFiNYC/cli.rb +125 -0
- data/lib/FreeWiFiNYC/scraper.rb +87 -0
- data/lib/FreeWiFiNYC/version.rb +3 -0
- data/lib/FreeWiFiNYC.rb +186 -0
- metadata +106 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 124477c71d65d632ae4c124bd23dde0d76684728c982f79dffe78d45dd8ace03
|
|
4
|
+
data.tar.gz: 5e4fd66ded1d38fb67703faca6f63817b9ed2f77eb391e0a7b4bf736a2a43b92
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4fead9d7c68b7fd6eacb42b5b3ead50a7e1c6848b9ad195976b574067db464eb60fba379d5b6f242855c8c3ae65c2506545515529f52eb7abf5e8ff15eca3f3c
|
|
7
|
+
data.tar.gz: 3aa1bd9955e2567c89313aba77538638cbda6d62b7a980a10a2555ad3c50b65411ceda3629374d1bb9a505b7274064b37b452c8615085285d60c2d6a2b0f4577
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -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 jaredjames2020@gmail.com. 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 [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
data/FreeWiFiNYC.gemspec
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
|
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require "FreeWiFiNYC/version"
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "FreeWiFiNYC"
|
|
8
|
+
spec.version = FreeWiFiNYC::VERSION
|
|
9
|
+
spec.authors = ["jaredjames2020"]
|
|
10
|
+
spec.email = ["jaredjames2020@gmail.com"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{Write a short summary, because RubyGems requires one.}
|
|
13
|
+
spec.description = %q{Write a longer description or delete this line.}
|
|
14
|
+
spec.homepage = "https://github.com/jaredjames2020/FreeWiFiNYC"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
19
|
+
end
|
|
20
|
+
spec.bindir = "bin"
|
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
22
|
+
spec.executables << "freewifinyc"
|
|
23
|
+
spec.require_paths = ["lib", "lib/FreeWiFiNYC/cli", "lib/FreeWiFiNYC/scraper", "lib/FreeWiFiNYC/FreeWiFiNYC", "lib/FreeWiFiNYC/api"]
|
|
24
|
+
|
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
27
|
+
end
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 jaredjames2020
|
|
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,45 @@
|
|
|
1
|
+
# FreeWiFiNYC
|
|
2
|
+
|
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/FreeWiFiNYC`. To experiment with that code, run `bin/console` for an interactive prompt.
|
|
4
|
+
|
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
|
6
|
+
|
|
7
|
+
test test
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
```ruby
|
|
14
|
+
gem 'FreeWiFiNYC'
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
And then execute:
|
|
18
|
+
|
|
19
|
+
$ bundle
|
|
20
|
+
|
|
21
|
+
Or install it yourself as:
|
|
22
|
+
|
|
23
|
+
$ gem install FreeWiFiNYC
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
TODO: Write usage instructions here
|
|
28
|
+
|
|
29
|
+
## Development
|
|
30
|
+
|
|
31
|
+
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.
|
|
32
|
+
|
|
33
|
+
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).
|
|
34
|
+
|
|
35
|
+
## Contributing
|
|
36
|
+
|
|
37
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/FreeWiFiNYC. 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.
|
|
38
|
+
|
|
39
|
+
## License
|
|
40
|
+
|
|
41
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
42
|
+
|
|
43
|
+
## Code of Conduct
|
|
44
|
+
|
|
45
|
+
Everyone interacting in the FreeWiFiNYC project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/FreeWiFiNYC/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
|
|
5
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
6
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
7
|
+
|
|
8
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
9
|
+
# require "pry"
|
|
10
|
+
# Pry.start
|
|
11
|
+
|
|
12
|
+
require "irb"
|
|
13
|
+
IRB.start(__FILE__)
|
data/bin/freewifinyc
ADDED
data/bin/setup
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require 'nokogiri'
|
|
2
|
+
require 'open-uri'
|
|
3
|
+
require 'json'
|
|
4
|
+
require 'pry'
|
|
5
|
+
|
|
6
|
+
require_relative '../lib/FreeWiFiNYC/FreeWiFiNYC'
|
|
7
|
+
require_relative '../lib/FreeWiFiNYC/scraper' #all the lib files to the app
|
|
8
|
+
require_relative '../lib/FreeWiFiNYC/cli'
|
|
9
|
+
require_relative '../lib/FreeWiFiNYC/api'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require_relative "cli.rb"
|
|
2
|
+
require_relative "scraper.rb"
|
|
3
|
+
require_relative "api.rb"
|
|
4
|
+
|
|
5
|
+
require 'open-uri'
|
|
6
|
+
require 'nokogiri'
|
|
7
|
+
require 'json'
|
|
8
|
+
require 'pry'
|
|
9
|
+
|
|
10
|
+
class WifiNYC
|
|
11
|
+
|
|
12
|
+
def initialize #self.program_exec
|
|
13
|
+
Cli.call
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
#WifiNYC.new#program_exec
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
class Api
|
|
2
|
+
|
|
3
|
+
attr_accessor :borough_name, :neighborhood_name
|
|
4
|
+
|
|
5
|
+
puts "API Class"
|
|
6
|
+
|
|
7
|
+
def self.neighborhood
|
|
8
|
+
puts "This is a list of the Wifi locations by neighborhood in #{Cli.borough_name}.\n"
|
|
9
|
+
neighborhood_array = []
|
|
10
|
+
# @data.each do |each_entry|
|
|
11
|
+
Scraper.all_data.each do |each_entry|
|
|
12
|
+
if each_entry["boroname"] == Cli.borough_name
|
|
13
|
+
neighborhood_list = "#{each_entry["ntaname"]} - #{each_entry["location_t"]} - #{each_entry["location"]}"
|
|
14
|
+
neighborhood_array << neighborhood_list unless neighborhood_array.include?(neighborhood_list)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
puts neighborhood_array.sort
|
|
18
|
+
Cli.search_again_met
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.zip_code
|
|
22
|
+
puts "\nSearching for WiFi in zip code: #{Cli.find_wifi_input}\n\n"
|
|
23
|
+
puts "\n...\n"
|
|
24
|
+
puts "......"
|
|
25
|
+
puts ".........."
|
|
26
|
+
puts "\n"
|
|
27
|
+
puts "You can find free WiFi at the following locations: \n"
|
|
28
|
+
zip_array = []
|
|
29
|
+
|
|
30
|
+
# @data.each do |each_entry|
|
|
31
|
+
Scraper.all_data.each do |each_entry|
|
|
32
|
+
if each_entry["zip"] == Cli.find_wifi_input
|
|
33
|
+
zip_list = "#{each_entry["ntaname"]} - #{each_entry["location_t"]} - #{each_entry["location"]}"
|
|
34
|
+
zip_array << zip_list unless zip_array.include?(zip_list)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
puts zip_array.sort
|
|
38
|
+
Cli.search_again_met
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.neighborhood_list
|
|
42
|
+
puts "Please select a #{@borough} neighborhood."
|
|
43
|
+
neighborhood_array = []
|
|
44
|
+
neighboorhood_hash = Hash.new
|
|
45
|
+
# @data.each do |each_entry|
|
|
46
|
+
Scraper.all_data.each do |each_entry|
|
|
47
|
+
if each_entry["boroname"] == Cli.borough_name
|
|
48
|
+
neighborhood_list = "#{each_entry["ntaname"]}"
|
|
49
|
+
neighborhood_array << neighborhood_list unless neighborhood_array.include?(neighborhood_list)
|
|
50
|
+
end #if
|
|
51
|
+
end #do PROBABLY GOING TO HAVE TO END THIS DO LOOP IF FAILED
|
|
52
|
+
neighborhood_array.sort.each.with_index(1) do |neighborhood,i|
|
|
53
|
+
puts "#{i} - #{neighborhood}"
|
|
54
|
+
neighboorhood_hash[i] = neighborhood
|
|
55
|
+
end #do
|
|
56
|
+
puts "\nPlease select a neighborhood to search."
|
|
57
|
+
neighborhood_search = gets.chomp.upcase
|
|
58
|
+
# @data.each do |each_entry|
|
|
59
|
+
Scraper.all_data.each do |each_entry|
|
|
60
|
+
neighborhood_list_array = []
|
|
61
|
+
if each_entry["ntaname"] == neighboorhood_hash[neighborhood_search.to_i]
|
|
62
|
+
neighborhood_list = "#{each_entry["ntaname"]} - #{each_entry["location_t"]} - #{each_entry["location"]}"
|
|
63
|
+
neighborhood_list_array << neighborhood_list unless neighborhood_list_array.include?(neighborhood_list)
|
|
64
|
+
end#if
|
|
65
|
+
puts neighborhood_list_array.sort
|
|
66
|
+
end #do
|
|
67
|
+
Cli.search_again_met
|
|
68
|
+
end#method
|
|
69
|
+
|
|
70
|
+
end
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
class Cli
|
|
2
|
+
|
|
3
|
+
puts "Cli Class"
|
|
4
|
+
|
|
5
|
+
def self.call
|
|
6
|
+
Scraper.scrape_data
|
|
7
|
+
welcome
|
|
8
|
+
find_wifi
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.welcome
|
|
12
|
+
puts "\nHello, I can help you find free Wi-Fi. You can search by zip code or neighborhood.\n"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.goodbye
|
|
16
|
+
puts "Thanks for using Search Free Wi-Fi NYC. Goodbye!"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.find_wifi
|
|
20
|
+
puts "Please enter a zip code or type 'help' to search by neighborhood or type 'exit':"
|
|
21
|
+
@find_wifi_input = gets.chomp.upcase
|
|
22
|
+
|
|
23
|
+
if @find_wifi_input == "HELP"
|
|
24
|
+
borough_selector
|
|
25
|
+
# elsif @zip_codes.include?(@find_wifi_input)
|
|
26
|
+
elsif Scraper.zips.include?(@find_wifi_input)
|
|
27
|
+
Api.zip_code
|
|
28
|
+
elsif @find_wifi_input == "EXIT"
|
|
29
|
+
return goodbye
|
|
30
|
+
elsif @find_wifi_input.length != 5
|
|
31
|
+
puts "Invalid entry. Please enter a 5 digit NYC zip code."
|
|
32
|
+
find_wifi
|
|
33
|
+
else
|
|
34
|
+
Scraper.zipcode_hardcode.include?(@find_wifi_input.to_i) ?
|
|
35
|
+
(puts "Sorry there is no free wifi in this area of NYC.\nType 'help' to search by neighborhood.")
|
|
36
|
+
: (puts "Invalid entry. Type 'help' to search by neighborhood.")
|
|
37
|
+
find_wifi
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.find_wifi_input
|
|
42
|
+
@find_wifi_input
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.help
|
|
46
|
+
puts "Enter 1 for list of neighborhoods. Enter 2 for list of location types."
|
|
47
|
+
help_num = gets.chomp
|
|
48
|
+
if help_num == "1"
|
|
49
|
+
borough
|
|
50
|
+
elsif help_num == "2"
|
|
51
|
+
location_type
|
|
52
|
+
else
|
|
53
|
+
help
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def self.search_again_met
|
|
58
|
+
puts "\nWould you like to search again? Type 'Yes' or 'No'."
|
|
59
|
+
search_again = gets.chomp.upcase
|
|
60
|
+
if search_again == "YES" || search_again == "Y"
|
|
61
|
+
find_wifi
|
|
62
|
+
elsif search_again == "NO" || search_again == "N"
|
|
63
|
+
return goodbye
|
|
64
|
+
else
|
|
65
|
+
puts "Please type 'Yes' or 'No'."
|
|
66
|
+
search_again_met
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
def self.borough_selector
|
|
71
|
+
puts "Please select a borough to begin your search."
|
|
72
|
+
puts "
|
|
73
|
+
1 - Bronx
|
|
74
|
+
2 - Brooklyn
|
|
75
|
+
3 - Manhattan
|
|
76
|
+
4 - Queens
|
|
77
|
+
5 - Staten Island
|
|
78
|
+
"
|
|
79
|
+
puts "Enter a number: \n"
|
|
80
|
+
borough_assigner
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def self.borough_assigner
|
|
84
|
+
borough = gets.chomp.upcase
|
|
85
|
+
case borough
|
|
86
|
+
when "1"
|
|
87
|
+
puts "Bronx"
|
|
88
|
+
@borough = "Bronx"
|
|
89
|
+
Api.neighborhood_list
|
|
90
|
+
when "2"
|
|
91
|
+
puts "Brooklyn"
|
|
92
|
+
@borough = "Brooklyn"
|
|
93
|
+
Api.neighborhood_list
|
|
94
|
+
when "3"
|
|
95
|
+
puts "Manhattan"
|
|
96
|
+
@borough = "Manhattan"
|
|
97
|
+
Api.neighborhood_list
|
|
98
|
+
when "4"
|
|
99
|
+
puts "Queens"
|
|
100
|
+
@borough = "Queens"
|
|
101
|
+
Api.neighborhood_list
|
|
102
|
+
when "5"
|
|
103
|
+
puts "Staten Island"
|
|
104
|
+
@borough = "Staten Island"
|
|
105
|
+
Api.neighborhood_list
|
|
106
|
+
when "EXIT"
|
|
107
|
+
find_wifi
|
|
108
|
+
else
|
|
109
|
+
puts "Invalid entry. Enter a number 1-5 or type 'exit'.\n"
|
|
110
|
+
puts "
|
|
111
|
+
1 - Bronx
|
|
112
|
+
2 - Brooklyn
|
|
113
|
+
3 - Manhattan
|
|
114
|
+
4 - Queens
|
|
115
|
+
5 - Staten Island
|
|
116
|
+
"
|
|
117
|
+
borough_assigner
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def self.borough_name
|
|
122
|
+
@borough
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# require './cli'
|
|
2
|
+
# require './FreeWiFiNYC'
|
|
3
|
+
|
|
4
|
+
class Scraper
|
|
5
|
+
|
|
6
|
+
puts "Scraper Class"
|
|
7
|
+
|
|
8
|
+
attr_accessor :data, :zip_codes, :find_wifi_input, :borough, :boro_code, :all_nyc_zips
|
|
9
|
+
|
|
10
|
+
def test
|
|
11
|
+
puts "Scraper Test"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.scrape_data
|
|
15
|
+
@all_nyc_zips = []
|
|
16
|
+
@zip_codes = []
|
|
17
|
+
|
|
18
|
+
parsed_data = Nokogiri::HTML(open("https://data.cityofnewyork.us/resource/yjub-udmw.json?$offset=0&$limit=5000"))
|
|
19
|
+
#zips_nyc_data = Nokogiri::HTML(open("http://www.city-data.com/zipmaps/New-York-New-York.html"))
|
|
20
|
+
|
|
21
|
+
@data = JSON.parse(parsed_data)
|
|
22
|
+
#@all_nyc_zips = zips_nyc_data.css("div.zip-codes a").text.scan(/\d{5}/)
|
|
23
|
+
|
|
24
|
+
zips
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.zipcode_hardcode
|
|
28
|
+
# zippers = #{Bronx =>
|
|
29
|
+
# {"Central Bronx" => [10453, 10457, 10460],
|
|
30
|
+
# "Bronx Park and Fordham" => [10458, 10467, 10468],
|
|
31
|
+
# "High Bridge and Morrisania" => [10451, 10452, 10456],
|
|
32
|
+
# "Hunts Point and Mott Haven" => [10454, 10455, 10459, 10474],
|
|
33
|
+
# "Kingsbridge and Riverdale" => [10463, 10471],
|
|
34
|
+
# "Northeast Bronx" => [10466, 10469, 10470, 10475],
|
|
35
|
+
# "Southeast Bronx" => [10461, 10462,10464, 10465, 10472, 10473]},
|
|
36
|
+
#
|
|
37
|
+
# #{Brooklyn =>
|
|
38
|
+
# {"Central Brooklyn" => [11212, 11213, 11216, 11233, 11238],
|
|
39
|
+
# "Southwest Brooklyn" => [11209, 11214, 11228],
|
|
40
|
+
# "Borough Park" => [11204, 11218, 11219, 11230],
|
|
41
|
+
# "Canarsie and Flatlands" => [11234, 11236, 11239],
|
|
42
|
+
# "Southern Brooklyn" => [11223, 11224, 11229, 11235],
|
|
43
|
+
# "Northwest Brooklyn" => [11201, 11205, 11215, 11217, 11231],
|
|
44
|
+
# "Flatbush" => [11203, 11210, 11225, 11226],
|
|
45
|
+
# "East New York and New Lots" => [11207, 11208],
|
|
46
|
+
# "Greenpoint" => [11211, 11222],
|
|
47
|
+
# "Sunset Park" => [11220, 11232],
|
|
48
|
+
# "Bushwick and Williamsburg" => [11206, 11221, 11237]}
|
|
49
|
+
# }
|
|
50
|
+
|
|
51
|
+
codes = [10001, 10002, 10003, 10004, 10005, 10006, 10007, 10009,
|
|
52
|
+
10010, 10011, 10012, 10013, 10014, 10016, 10017, 10018, 10019, 10020,
|
|
53
|
+
10021, 10022, 10023, 10024, 10025, 10026, 10027, 10028, 10029, 10030,
|
|
54
|
+
10031, 10032, 10033, 10034, 10035, 10036, 10037, 10038, 10039, 10040,
|
|
55
|
+
10044, 10065, 10069, 10075, 10103, 10110, 10111, 10112, 10115, 10119,
|
|
56
|
+
10128, 10152, 10153, 10154, 10162, 10165, 10167, 10168, 10169, 10170,
|
|
57
|
+
10171, 10172, 10173, 10174, 10177, 10199, 10271, 10278, 10279, 10280,
|
|
58
|
+
10282, 10301, 10302, 10303, 10304, 10305, 10306, 10307, 10308, 10309,
|
|
59
|
+
10310, 10311, 10312, 10314, 10451, 10452, 10453, 10454, 10455, 10456,
|
|
60
|
+
10457, 10458, 10459, 10460, 10461, 10462, 10463, 10464, 10465, 10466,
|
|
61
|
+
10467, 10468, 10469, 10470, 10471, 10472, 10473, 10474, 10475, 11001,
|
|
62
|
+
11003, 11004, 11005, 11040, 11101, 11102, 11103, 11104, 11105, 11106,
|
|
63
|
+
11109, 11201, 11203, 11204, 11205, 11206, 11207, 11208, 11209, 11210,
|
|
64
|
+
11211, 11212, 11213, 11214, 11215, 11216, 11217, 11218, 11219, 11220,
|
|
65
|
+
11221, 11222, 11223, 11224, 11225, 11226, 11228, 11229, 11230, 11231,
|
|
66
|
+
11232, 11233, 11234, 11235, 11236, 11237, 11238, 11239, 11351, 11354,
|
|
67
|
+
11355, 11356, 11357, 11358, 11359, 11360, 11361, 11362, 11363, 11364,
|
|
68
|
+
11365, 11366, 11367, 11368, 11369, 11370, 11371, 11372, 11373, 11374,
|
|
69
|
+
11375, 11377, 11378, 11379, 11385, 11411, 11412, 11413, 11414, 11415,
|
|
70
|
+
11416, 11417, 11418, 11419, 11420, 11421, 11422, 11423, 11424, 11425,
|
|
71
|
+
11426, 11427, 11428, 11429, 11430, 11432, 11433, 11434, 11435, 11436,
|
|
72
|
+
11451, 11691, 11692, 11693, 11694, 11697]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.zips
|
|
76
|
+
# @data.each do |each_entry|
|
|
77
|
+
Scraper.all_data.each do |each_entry|
|
|
78
|
+
@zip_codes << each_entry["zip"] unless @zip_codes.include?(each_entry["zip"])
|
|
79
|
+
end
|
|
80
|
+
@zip_codes.sort
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def self.all_data
|
|
84
|
+
@data
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
end
|
data/lib/FreeWiFiNYC.rb
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# require "FreeWiFiNYC/version"
|
|
2
|
+
# require 'nokogiri'
|
|
3
|
+
# require 'open-uri'
|
|
4
|
+
# require 'json'
|
|
5
|
+
# require 'pry'
|
|
6
|
+
#
|
|
7
|
+
# module FreeWiFiNYC
|
|
8
|
+
#
|
|
9
|
+
# attr_accessor :data, :zip_codes, :find_wifi_input, :borough, :boro_code, :all_nyc_zips
|
|
10
|
+
#
|
|
11
|
+
# def self.initialize
|
|
12
|
+
# @all_nyc_zips = []
|
|
13
|
+
# @zip_codes = []
|
|
14
|
+
#
|
|
15
|
+
# parsed_data = Nokogiri::HTML(open("https://data.cityofnewyork.us/resource/yjub-udmw.json?$offset=0&$limit=5000"))
|
|
16
|
+
# zips_nyc_data = Nokogiri::HTML(open("http://www.city-data.com/zipmaps/New-York-New-York.html"))
|
|
17
|
+
#
|
|
18
|
+
# @data = JSON.parse(parsed_data)
|
|
19
|
+
# @all_nyc_zips = zips_nyc_data.css("div.zip-codes a").text.scan(/\d{5}/)
|
|
20
|
+
#
|
|
21
|
+
# self.zips
|
|
22
|
+
# self.welcome
|
|
23
|
+
# self.find_wifi
|
|
24
|
+
# end
|
|
25
|
+
#
|
|
26
|
+
# def self.zips
|
|
27
|
+
# @data.each do |each_entry|
|
|
28
|
+
# @zip_codes << each_entry["zip"] unless @zip_codes.include?(each_entry["zip"])
|
|
29
|
+
# end
|
|
30
|
+
# @zip_codes.sort
|
|
31
|
+
# end
|
|
32
|
+
#
|
|
33
|
+
# def self.welcome
|
|
34
|
+
# puts "Hello, I can help you find free Wi-Fi. You can search by zip code or neighborhood."
|
|
35
|
+
# end
|
|
36
|
+
#
|
|
37
|
+
# def self.find_wifi
|
|
38
|
+
# puts "Please enter a zip code or type 'help' to search by neighborhood or type 'exit':"
|
|
39
|
+
# @find_wifi_input = gets.chomp.upcase
|
|
40
|
+
#
|
|
41
|
+
# if @find_wifi_input == "HELP"
|
|
42
|
+
# borough
|
|
43
|
+
# elsif @zip_codes.include?(@find_wifi_input)
|
|
44
|
+
# zip_code_input
|
|
45
|
+
# elsif @find_wifi_input == "EXIT"
|
|
46
|
+
# return puts "Thanks for using Search Free Wi-Fi NYC. Goodbye!"
|
|
47
|
+
# elsif @find_wifi_input.length != 5
|
|
48
|
+
# puts "Invalid entry. Please enter a 5 digit NYC zip code."
|
|
49
|
+
# find_wifi
|
|
50
|
+
# else
|
|
51
|
+
# @all_nyc_zips.include?(@find_wifi_input) ?
|
|
52
|
+
# (puts "Sorry there is no free wifi in this area of NYC.\nType 'help' to search by neighborhood.")
|
|
53
|
+
# : (puts "Invalid entry. Type 'help' to search by neighborhood.")
|
|
54
|
+
# find_wifi
|
|
55
|
+
# end
|
|
56
|
+
# end
|
|
57
|
+
#
|
|
58
|
+
# def self.help
|
|
59
|
+
# puts "Enter 1 for list of neighborhoods. Enter 2 for list of location types."
|
|
60
|
+
# help_num = gets.chomp
|
|
61
|
+
# if help_num == "1"
|
|
62
|
+
# borough
|
|
63
|
+
# elsif help_num == "2"
|
|
64
|
+
# location_type
|
|
65
|
+
# else
|
|
66
|
+
# help
|
|
67
|
+
# end
|
|
68
|
+
# end
|
|
69
|
+
#
|
|
70
|
+
# def self.neighborhood
|
|
71
|
+
# puts "This is a list of the Wifi locations by neighborhood in #{@borough}.\n"
|
|
72
|
+
# neighborhood_array = []
|
|
73
|
+
#
|
|
74
|
+
# @data.each do |each_entry|
|
|
75
|
+
# if each_entry["boroname"] == @borough
|
|
76
|
+
# neighborhood_list = "#{each_entry["ntaname"]} - #{each_entry["location_t"]} - #{each_entry["location"]}"
|
|
77
|
+
# neighborhood_array << neighborhood_list unless neighborhood_array.include?(neighborhood_list)
|
|
78
|
+
# end
|
|
79
|
+
# end
|
|
80
|
+
# puts neighborhood_array.sort
|
|
81
|
+
# puts "\nWould you like to search again? Type 'Yes' or 'No'."
|
|
82
|
+
# search_again = gets.chomp.upcase
|
|
83
|
+
# if search_again == "YES"
|
|
84
|
+
# find_wifi
|
|
85
|
+
# else
|
|
86
|
+
# return puts "\nThanks for using Search Free Wi-Fi NYC. Goodbye!\n"
|
|
87
|
+
# end
|
|
88
|
+
# end
|
|
89
|
+
#
|
|
90
|
+
# def self.zip_code_input
|
|
91
|
+
# puts "\nSearching for WiFi in zip code: #{@find_wifi_input}\n\n"
|
|
92
|
+
# puts "You can find free WiFi at the following locations:"
|
|
93
|
+
# zip_array = []
|
|
94
|
+
#
|
|
95
|
+
# @data.each do |each_entry|
|
|
96
|
+
# if each_entry["zip"] == @find_wifi_input
|
|
97
|
+
# zip_list = "#{each_entry["ntaname"]} - #{each_entry["location_t"]} - #{each_entry["location"]}"
|
|
98
|
+
# zip_array << zip_list unless zip_array.include?(zip_list)
|
|
99
|
+
# end
|
|
100
|
+
# end
|
|
101
|
+
# puts zip_array.sort
|
|
102
|
+
# puts "\nWould you like to search again? Type 'Yes' or 'No'."
|
|
103
|
+
# search_again = gets.chomp.upcase
|
|
104
|
+
# if search_again == "YES"
|
|
105
|
+
# find_wifi
|
|
106
|
+
# else
|
|
107
|
+
# return puts "Thanks for using Search Free Wi-Fi NYC. Goodbye!"
|
|
108
|
+
# end
|
|
109
|
+
# end
|
|
110
|
+
#
|
|
111
|
+
# def self.borough
|
|
112
|
+
# puts "Please select a borough to begin your search."
|
|
113
|
+
# puts "
|
|
114
|
+
# 1 - Bronx
|
|
115
|
+
# 2 - Brooklyn
|
|
116
|
+
# 3 - Manhattan
|
|
117
|
+
# 4 - Queens
|
|
118
|
+
# 5 - Staten Island
|
|
119
|
+
# "
|
|
120
|
+
# puts "Enter a number: "
|
|
121
|
+
# borough = gets.chomp.upcase
|
|
122
|
+
# case borough
|
|
123
|
+
# when "1"
|
|
124
|
+
# puts "Bronx"
|
|
125
|
+
# @borough = "Bronx"
|
|
126
|
+
# neighborhood_list
|
|
127
|
+
# when "2"
|
|
128
|
+
# puts "Brooklyn"
|
|
129
|
+
# @borough = "Brooklyn"
|
|
130
|
+
# neighborhood_list
|
|
131
|
+
# when "3"
|
|
132
|
+
# puts "Manhattan"
|
|
133
|
+
# @borough = "Manhattan"
|
|
134
|
+
# neighborhood_list
|
|
135
|
+
# when "4"
|
|
136
|
+
# puts "Queens"
|
|
137
|
+
# @borough = "Queens"
|
|
138
|
+
# neighborhood_list
|
|
139
|
+
# when "5"
|
|
140
|
+
# puts "Staten Island"
|
|
141
|
+
# @borough = "Staten Island"
|
|
142
|
+
# neighborhood_list
|
|
143
|
+
# when "EXIT"
|
|
144
|
+
# find_wifi
|
|
145
|
+
# else
|
|
146
|
+
# puts "Enter a number 1-5 or type 'exit'.\n"
|
|
147
|
+
# find_wifi
|
|
148
|
+
# end
|
|
149
|
+
#
|
|
150
|
+
# end
|
|
151
|
+
#
|
|
152
|
+
# def self.neighborhood_list
|
|
153
|
+
# puts "Please select a #{@borough} neighborhood."
|
|
154
|
+
# neighborhood_array = []
|
|
155
|
+
# neighboorhood_hash = Hash.new
|
|
156
|
+
# @data.each do |each_entry|
|
|
157
|
+
# if each_entry["boroname"] == @borough
|
|
158
|
+
# neighborhood_list = "#{each_entry["ntaname"]}"
|
|
159
|
+
# neighborhood_array << neighborhood_list unless neighborhood_array.include?(neighborhood_list)
|
|
160
|
+
# end #if
|
|
161
|
+
# end #do PROBABLY GOING TO HAVE TO END THIS DO LOOP IF FAILED
|
|
162
|
+
# neighborhood_array.sort.each.with_index(1) do |neighborhood,i|
|
|
163
|
+
# puts "#{i} - #{neighborhood}"
|
|
164
|
+
# neighboorhood_hash[i] = neighborhood
|
|
165
|
+
# end #do
|
|
166
|
+
# puts "\nPlease select a neighborhood to search."
|
|
167
|
+
# search_again = gets.chomp.upcase
|
|
168
|
+
# @data.each do |each_entry|
|
|
169
|
+
# neighborhood_list_array = []
|
|
170
|
+
# if each_entry["ntaname"] == neighboorhood_hash[search_again.to_i]
|
|
171
|
+
# neighborhood_list = "#{each_entry["ntaname"]} - #{each_entry["location_t"]} - #{each_entry["location"]}"
|
|
172
|
+
# neighborhood_list_array << neighborhood_list unless neighborhood_list_array.include?(neighborhood_list)
|
|
173
|
+
# end#if
|
|
174
|
+
# puts neighborhood_list_array.sort
|
|
175
|
+
# end #do
|
|
176
|
+
# puts "\nWould you like to search again? Type 'Yes' or 'No'."
|
|
177
|
+
# search_again = gets.chomp.upcase
|
|
178
|
+
# if search_again == "YES"
|
|
179
|
+
# find_wifi
|
|
180
|
+
# else
|
|
181
|
+
# return puts "Thanks for using Search Free Wi-Fi NYC. Goodbye!"
|
|
182
|
+
# end#if
|
|
183
|
+
# end#method
|
|
184
|
+
#
|
|
185
|
+
#
|
|
186
|
+
# end#module
|
metadata
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: FreeWiFiNYC
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.10
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- jaredjames2020
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-11-02 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: '1.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
description: Write a longer description or delete this line.
|
|
42
|
+
email:
|
|
43
|
+
- jaredjames2020@gmail.com
|
|
44
|
+
executables:
|
|
45
|
+
- console
|
|
46
|
+
- freewifinyc
|
|
47
|
+
- setup
|
|
48
|
+
extensions: []
|
|
49
|
+
extra_rdoc_files: []
|
|
50
|
+
files:
|
|
51
|
+
- ".gitignore"
|
|
52
|
+
- CODE_OF_CONDUCT.md
|
|
53
|
+
- FreeWiFiNYC-0.1.0.gem
|
|
54
|
+
- FreeWiFiNYC-0.1.1.gem
|
|
55
|
+
- FreeWiFiNYC-0.1.2.gem
|
|
56
|
+
- FreeWiFiNYC-0.1.3.gem
|
|
57
|
+
- FreeWiFiNYC-0.1.4.gem
|
|
58
|
+
- FreeWiFiNYC-0.1.5.gem
|
|
59
|
+
- FreeWiFiNYC-0.1.6.gem
|
|
60
|
+
- FreeWiFiNYC-0.1.7.gem
|
|
61
|
+
- FreeWiFiNYC-0.1.8.gem
|
|
62
|
+
- FreeWiFiNYC-0.1.9.gem
|
|
63
|
+
- FreeWiFiNYC.gemspec
|
|
64
|
+
- Gemfile
|
|
65
|
+
- LICENSE.txt
|
|
66
|
+
- README.md
|
|
67
|
+
- Rakefile
|
|
68
|
+
- bin/console
|
|
69
|
+
- bin/freewifinyc
|
|
70
|
+
- bin/setup
|
|
71
|
+
- config/environment.rb
|
|
72
|
+
- lib/FreeWiFiNYC.rb
|
|
73
|
+
- lib/FreeWiFiNYC/FreeWiFiNYC.rb
|
|
74
|
+
- lib/FreeWiFiNYC/api.rb
|
|
75
|
+
- lib/FreeWiFiNYC/cli.rb
|
|
76
|
+
- lib/FreeWiFiNYC/scraper.rb
|
|
77
|
+
- lib/FreeWiFiNYC/version.rb
|
|
78
|
+
homepage: https://github.com/jaredjames2020/FreeWiFiNYC
|
|
79
|
+
licenses:
|
|
80
|
+
- MIT
|
|
81
|
+
metadata: {}
|
|
82
|
+
post_install_message:
|
|
83
|
+
rdoc_options: []
|
|
84
|
+
require_paths:
|
|
85
|
+
- lib
|
|
86
|
+
- lib/FreeWiFiNYC/cli
|
|
87
|
+
- lib/FreeWiFiNYC/scraper
|
|
88
|
+
- lib/FreeWiFiNYC/FreeWiFiNYC
|
|
89
|
+
- lib/FreeWiFiNYC/api
|
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
|
+
requirements:
|
|
97
|
+
- - ">="
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
requirements: []
|
|
101
|
+
rubyforge_project:
|
|
102
|
+
rubygems_version: 2.7.7
|
|
103
|
+
signing_key:
|
|
104
|
+
specification_version: 4
|
|
105
|
+
summary: Write a short summary, because RubyGems requires one.
|
|
106
|
+
test_files: []
|