surf_rockaway 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c9eb8bf9bcf9d8e206a2c1038d37b9bf6d7b2dcd264f14602275dd108b8cb236
4
+ data.tar.gz: 51ed24eab166dc88c7cf9b7379a6ca743f0dfdecffecbe5ac4f70d992ea1b5e6
5
+ SHA512:
6
+ metadata.gz: 4b1b3909933faf464e7c5c110a7dcae32aa02ab73d15ef5d79e8864354ec6ea723c1dc056fe5795b2150b1f9fb5d01dccf1e1fb06d8f6657a75e236c8b67e5bc
7
+ data.tar.gz: 770dc6e1b2d6005d20d6b6af7e300862be8ca47afaa36870a82fb923ca4f82f2ad01236e35885da12bd7842c92f750309cc8fea77f07c9e4fa8099cd291f686a
data/.DS_Store ADDED
Binary file
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in surf_rockaway.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 <github username>
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,33 @@
1
+ # SurfRockaway
2
+
3
+ Simple ruby based CLI application to pull a surf report for Rockaway Beach, Queens, NY.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ $ gem install surf-rockaway
9
+ ```
10
+
11
+ ## Detailed Description
12
+
13
+ A Florida native for most of my life, moving to NYC over the summer left me longing for the beach. I soon discovered Rockaway Beach is the closest surf spot to the city. (bonus you can take the water ferry!) All too often, I found myself lost in a terminal screen ... searching for an excuse to hit the beach for a few hours. So, I created surf-rockaway. This gem provides a quick way to check the current surf condtions without ever leaving the terminal.
14
+
15
+ ## Data Provided
16
+
17
+ --- current forcast
18
+ --- 3-day surf condtions
19
+ --- (in development) Set notification based on wave size
20
+
21
+ ## Development
22
+
23
+ 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.
24
+
25
+ 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.
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kyle-crews/surf-rockaway. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
30
+
31
+ ## License
32
+
33
+ All the works are available under the MIT license.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/.DS_Store ADDED
Binary file
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "surf_data"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bin/surf-rockaway ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require './lib/environment'
4
+
5
+ SurfRockaway::CLI.new.call
6
+
data/lib/.DS_Store ADDED
Binary file
@@ -0,0 +1,10 @@
1
+ require "nokogiri"
2
+ require "open-uri"
3
+ require "pry"
4
+ require "tty-prompt"
5
+ require "colorize"
6
+ require "tty-table"
7
+
8
+ require_relative "./surf_data/version"
9
+ require_relative './surf_data/cli'
10
+ require_relative './surf_data/surf_report.rb'
Binary file
@@ -0,0 +1,46 @@
1
+ class SurfRockaway::CLI
2
+
3
+ def call
4
+ welcome
5
+ main_menu
6
+ end
7
+
8
+ def welcome
9
+ puts ""
10
+ puts "|| Welcome".blue
11
+ puts "|| to".blue
12
+ puts "|| Surf Rockaway".blue
13
+ puts ""
14
+ puts "| Ready to surf? |".green
15
+ puts ""
16
+ end
17
+
18
+ def main_menu
19
+ prompt = TTY::Prompt.new
20
+ input = ""
21
+ while input != "Exit"
22
+ input = prompt.select('Please select an options below:') do |menu|
23
+ menu.choice 'Current conditions', 'Current'
24
+ menu.choice '3 day forecast', '3 day'
25
+ menu.choice 'Set notification', 'Set notification', disabled: '(in development)'
26
+ menu.choice 'Exit the program', 'Exit'
27
+ end
28
+
29
+ if input == "Current"
30
+ puts ""
31
+ SurfRockaway::SurfReport.current
32
+ puts ""
33
+ elsif input == "3 day"
34
+ puts ""
35
+ SurfRockaway::SurfReport.multi_day
36
+ puts ""
37
+ else input == "Exit"
38
+ puts ""
39
+ puts ""
40
+ puts "__̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡| ̲▫̲͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡ ̡͌l̡̡̡̡.___ ... See you soon! "
41
+ puts ""
42
+ exit
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,141 @@
1
+ class SurfRockaway::SurfReport
2
+ attr_accessor :location, :wave_size, :wind, :primary_swell, :weather, :temp, :date, :time
3
+
4
+ def self.current
5
+ # Scrape magicseaweed.com and return current conditions for rockaway
6
+ puts "### Pulling current report ... this may take up to seconds ###"
7
+ puts ""
8
+ self.scrape_data
9
+ end
10
+
11
+ def self.scrape_data
12
+ # creates empty array to store data
13
+ conditions = []
14
+
15
+ # pushes new instances of data from magicseaweed.com to conditions array
16
+ conditions << self.scrape_magicseaweed
17
+
18
+ conditions
19
+ end
20
+
21
+ def self.multi_day
22
+ # Scrape 3-day forecast
23
+ puts "### Pulling current report ... this may take up to seconds ###"
24
+ puts ""
25
+ self.scrape_data_multi
26
+ end
27
+
28
+ def self.scrape_data_multi
29
+
30
+ multi_day = []
31
+
32
+ multi_day << self.scrape_magicseaweed_3day
33
+
34
+ multi_day
35
+ end
36
+
37
+
38
+ def self.scrape_magicseaweed
39
+ doc = Nokogiri::HTML(open('https://magicseaweed.com/Rockaway-Surf-Report/384/'))
40
+
41
+ current_report = self.new
42
+ location_raw = doc.search("div.forecast-sub-title-fluid").text.strip.split
43
+ current_report.location = location_raw.first(5).join(" ")
44
+ current_report.wave_size = doc.xpath("//ul[@class='rating rating-large clearfix']/li").text.strip
45
+ current_report.wind = doc.xpath("//p[@class='h5 nomargin-top']").text.strip
46
+ p_swell = doc.search("div.list-group-content").text.strip.split
47
+ current_report.primary_swell = p_swell.first(3).join(" ")
48
+ current_report.weather = doc.xpath("//p[@class='nomargin-bottom']/i").text.strip
49
+
50
+ puts "================================"
51
+ puts "#{current_report.location}"
52
+ puts "================================"
53
+ puts ""
54
+ puts " Wave Size: // #{current_report.wave_size} //".blue
55
+ puts " Wind: // #{current_report.wind} // ".blue
56
+ puts " Primary_swell: // #{current_report.primary_swell} //".blue
57
+ puts " Weather: // #{current_report.weather} //".blue
58
+ puts ""
59
+ puts ""
60
+ puts "######################################"
61
+ end
62
+
63
+ def self.scrape_magicseaweed_3day
64
+ doc = Nokogiri::HTML(open('https://magicseaweed.com/Rockaway-Surf-Report/384/'))
65
+
66
+ # collect Day 1
67
+
68
+ day_1 = self.new
69
+ day_1.date = doc.search("tr.tbody-title").text.strip.split(" ").compact.first
70
+ day_1.time = doc.search("td.nopadding-left").text.strip.split[2..6]
71
+ day_1.wave_size = doc.search("td.background-info").text.strip.split[2..6]
72
+ day_1.primary_swell = doc.search("h4.font-sans-serif").text.strip.split[4..13]
73
+ day_1.temp = doc.search("h5.heavy").text.strip.split("f")[2..6]
74
+
75
+ # collect Day 2
76
+
77
+ day_2 = self.new
78
+ day_2.date = doc.search("tr.tbody-title").text.strip.split.slice(4..5).join(" ")
79
+ day_2.time = doc.search("td.nopadding-left").text.strip.split[2..6]
80
+ day_2.wave_size = doc.search("td.background-info").text.strip.split[10..14]
81
+ day_2.primary_swell = doc.search("h4.font-sans-serif").text.strip.split[20..29]
82
+ day_2.temp = doc.search("h5.heavy").text.strip.split("f")[10..14]
83
+
84
+ # collect Day 3
85
+
86
+ day_3 = self.new
87
+ day_3.date = doc.search("tr.tbody-title").text.strip.split.slice(6..7).join(" ")
88
+ day_3.time = doc.search("td.nopadding-left").text.strip.split[2..6]
89
+ day_3.wave_size = doc.search("td.background-info").text.strip.split[18..22]
90
+ day_3.primary_swell = doc.search("h4.font-sans-serif").text.strip.split[36..45]
91
+ day_3.temp = doc.search("h5.heavy").text.strip.split("f")[18..22]
92
+
93
+ # CLI display for 3 day forecast
94
+
95
+ puts ""
96
+ puts "==========================="
97
+ puts "#{day_1.date}"
98
+ puts "==========================="
99
+ table = TTY::Table.new ['', 'wave_size', 'primary_swell', 'temp'],
100
+ [
101
+ ["#{day_1.time[0]}", "#{day_1.wave_size[0]}", "#{day_1.primary_swell[0]}", "#{day_1.temp[0]}"],
102
+ ["#{day_1.time[1]}", "#{day_1.wave_size[1]}", "#{day_1.primary_swell[1]}", "#{day_1.temp[1]}"],
103
+ ["#{day_1.time[2]}", "#{day_1.wave_size[2]}", "#{day_1.primary_swell[2]}", "#{day_1.temp[2]}"],
104
+ ["#{day_1.time[3]}", "#{day_1.wave_size[3]}", "#{day_1.primary_swell[3]}", "#{day_1.temp[3]}"],
105
+ ["#{day_1.time[4]}", "#{day_1.wave_size[4]}", "#{day_1.primary_swell[4]}", "#{day_1.temp[4]}"]
106
+ ]
107
+ puts table.render(:ascii).green
108
+ puts ""
109
+ puts "==========================="
110
+ puts "#{day_2.date}"
111
+ puts "==========================="
112
+ table = TTY::Table.new ['', 'wave_size', 'primary_swell', 'temp'],
113
+ [
114
+ ["#{day_2.time[0]}", "#{day_2.wave_size[0]}", "#{day_2.primary_swell[0]}", "#{day_2.temp[0]}"],
115
+ ["#{day_2.time[1]}", "#{day_2.wave_size[1]}", "#{day_2.primary_swell[1]}", "#{day_2.temp[1]}"],
116
+ ["#{day_2.time[2]}", "#{day_2.wave_size[2]}", "#{day_2.primary_swell[2]}", "#{day_2.temp[2]}"],
117
+ ["#{day_2.time[3]}", "#{day_2.wave_size[3]}", "#{day_2.primary_swell[3]}", "#{day_2.temp[3]}"],
118
+ ["#{day_2.time[4]}", "#{day_2.wave_size[4]}", "#{day_2.primary_swell[4]}", "#{day_2.temp[4]}"]
119
+ ]
120
+ puts table.render(:ascii).green
121
+
122
+ puts ""
123
+ puts "==========================="
124
+ puts "#{day_3.date}"
125
+ puts "==========================="
126
+ table = TTY::Table.new ['', 'wave_size', 'primary_swell', 'temp'],
127
+ [
128
+ ["#{day_3.time[0]}", "#{day_3.wave_size[0]}", "#{day_3.primary_swell[0]}", "#{day_3.temp[0]}"],
129
+ ["#{day_3.time[1]}", "#{day_3.wave_size[1]}", "#{day_3.primary_swell[1]}", "#{day_3.temp[1]}"],
130
+ ["#{day_3.time[2]}", "#{day_3.wave_size[2]}", "#{day_3.primary_swell[2]}", "#{day_3.temp[2]}"],
131
+ ["#{day_3.time[3]}", "#{day_3.wave_size[3]}", "#{day_3.primary_swell[3]}", "#{day_3.temp[3]}"],
132
+ ["#{day_3.time[4]}", "#{day_3.wave_size[4]}", "#{day_3.primary_swell[4]}", "#{day_3.temp[4]}"]
133
+ ]
134
+ puts table.render(:ascii).green
135
+ puts ""
136
+ puts ""
137
+ puts "######################################"
138
+
139
+ end
140
+
141
+ end
@@ -0,0 +1,3 @@
1
+ module SurfRockaway
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,49 @@
1
+ =begin
2
+ require 'terminal-notifier'
3
+
4
+ gem install terminal-notifier
5
+
6
+ TerminalNotifier.notify('Hello World')
7
+
8
+
9
+ def request_email
10
+ prompt = TTY::Prompt.new
11
+ puts ""
12
+ puts ">> What's your email address?"
13
+ prompt.ask('What is your email?') { |q| q.validate :email }
14
+ end
15
+
16
+ def verify_email
17
+ prompt = TTY::Prompt.new
18
+ puts "Your email: #{email} "
19
+ puts ""
20
+ prompt.yes?("Is this correct?")
21
+ end
22
+
23
+
24
+ def notify_settings
25
+ prompt = TTY::Prompt.new
26
+ puts "-----------------------------"
27
+ prompt.select("When do you want to be notified?") do |prompt|
28
+ prompt.choice ">>>> waves @ 1-2ft", 1
29
+ prompt.choice ">> waves @ 2-3ft", 2
30
+ prompt.choice ">> waves @ 4-5ft", 3
31
+ prompt.choice ">> waves >= 6ft", 4
32
+ end
33
+ puts "-----------------------------"
34
+ end
35
+
36
+
37
+ def finalize_notify
38
+ prompt = TTY::Prompt.new
39
+
40
+ puts ""
41
+ prompt.select("Nice, your notification set. What would you like to do now?") do |prompt|
42
+ prompt.choice "return to main menu"
43
+ prompt.choice "set another notification"
44
+ end
45
+ end
46
+
47
+ end
48
+
49
+ =end
@@ -0,0 +1,48 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "./lib/surf_data/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "surf_rockaway"
8
+ spec.version = SurfRockaway::VERSION
9
+ spec.authors = ["kyle crews"]
10
+ spec.email = ["dev.kylecrews@gmail.com"]
11
+
12
+ spec.summary = %q{ A Florida native for most of my life, moving to NYC over the summer
13
+ left me longing for the beach. I soon discovered Rockaway Beach is
14
+ the closest surf spot to the city. (bonus you can take the water ferry!)
15
+ All too often, I found myself lost in a terminal screen ... searching for
16
+ an excuse to hit the beach for a few hours. So, I created surf-rockaway.
17
+ This gem provides a quick way to check the current surf condtions without ever leaving the terminal }
18
+ spec.description = %q{ Simple ruby based CLI application to pull a surf report for Rockaway Beach, Queens, NY }
19
+ spec.homepage = "https://github.com/kyle-crews/surf-rockaway"
20
+ spec.license = "MIT"
21
+
22
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
23
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
24
+ #if spec.respond_to?(:metadata)
25
+ # spec.metadata["allowed_push_host"] = "http://mygemserver.com"
26
+ #
27
+ #
28
+ # spec.metadata["homepage_uri"] = spec.homepage
29
+ # spec.metadata["source_code_uri"] = "https://github.com/kyle-crews/surf-rockaway"
30
+ # spec.metadata["changelog_uri"] = "https://github.com/kyle-crews/surf-rockaway/blob/master/CHANGELOG.md"
31
+ #else
32
+ # raise "RubyGems 2.0 or newer is required to protect against " \
33
+ # "public gem pushes."
34
+ #end
35
+
36
+ # Specify which files should be added to the gem when it is released.
37
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
38
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
39
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
40
+ end
41
+ spec.bindir = "exe"
42
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
43
+ spec.require_paths = ["lib"]
44
+
45
+ spec.add_development_dependency "bundler", "~> 2.0"
46
+ spec.add_development_dependency "rake", "~> 10.0"
47
+ spec.add_development_dependency "rspec", "~> 3.0"
48
+ end
metadata ADDED
@@ -0,0 +1,108 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: surf_rockaway
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - kyle crews
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-10-07 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: '2.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
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
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: " Simple ruby based CLI application to pull a surf report for Rockaway
56
+ Beach, Queens, NY "
57
+ email:
58
+ - dev.kylecrews@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".DS_Store"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/.DS_Store
69
+ - bin/console
70
+ - bin/setup
71
+ - bin/surf-rockaway
72
+ - lib/.DS_Store
73
+ - lib/environment.rb
74
+ - lib/surf_data/.DS_Store
75
+ - lib/surf_data/cli.rb
76
+ - lib/surf_data/surf_report.rb
77
+ - lib/surf_data/version.rb
78
+ - still_in_progress/notification.rb
79
+ - surf_rockaway.gemspec
80
+ homepage: https://github.com/kyle-crews/surf-rockaway
81
+ licenses:
82
+ - MIT
83
+ metadata: {}
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ requirements: []
99
+ rubygems_version: 3.0.3
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: A Florida native for most of my life, moving to NYC over the summer left
103
+ me longing for the beach. I soon discovered Rockaway Beach is the closest surf
104
+ spot to the city. (bonus you can take the water ferry!) All too often, I found
105
+ myself lost in a terminal screen ... searching for an excuse to hit the beach for
106
+ a few hours. So, I created surf-rockaway. This gem provides a quick way to check
107
+ the current surf condtions without ever leaving the terminal
108
+ test_files: []