surf_report 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e39a3781b7d49b0a583297ded9c91f0adf5c78fe
4
+ data.tar.gz: 49b6597fd0c5a1359e1f65deee158aa95bae1d7b
5
+ SHA512:
6
+ metadata.gz: 6b069f7ce523b7e0d244955c6da581f17ba105f3390b9bae24343efdd43a445408dff4e184e875617b511f9042d061351e440f55959577e5397c0ca719844bd4
7
+ data.tar.gz: f607d7a920695874f67578052ec8f595f69dddcedb975f2a1ab6806c7a1ac0d5e1d79c2a4262910d2a4aa96268e54eaaa979ab95dc1851b15650b8e5d17caf34
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at thesiameseelectric@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in surf_report.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,34 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ surf-report-cli-gem (0.1.0)
5
+ colorize
6
+ nokogiri
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ coderay (1.1.1)
12
+ colorize (0.7.7)
13
+ method_source (0.8.2)
14
+ mini_portile2 (2.0.0)
15
+ nokogiri (1.6.7.2)
16
+ mini_portile2 (~> 2.0.0.rc2)
17
+ pry (0.10.3)
18
+ coderay (~> 1.1.0)
19
+ method_source (~> 0.8.1)
20
+ slop (~> 3.4)
21
+ rake (10.4.2)
22
+ slop (3.6.0)
23
+
24
+ PLATFORMS
25
+ ruby
26
+
27
+ DEPENDENCIES
28
+ bundler (~> 1.11)
29
+ pry
30
+ rake (~> 10.0)
31
+ surf-report-cli-gem!
32
+
33
+ BUNDLED WITH
34
+ 1.11.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 SiamKing
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/NOTES.md ADDED
@@ -0,0 +1,22 @@
1
+ - A command line interface for Los Angeles surf report
2
+
3
+ Show the surf report for the next three days
4
+
5
+ 1. Today
6
+ 2. Tomorrow
7
+ 3. The next day
8
+
9
+ Which day would you like to know more about?
10
+
11
+ 1. Today
12
+ - full forecast
13
+ 2. Tomorrow
14
+ - full forecast
15
+ 3. The next day
16
+ - full forecast
17
+
18
+ What does the forecast show?
19
+ The date
20
+ The wave Height
21
+ wave description
22
+ Swell direction
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # SurfReport
2
+
3
+ What's up brah! This is a totally wicked program that will tell you which pipe you should hit!
4
+
5
+ ## Installation
6
+
7
+ You can install this gem via `gem install surf-report-cli-gem`. The `surf-report` CLI will be installed and you can run `surf-report` to get a list of the waves you can hit now right in your command line.
8
+
9
+ And then execute:
10
+
11
+ $ bundle
12
+
13
+ Or install it yourself as:
14
+
15
+ $ gem install surf_report
16
+
17
+ ## Usage
18
+
19
+ Want to hit the waves today, tomorrow or the next day? Our own surfer dude will tell you whether to hit the waves or hit the snooze!
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](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/SiamKing/surf-report-cli-gem. 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.
30
+
31
+
32
+ ## License
33
+
34
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "surf_report"
5
+
6
+ require "irb"
7
+ IRB.start
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-report ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require "bundler/setup"
3
+ require "surf_report"
4
+
5
+ SurfReport::CLI.new.call
@@ -0,0 +1,61 @@
1
+ require_relative "../surf_report/scraper.rb"
2
+ require_relative "../surf_report/report.rb"
3
+ require 'colorize'
4
+
5
+ require 'pry'
6
+ class SurfReport::CLI
7
+
8
+ def call
9
+ make_days
10
+ list_surf_reports
11
+ menu
12
+ later
13
+ end
14
+
15
+ def make_days
16
+ days_array = Scraper.scrape_index_page
17
+ SurfReport::Report.create_from_collection(days_array)
18
+ end
19
+
20
+ def list_surf_reports
21
+ puts "\n"
22
+ puts "******".colorize(:blue) + "3 Day Surf Report for Los Angeles".colorize(:black) + "******".colorize(:blue)
23
+ puts "\n"
24
+ @days = SurfReport::Report.all
25
+ @days.each.with_index(1) do |day, i|
26
+ puts "#{i}.".colorize(:magenta) + "#{day.date}".colorize(:black) + "- #{day.forecast.colorize(:blue)}"
27
+ end
28
+ end
29
+
30
+ def menu
31
+ input = nil
32
+ while input != "exit"
33
+ puts "\n"
34
+ puts "What number would you like to see a detailed report for? Oh yeah...you can type 'list' to see the days again or 'later' to get outta here!"
35
+ input = gets.strip.downcase
36
+
37
+ if input.to_i.between?(1, 3)
38
+ the_day = @days[input.to_i - 1]
39
+ puts "\n"
40
+ puts "The date you chose is #{the_day.date}".colorize(:red)
41
+ puts "Wave Height : ".colorize(:cyan) + "#{the_day.wave_size.colorize(:black)}"
42
+ puts "Wave Description: ".colorize(:cyan) + "#{the_day.wave_description.colorize(:black)}"
43
+ puts "Swell Direction: ".colorize(:cyan) + "#{the_day.swell_direction.colorize(:black)}"
44
+ puts "Surfer Dude says: ".colorize(:cyan) + "#{the_day.surfer_dude_says.colorize(:black)}"
45
+
46
+ elsif input == "list"
47
+ list_surf_reports
48
+ elsif input == "later"
49
+ break
50
+ else
51
+ puts "\n"
52
+ puts "Not sure what you're getting at man. Maybe you should slow down a little. Take a deep breath."
53
+ end
54
+ end
55
+
56
+ end
57
+
58
+ def later
59
+ puts "Later brah! Hope the waves are swell;)"
60
+ end
61
+ end
@@ -0,0 +1,56 @@
1
+ class SurfReport::Report
2
+ attr_accessor :name, :date, :forecast, :wave_size, :wave_description, :swell_direction, :surfer_dude_says, :url
3
+ @@all = []
4
+
5
+ def initialize(report_hash)
6
+ report_hash.collect {|key, value| self.send(("#{key}="), value)}
7
+ @@all << self
8
+ end
9
+
10
+ def self.create_from_collection(days_array)
11
+ days_array.each{|day| self.new(day)}
12
+ end
13
+
14
+ def surfer_dude_says
15
+ if @wave_size == "1-3ft"
16
+ self.surfer_dude_says = "Stay home and have a brewsky instead brah! Tomorrow will be a better day (if you're not too hungover)!"
17
+ elsif @wave_size == "2-3ft+" || @wave_size == "2-3ft"
18
+ self.surfer_dude_says = "Might be a few good ones out there! Remember: The water is you and you are the water."
19
+ else
20
+ self.surfer_dude_says = "EPIC SWELL! Show Keanu how it's done in SoCal! GET OFF MY WAAAAAVE!!!"
21
+ end
22
+ end
23
+
24
+ def self.all
25
+ @@all
26
+ end
27
+ end
28
+ # day_1 = self.new
29
+ # day_1.date = "4/7/2016"
30
+ # day_1.forecast = "poor"
31
+ # day_1.wave_size = "1-2 ft"
32
+ # day_1.wave_description = "wave_description"
33
+ # day_1.swell_direction = "swell_direction"
34
+ # day_1.surfer_dude_says = "Stay home and have a brewsky instead brah!"
35
+ # day_1.url = "http://www.surfline.com/surf-forecasts/southern-california/south-los-angeles_2951"
36
+ #
37
+ # day_2 = self.new
38
+ # day_2.date = "date"
39
+ # day_2.forecast = "shitty"
40
+ # day_2.wave_size = "wave_size"
41
+ # day_2.wave_description = "wave_description"
42
+ # day_2.swell_direction = "swell_direction"
43
+ # day_2.surfer_dude_says = "Wicked! Get out there and shred!"
44
+ # day_2.url = "http://www.surfline.com/surf-forecasts/southern-california/south-los-angeles_2951"
45
+ #
46
+ # day_3 = self.new
47
+ # day_3.date = "date"
48
+ # day_3.forecast = "fair"
49
+ # day_3.wave_size = "wave_size"
50
+ # day_3.wave_description = "wave_description"
51
+ # day_3.swell_direction = "swell_direction"
52
+ # day_3.surfer_dude_says = "EPIC SWELL! Show Keanu how it's done in SoCal!"
53
+ # day_3.url = "http://www.surfline.com/surf-forecasts/southern-california/south-los-angeles_2951"
54
+ #
55
+ # [day_1, day_2, day_3]
56
+ # end
@@ -0,0 +1,46 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+ require 'pry'
4
+
5
+ class Scraper
6
+
7
+ def self.scrape_index_page
8
+ doc = Nokogiri::HTML(open("http://www.surfline.com/surf-forecasts/southern-california/south-los-angeles_2951"))
9
+ days = doc.css("div.day-slider-container")
10
+ report = {}
11
+ surf_days = [days.children[1], days.children[3], days.children[5]]
12
+
13
+ surf_days.each_with_index.map do |day, i|
14
+ { :date => day.children.css("span")[0].text,
15
+ :forecast => day.css("strong").text,
16
+ :wave_size => day.css("h1").text,
17
+ :wave_description => day.children.css("span")[2].text,
18
+ :swell_direction => day.children.css("span")[3].text }
19
+ end
20
+
21
+ end
22
+ end
23
+
24
+
25
+ # all info are nested in divs
26
+ # days = doc.css("div.day-slider-container").text
27
+ # children indexes are odd numbers - 1, 3, & 5 so I'm setting them equal to their own array
28
+ # surf_days = [days.children[1], days.children[3], days.children[5]]
29
+ # :date => day.children.css("span")[0].text
30
+ # :forecast => day.css("strong").text
31
+ # :wave_size => day.children.css("span")[2].text
32
+ # :wave_description => day.children.css("span")[3].text}
33
+ # dates = days.children[1].children.css("span")[0].text
34
+ # wave_size = days.children[1].children.css("span")[2].text
35
+ # wave_description = days.children[1].children.css("span")[3].text
36
+
37
+
38
+
39
+
40
+ # Scrape webpage for 3 days:
41
+ # => each day has:
42
+ # => date
43
+ # => brief forecast
44
+ # => wave_size
45
+ # => wave_description
46
+ # => swell_direction
@@ -0,0 +1,3 @@
1
+ module SurfReport
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require_relative './surf_report/version'
2
+ require_relative './surf_report/cli'
3
+ require_relative './surf_report/report'
4
+ require_relative './surf_report/scraper'
5
+ require "nokogiri"
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'surf_report/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "surf_report"
8
+ spec.version = SurfReport::VERSION
9
+ spec.authors = ["SiamKing"]
10
+ spec.email = ["thesiameseelectric@gmail.com"]
11
+
12
+ spec.summary = %q{Waves in Los Angeles}
13
+ spec.description = %q{Waves in Los Angeles}
14
+ spec.homepage = "https://github.com/SiamKing/surf-report-cli-gem."
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.11"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+
26
+ spec.add_development_dependency "pry"
27
+ spec.add_dependency "nokogiri"
28
+ spec.add_dependency "colorize"
29
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: surf_report
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - SiamKing
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-09 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.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
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: colorize
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: Waves in Los Angeles
84
+ email:
85
+ - thesiameseelectric@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - CODE_OF_CONDUCT.md
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - LICENSE.txt
94
+ - NOTES.md
95
+ - README.md
96
+ - Rakefile
97
+ - bin/console
98
+ - bin/setup
99
+ - bin/surf-report
100
+ - lib/surf_report.rb
101
+ - lib/surf_report/cli.rb
102
+ - lib/surf_report/report.rb
103
+ - lib/surf_report/scraper.rb
104
+ - lib/surf_report/version.rb
105
+ - surf_report.gemspec
106
+ homepage: https://github.com/SiamKing/surf-report-cli-gem.
107
+ licenses:
108
+ - MIT
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.4.5.1
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Waves in Los Angeles
130
+ test_files: []
131
+ has_rdoc: