dwml 1.0.0 → 1.1.0

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
  SHA1:
3
- metadata.gz: bd148c3dd2ef35a098cdaab6f8dc37e7c35276ee
4
- data.tar.gz: c4844f0451e8cba714da7af6837aad3756d713b8
3
+ metadata.gz: 0ad3fa1473b54cef4122ad9ff01aa394627674fa
4
+ data.tar.gz: 7599b77d6b7eb5861e8416dd6f3193747cb059a6
5
5
  SHA512:
6
- metadata.gz: c8f59e69faa76af529e15c2b1722b7e26fdeb4d380dd93d36ebe6fde37419a4ef94cfd92ea32b606f0830741d53a7abb1ec83895a2e631820a37b1bd8fa62213
7
- data.tar.gz: 3e17350c0a31ee30197f2c3beef7914043f02b30e6903d6226fce9d06f4f9a0c5b71b51d254f6adf900c6f1841a3e275272e11848870015d71a5f915873d2060
6
+ metadata.gz: be7c1920941e3d56fea05f7662b49e94ee728b39267c809527048b73a83ec2f0b4e2b556af8bad548ff5e3b655c08a58835e3201608be769a898ff7726ee3fe0
7
+ data.tar.gz: 69cc7789a51d860406c997e042feecec5c779798ab7a0e0c17af9012cba185fe5234354b64d4be2d44c7c55884e815f48fdf15d138bdb556e8b6812f2fbc9e99
@@ -20,9 +20,9 @@ class DWML
20
20
 
21
21
  @output.merge!(
22
22
  :product => {
23
- :title => element.xpath('product/title').text,
24
- :field => element.xpath('product/field').text,
25
- :category => element.xpath('product/category').text,
23
+ :title => normalize_content( 'product/title' ),
24
+ :field => normalize_content( 'product/field' ),
25
+ :category => normalize_content( 'product/category' ),
26
26
  :creation_date => creation_date
27
27
  }
28
28
  )
@@ -34,14 +34,24 @@ class DWML
34
34
 
35
35
  @output.merge!(
36
36
  :source => {
37
- :more_information => element.xpath('source/more-information').text,
38
37
  :product_center => production_center.gsub(sub_center, " - #{sub_center}"),
39
- :disclaimer => element.xpath('source/disclaimer').text,
40
- :credit => element.xpath('source/credit').text,
41
- :credit_logo => element.xpath('source/credit-logo').text,
42
- :feedback => element.xpath('source/feedback').text
38
+ :more_information => normalize_content( 'source/more-information' ),
39
+ :disclaimer => normalize_content( 'source/disclaimer' ),
40
+ :credit => normalize_content( 'source/credit' ),
41
+ :credit_logo => normalize_content( 'source/credit-logo' ),
42
+ :feedback => normalize_content( 'source/feedback' )
43
43
  }
44
44
  )
45
45
  end
46
+
47
+ def normalize_content(selector)
48
+ node = element.xpath(selector)
49
+
50
+ if node.blank?
51
+ ""
52
+ else
53
+ node.text
54
+ end
55
+ end
46
56
  end
47
57
  end
@@ -213,27 +213,21 @@ class DWML
213
213
  value = condition.xpath("value").first
214
214
  next if value.blank?
215
215
 
216
+ hsh = { :start_time => layout.valid_times[index].start }
217
+
216
218
  visibility_node = value.xpath("visibility").first
217
- visibility = if visibility_node.present? && visibility_node.text.present?
218
- {
219
+ if visibility_node.present? && visibility_node.text.present?
220
+ visibility = {
219
221
  :unit => visibility_node.attributes["units"].text,
220
222
  :value => visibility_node.text.to_f
221
223
  }
222
- else
223
- ""
224
- end
225
-
226
- hsh = {
227
- :start_time => layout.valid_times[index].start,
228
- :coverage => value.attributes["coverage"].text,
229
- :intensity => value.attributes["intensity"].text,
230
- :"weather-type" => value.attributes["weather-type"].text,
231
- :qualifier => value.attributes["qualifier"].text,
232
- :visibility => visibility
233
- }
224
+ hsh.merge!( :visibility => visibility)
225
+ end
234
226
 
235
- additive = value.attributes["additive"]
236
- hsh.merge!(:additive => additive) if additive.present?
227
+ [:coverage, :intensity, :additive, :qualifier, :"weather-type"].each do |key|
228
+ attribute = value.attributes[key.to_s]
229
+ hsh.merge!(key => attribute.to_s) if attribute.present?
230
+ end
237
231
 
238
232
  @output[:weather][:conditions] << hsh
239
233
  end
data/lib/dwml/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class DWML
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  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.0.0
4
+ version: 1.1.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: 2014-05-15 00:00:00.000000000 Z
11
+ date: 2014-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri