ndbc 0.0.2 → 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 +4 -4
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/README.md +2 -0
- data/Rakefile +5 -0
- data/changelog.md +3 -0
- data/lib/ndbc.rb +1 -0
- data/lib/ndbc/exceptions.rb +4 -0
- data/lib/ndbc/station.rb +15 -6
- data/lib/ndbc/station_table.rb +7 -1
- data/lib/ndbc/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/continuous_winds_data_station_not_found.yml +87 -0
- data/spec/fixtures/vcr_cassettes/spectral_wave_forecasts_station_not_found.yml +91 -0
- data/spec/fixtures/vcr_cassettes/spectral_wave_summaries_station_not_found.yml +87 -0
- data/spec/fixtures/vcr_cassettes/standard_meteorological_data_station_not_found.yml +87 -0
- data/spec/ndbc/station_spec.rb +25 -52
- metadata +14 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 798a2b4c6804dd746f2b8c8bb43ae3f03ddda398
|
|
4
|
+
data.tar.gz: d51b10530562554036cdd49c45a2b3c77c4ef0ac
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f94a80a9ea4639a9aa11a0be4ae6461ed33dd37ea004ab3589bedb1bd08c1565b33bc73bf162df24aac3dc9842605114c526c4dbc1e0fdfb068ce3b558d0d79
|
|
7
|
+
data.tar.gz: bfd72cef81ca3e3c70bb6204b5a1d4a92645f34b5e624c5b0a1618f96eec83dbda96e8e5a085e5d3aa893762fe0e9e969a048196e05d8a0b95bc8f5bfb5fea0b
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.2.5
|
data/.travis.yml
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/changelog.md
CHANGED
data/lib/ndbc.rb
CHANGED
data/lib/ndbc/station.rb
CHANGED
|
@@ -13,7 +13,7 @@ module NDBC
|
|
|
13
13
|
|
|
14
14
|
attr_accessor :id, :connection
|
|
15
15
|
attr_reader :owner, :ttype, :hull, :name, :payload, :location, :timezone, :forecast, :note,
|
|
16
|
-
:active
|
|
16
|
+
:active, :tide_station_id
|
|
17
17
|
|
|
18
18
|
alias_method :active?, :active
|
|
19
19
|
|
|
@@ -29,6 +29,7 @@ module NDBC
|
|
|
29
29
|
@forecast = station_data[:forecast]
|
|
30
30
|
@note = station_data[:note]
|
|
31
31
|
@active = station_data[:active]
|
|
32
|
+
@tide_station_id = station_data[:tide_station_id]
|
|
32
33
|
@connection = Connection.new
|
|
33
34
|
end
|
|
34
35
|
|
|
@@ -37,7 +38,9 @@ module NDBC
|
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
def standard_meteorological_data
|
|
40
|
-
parse_observation_response
|
|
41
|
+
@standard_meteorological_data ||= parse_observation_response(
|
|
42
|
+
get_data(NDBC.config[:urls][:observations] + id + ".txt")
|
|
43
|
+
)
|
|
41
44
|
end
|
|
42
45
|
|
|
43
46
|
def latest_standard_meteorological_data
|
|
@@ -45,7 +48,9 @@ module NDBC
|
|
|
45
48
|
end
|
|
46
49
|
|
|
47
50
|
def continuous_winds_data
|
|
48
|
-
parse_observation_response
|
|
51
|
+
@continuous_winds_data ||= parse_observation_response(
|
|
52
|
+
get_data(NDBC.config[:urls][:observations] + id + ".cwind")
|
|
53
|
+
)
|
|
49
54
|
end
|
|
50
55
|
|
|
51
56
|
def latest_continuous_winds_data
|
|
@@ -53,7 +58,9 @@ module NDBC
|
|
|
53
58
|
end
|
|
54
59
|
|
|
55
60
|
def spectral_wave_summaries
|
|
56
|
-
parse_observation_response
|
|
61
|
+
@spectral_wave_summaries ||= parse_observation_response(
|
|
62
|
+
get_data(NDBC.config[:urls][:observations] + id + ".spec")
|
|
63
|
+
)
|
|
57
64
|
end
|
|
58
65
|
|
|
59
66
|
def latest_spectral_wave_summaries
|
|
@@ -61,7 +68,9 @@ module NDBC
|
|
|
61
68
|
end
|
|
62
69
|
|
|
63
70
|
def spectral_wave_forecasts
|
|
64
|
-
parse_prediction_response
|
|
71
|
+
@spectral_wave_forecasts ||= parse_prediction_response(
|
|
72
|
+
get_data(NDBC.config[:urls][:predictions] + "multi_1.#{id}.bull")
|
|
73
|
+
)
|
|
65
74
|
end
|
|
66
75
|
|
|
67
76
|
def latest_spectral_wave_forecasts
|
|
@@ -111,7 +120,7 @@ module NDBC
|
|
|
111
120
|
def get_data(path)
|
|
112
121
|
connection.get(path)
|
|
113
122
|
rescue NotFound => error
|
|
114
|
-
|
|
123
|
+
raise NDBC::StationNotFound, "Could not find station #{id}"
|
|
115
124
|
end
|
|
116
125
|
|
|
117
126
|
def parse_observation_response(response)
|
data/lib/ndbc/station_table.rb
CHANGED
|
@@ -18,13 +18,19 @@ module NDBC
|
|
|
18
18
|
time_zone: station_parts[7],
|
|
19
19
|
forecast: station_parts[8],
|
|
20
20
|
note: station_parts[9],
|
|
21
|
-
active: active?(station_parts)
|
|
21
|
+
active: active?(station_parts),
|
|
22
|
+
tide_station_id: tide_station_id(station_parts[4])
|
|
22
23
|
}
|
|
23
24
|
end
|
|
24
25
|
end
|
|
25
26
|
|
|
26
27
|
private
|
|
27
28
|
|
|
29
|
+
def tide_station_id(name)
|
|
30
|
+
return '' unless name
|
|
31
|
+
name.match(/\d{7}/).to_s
|
|
32
|
+
end
|
|
33
|
+
|
|
28
34
|
def cleanup_parts!(station_parts)
|
|
29
35
|
station_parts.map! do |part|
|
|
30
36
|
part = part.gsub(' ', ' ')
|
data/lib/ndbc/version.rb
CHANGED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://www.ndbc.noaa.gov/data/realtime2/0.cwind
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
User-Agent:
|
|
11
|
+
- Faraday v0.9.2
|
|
12
|
+
Accept-Encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
Accept:
|
|
15
|
+
- "*/*"
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 404
|
|
19
|
+
message: Not Found
|
|
20
|
+
headers:
|
|
21
|
+
Date:
|
|
22
|
+
- Sun, 10 Sep 2017 14:09:37 GMT
|
|
23
|
+
Server:
|
|
24
|
+
- Apache
|
|
25
|
+
Vary:
|
|
26
|
+
- Accept-Encoding
|
|
27
|
+
Content-Length:
|
|
28
|
+
- '190'
|
|
29
|
+
Connection:
|
|
30
|
+
- close
|
|
31
|
+
Content-Type:
|
|
32
|
+
- text/html; charset=iso-8859-1
|
|
33
|
+
body:
|
|
34
|
+
encoding: ASCII-8BIT
|
|
35
|
+
string: |
|
|
36
|
+
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
|
37
|
+
<html><head>
|
|
38
|
+
<title>404 Not Found</title>
|
|
39
|
+
</head><body>
|
|
40
|
+
<h1>Not Found</h1>
|
|
41
|
+
<p>The requested URL /data/realtime2/0.cwind was not found on this server.</p>
|
|
42
|
+
</body></html>
|
|
43
|
+
http_version:
|
|
44
|
+
recorded_at: Sun, 10 Sep 2017 14:09:37 GMT
|
|
45
|
+
- request:
|
|
46
|
+
method: get
|
|
47
|
+
uri: http://www.ndbc.noaa.gov/data/realtime2/00000.cwind
|
|
48
|
+
body:
|
|
49
|
+
encoding: US-ASCII
|
|
50
|
+
string: ''
|
|
51
|
+
headers:
|
|
52
|
+
User-Agent:
|
|
53
|
+
- Faraday v0.9.2
|
|
54
|
+
Accept-Encoding:
|
|
55
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
56
|
+
Accept:
|
|
57
|
+
- "*/*"
|
|
58
|
+
response:
|
|
59
|
+
status:
|
|
60
|
+
code: 404
|
|
61
|
+
message: Not Found
|
|
62
|
+
headers:
|
|
63
|
+
Date:
|
|
64
|
+
- Sun, 10 Sep 2017 14:52:32 GMT
|
|
65
|
+
Server:
|
|
66
|
+
- Apache
|
|
67
|
+
Vary:
|
|
68
|
+
- Accept-Encoding
|
|
69
|
+
Content-Length:
|
|
70
|
+
- '192'
|
|
71
|
+
Connection:
|
|
72
|
+
- close
|
|
73
|
+
Content-Type:
|
|
74
|
+
- text/html; charset=iso-8859-1
|
|
75
|
+
body:
|
|
76
|
+
encoding: ASCII-8BIT
|
|
77
|
+
string: |
|
|
78
|
+
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
|
79
|
+
<html><head>
|
|
80
|
+
<title>404 Not Found</title>
|
|
81
|
+
</head><body>
|
|
82
|
+
<h1>Not Found</h1>
|
|
83
|
+
<p>The requested URL /data/realtime2/00000.cwind was not found on this server.</p>
|
|
84
|
+
</body></html>
|
|
85
|
+
http_version:
|
|
86
|
+
recorded_at: Sun, 10 Sep 2017 14:52:32 GMT
|
|
87
|
+
recorded_with: VCR 2.9.3
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://polar.ncep.noaa.gov/waves/WEB/multi_1.latest_run/plots/multi_1.0.bull
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
User-Agent:
|
|
11
|
+
- Faraday v0.9.2
|
|
12
|
+
Accept-Encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
Accept:
|
|
15
|
+
- "*/*"
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 404
|
|
19
|
+
message: Not Found
|
|
20
|
+
headers:
|
|
21
|
+
Date:
|
|
22
|
+
- Sun, 10 Sep 2017 14:10:10 GMT
|
|
23
|
+
Server:
|
|
24
|
+
- Apache
|
|
25
|
+
X-Frame-Options:
|
|
26
|
+
- SAMEORIGIN
|
|
27
|
+
X-Content-Type-Options:
|
|
28
|
+
- nosniff
|
|
29
|
+
X-Xss-Protection:
|
|
30
|
+
- 1; mode=block
|
|
31
|
+
Content-Length:
|
|
32
|
+
- '247'
|
|
33
|
+
Content-Type:
|
|
34
|
+
- text/html; charset=iso-8859-1
|
|
35
|
+
body:
|
|
36
|
+
encoding: UTF-8
|
|
37
|
+
string: |
|
|
38
|
+
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
|
39
|
+
<html><head>
|
|
40
|
+
<title>404 Not Found</title>
|
|
41
|
+
</head><body>
|
|
42
|
+
<h1>Not Found</h1>
|
|
43
|
+
<p>The requested URL /waves/WEB/multi_1.latest_run/plots/multi_1.0.bull was not found on this server.</p>
|
|
44
|
+
</body></html>
|
|
45
|
+
http_version:
|
|
46
|
+
recorded_at: Sun, 10 Sep 2017 14:10:10 GMT
|
|
47
|
+
- request:
|
|
48
|
+
method: get
|
|
49
|
+
uri: http://polar.ncep.noaa.gov/waves/WEB/multi_1.latest_run/plots/multi_1.00000.bull
|
|
50
|
+
body:
|
|
51
|
+
encoding: US-ASCII
|
|
52
|
+
string: ''
|
|
53
|
+
headers:
|
|
54
|
+
User-Agent:
|
|
55
|
+
- Faraday v0.9.2
|
|
56
|
+
Accept-Encoding:
|
|
57
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
58
|
+
Accept:
|
|
59
|
+
- "*/*"
|
|
60
|
+
response:
|
|
61
|
+
status:
|
|
62
|
+
code: 404
|
|
63
|
+
message: Not Found
|
|
64
|
+
headers:
|
|
65
|
+
Date:
|
|
66
|
+
- Sun, 10 Sep 2017 14:52:53 GMT
|
|
67
|
+
Server:
|
|
68
|
+
- Apache
|
|
69
|
+
X-Frame-Options:
|
|
70
|
+
- SAMEORIGIN
|
|
71
|
+
X-Content-Type-Options:
|
|
72
|
+
- nosniff
|
|
73
|
+
X-Xss-Protection:
|
|
74
|
+
- 1; mode=block
|
|
75
|
+
Content-Length:
|
|
76
|
+
- '251'
|
|
77
|
+
Content-Type:
|
|
78
|
+
- text/html; charset=iso-8859-1
|
|
79
|
+
body:
|
|
80
|
+
encoding: UTF-8
|
|
81
|
+
string: |
|
|
82
|
+
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
|
83
|
+
<html><head>
|
|
84
|
+
<title>404 Not Found</title>
|
|
85
|
+
</head><body>
|
|
86
|
+
<h1>Not Found</h1>
|
|
87
|
+
<p>The requested URL /waves/WEB/multi_1.latest_run/plots/multi_1.00000.bull was not found on this server.</p>
|
|
88
|
+
</body></html>
|
|
89
|
+
http_version:
|
|
90
|
+
recorded_at: Sun, 10 Sep 2017 14:52:53 GMT
|
|
91
|
+
recorded_with: VCR 2.9.3
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://www.ndbc.noaa.gov/data/realtime2/0.spec
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
User-Agent:
|
|
11
|
+
- Faraday v0.9.2
|
|
12
|
+
Accept-Encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
Accept:
|
|
15
|
+
- "*/*"
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 404
|
|
19
|
+
message: Not Found
|
|
20
|
+
headers:
|
|
21
|
+
Date:
|
|
22
|
+
- Sun, 10 Sep 2017 14:09:53 GMT
|
|
23
|
+
Server:
|
|
24
|
+
- Apache
|
|
25
|
+
Vary:
|
|
26
|
+
- Accept-Encoding
|
|
27
|
+
Content-Length:
|
|
28
|
+
- '189'
|
|
29
|
+
Connection:
|
|
30
|
+
- close
|
|
31
|
+
Content-Type:
|
|
32
|
+
- text/html; charset=iso-8859-1
|
|
33
|
+
body:
|
|
34
|
+
encoding: ASCII-8BIT
|
|
35
|
+
string: |
|
|
36
|
+
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
|
37
|
+
<html><head>
|
|
38
|
+
<title>404 Not Found</title>
|
|
39
|
+
</head><body>
|
|
40
|
+
<h1>Not Found</h1>
|
|
41
|
+
<p>The requested URL /data/realtime2/0.spec was not found on this server.</p>
|
|
42
|
+
</body></html>
|
|
43
|
+
http_version:
|
|
44
|
+
recorded_at: Sun, 10 Sep 2017 14:09:53 GMT
|
|
45
|
+
- request:
|
|
46
|
+
method: get
|
|
47
|
+
uri: http://www.ndbc.noaa.gov/data/realtime2/00000.spec
|
|
48
|
+
body:
|
|
49
|
+
encoding: US-ASCII
|
|
50
|
+
string: ''
|
|
51
|
+
headers:
|
|
52
|
+
User-Agent:
|
|
53
|
+
- Faraday v0.9.2
|
|
54
|
+
Accept-Encoding:
|
|
55
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
56
|
+
Accept:
|
|
57
|
+
- "*/*"
|
|
58
|
+
response:
|
|
59
|
+
status:
|
|
60
|
+
code: 404
|
|
61
|
+
message: Not Found
|
|
62
|
+
headers:
|
|
63
|
+
Date:
|
|
64
|
+
- Sun, 10 Sep 2017 14:52:33 GMT
|
|
65
|
+
Server:
|
|
66
|
+
- Apache
|
|
67
|
+
Vary:
|
|
68
|
+
- Accept-Encoding
|
|
69
|
+
Content-Length:
|
|
70
|
+
- '191'
|
|
71
|
+
Connection:
|
|
72
|
+
- close
|
|
73
|
+
Content-Type:
|
|
74
|
+
- text/html; charset=iso-8859-1
|
|
75
|
+
body:
|
|
76
|
+
encoding: ASCII-8BIT
|
|
77
|
+
string: |
|
|
78
|
+
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
|
79
|
+
<html><head>
|
|
80
|
+
<title>404 Not Found</title>
|
|
81
|
+
</head><body>
|
|
82
|
+
<h1>Not Found</h1>
|
|
83
|
+
<p>The requested URL /data/realtime2/00000.spec was not found on this server.</p>
|
|
84
|
+
</body></html>
|
|
85
|
+
http_version:
|
|
86
|
+
recorded_at: Sun, 10 Sep 2017 14:52:33 GMT
|
|
87
|
+
recorded_with: VCR 2.9.3
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
---
|
|
2
|
+
http_interactions:
|
|
3
|
+
- request:
|
|
4
|
+
method: get
|
|
5
|
+
uri: http://www.ndbc.noaa.gov/data/realtime2/0.txt
|
|
6
|
+
body:
|
|
7
|
+
encoding: US-ASCII
|
|
8
|
+
string: ''
|
|
9
|
+
headers:
|
|
10
|
+
User-Agent:
|
|
11
|
+
- Faraday v0.9.2
|
|
12
|
+
Accept-Encoding:
|
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
14
|
+
Accept:
|
|
15
|
+
- "*/*"
|
|
16
|
+
response:
|
|
17
|
+
status:
|
|
18
|
+
code: 404
|
|
19
|
+
message: Not Found
|
|
20
|
+
headers:
|
|
21
|
+
Date:
|
|
22
|
+
- Sun, 10 Sep 2017 14:09:37 GMT
|
|
23
|
+
Server:
|
|
24
|
+
- Apache
|
|
25
|
+
Vary:
|
|
26
|
+
- Accept-Encoding
|
|
27
|
+
Content-Length:
|
|
28
|
+
- '188'
|
|
29
|
+
Connection:
|
|
30
|
+
- close
|
|
31
|
+
Content-Type:
|
|
32
|
+
- text/html; charset=iso-8859-1
|
|
33
|
+
body:
|
|
34
|
+
encoding: ASCII-8BIT
|
|
35
|
+
string: |
|
|
36
|
+
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
|
37
|
+
<html><head>
|
|
38
|
+
<title>404 Not Found</title>
|
|
39
|
+
</head><body>
|
|
40
|
+
<h1>Not Found</h1>
|
|
41
|
+
<p>The requested URL /data/realtime2/0.txt was not found on this server.</p>
|
|
42
|
+
</body></html>
|
|
43
|
+
http_version:
|
|
44
|
+
recorded_at: Sun, 10 Sep 2017 14:09:37 GMT
|
|
45
|
+
- request:
|
|
46
|
+
method: get
|
|
47
|
+
uri: http://www.ndbc.noaa.gov/data/realtime2/00000.txt
|
|
48
|
+
body:
|
|
49
|
+
encoding: US-ASCII
|
|
50
|
+
string: ''
|
|
51
|
+
headers:
|
|
52
|
+
User-Agent:
|
|
53
|
+
- Faraday v0.9.2
|
|
54
|
+
Accept-Encoding:
|
|
55
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
56
|
+
Accept:
|
|
57
|
+
- "*/*"
|
|
58
|
+
response:
|
|
59
|
+
status:
|
|
60
|
+
code: 404
|
|
61
|
+
message: Not Found
|
|
62
|
+
headers:
|
|
63
|
+
Date:
|
|
64
|
+
- Sun, 10 Sep 2017 14:52:31 GMT
|
|
65
|
+
Server:
|
|
66
|
+
- Apache
|
|
67
|
+
Vary:
|
|
68
|
+
- Accept-Encoding
|
|
69
|
+
Content-Length:
|
|
70
|
+
- '190'
|
|
71
|
+
Connection:
|
|
72
|
+
- close
|
|
73
|
+
Content-Type:
|
|
74
|
+
- text/html; charset=iso-8859-1
|
|
75
|
+
body:
|
|
76
|
+
encoding: ASCII-8BIT
|
|
77
|
+
string: |
|
|
78
|
+
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
|
|
79
|
+
<html><head>
|
|
80
|
+
<title>404 Not Found</title>
|
|
81
|
+
</head><body>
|
|
82
|
+
<h1>Not Found</h1>
|
|
83
|
+
<p>The requested URL /data/realtime2/00000.txt was not found on this server.</p>
|
|
84
|
+
</body></html>
|
|
85
|
+
http_version:
|
|
86
|
+
recorded_at: Sun, 10 Sep 2017 14:52:31 GMT
|
|
87
|
+
recorded_with: VCR 2.9.3
|
data/spec/ndbc/station_spec.rb
CHANGED
|
@@ -3,6 +3,8 @@ require 'spec_helper'
|
|
|
3
3
|
describe NDBC::Station do
|
|
4
4
|
|
|
5
5
|
subject(:station) { NDBC::Station.new(41009) }
|
|
6
|
+
|
|
7
|
+
let(:not_found_station) { NDBC::Station.new('00000') }
|
|
6
8
|
|
|
7
9
|
methods = %i(wdir wspd gst wvht dpd apd mwd pres atmp wtmp dewp vis ptdy tide dir spd gdr gsp
|
|
8
10
|
gtime h0 wwh wwp wwd steepness avp swh swp swd swd owner ttype hull name payload
|
|
@@ -52,7 +54,14 @@ describe NDBC::Station do
|
|
|
52
54
|
end
|
|
53
55
|
end
|
|
54
56
|
|
|
55
|
-
shared_examples_for
|
|
57
|
+
shared_examples_for :results_format do |meth|
|
|
58
|
+
|
|
59
|
+
let(:result) do
|
|
60
|
+
VCR.use_cassette(meth) do
|
|
61
|
+
station.public_send(meth)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
56
65
|
it "returns a hash with units and values" do
|
|
57
66
|
expect(result[:units]).to be_a(Hash)
|
|
58
67
|
expect(result[:values]).to be_a(Array)
|
|
@@ -87,68 +96,30 @@ describe NDBC::Station do
|
|
|
87
96
|
|
|
88
97
|
end
|
|
89
98
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it_behaves_like "station"
|
|
99
|
-
|
|
100
|
-
context 'when the station is not found' do
|
|
101
|
-
|
|
102
|
-
let(:not_found_station) { NDBC::Station.new(00000) }
|
|
103
|
-
|
|
104
|
-
let(:not_found_result) do
|
|
105
|
-
VCR.use_cassette("standard_meteorological_data_not_found") do
|
|
106
|
-
not_found_station.standard_meteorological_data
|
|
107
|
-
end
|
|
99
|
+
shared_examples_for :station_not_found do |meth|
|
|
100
|
+
it "raises NDBC::StationNotFound when the station url can't be found" do
|
|
101
|
+
VCR.use_cassette("#{meth}_station_not_found") do
|
|
102
|
+
expect{not_found_station.public_send(meth)}.to raise_error(
|
|
103
|
+
NDBC::StationNotFound, "Could not find station #{not_found_station.id}")
|
|
108
104
|
end
|
|
109
|
-
|
|
110
|
-
it "returns a hash with units and values" do
|
|
111
|
-
expect(not_found_result[:units]).to be_a(Hash)
|
|
112
|
-
expect(not_found_result[:values]).to be_a(Array)
|
|
113
|
-
end
|
|
114
|
-
|
|
115
105
|
end
|
|
106
|
+
end
|
|
116
107
|
|
|
108
|
+
describe "#standard_meteorological_data" do
|
|
109
|
+
it_behaves_like :results_format, 'standard_meteorological_data'
|
|
110
|
+
it_behaves_like :station_not_found, 'standard_meteorological_data'
|
|
117
111
|
end
|
|
118
112
|
|
|
119
113
|
describe "#continuous_winds_data" do
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
station.continuous_winds_data
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it_behaves_like "station"
|
|
114
|
+
it_behaves_like :results_format, 'continuous_winds_data'
|
|
115
|
+
it_behaves_like :station_not_found, 'continuous_winds_data'
|
|
127
116
|
end
|
|
128
117
|
|
|
129
118
|
describe "#spectral_wave_summaries" do
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
station.spectral_wave_summaries
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
it_behaves_like "station"
|
|
119
|
+
it_behaves_like :results_format, 'spectral_wave_summaries'
|
|
120
|
+
it_behaves_like :station_not_found, 'spectral_wave_summaries'
|
|
137
121
|
end
|
|
138
122
|
|
|
139
|
-
describe "error handling" do
|
|
140
|
-
|
|
141
|
-
let(:not_found) do
|
|
142
|
-
NDBC::Station.new(00000)
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
it "catches 404's" do
|
|
146
|
-
VCR.use_cassette("station_not_found") do
|
|
147
|
-
expect{not_found.standard_meteorological_data}.not_to raise_error
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
123
|
|
|
153
124
|
describe "#spectral_wave_forecasts" do
|
|
154
125
|
|
|
@@ -160,6 +131,8 @@ describe NDBC::Station do
|
|
|
160
131
|
end
|
|
161
132
|
end
|
|
162
133
|
|
|
134
|
+
it_behaves_like :station_not_found, 'spectral_wave_forecasts'
|
|
135
|
+
|
|
163
136
|
it "makes a request" do
|
|
164
137
|
expect(buoy.connection).to receive(:get).with("http://polar.ncep.noaa.gov/waves/WEB/multi_1.latest_run/plots/multi_1.41009.bull")
|
|
165
138
|
buoy.spectral_wave_forecasts
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ndbc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ryan Hertz
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-09-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -131,6 +131,8 @@ extra_rdoc_files: []
|
|
|
131
131
|
files:
|
|
132
132
|
- ".gitignore"
|
|
133
133
|
- ".rspec"
|
|
134
|
+
- ".ruby-version"
|
|
135
|
+
- ".travis.yml"
|
|
134
136
|
- Gemfile
|
|
135
137
|
- Guardfile
|
|
136
138
|
- LICENSE.txt
|
|
@@ -139,16 +141,21 @@ files:
|
|
|
139
141
|
- changelog.md
|
|
140
142
|
- lib/ndbc.rb
|
|
141
143
|
- lib/ndbc/connection.rb
|
|
144
|
+
- lib/ndbc/exceptions.rb
|
|
142
145
|
- lib/ndbc/station.rb
|
|
143
146
|
- lib/ndbc/station_table.rb
|
|
144
147
|
- lib/ndbc/version.rb
|
|
145
148
|
- ndbc.gemspec
|
|
146
149
|
- spec/fixtures/vcr_cassettes/continuous_winds_data.yml
|
|
150
|
+
- spec/fixtures/vcr_cassettes/continuous_winds_data_station_not_found.yml
|
|
147
151
|
- spec/fixtures/vcr_cassettes/not_found.yml
|
|
148
152
|
- spec/fixtures/vcr_cassettes/spectral_wave_forecasts.yml
|
|
153
|
+
- spec/fixtures/vcr_cassettes/spectral_wave_forecasts_station_not_found.yml
|
|
149
154
|
- spec/fixtures/vcr_cassettes/spectral_wave_summaries.yml
|
|
155
|
+
- spec/fixtures/vcr_cassettes/spectral_wave_summaries_station_not_found.yml
|
|
150
156
|
- spec/fixtures/vcr_cassettes/standard_meteorological_data.yml
|
|
151
157
|
- spec/fixtures/vcr_cassettes/standard_meteorological_data_not_found.yml
|
|
158
|
+
- spec/fixtures/vcr_cassettes/standard_meteorological_data_station_not_found.yml
|
|
152
159
|
- spec/fixtures/vcr_cassettes/station_not_found.yml
|
|
153
160
|
- spec/fixtures/vcr_cassettes/station_table.yml
|
|
154
161
|
- spec/ndbc/connection_spec.rb
|
|
@@ -175,17 +182,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
175
182
|
version: '0'
|
|
176
183
|
requirements: []
|
|
177
184
|
rubyforge_project:
|
|
178
|
-
rubygems_version: 2.4.
|
|
185
|
+
rubygems_version: 2.4.8
|
|
179
186
|
signing_key:
|
|
180
187
|
specification_version: 4
|
|
181
188
|
summary: Get NDBC buoy data.
|
|
182
189
|
test_files:
|
|
183
190
|
- spec/fixtures/vcr_cassettes/continuous_winds_data.yml
|
|
191
|
+
- spec/fixtures/vcr_cassettes/continuous_winds_data_station_not_found.yml
|
|
184
192
|
- spec/fixtures/vcr_cassettes/not_found.yml
|
|
185
193
|
- spec/fixtures/vcr_cassettes/spectral_wave_forecasts.yml
|
|
194
|
+
- spec/fixtures/vcr_cassettes/spectral_wave_forecasts_station_not_found.yml
|
|
186
195
|
- spec/fixtures/vcr_cassettes/spectral_wave_summaries.yml
|
|
196
|
+
- spec/fixtures/vcr_cassettes/spectral_wave_summaries_station_not_found.yml
|
|
187
197
|
- spec/fixtures/vcr_cassettes/standard_meteorological_data.yml
|
|
188
198
|
- spec/fixtures/vcr_cassettes/standard_meteorological_data_not_found.yml
|
|
199
|
+
- spec/fixtures/vcr_cassettes/standard_meteorological_data_station_not_found.yml
|
|
189
200
|
- spec/fixtures/vcr_cassettes/station_not_found.yml
|
|
190
201
|
- spec/fixtures/vcr_cassettes/station_table.yml
|
|
191
202
|
- spec/ndbc/connection_spec.rb
|