daily_surfing 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bf0e77e0bfb9f6261f5b7ebba35ec5ec940de3a6
4
+ data.tar.gz: 18c7da4b66a19a2b7c875f37798bcc2bb4856f0c
5
+ SHA512:
6
+ metadata.gz: 7e467056a61d00853f44a727f38b9080019c5e2b2a6ca15f2ad1cd0f3d970e6490a020ff5d77f6a20a0161a975c105589eb0ae1978e878eb41e8cff3c62b6760
7
+ data.tar.gz: 07db38dfc2da33da0ccafca0395b1410d84e51a6bb5aca90da12bb64949775d7c612359a1b201b439df487f422e977c5831392619502a7665348c08b899ac1a2
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,13 @@
1
+ ##Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers 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. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the Contributor Covenant, version 1.0.0, available at http://contributor-covenant.org/version/1/0/0/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in daily_surfing.gemspec
6
+ gemspec
@@ -0,0 +1,32 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ daily_surfing (0.1.0)
5
+ nokogiri
6
+ require_all
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ coderay (1.1.2)
12
+ method_source (0.9.0)
13
+ mini_portile2 (2.3.0)
14
+ nokogiri (1.8.1-x64-mingw32)
15
+ mini_portile2 (~> 2.3.0)
16
+ pry (0.11.3)
17
+ coderay (~> 1.1.0)
18
+ method_source (~> 0.9.0)
19
+ rake (10.5.0)
20
+ require_all (1.4.0)
21
+
22
+ PLATFORMS
23
+ x64-mingw32
24
+
25
+ DEPENDENCIES
26
+ bundler (~> 1.16)
27
+ daily_surfing!
28
+ pry
29
+ rake (~> 10.0)
30
+
31
+ BUNDLED WITH
32
+ 1.16.0
@@ -0,0 +1,22 @@
1
+
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) 2015 Jered Sweeney
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ # DailySurfing
2
+
3
+ Welcome to the daily_surfing gem! This gem is designed for surfing enthusiasts who do not want to waste their time finding quick surfing forecasts for Florida's East Coast. Just run this gem and you can get an up-to-date 3-day forecast of the entire coast, or select one of four regions (North Florida, Central Florida, Palm Beach area or the Broward/Miami/Dade area). This will give you enough information to determine when and where your next surf will be.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'daily_surfing'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install daily_surfing
20
+
21
+ ## Usage
22
+
23
+ Run: daily_surfing after installing the gem.
24
+
25
+ ## Development
26
+
27
+ 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.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/JDSweeney1/daily_surfing.
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the MIT License.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require_relative '../config/environment'
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
+ Cli.run
13
+ #require "irb"
14
+ #IRB.start(__FILE__)
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../config/environment'
4
+
5
+ Cli.run
@@ -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
@@ -0,0 +1,10 @@
1
+ require 'bundler'
2
+ Bundler.require
3
+
4
+ require 'pry'
5
+ require 'nokogiri'
6
+ require 'open-uri'
7
+ require 'require_all'
8
+
9
+
10
+ require_all '../lib/daily_surfing'
@@ -0,0 +1,38 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "daily_surfing/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "daily_surfing"
8
+ spec.version = DailySurfing::VERSION
9
+ spec.authors = ["Jered Sweeney"]
10
+ spec.email = ["sweeneyjered@gmail.com"]
11
+
12
+ spec.summary = %q{A gem used to get three day surf forecasts of Florida's East Coast.}
13
+ spec.homepage = "https://github.com/JDSweeney1/daily_surfing"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ # if spec.respond_to?(:metadata)
19
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
+ # else
21
+ # raise "RubyGems 2.0 or newer is required to protect against " \
22
+ # "public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.16"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "pry"
35
+
36
+ spec.add_dependency "nokogiri"
37
+ spec.add_dependency "require_all"
38
+ end
@@ -0,0 +1,4 @@
1
+ require "daily_surfing/version"
2
+ module DailySurfing
3
+ # Your code goes here...
4
+ end
@@ -0,0 +1,98 @@
1
+ class Cli
2
+
3
+ def self.run
4
+ puts "welcome to Daily Surfing!"
5
+
6
+ loop do
7
+ puts ""
8
+ puts "Get your 3 day forecast for the entire east coast of Florida by typing 'all'"
9
+ puts "Or select one of four regions using their corresponding number.
10
+ 1. North Florida
11
+ 2. Central Florida
12
+ 3. Treasure Coast - Palm Beach
13
+ 4. Broward - Miami Dade"
14
+ puts " -----Type 'exit' to exit-----"
15
+ input = gets.strip
16
+ if input == "all"
17
+ self.all
18
+ elsif input == "1"
19
+ self.output_north_florida
20
+ self.start_over?
21
+ elsif input == "2"
22
+ self.output_cental_florida
23
+ self.start_over?
24
+ elsif input == "3"
25
+ self.output_palm_beach
26
+ self.start_over?
27
+ elsif input == "4"
28
+ self.output_broward_miami_dade
29
+ self.start_over?
30
+ elsif input == "exit"
31
+ puts ""
32
+ puts ""
33
+ puts "Thank you, please come again!"
34
+ exit
35
+ else
36
+ puts "I'm sorry, I didn't catch that. Please type all, 1, 2, 3, or 4"
37
+ end
38
+ end
39
+ end
40
+
41
+ def self.output_broward_miami_dade
42
+ report = Scraper.broward_miami_dade
43
+ self.cli_outline(report)
44
+ end
45
+
46
+ def self.output_palm_beach
47
+ report = Scraper.palm_beach
48
+ self.cli_outline(report)
49
+ end
50
+
51
+ def self.output_cental_florida
52
+ report = Scraper.cental_florida
53
+ self.cli_outline(report)
54
+ end
55
+
56
+ def self.output_north_florida
57
+ report = Scraper.north_florida
58
+ self.cli_outline(report)
59
+ end
60
+
61
+ def self.cli_outline(report)
62
+ puts "#{report.name}"
63
+ puts "------------------------------------------------------------------------------------------------------------------"
64
+ puts "#{report.date[0]} | Wave height: #{report.wave_height[0]} | Surfing Conditions: #{report.condition[0]} | Weather: #{report.weather[0]} - #{report.weather_temp[0]} |"
65
+ puts ""
66
+ puts "#{report.wind[0]}"
67
+ puts "------------------------------------------------------------------------------------------------------------------"
68
+ puts "#{report.date[1]} | Wave height: #{report.wave_height[1]} | Surfing Conditions: #{report.condition[1]} | Weather: #{report.weather[1]} - #{report.weather_temp[1]} |"
69
+ puts ""
70
+ puts "#{report.wind[1]}"
71
+ puts "------------------------------------------------------------------------------------------------------------------"
72
+ puts "#{report.date[2]} | Wave height: #{report.wave_height[2]} | Surfing Conditions: #{report.condition[2]} | Weather: #{report.weather[2]} - #{report.weather_temp[2]} |"
73
+ puts ""
74
+ puts "#{report.wind[2]}"
75
+ puts "------------------------------------------------------------------------------------------------------------------"
76
+ puts ""
77
+ puts ""
78
+ end
79
+
80
+ def self.start_over?
81
+ puts "Would you like to go back to the main menu? (Yes/No)"
82
+ input = gets.upcase.strip
83
+ if input == ("NO" || "EXIT")
84
+ puts ""
85
+ puts ""
86
+ puts "Thank you, please come again!"
87
+ exit
88
+ end
89
+ end
90
+
91
+ def self.all
92
+ self.output_north_florida
93
+ self.output_cental_florida
94
+ self.output_palm_beach
95
+ self.output_broward_miami_dade
96
+ self.start_over?
97
+ end
98
+ end
@@ -0,0 +1,3 @@
1
+ module Attributes
2
+ attr_accessor :name, :date, :condition, :wave_height, :wind, :weather, :weather_temp
3
+ end
@@ -0,0 +1,40 @@
1
+ class Scraper
2
+ include Attributes
3
+
4
+ def initialize(url)
5
+ surf_report = Nokogiri::HTML(open(url))
6
+
7
+ self.condition = surf_report.css("div.day-slider-container div div strong").collect{|w| w.text}
8
+ self.wave_height = surf_report.css("div.day-slider-container h1").collect{|h| h.text}
9
+ # All information in the data array use "span" with no identifying attributes, therefore array indecies were used to sort them out.
10
+ data = surf_report.css("div.day-slider-container div div span").collect{|t| t.text}.delete_if{|k| k.include?("Kurt")}
11
+ self.date = [data[0], data[3], data[6]]
12
+ self.wind = [data[2], data[5], data[8]]
13
+ self.weather = [data[9], data[11], data[13]]
14
+ self.weather_temp = [
15
+ data[10].gsub(/\u00B0/, ""),
16
+ data[12].gsub(/\u00B0/, ""),
17
+ data[14].gsub(/\u00B0/, "")
18
+ ]
19
+ end
20
+
21
+ def self.broward_miami_dade
22
+ scraper = self.new("http://www.surfline.com/surf-forecasts/florida/broward---miami-dade_121124/")
23
+ Surf_Data.new("Broward/Miami/Dade", scraper.date, scraper.condition, scraper.wave_height, scraper.wind, scraper.weather, scraper.weather_temp)
24
+ end
25
+
26
+ def self.palm_beach
27
+ scraper = self.new("http://www.surfline.com/surf-forecasts/florida/treasure-coast---palm-beach_2155/")
28
+ Surf_Data.new("Palm Beach", scraper.date, scraper.condition, scraper.wave_height, scraper.wind, scraper.weather, scraper.weather_temp)
29
+ end
30
+
31
+ def self.cental_florida
32
+ scraper = self.new("http://www.surfline.com/surf-forecasts/florida/central-florida_2154/")
33
+ Surf_Data.new("Central Florida", scraper.date, scraper.condition, scraper.wave_height, scraper.wind, scraper.weather, scraper.weather_temp)
34
+ end
35
+
36
+ def self.north_florida
37
+ scraper = self.new("http://www.surfline.com/surf-forecasts/florida/north-florida_2153/")
38
+ Surf_Data.new("North Florida", scraper.date, scraper.condition, scraper.wave_height, scraper.wind, scraper.weather, scraper.weather_temp)
39
+ end
40
+ end
@@ -0,0 +1,13 @@
1
+ class Surf_Data
2
+ include Attributes
3
+
4
+ def initialize(name = nil, date = nil, condition = nil, wave_height = nil, wind = nil, weather = nil, weather_temp = nil)
5
+ @name = name
6
+ @date = date
7
+ @condition = condition
8
+ @wave_height = wave_height
9
+ @wind = wind
10
+ @weather = weather
11
+ @weather_temp = weather_temp
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module DailySurfing
2
+ VERSION = "0.1.0"
3
+ end
data/spec.md ADDED
@@ -0,0 +1,6 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [ ] Have a CLI for interfacing with the application
5
+ - [ ] Pull data from an external source
6
+ - [ ] Implement both list and detail views
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: daily_surfing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jered Sweeney
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-12-08 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
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: require_all
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description:
84
+ email:
85
+ - sweeneyjered@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - CODE_OF_CONDUCT.md
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/daily_surfing
99
+ - bin/setup
100
+ - config/environment.rb
101
+ - daily_surfing.gemspec
102
+ - lib/daily_surfing.rb
103
+ - lib/daily_surfing/cli.rb
104
+ - lib/daily_surfing/daily_surfing.rb
105
+ - lib/daily_surfing/scraper.rb
106
+ - lib/daily_surfing/surf_data.rb
107
+ - lib/daily_surfing/version.rb
108
+ - spec.md
109
+ homepage: https://github.com/JDSweeney1/daily_surfing
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.6.13
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: A gem used to get three day surf forecasts of Florida's East Coast.
133
+ test_files: []