clima_tempo 2.0 → 2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/clima_tempo.rb +13 -14
- data/lib/clima_tempo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e7573afa20d4f4c360f5fba6fff230952127bbb
|
4
|
+
data.tar.gz: 5c5b8cecbc3a8f26f0afbea1824008da7d903701
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d9ff9a25d33598f1f17e58dfb170824fbf86f56d1e8337b6a205412027a85ddb0ed227a61922ee8da95a4eadcaad6dbab0149d5ebc634a549db48704e178f0b
|
7
|
+
data.tar.gz: 73521a0be3cb7d97935a1a857591df9aa675e7f55bdc39d681e05159bebadeb2fa00bf5938fcb474f46f9876b023ffb72a61681b1631ede75a78090cc7f36e17
|
data/Gemfile.lock
CHANGED
data/lib/clima_tempo.rb
CHANGED
@@ -12,35 +12,36 @@ class ClimaTempo
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def now
|
15
|
-
html =
|
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(
|
23
|
-
:condition =>
|
24
|
-
:pressure =>
|
25
|
-
:intensity =>
|
26
|
-
:moisture =>
|
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
|
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
|
39
|
+
def prepare(value)
|
39
40
|
value.gsub! /^.+:\s*/, ""
|
40
41
|
end
|
41
42
|
|
42
|
-
def wind_direction
|
43
|
-
|
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
|
data/lib/clima_tempo/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2013-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|