clima_tempo 2.0 → 2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efca641f5337e17a1a9a6ed5a2d0d51670af670b
4
- data.tar.gz: e8919b5a5b52b83daefbe81844ddce358a0da80f
3
+ metadata.gz: 4e7573afa20d4f4c360f5fba6fff230952127bbb
4
+ data.tar.gz: 5c5b8cecbc3a8f26f0afbea1824008da7d903701
5
5
  SHA512:
6
- metadata.gz: 1f8ed1723e2b56fd3df61e2e108cb8f7c45d30b8f07a227eae3f9461fd3dd0970c111d53bfa139330d6c5e5d9d28b5e75dd72782c7b5584b20efa29e292ec671
7
- data.tar.gz: d37a760d87858e653454d63314fc732188687e3c667d808bfc3e0907512eb9fa8867933690601e85bbfdf415b75a09e28a721b21aa0918009204818fc8ee05c3
6
+ metadata.gz: 0d9ff9a25d33598f1f17e58dfb170824fbf86f56d1e8337b6a205412027a85ddb0ed227a61922ee8da95a4eadcaad6dbab0149d5ebc634a549db48704e178f0b
7
+ data.tar.gz: 73521a0be3cb7d97935a1a857591df9aa675e7f55bdc39d681e05159bebadeb2fa00bf5938fcb474f46f9876b023ffb72a61681b1631ede75a78090cc7f36e17
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clima_tempo (1.2.0)
4
+ clima_tempo (2.0)
5
5
  nokogiri (>= 1.5.9)
6
6
 
7
7
  GEM
data/lib/clima_tempo.rb CHANGED
@@ -12,35 +12,36 @@ class ClimaTempo
12
12
  end
13
13
 
14
14
  def now
15
- html = request_page
15
+ html = request
16
16
 
17
17
  values = html.xpath "//li[@class='dados-momento-li list-style-none']"
18
18
  region = html.xpath "//a[@class='thumb-play-prev']"
19
19
 
20
- {
20
+ now = {
21
21
  :temperature => html.xpath("//span[@class='left temp-momento top10']").text,
22
- :wind => wind_direction(prepare_value(values[0].text)),
23
- :condition => prepare_value(values[1].text),
24
- :pressure => prepare_value(values[2].text),
25
- :intensity => prepare_value(values[3].text),
26
- :moisture => prepare_value(values[4].text),
27
- :video => "http://www.climatempo.com.br#{region.first.attribute('href').value}"
22
+ :wind => wind_direction[prepare(values[0].text)],
23
+ :condition => prepare(values[1].text),
24
+ :pressure => prepare(values[2].text),
25
+ :intensity => prepare(values[3].text),
26
+ :moisture => prepare(values[4].text)
28
27
  }
28
+
29
+ now.merge! :video => "http://www.climatempo.com.br#{region.first.attribute('href').value}" unless region.first.nil?
29
30
  end
30
31
 
31
32
  private
32
- def request_page
33
+ def request
33
34
  request = Net::HTTP.get URI.parse("http://www.climatempo.com.br/previsao-do-tempo/cidade/#{@code}/empty")
34
35
 
35
36
  Nokogiri::HTML request
36
37
  end
37
38
 
38
- def prepare_value(value)
39
+ def prepare(value)
39
40
  value.gsub! /^.+:\s*/, ""
40
41
  end
41
42
 
42
- def wind_direction(acronym)
43
- direction = {
43
+ def wind_direction
44
+ {
44
45
  "N" => "Norte",
45
46
  "S" => "Sul",
46
47
  "E" => "Leste",
@@ -58,7 +59,5 @@ class ClimaTempo
58
59
  "WSW" => "Oés-sudoeste",
59
60
  "WNW" => "Oés-noroeste"
60
61
  }
61
-
62
- direction[acronym]
63
62
  end
64
63
  end
@@ -1,3 +1,3 @@
1
1
  class ClimaTempo
2
- VERSION = "2.0"
2
+ VERSION = "2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clima_tempo
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.0'
4
+ version: '2.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rogério Zambon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-17 00:00:00.000000000 Z
11
+ date: 2013-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri