cpdundon_cli_app_take3 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b02a75a0b1ba350c30a0c8d1969b98b3eb9754fcf8c93e9ee5377347228c59c0
4
- data.tar.gz: 63facdf978a65288fcb3cae37ed95bcea9fc90f7fc7d75e2c318d5e08b807acf
3
+ metadata.gz: e72112879e2f0b16e7074248851506828e96995ad90b8666fbf608962dc44fd8
4
+ data.tar.gz: 9954503ebf783bb19fc3164231863315963c97dd0f3e061eff5543a7ab91d53b
5
5
  SHA512:
6
- metadata.gz: 7d5ed4cf1c3308ccf6551c1bbab12678c7187785f835b27326e4229211f74b867bdea9b7fdef44f2afa87111257dad8bda42a5e774b63a0310a9552fab9db20e
7
- data.tar.gz: 30b2d6bce264e3086583ecaefd41c29ef5d1d191a594b197173fe283a27cef7be05c399573e4de39993c8e0da0ee465813ee3c1dd006eb1660705afd9a8fe792
6
+ metadata.gz: ea29852392d039f467a18901a68123d6ddc750a1c63233c8aab2c2aa32bae9108bfe5e2bdb6ae311e0681245e24eec1f4306db90fe7584167cc6a1f41bb79038
7
+ data.tar.gz: '029b0c908762170ce7e809a519f634a09b200b624aef96d34a31709d455efd7f94010eca88ae2a75f802bd6b391240471c44bf9f227ad5f8f72752cfc65a9a15'
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
@@ -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 chris.dundon@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/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
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 cpdundon_cli_app_take3.gemspec
6
+ gemspec
7
+ #require 'cpdundon_cli_app_take3'
data/Gemfile.lock ADDED
@@ -0,0 +1,62 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cpdundon_cli_app_take3 (0.1.1)
5
+ savon (~> 2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ akami (1.3.1)
11
+ gyoku (>= 0.4.0)
12
+ nokogiri
13
+ builder (3.2.3)
14
+ diff-lcs (1.3)
15
+ gyoku (1.3.1)
16
+ builder (>= 2.1.2)
17
+ httpi (2.4.3)
18
+ rack
19
+ socksify
20
+ mini_portile2 (2.3.0)
21
+ nokogiri (1.8.2)
22
+ mini_portile2 (~> 2.3.0)
23
+ nori (2.6.0)
24
+ rack (2.0.5)
25
+ rake (10.5.0)
26
+ rspec (3.7.0)
27
+ rspec-core (~> 3.7.0)
28
+ rspec-expectations (~> 3.7.0)
29
+ rspec-mocks (~> 3.7.0)
30
+ rspec-core (3.7.1)
31
+ rspec-support (~> 3.7.0)
32
+ rspec-expectations (3.7.0)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.7.0)
35
+ rspec-mocks (3.7.0)
36
+ diff-lcs (>= 1.2.0, < 2.0)
37
+ rspec-support (~> 3.7.0)
38
+ rspec-support (3.7.1)
39
+ savon (2.12.0)
40
+ akami (~> 1.2)
41
+ builder (>= 2.1.2)
42
+ gyoku (~> 1.2)
43
+ httpi (~> 2.3)
44
+ nokogiri (>= 1.8.1)
45
+ nori (~> 2.4)
46
+ wasabi (~> 3.4)
47
+ socksify (1.7.1)
48
+ wasabi (3.5.0)
49
+ httpi (~> 2.0)
50
+ nokogiri (>= 1.4.2)
51
+
52
+ PLATFORMS
53
+ ruby
54
+
55
+ DEPENDENCIES
56
+ bundler (~> 1.16)
57
+ cpdundon_cli_app_take3!
58
+ rake (~> 10.0)
59
+ rspec (~> 3.0)
60
+
61
+ BUNDLED WITH
62
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Christopher P. Dundon
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,43 @@
1
+ # CpdundonCliAppTake3
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/cpdundon_cli_app_take3`. 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
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'cpdundon_cli_app_take3'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install cpdundon_cli_app_take3
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cpdundon_cli_app_take3. 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.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the CpdundonCliAppTake3 project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cpdundon_cli_app_take3/blob/master/CODE_OF_CONDUCT.md).
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/bin ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/config'
4
+
5
+ cli = CLI.new(8530973, 8518750, 'New York Harbor')
6
+ cli.main
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ #require "cpdundon_cli_app_take3"
5
+
6
+ require "irb"
7
+ require_relative "../lib/config"
8
+
9
+ # You can add fixtures and/or initialization code here to make experimenting
10
+ # with your gem easier. You can also use a different console, if you like.
11
+
12
+ # (If you use this, don't forget to add pry to your Gemfile!)
13
+ # require "pry"
14
+ # Pry.start
15
+
16
+ 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
@@ -0,0 +1,37 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "cpdundon_cli_app_take3/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cpdundon_cli_app_take3"
8
+ spec.version = CpdundonCliAppTake3::VERSION
9
+ spec.authors = ["Christopher P. Dundon"]
10
+ spec.email = ["chris.dundon@gmail.com"]
11
+
12
+ spec.summary = %q{Scrape wind velocity and water level data from NOAA CO-OPS SOAP web services.}
13
+ spec.homepage = "https://github.com/cpdundon/cpdundon_cli_app_take3"
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"] = "https://rubygems.org"
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 "rspec", "~> 3.0"
35
+
36
+ spec.add_dependency "savon", "~>2.0"
37
+ end
data/lib/cli.rb ADDED
@@ -0,0 +1,54 @@
1
+ require_relative './config'
2
+
3
+ class CLI
4
+
5
+ attr_reader :windID, :tideID, :location
6
+
7
+ def initialize (windID, tideID, location)
8
+ @windID = windID
9
+ @tideID = tideID
10
+ @location = location
11
+ end
12
+
13
+ def main()
14
+ input = nil
15
+ puts
16
+ puts "================================="
17
+ puts "'Exit' will stop data collection."
18
+ puts "================================="
19
+ puts
20
+
21
+ until (input == "exit") do
22
+ puts "Enter 'y' to pull wind and tide measurements at the #{self.location} location."
23
+ puts "Enter 'yd' for more detail."
24
+ puts
25
+ puts "The NOAA service updates every 6 minutes."
26
+ puts
27
+
28
+ input = gets.strip.downcase
29
+ puts
30
+
31
+ if input == "y" || input == "yd"
32
+ gwl = GetWaterLevel.new
33
+ gwv = GetWind.new
34
+
35
+ wl_data = gwl.pull_data
36
+ wv_data = gwv.pull_data
37
+
38
+ wl = NOAA_SOAP.most_recent(wl_data)
39
+ wv = NOAA_SOAP.most_recent(wv_data)
40
+
41
+ puts "Wind Speed at #{wv[:time_stamp]} GMT:"
42
+ puts "Wind speed is #{wv[:ws]} m\/s out of #{wv[:wd]} degrees."
43
+ puts "Gusts to #{wv[:wg]} m\/s are reported." if input == 'yd'
44
+
45
+
46
+ puts
47
+ puts "Water level at #{wl[:time_stamp]} GMT:"
48
+ puts "The water level is #{wl[:wl]} meters above/below sea level."
49
+ puts "Water level standard deviation is #{wl[:sigma]} meters." if input == 'yd'
50
+ end
51
+ puts
52
+ end
53
+ end
54
+ end
data/lib/config.rb ADDED
@@ -0,0 +1,8 @@
1
+ require_relative './gmt'
2
+ require_relative './noaa_soap'
3
+ require_relative './get_water_level'
4
+ require_relative './get_wind'
5
+ require_relative './cli'
6
+
7
+ require 'time'
8
+ require 'savon'
@@ -0,0 +1,3 @@
1
+ module CpdundonCliAppTake3
2
+ VERSION = "0.2.3"
3
+ end
@@ -0,0 +1,10 @@
1
+ require "cpdundon_cli_app_take3/version"
2
+
3
+ module CpdundonCliAppTake3
4
+ require 'gmt'
5
+ require 'noaa_soap'
6
+ require 'get_water_level'
7
+ require 'get_wind'
8
+ require 'cli'
9
+ require 'config'
10
+ end
@@ -0,0 +1,23 @@
1
+ require_relative './config'
2
+
3
+ class GetWaterLevel < NOAA_SOAP
4
+
5
+ WSDL = "https://opendap.co-ops.nos.noaa.gov/axis/webservices/waterlevelrawsixmin/wsdl/WaterLevelRawSixMin.wsdl"
6
+
7
+ def initialize
8
+ super WSDL
9
+ end
10
+
11
+ def client
12
+ super
13
+ end
14
+
15
+ def pull_data (station_id = 8454000)
16
+ message = {stationId: station_id.to_s, beginDate: GMT.gmt_less_1h, endDate: GMT.gmt_now, \
17
+ datum: "MLLW", unit: 0, timeZone: 0}
18
+
19
+ response = self.pull_response(:get_wl_raw_six_min_and_metadata, message)
20
+ response.to_hash[:water_level_raw_six_min_measurements][:data][:item] #this returns a hash of the data points.
21
+ end
22
+
23
+ end
data/lib/get_wind.rb ADDED
@@ -0,0 +1,23 @@
1
+ require_relative './config'
2
+
3
+ class GetWind < NOAA_SOAP
4
+
5
+ WSDL = "https://opendap.co-ops.nos.noaa.gov/axis/webservices/wind/wsdl/Wind.wsdl"
6
+
7
+ def initialize
8
+ super WSDL
9
+ end
10
+
11
+ def client
12
+ super
13
+ end
14
+
15
+ def pull_data (station_id = 8454000)
16
+ message = {stationId: station_id.to_s, beginDate: GMT.gmt_less_1h, endDate: GMT.gmt_now, \
17
+ unit: "Meters", timeZone: 0}
18
+
19
+ response = self.pull_response(:get_wind_and_metadata, message)
20
+ response.to_hash[:wind_measurements][:data][:item] #this returns a hash of the data points.
21
+ end
22
+
23
+ end
data/lib/gmt.rb ADDED
@@ -0,0 +1,19 @@
1
+ require_relative './config'
2
+
3
+ class GMT
4
+ def self.gmt_now
5
+ t = Time.now.gmtime
6
+ t.utc.strftime "%Y%m%d %H:%M"
7
+ end
8
+
9
+ def self.gmt_less_48h
10
+ t = Time.now.gmtime - (2 * 24 * 60 * 60)
11
+ t.utc.strftime "%Y%m%d %H:%M"
12
+ end
13
+
14
+ def self.gmt_less_1h
15
+ t = Time.now.gmtime - (60 * 60)
16
+ t.utc.strftime "%Y%m%d %H:%M"
17
+ end
18
+ end
19
+
data/lib/noaa_pull_NYH ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'cpdundon_cli_app_take3'
4
+
5
+ cli = CLI.new(8530973, 8518750, 'New York Harbor')
6
+ cli.main
data/lib/noaa_soap.rb ADDED
@@ -0,0 +1,34 @@
1
+ require_relative './config'
2
+
3
+ class NOAA_SOAP
4
+ attr_reader :client
5
+
6
+ def self.most_recent(data)
7
+ d = data.sort { |x,y| y[:time_stamp] <=> x[:time_stamp] }[0]
8
+ d
9
+ end
10
+
11
+ def initialize(wsdl = "https://opendap.co-ops.nos.noaa.gov/axis/webservices/waterlevelrawsixmin/wsdl/WaterLevelRawSixMin.wsdl")
12
+ create_client(wsdl)
13
+ end
14
+
15
+ def pull_response(operation, message)
16
+ response = self.client.call(operation, message: message)
17
+ response
18
+ rescue Savon::SOAPFault => error
19
+ fault_code = error.to_hash[:fault][:faultcode]
20
+ raise CustomError, fault_code
21
+ end
22
+
23
+ private
24
+ def create_client(wsdl)
25
+ client = Savon.client(wsdl: wsdl, \
26
+ open_timeout: 30, \
27
+ read_timeout: 30, \
28
+ log: false, \
29
+ follow_redirects: true)
30
+
31
+ @client = client
32
+ self.client
33
+ end
34
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpdundon_cli_app_take3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher P. Dundon
@@ -72,7 +72,29 @@ email:
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
- files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/bin
86
+ - bin/console
87
+ - bin/setup
88
+ - cpdundon_cli_app_take3.gemspec
89
+ - lib/cli.rb
90
+ - lib/config.rb
91
+ - lib/cpdundon_cli_app_take3.rb
92
+ - lib/cpdundon_cli_app_take3/version.rb
93
+ - lib/get_water_level.rb
94
+ - lib/get_wind.rb
95
+ - lib/gmt.rb
96
+ - lib/noaa_pull_NYH
97
+ - lib/noaa_soap.rb
76
98
  homepage: https://github.com/cpdundon/cpdundon_cli_app_take3
77
99
  licenses:
78
100
  - MIT