tide 0.1.2 → 0.1.3
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.
- data/README.rdoc +3 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/tide.rb +3 -7
- data/test/test_tide.rb +2 -2
- data/tide.gemspec +2 -3
- metadata +3 -4
- data/lib/.gitignore +0 -1
data/README.rdoc
CHANGED
@@ -2,10 +2,12 @@
|
|
2
2
|
|
3
3
|
Tide class fetches and returns Canadian tide prediction data from waterlevels.gc.ca
|
4
4
|
|
5
|
-
Accepts options for tide
|
5
|
+
Accepts options for tide station, date and timezone. Defaults to 7 days of tide prediction data (starting from today) for Sydney, Nova Scotia in Atlantic time.
|
6
6
|
|
7
7
|
Outputs a comma separated list of tides (date, time, height in meters) with Tide.new.to_csv or a formatted html table with Tide.new.to_html.
|
8
8
|
|
9
|
+
Alphabetical ist of station IDs can be found here: http://www.waterlevels.gc.ca/cgi-bin/tide-shc.cgi?queryType=showIndex&language=english&letter=A
|
10
|
+
|
9
11
|
== Example Output
|
10
12
|
|
11
13
|
===Tide.new.to_csv
|
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ Jeweler::Tasks.new do |gem|
|
|
18
18
|
gem.homepage = "http://github.com/kenzie/tide"
|
19
19
|
gem.license = "MIT"
|
20
20
|
gem.summary = %Q{Tide class fetches and returns Canadian tide prediction data from waterlevels.gc.ca}
|
21
|
-
gem.description = %Q{Tide class fetches and returns Canadian tide prediction data from waterlevels.gc.ca. Accepts options for tide
|
21
|
+
gem.description = %Q{Tide class fetches and returns Canadian tide prediction data from waterlevels.gc.ca. Accepts options for tide station, date and timezone. Defaults to 7 days of tide prediction data (starting from today) for Sydney, Nova Scotia in Atlantic time. Outputs a comma separated list of tides (date, time, height in meters) with Tide.new.to_csv or a formatted html table with Tide.new.to_html.}
|
22
22
|
gem.email = "kenzie@route19.com"
|
23
23
|
gem.authors = ["Kenzie Campbell"]
|
24
24
|
# dependencies defined in Gemfile
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/lib/tide.rb
CHANGED
@@ -6,23 +6,21 @@ class Tide
|
|
6
6
|
|
7
7
|
POST_URL = 'http://www.waterlevels.gc.ca/cgi-bin/tide-shc.cgi'
|
8
8
|
TIDE_REGEX = /#\sDate;Time;Height<br>(.*)<br><\/p><\/td>/
|
9
|
-
STATION_REGEX =
|
10
|
-
INIT_DEFAULTS = { :
|
9
|
+
STATION_REGEX = /#\sStation\s:\s(.*)\s\(\d+\).*/
|
10
|
+
INIT_DEFAULTS = { :station => 610, :timezone => 'AST', :date => Time.now }
|
11
11
|
|
12
12
|
attr_reader :location
|
13
13
|
|
14
14
|
# Create new tide table.
|
15
15
|
def initialize(options = {})
|
16
16
|
options = INIT_DEFAULTS.merge(options)
|
17
|
-
@zone = options[:zone]
|
18
|
-
@region = options[:region]
|
19
17
|
@station = options[:station]
|
20
18
|
@timezone = options[:timezone]
|
21
19
|
@date = options[:date]
|
22
20
|
@location = data.match(STATION_REGEX)[1]
|
23
21
|
end
|
24
22
|
|
25
|
-
#
|
23
|
+
# Download raw data
|
26
24
|
def data
|
27
25
|
@data ||= download_tide_data
|
28
26
|
end
|
@@ -44,8 +42,6 @@ private
|
|
44
42
|
res = Net::HTTP.post_form(
|
45
43
|
URI.parse(POST_URL),
|
46
44
|
{
|
47
|
-
'zone' => @zone,
|
48
|
-
'region' => @region,
|
49
45
|
'station' => @station,
|
50
46
|
'year' => @date.year,
|
51
47
|
'month' => @date.month,
|
data/test/test_tide.rb
CHANGED
@@ -6,8 +6,8 @@ class TideTest < Test::Unit::TestCase
|
|
6
6
|
# TODO fake web requests
|
7
7
|
|
8
8
|
def test_location
|
9
|
-
@tide = Tide.new(:
|
10
|
-
assert_match "
|
9
|
+
@tide = Tide.new(:station => 9)
|
10
|
+
assert_match "Garnet Point", @tide.location
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_to_csv
|
data/tide.gemspec
CHANGED
@@ -5,12 +5,12 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{tide}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Kenzie Campbell}]
|
12
12
|
s.date = %q{2011-06-09}
|
13
|
-
s.description = %q{Tide class fetches and returns Canadian tide prediction data from waterlevels.gc.ca. Accepts options for tide
|
13
|
+
s.description = %q{Tide class fetches and returns Canadian tide prediction data from waterlevels.gc.ca. Accepts options for tide station, date and timezone. Defaults to 7 days of tide prediction data (starting from today) for Sydney, Nova Scotia in Atlantic time. Outputs a comma separated list of tides (date, time, height in meters) with Tide.new.to_csv or a formatted html table with Tide.new.to_html.}
|
14
14
|
s.email = %q{kenzie@route19.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE.txt",
|
@@ -24,7 +24,6 @@ Gem::Specification.new do |s|
|
|
24
24
|
"README.rdoc",
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
|
-
"lib/.gitignore",
|
28
27
|
"lib/tide.rb",
|
29
28
|
"test/helper.rb",
|
30
29
|
"test/test_tide.rb",
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: tide
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kenzie Campbell
|
@@ -56,7 +56,7 @@ dependencies:
|
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
58
|
version_requirements: *id004
|
59
|
-
description: Tide class fetches and returns Canadian tide prediction data from waterlevels.gc.ca. Accepts options for tide
|
59
|
+
description: Tide class fetches and returns Canadian tide prediction data from waterlevels.gc.ca. Accepts options for tide station, date and timezone. Defaults to 7 days of tide prediction data (starting from today) for Sydney, Nova Scotia in Atlantic time. Outputs a comma separated list of tides (date, time, height in meters) with Tide.new.to_csv or a formatted html table with Tide.new.to_html.
|
60
60
|
email: kenzie@route19.com
|
61
61
|
executables: []
|
62
62
|
|
@@ -73,7 +73,6 @@ files:
|
|
73
73
|
- README.rdoc
|
74
74
|
- Rakefile
|
75
75
|
- VERSION
|
76
|
-
- lib/.gitignore
|
77
76
|
- lib/tide.rb
|
78
77
|
- test/helper.rb
|
79
78
|
- test/test_tide.rb
|
@@ -91,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
91
90
|
requirements:
|
92
91
|
- - ">="
|
93
92
|
- !ruby/object:Gem::Version
|
94
|
-
hash:
|
93
|
+
hash: -3486769737923497974
|
95
94
|
segments:
|
96
95
|
- 0
|
97
96
|
version: "0"
|
data/lib/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rdoc/
|