dwml 1.1.5 → 1.2.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 +5 -5
- data/.gitignore +5 -1
- data/.travis.yml +8 -0
- data/Gemfile +10 -5
- data/README.md +94 -6
- data/dwml.gemspec +3 -4
- data/lib/dwml.rb +104 -8
- data/lib/dwml/error.rb +7 -0
- data/lib/dwml/head_extractor.rb +2 -0
- data/lib/dwml/version.rb +1 -1
- data/spec/docs/basic.xml +70 -0
- data/spec/lib/dwml_spec.rb +61 -0
- data/spec/spec_helper.rb +3 -1
- metadata +15 -30
- data/spec/lib/dwml/location_spec.rb +0 -24
- data/spec/lib/dwml/parameter_extractor_spec.rb +0 -81
- data/spec/lib/dwml/time_layout_spec.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7ec231f50c9554e9786904184ed8882282e7c18d9c2bd4468c2558357f97c67a
|
4
|
+
data.tar.gz: 7b969e854e28bd5b8cdf8cc1eaa0f32b6edea0155598a8ed66454a7290c9e5f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f526d85f696e9beda524e940a7fdd7b0483675794d71fbd986b516c57140fae2bd647f92e8cbf37130bb2cab3608d728f59eee72085cbce25e9c4fc8b4935657
|
7
|
+
data.tar.gz: edaffa8afadbcd022e4f2a906461b8cd9a432b24766aeacbccfbea5cf891ee85995f01b51d4586abcc3b9fef36cfbf374409c7c32a902366f70d8f7a232225ba
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
gemspec
|
3
3
|
|
4
|
+
group :development do
|
5
|
+
gem 'yard', '~>0.9'
|
6
|
+
end
|
7
|
+
|
4
8
|
group :test do
|
5
|
-
gem 'simplecov', '~>0.
|
6
|
-
gem '
|
7
|
-
|
8
|
-
|
9
|
-
|
9
|
+
gem 'simplecov', '~>0.17', :require => false
|
10
|
+
gem 'rspec', '~>3.9'
|
11
|
+
end
|
12
|
+
|
13
|
+
group :development, :test do
|
14
|
+
gem 'byebug'
|
10
15
|
end
|
data/README.md
CHANGED
@@ -1,8 +1,96 @@
|
|
1
|
-
dwml
|
2
|
-
====
|
1
|
+
# dwml [](http://badge.fury.io/rb/dwml) [](http://travis-ci.org/alakra/dwml) [](https://codeclimate.com/github/alakra/dwml)
|
3
2
|
|
4
|
-
|
5
|
-
[](https://gemnasium.com/alakra/dwml)
|
6
|
-
[](https://codeclimate.com/github/alakra/dwml)
|
3
|
+
A parser for NOAA's Digital Weather Markup Language (DWML).
|
7
4
|
|
8
|
-
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
* ruby >= `2.5.x`
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
In your `Gemfile`:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'dwml', '~>1.2'
|
15
|
+
```
|
16
|
+
|
17
|
+
In your application:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
output = DWML.new(nokogiri_xml_doc).process
|
21
|
+
```
|
22
|
+
|
23
|
+
The output will look something like this:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
{:product=>
|
27
|
+
{:title=>"NOAA's National Weather Service Forecast Data",
|
28
|
+
:field=>"meteorological",
|
29
|
+
:category=>"forecast",
|
30
|
+
:creation_date=>Thu, 05 Mar 2020 18:49:42 UTC +00:00},
|
31
|
+
:source=>
|
32
|
+
{:product_center=>
|
33
|
+
"Meteorological Development Laboratory - Product Generation Branch",
|
34
|
+
:more_information=>"https://graphical.weather.gov/xml/",
|
35
|
+
:disclaimer=>"http://www.nws.noaa.gov/disclaimer.html",
|
36
|
+
:credit=>"https://www.weather.gov/",
|
37
|
+
:credit_logo=>"https://www.weather.gov/logorequest",
|
38
|
+
:feedback=>"https://www.weather.gov/contact"},
|
39
|
+
:parameters=>
|
40
|
+
{"point1"=>
|
41
|
+
{:latitude=>38.99,
|
42
|
+
:longitude=>-77.01,
|
43
|
+
:temperature=>
|
44
|
+
{:maximum=>
|
45
|
+
{:name=>"Daily Maximum Temperature",
|
46
|
+
:values=>
|
47
|
+
[{:value=>48.0,
|
48
|
+
:start_time=>Sat, 07 Mar 2020 12:00:00 UTC +00:00,
|
49
|
+
:unit=>"Fahrenheit",
|
50
|
+
:end_time=>Sun, 08 Mar 2020 00:00:00 UTC +00:00},
|
51
|
+
{:value=>59.0,
|
52
|
+
:start_time=>Sun, 08 Mar 2020 12:00:00 UTC +00:00,
|
53
|
+
:unit=>"Fahrenheit",
|
54
|
+
:end_time=>Mon, 09 Mar 2020 00:00:00 UTC +00:00},
|
55
|
+
{:value=>68.0,
|
56
|
+
:start_time=>Mon, 09 Mar 2020 12:00:00 UTC +00:00,
|
57
|
+
:unit=>"Fahrenheit",
|
58
|
+
:end_time=>Tue, 10 Mar 2020 00:00:00 UTC +00:00},
|
59
|
+
{:value=>66.0,
|
60
|
+
:start_time=>Tue, 10 Mar 2020 12:00:00 UTC +00:00,
|
61
|
+
:unit=>"Fahrenheit",
|
62
|
+
:end_time=>Wed, 11 Mar 2020 00:00:00 UTC +00:00},
|
63
|
+
{:value=>62.0,
|
64
|
+
:start_time=>Wed, 11 Mar 2020 12:00:00 UTC +00:00,
|
65
|
+
:unit=>"Fahrenheit",
|
66
|
+
:end_time=>Thu, 12 Mar 2020 00:00:00 UTC +00:00}]},
|
67
|
+
:minimum=>
|
68
|
+
{:name=>"Daily Minimum Temperature",
|
69
|
+
:values=>
|
70
|
+
[{:value=>35.0,
|
71
|
+
:start_time=>Sat, 07 Mar 2020 00:00:00 UTC +00:00,
|
72
|
+
:unit=>"Fahrenheit",
|
73
|
+
:end_time=>Sat, 07 Mar 2020 13:00:00 UTC +00:00},
|
74
|
+
{:value=>31.0,
|
75
|
+
:start_time=>Sun, 08 Mar 2020 01:00:00 UTC +00:00,
|
76
|
+
:unit=>"Fahrenheit",
|
77
|
+
:end_time=>Sun, 08 Mar 2020 13:00:00 UTC +00:00},
|
78
|
+
{:value=>40.0,
|
79
|
+
:start_time=>Mon, 09 Mar 2020 00:00:00 UTC +00:00,
|
80
|
+
:unit=>"Fahrenheit",
|
81
|
+
:end_time=>Mon, 09 Mar 2020 13:00:00 UTC +00:00},
|
82
|
+
{:value=>51.0,
|
83
|
+
:start_time=>Tue, 10 Mar 2020 00:00:00 UTC +00:00,
|
84
|
+
:unit=>"Fahrenheit",
|
85
|
+
:end_time=>Tue, 10 Mar 2020 13:00:00 UTC +00:00},
|
86
|
+
{:value=>48.0,
|
87
|
+
:start_time=>Wed, 11 Mar 2020 00:00:00 UTC +00:00,
|
88
|
+
:unit=>"Fahrenheit",
|
89
|
+
:end_time=>Wed, 11 Mar 2020 13:00:00 UTC +00:00}]}}}}}
|
90
|
+
```
|
91
|
+
|
92
|
+
## FAQ
|
93
|
+
|
94
|
+
### Where do I get DWML documents from?
|
95
|
+
|
96
|
+
You can download them directly from the [National Digital Forecast Database (NDFD) Digital Weather Markup Language (DWML) Generator](https://graphical.weather.gov/xml/SOAP_server/ndfdXML.htm).
|
data/dwml.gemspec
CHANGED
@@ -20,11 +20,10 @@ Gem::Specification.new do |s|
|
|
20
20
|
|
21
21
|
s.extra_rdoc_files = ['README.md']
|
22
22
|
|
23
|
-
s.add_runtime_dependency 'nokogiri', '>= 1.6
|
24
|
-
s.add_runtime_dependency '
|
25
|
-
s.add_runtime_dependency 'activesupport', '>= 4.2.2'
|
23
|
+
s.add_runtime_dependency 'nokogiri', '>= 1.6'
|
24
|
+
s.add_runtime_dependency 'activesupport', '>= 5.2'
|
26
25
|
|
27
|
-
s.required_ruby_version = '>=
|
26
|
+
s.required_ruby_version = '>= 2.5'
|
28
27
|
|
29
28
|
s.files = `git ls-files`.split("\n")
|
30
29
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
data/lib/dwml.rb
CHANGED
@@ -1,25 +1,121 @@
|
|
1
|
-
require '
|
2
|
-
|
1
|
+
require 'dwml/error'
|
3
2
|
require 'dwml/head_extractor'
|
4
3
|
require 'dwml/data_extractor'
|
5
4
|
|
5
|
+
|
6
|
+
##
|
7
|
+
# The DWML class is the main entrypoint for processing DWML Nokogiri
|
8
|
+
# XML documents.
|
6
9
|
#
|
7
|
-
#
|
10
|
+
# See
|
11
|
+
# http://graphical.weather.gov/xml/mdl/XML/Design/MDL_XML_Design.pdf
|
8
12
|
# for authoritative type definitions
|
9
|
-
|
10
|
-
|
13
|
+
#
|
14
|
+
# == Usage
|
15
|
+
#
|
16
|
+
# output = DWML.new(nokogiri_xml_doc).process
|
17
|
+
#
|
11
18
|
class DWML
|
12
19
|
attr_reader :output, :xmldoc
|
13
20
|
|
21
|
+
##
|
22
|
+
# Creates a new instance of the +DWML+ class.
|
23
|
+
#
|
24
|
+
# @param Nokogiri::XML::Document
|
25
|
+
# @return [DWML]
|
14
26
|
def initialize(xmldoc)
|
15
27
|
@xmldoc = xmldoc
|
16
28
|
@output = {}
|
17
29
|
end
|
18
30
|
|
31
|
+
##
|
32
|
+
# Processes the associated XML document with +DWML+ object and
|
33
|
+
# returns a detailed hash of the weather metrics and also stores it
|
34
|
+
# in the +@output+ instance variable.
|
35
|
+
#
|
36
|
+
# @return [Hash]
|
37
|
+
#
|
38
|
+
# == Hash Structure
|
39
|
+
#
|
40
|
+
# The returned hash will have a consistent structure under
|
41
|
+
# +:product+ and +:source+ keys. The +:parameters+ value will vary
|
42
|
+
# depending on the original XML/DWML document that is passed to
|
43
|
+
# +DWML.new+.
|
44
|
+
#
|
45
|
+
# == Example Output
|
46
|
+
#
|
47
|
+
# {:product=>
|
48
|
+
# {:title=>"NOAA's National Weather Service Forecast Data",
|
49
|
+
# :field=>"meteorological",
|
50
|
+
# :category=>"forecast",
|
51
|
+
# :creation_date=>Thu, 05 Mar 2020 18:49:42 UTC +00:00},
|
52
|
+
# :source=>
|
53
|
+
# {:product_center=>
|
54
|
+
# "Meteorological Development Laboratory - Product Generation Branch",
|
55
|
+
# :more_information=>"https://graphical.weather.gov/xml/",
|
56
|
+
# :disclaimer=>"http://www.nws.noaa.gov/disclaimer.html",
|
57
|
+
# :credit=>"https://www.weather.gov/",
|
58
|
+
# :credit_logo=>"https://www.weather.gov/logorequest",
|
59
|
+
# :feedback=>"https://www.weather.gov/contact"},
|
60
|
+
# :parameters=>
|
61
|
+
# {"point1"=>
|
62
|
+
# {:latitude=>38.99,
|
63
|
+
# :longitude=>-77.01,
|
64
|
+
# :temperature=>
|
65
|
+
# {:maximum=>
|
66
|
+
# {:name=>"Daily Maximum Temperature",
|
67
|
+
# :values=>
|
68
|
+
# [{:value=>48.0,
|
69
|
+
# :start_time=>Sat, 07 Mar 2020 12:00:00 UTC +00:00,
|
70
|
+
# :unit=>"Fahrenheit",
|
71
|
+
# :end_time=>Sun, 08 Mar 2020 00:00:00 UTC +00:00},
|
72
|
+
# {:value=>59.0,
|
73
|
+
# :start_time=>Sun, 08 Mar 2020 12:00:00 UTC +00:00,
|
74
|
+
# :unit=>"Fahrenheit",
|
75
|
+
# :end_time=>Mon, 09 Mar 2020 00:00:00 UTC +00:00},
|
76
|
+
# {:value=>68.0,
|
77
|
+
# :start_time=>Mon, 09 Mar 2020 12:00:00 UTC +00:00,
|
78
|
+
# :unit=>"Fahrenheit",
|
79
|
+
# :end_time=>Tue, 10 Mar 2020 00:00:00 UTC +00:00},
|
80
|
+
# {:value=>66.0,
|
81
|
+
# :start_time=>Tue, 10 Mar 2020 12:00:00 UTC +00:00,
|
82
|
+
# :unit=>"Fahrenheit",
|
83
|
+
# :end_time=>Wed, 11 Mar 2020 00:00:00 UTC +00:00},
|
84
|
+
# {:value=>62.0,
|
85
|
+
# :start_time=>Wed, 11 Mar 2020 12:00:00 UTC +00:00,
|
86
|
+
# :unit=>"Fahrenheit",
|
87
|
+
# :end_time=>Thu, 12 Mar 2020 00:00:00 UTC +00:00}]},
|
88
|
+
# :minimum=>
|
89
|
+
# {:name=>"Daily Minimum Temperature",
|
90
|
+
# :values=>
|
91
|
+
# [{:value=>35.0,
|
92
|
+
# :start_time=>Sat, 07 Mar 2020 00:00:00 UTC +00:00,
|
93
|
+
# :unit=>"Fahrenheit",
|
94
|
+
# :end_time=>Sat, 07 Mar 2020 13:00:00 UTC +00:00},
|
95
|
+
# {:value=>31.0,
|
96
|
+
# :start_time=>Sun, 08 Mar 2020 01:00:00 UTC +00:00,
|
97
|
+
# :unit=>"Fahrenheit",
|
98
|
+
# :end_time=>Sun, 08 Mar 2020 13:00:00 UTC +00:00},
|
99
|
+
# {:value=>40.0,
|
100
|
+
# :start_time=>Mon, 09 Mar 2020 00:00:00 UTC +00:00,
|
101
|
+
# :unit=>"Fahrenheit",
|
102
|
+
# :end_time=>Mon, 09 Mar 2020 13:00:00 UTC +00:00},
|
103
|
+
# {:value=>51.0,
|
104
|
+
# :start_time=>Tue, 10 Mar 2020 00:00:00 UTC +00:00,
|
105
|
+
# :unit=>"Fahrenheit",
|
106
|
+
# :end_time=>Tue, 10 Mar 2020 13:00:00 UTC +00:00},
|
107
|
+
# {:value=>48.0,
|
108
|
+
# :start_time=>Wed, 11 Mar 2020 00:00:00 UTC +00:00,
|
109
|
+
# :unit=>"Fahrenheit",
|
110
|
+
# :end_time=>Wed, 11 Mar 2020 13:00:00 UTC +00:00}]}}}}}
|
19
111
|
def process
|
20
|
-
|
21
|
-
|
22
|
-
|
112
|
+
if @xmldoc.is_a?(Nokogiri::XML::Document)
|
113
|
+
build_head
|
114
|
+
build_data
|
115
|
+
output
|
116
|
+
else
|
117
|
+
raise DWML::NokogiriDocumentError, "The input is not an Nokogiri::XML::Document"
|
118
|
+
end
|
23
119
|
end
|
24
120
|
|
25
121
|
protected
|
data/lib/dwml/error.rb
ADDED
data/lib/dwml/head_extractor.rb
CHANGED
data/lib/dwml/version.rb
CHANGED
data/spec/docs/basic.xml
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<dwml version="1.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://graphical.weather.gov/xml/DWMLgen/schema/DWML.xsd">
|
3
|
+
<head>
|
4
|
+
<product srsName="WGS 1984" concise-name="time-series" operational-mode="official">
|
5
|
+
<title>NOAA's National Weather Service Forecast Data</title>
|
6
|
+
<field>meteorological</field>
|
7
|
+
<category>forecast</category>
|
8
|
+
<creation-date refresh-frequency="PT1H">2020-03-05T18:49:42Z</creation-date>
|
9
|
+
</product>
|
10
|
+
<source>
|
11
|
+
<more-information>https://graphical.weather.gov/xml/</more-information>
|
12
|
+
<production-center>Meteorological Development Laboratory<sub-center>Product Generation Branch</sub-center></production-center>
|
13
|
+
<disclaimer>http://www.nws.noaa.gov/disclaimer.html</disclaimer>
|
14
|
+
<credit>https://www.weather.gov/</credit>
|
15
|
+
<credit-logo>https://www.weather.gov/logorequest</credit-logo>
|
16
|
+
<feedback>https://www.weather.gov/contact</feedback>
|
17
|
+
</source>
|
18
|
+
</head>
|
19
|
+
<data>
|
20
|
+
<location>
|
21
|
+
<location-key>point1</location-key>
|
22
|
+
<point latitude="38.99" longitude="-77.01"/>
|
23
|
+
</location>
|
24
|
+
<moreWeatherInformation applicable-location="point1">https://forecast-v3.weather.gov/point/38.99,-77.01</moreWeatherInformation>
|
25
|
+
<time-layout time-coordinate="local" summarization="none">
|
26
|
+
<layout-key>k-p24h-n5-1</layout-key>
|
27
|
+
<start-valid-time>2020-03-07T07:00:00-05:00</start-valid-time>
|
28
|
+
<end-valid-time>2020-03-07T19:00:00-05:00</end-valid-time>
|
29
|
+
<start-valid-time>2020-03-08T08:00:00-04:00</start-valid-time>
|
30
|
+
<end-valid-time>2020-03-08T20:00:00-04:00</end-valid-time>
|
31
|
+
<start-valid-time>2020-03-09T08:00:00-04:00</start-valid-time>
|
32
|
+
<end-valid-time>2020-03-09T20:00:00-04:00</end-valid-time>
|
33
|
+
<start-valid-time>2020-03-10T08:00:00-04:00</start-valid-time>
|
34
|
+
<end-valid-time>2020-03-10T20:00:00-04:00</end-valid-time>
|
35
|
+
<start-valid-time>2020-03-11T08:00:00-04:00</start-valid-time>
|
36
|
+
<end-valid-time>2020-03-11T20:00:00-04:00</end-valid-time>
|
37
|
+
</time-layout>
|
38
|
+
<time-layout time-coordinate="local" summarization="none">
|
39
|
+
<layout-key>k-p24h-n5-2</layout-key>
|
40
|
+
<start-valid-time>2020-03-06T19:00:00-05:00</start-valid-time>
|
41
|
+
<end-valid-time>2020-03-07T08:00:00-05:00</end-valid-time>
|
42
|
+
<start-valid-time>2020-03-07T20:00:00-05:00</start-valid-time>
|
43
|
+
<end-valid-time>2020-03-08T09:00:00-04:00</end-valid-time>
|
44
|
+
<start-valid-time>2020-03-08T20:00:00-04:00</start-valid-time>
|
45
|
+
<end-valid-time>2020-03-09T09:00:00-04:00</end-valid-time>
|
46
|
+
<start-valid-time>2020-03-09T20:00:00-04:00</start-valid-time>
|
47
|
+
<end-valid-time>2020-03-10T09:00:00-04:00</end-valid-time>
|
48
|
+
<start-valid-time>2020-03-10T20:00:00-04:00</start-valid-time>
|
49
|
+
<end-valid-time>2020-03-11T09:00:00-04:00</end-valid-time>
|
50
|
+
</time-layout>
|
51
|
+
<parameters applicable-location="point1">
|
52
|
+
<temperature type="maximum" units="Fahrenheit" time-layout="k-p24h-n5-1">
|
53
|
+
<name>Daily Maximum Temperature</name>
|
54
|
+
<value>48</value>
|
55
|
+
<value>59</value>
|
56
|
+
<value>68</value>
|
57
|
+
<value>66</value>
|
58
|
+
<value>62</value>
|
59
|
+
</temperature>
|
60
|
+
<temperature type="minimum" units="Fahrenheit" time-layout="k-p24h-n5-2">
|
61
|
+
<name>Daily Minimum Temperature</name>
|
62
|
+
<value>35</value>
|
63
|
+
<value>31</value>
|
64
|
+
<value>40</value>
|
65
|
+
<value>51</value>
|
66
|
+
<value>48</value>
|
67
|
+
</temperature>
|
68
|
+
</parameters>
|
69
|
+
</data>
|
70
|
+
</dwml>
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'nokogiri'
|
3
|
+
|
4
|
+
describe DWML do
|
5
|
+
let(:basic_xml) { File.read("spec/docs/basic.xml") }
|
6
|
+
|
7
|
+
describe ".new" do
|
8
|
+
it "creates a new DWML object" do
|
9
|
+
doc = Nokogiri::XML.parse(basic_xml)
|
10
|
+
expect(DWML.new(doc)).to be_a_kind_of(DWML)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#process" do
|
15
|
+
it "processes an xml document successfully" do
|
16
|
+
doc = Nokogiri::XML.parse(basic_xml)
|
17
|
+
output = DWML.new(doc).process
|
18
|
+
|
19
|
+
expect(output).to be_a_kind_of(Hash)
|
20
|
+
expect(output).to have_key(:product)
|
21
|
+
expect(output).to have_key(:source)
|
22
|
+
expect(output).to have_key(:parameters)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "attempts to process a non-xml document and fails" do
|
26
|
+
expect {
|
27
|
+
DWML.new("").process
|
28
|
+
}.to raise_error(DWML::NokogiriDocumentError)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "attributes" do
|
33
|
+
it "can read the original xml document" do
|
34
|
+
doc = Nokogiri::XML.parse(basic_xml)
|
35
|
+
output = DWML.new(doc).process
|
36
|
+
|
37
|
+
params = output[:parameters]
|
38
|
+
|
39
|
+
expect(params["point1"][:latitude]).to eq(38.99)
|
40
|
+
expect(params["point1"][:longitude]).to eq(-77.01)
|
41
|
+
|
42
|
+
temperatures = params["point1"][:temperature]
|
43
|
+
|
44
|
+
expect(temperatures[:maximum][:name]).to eq("Daily Maximum Temperature")
|
45
|
+
max_values = temperatures[:maximum][:values].map {|x| x[:value] }
|
46
|
+
expect(max_values).to eq([48, 59, 68, 66, 62])
|
47
|
+
|
48
|
+
expect(temperatures[:minimum][:name]).to eq("Daily Minimum Temperature")
|
49
|
+
min_values = temperatures[:minimum][:values].map {|x| x[:value] }
|
50
|
+
expect(min_values).to eq([35, 31, 40, 51, 48])
|
51
|
+
end
|
52
|
+
|
53
|
+
it "can read the cached output" do
|
54
|
+
doc = Nokogiri::XML.parse(basic_xml)
|
55
|
+
dwml = DWML.new(doc)
|
56
|
+
output = dwml.process
|
57
|
+
|
58
|
+
expect(dwml.output).to eq(output)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'byebug'
|
1
2
|
require 'dwml'
|
2
3
|
|
3
4
|
# This file was generated by the `rspec --init` command. Conventionally, all
|
@@ -7,7 +8,6 @@ require 'dwml'
|
|
7
8
|
#
|
8
9
|
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
9
10
|
RSpec.configure do |config|
|
10
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
11
|
config.run_all_when_everything_filtered = true
|
12
12
|
config.filter_run :focus
|
13
13
|
|
@@ -16,4 +16,6 @@ RSpec.configure do |config|
|
|
16
16
|
# the seed, which is printed after each run.
|
17
17
|
# --seed 1234
|
18
18
|
config.order = 'random'
|
19
|
+
|
20
|
+
Time.zone = "UTC"
|
19
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dwml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Angelo Lakra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -16,44 +16,29 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.6
|
19
|
+
version: '1.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.6
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: multi_json
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.11.1
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.11.1
|
26
|
+
version: '1.6'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: activesupport
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
33
|
+
version: '5.2'
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
description:
|
56
|
-
Parses DWML and outputs it into ruby arrays/hashes
|
40
|
+
version: '5.2'
|
41
|
+
description: " Parses DWML and outputs it into ruby arrays/hashes\n"
|
57
42
|
email:
|
58
43
|
- angelo.lakra@gmail.com
|
59
44
|
executables: []
|
@@ -63,20 +48,21 @@ extra_rdoc_files:
|
|
63
48
|
files:
|
64
49
|
- ".gitignore"
|
65
50
|
- ".rspec"
|
51
|
+
- ".travis.yml"
|
66
52
|
- Gemfile
|
67
53
|
- LICENSE
|
68
54
|
- README.md
|
69
55
|
- dwml.gemspec
|
70
56
|
- lib/dwml.rb
|
71
57
|
- lib/dwml/data_extractor.rb
|
58
|
+
- lib/dwml/error.rb
|
72
59
|
- lib/dwml/head_extractor.rb
|
73
60
|
- lib/dwml/location.rb
|
74
61
|
- lib/dwml/parameter_extractor.rb
|
75
62
|
- lib/dwml/time_layout.rb
|
76
63
|
- lib/dwml/version.rb
|
77
|
-
- spec/
|
78
|
-
- spec/lib/
|
79
|
-
- spec/lib/dwml/time_layout_spec.rb
|
64
|
+
- spec/docs/basic.xml
|
65
|
+
- spec/lib/dwml_spec.rb
|
80
66
|
- spec/spec_helper.rb
|
81
67
|
homepage: https://github.com/alakra/dwml
|
82
68
|
licenses:
|
@@ -90,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
76
|
requirements:
|
91
77
|
- - ">="
|
92
78
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
79
|
+
version: '2.5'
|
94
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
81
|
requirements:
|
96
82
|
- - ">="
|
@@ -98,12 +84,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
84
|
version: '0'
|
99
85
|
requirements: []
|
100
86
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
87
|
+
rubygems_version: 2.7.6.2
|
102
88
|
signing_key:
|
103
89
|
specification_version: 4
|
104
90
|
summary: A parser for NOAA's Digital Weather Markup Language (DWML)
|
105
91
|
test_files:
|
106
|
-
- spec/
|
107
|
-
- spec/lib/
|
108
|
-
- spec/lib/dwml/time_layout_spec.rb
|
92
|
+
- spec/docs/basic.xml
|
93
|
+
- spec/lib/dwml_spec.rb
|
109
94
|
- spec/spec_helper.rb
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe DWML::Location do
|
4
|
-
describe ".extract" do
|
5
|
-
end
|
6
|
-
|
7
|
-
context "after initialization" do
|
8
|
-
describe "#element" do
|
9
|
-
it "returns original element"
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#location_key" do
|
13
|
-
it "returns the location_key"
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#latitude" do
|
17
|
-
it "returns the correct latitude"
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#longitude" do
|
21
|
-
it "returns the correct longitude"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe DWML::ParameterExtractor do
|
4
|
-
describe "after initialize" do
|
5
|
-
describe "#element" do
|
6
|
-
it "returns the original XML element"
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "#location" do
|
10
|
-
it "returns the location"
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "#time_layouts" do
|
14
|
-
it "returns time layouts"
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "#output" do
|
18
|
-
it "returns a pair of lat/longs"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe "#process" do
|
23
|
-
context "for temperatures" do
|
24
|
-
it "returns valid temperatures with associated timestamps"
|
25
|
-
end
|
26
|
-
|
27
|
-
context "for extracting precipitation" do
|
28
|
-
it "returns valid precipitation with associated timestamps"
|
29
|
-
end
|
30
|
-
|
31
|
-
context "for extracting wind speed" do
|
32
|
-
it "returns valid wind speed with associated timestamps"
|
33
|
-
end
|
34
|
-
|
35
|
-
context "for extracting wind direction" do
|
36
|
-
it "returns valid wind direction with associated timestamps"
|
37
|
-
end
|
38
|
-
|
39
|
-
context "for extracting cloud cover" do
|
40
|
-
it "returns valid cloud cover with associated timestamps"
|
41
|
-
end
|
42
|
-
|
43
|
-
context "for extracting probability of precipitation" do
|
44
|
-
it "returns valid probability of precipitation with associated timestamps"
|
45
|
-
end
|
46
|
-
|
47
|
-
context "for extracting fire weather" do
|
48
|
-
it "returns valid fire weather with associated timestamps"
|
49
|
-
end
|
50
|
-
|
51
|
-
context "for extracting convective hazard" do
|
52
|
-
it "returns valid convective hazard with associated timestamps"
|
53
|
-
end
|
54
|
-
|
55
|
-
context "for extracting climate anomaly" do
|
56
|
-
it "returns valid climate anomaly with associated timestamps"
|
57
|
-
end
|
58
|
-
|
59
|
-
context "for extracting humidity" do
|
60
|
-
it "returns valid humidity with associated timestamps"
|
61
|
-
end
|
62
|
-
|
63
|
-
context "for extracting weather" do
|
64
|
-
it "returns valid weather with associated timestamps"
|
65
|
-
end
|
66
|
-
|
67
|
-
context "for extracting conditions icons" do
|
68
|
-
it "returns valid conditions icons with associated timestamps"
|
69
|
-
end
|
70
|
-
|
71
|
-
context "for extracting hazards" do
|
72
|
-
it "returns valid hazards with associated timestamps"
|
73
|
-
end
|
74
|
-
|
75
|
-
context "for extracting water state" do
|
76
|
-
it "returns valid water state with associated timestamps"
|
77
|
-
end
|
78
|
-
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe DWML::TimeLayout do
|
4
|
-
describe ".extract" do
|
5
|
-
it "returns a list of parsed XML elements"
|
6
|
-
end
|
7
|
-
|
8
|
-
describe "#element" do
|
9
|
-
it "returns the original XML element"
|
10
|
-
end
|
11
|
-
|
12
|
-
describe "#time_coordinate" do
|
13
|
-
it "returns the extracted time coordinate"
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "#summarization" do
|
17
|
-
it "returns the extracted summarization"
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#layout_key" do
|
21
|
-
it "returns the extracted layout_key"
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "#valid_times" do
|
25
|
-
it "returns the valid start and stop times as a ValidTime"
|
26
|
-
end
|
27
|
-
end
|