skiplan_client 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/skiplan_client/version.rb +1 -1
- data/lib/skiplan_client.rb +44 -34
- data/test/skiplan_client/skiplan_client_test.rb +27 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Y2M1OWQxZjdkMDk5NTg1NTU1MTM2NzI4YjgxNjMwMzMzODYwYzljNA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWM4MjRiMGM0ZTFlY2M5OWU0MjJmODEwNTM0YTVmN2U0NDA2ZGI2NA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODQ5ZWZjODgwOTM5MGQ2OTA2ZDA3OTUyNmVlODhlMGRiZmE0N2I5MzVhZDE2
|
10
|
+
NmNlZTRiZTU2MzZiZWM4OWEyMjllYjFlNmFmMDZjODExYzQyNzQ1N2M2NjYw
|
11
|
+
YTVlNzAwZDNjM2NmZWIzZDJiNDI4N2I1NGU2MDQ5NTM1OTE3ODE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTAwNGM5ODcwMzhkZDA0NzViODg5MDM2YjgxNDBiM2ZmNmI2NGYxZDc0YjIx
|
14
|
+
ODdlNmJkODI5NjI2NDkzZjhiNjUyZTg5ZDc3N2NiYzk0MDBkMzhlZTc2YWMy
|
15
|
+
ODI1MzhlNGI4NTNjMGRmODc0MTE3NjgzMzNmNTFlYjczMTA0Nzg=
|
data/lib/skiplan_client.rb
CHANGED
@@ -13,46 +13,56 @@ module SkiplanClient
|
|
13
13
|
@config[:base_url] = url
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.get_weather
|
16
|
+
def self.get_weather(zone)
|
17
17
|
@info = []
|
18
18
|
|
19
19
|
xml = Nokogiri::XML(open(@config[:base_url]))
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
21
|
+
today_element = xml.xpath('//ZONE[@nom="' + zone + '"]')
|
22
|
+
ciel_id_auj_mat = today_element.xpath('./CIEL_ID').text
|
23
|
+
ciel_id_auj_apm = today_element.xpath('./CIEL_ID_APM').text
|
24
|
+
auj_temp_matin = today_element.xpath('./TEMPERATURE').text
|
25
|
+
auj_temp_apm = today_element.xpath('./TEMPERATURE_APM').text
|
26
|
+
auj_temp_rst = today_element.xpath('./TEMPERATURE_RESSENTIE').text
|
27
|
+
auj_vent_kmh = today_element.xpath('./VENT').text
|
28
|
+
auj_vent_dir = today_element.xpath('./DIRECTION').text
|
29
|
+
auj_vit_rafales = today_element.xpath('./RAFALES').text
|
30
|
+
auj_visibilite = today_element.xpath('./VISIBILITE').text
|
31
|
+
|
30
32
|
meteo_jour = xml.xpath('//JOUR/LANGUE[@val="fr"]').text
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
|
34
|
+
tomorrow_element = xml.xpath('//ZONE[starts-with(@nom,"J+1") and @reference="' + zone + '"]')
|
35
|
+
ciel_id_dem_mat = tomorrow_element.xpath('./CIEL_ID').text
|
36
|
+
ciel_id_dem_apm = tomorrow_element.xpath('./CIEL_ID_APM').text
|
37
|
+
dem_temp_matin = tomorrow_element.xpath('./TEMPERATURE').text
|
38
|
+
dem_temp_apm = tomorrow_element.xpath('./TEMPERATURE_APM').text
|
39
|
+
dem_vent_kmh = tomorrow_element.xpath('./VENT').text
|
40
|
+
dem_vent_dir = tomorrow_element.xpath('./DIRECTION').text
|
41
|
+
dem_vit_rafales = tomorrow_element.xpath('./RAFALES').text
|
42
|
+
dem_visibilite = tomorrow_element.xpath('./VISIBILITE').text
|
43
|
+
|
39
44
|
meteo_lendemain = xml.xpath('//LENDEMAIN/LANGUE[@val="fr"]').text
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
45
|
+
|
46
|
+
j2_element = xml.xpath('//ZONE[starts-with(@nom,"J+2") and @reference="' + zone + '"]')
|
47
|
+
j2_mat_ciel_id = j2_element.xpath('./CIEL_ID').text
|
48
|
+
j2_apm_ciel_id = j2_element.xpath('./CIEL_ID_APM').text
|
49
|
+
j2_temp_matin = j2_element.xpath('./TEMPERATURE').text
|
50
|
+
j2_temp_apm = j2_element.xpath('./TEMPERATURE_APM').text
|
51
|
+
j2_vent_kmh = j2_element.xpath('./VENT').text
|
52
|
+
j2_vent_dir = j2_element.xpath('./DIRECTION').text
|
53
|
+
j2_vit_rafales = j2_element.xpath('./RAFALES').text
|
54
|
+
j2_visibilite = j2_element.xpath('./VISIBILITE').text
|
55
|
+
|
56
|
+
j3_element = xml.xpath('//ZONE[starts-with(@nom,"J+3") and @reference="' + zone + '"]')
|
57
|
+
j3_mat_ciel_id = j3_element.xpath('./CIEL_ID').text
|
58
|
+
j3_apm_ciel_id = j3_element.xpath('./CIEL_ID_APM').text
|
59
|
+
j3_temp_matin = j3_element.xpath('./TEMPERATURE').text
|
60
|
+
j3_temp_apm = j3_element.xpath('./TEMPERATURE_APM').text
|
61
|
+
j3_vent_kmh = j3_element.xpath('./VENT').text
|
62
|
+
j3_vent_dir = j3_element.xpath('./DIRECTION').text
|
63
|
+
j3_vit_rafales = j3_element.xpath('./RAFALES').text
|
64
|
+
j3_visibilite = j3_element.xpath('./VISIBILITE').text
|
65
|
+
|
56
66
|
meteo_semaine = xml.xpath('//SEMAINE/LANGUE[@val="fr"]').text
|
57
67
|
|
58
68
|
|
@@ -8,25 +8,13 @@ require 'skiplan_client/weather_object'
|
|
8
8
|
|
9
9
|
class SkiplanClientTest < Test::Unit::TestCase
|
10
10
|
|
11
|
-
should '
|
12
|
-
|
13
|
-
xml = Nokogiri::XML(open('http://api.openweathermap.org/data/2.5/forecast/daily?q=tokyo&mode=xml&units=metric&cnt=1'))
|
14
|
-
city = xml.xpath('//name').text
|
15
|
-
country = xml.xpath('//country').text
|
16
|
-
|
17
|
-
assert_equal 'Tokyo', city
|
18
|
-
assert_equal 'JP', country
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
should 'test get_weather founction' do
|
11
|
+
should 'retrieve weather data' do
|
23
12
|
|
24
13
|
jour = 'Soleil et ciel bleu pr??dominent. Vent variable faible. Cette nuit : Nuit ??toil??e, puis d??gradation nuageuse en fin de nuit.En fin de nuit vent de sud-est mod??r?? dans le Pays du Mont Blanc. Sur les autres r??gions, vent plus faible.'
|
25
14
|
dem = 'Temps nuageux ?? tr??s nuageux, averses parfois orageuses en journ??e. En d??but de matin??e, vent de sud-est soufflant mod??r??ment dans le Pays du Mont Blanc, avec des rafales atteignant 55 km/h; puis att??nuation. Ailleurs, vent plus faible.'
|
26
|
-
semaine = ""
|
27
15
|
|
28
|
-
|
29
|
-
weather = SkiplanClient.get_weather
|
16
|
+
SkiplanClient.configure('../../data/lumi_response.xml')
|
17
|
+
weather = SkiplanClient.get_weather('CHINAILLON')
|
30
18
|
|
31
19
|
assert_equal '101' , weather.auj_ciel_id_matin
|
32
20
|
assert_equal '101' , weather.auj_ciel_id_apm
|
@@ -69,6 +57,30 @@ class SkiplanClientTest < Test::Unit::TestCase
|
|
69
57
|
|
70
58
|
end
|
71
59
|
|
60
|
+
should 'retrieve weather data for provided zone' do
|
61
|
+
|
62
|
+
SkiplanClient.configure('../../data/lumi_response.xml')
|
63
|
+
weather = SkiplanClient.get_weather('MONT-LACHAT')
|
64
|
+
|
65
|
+
assert_equal '101' , weather.auj_ciel_id_matin
|
66
|
+
assert_equal '101' , weather.auj_ciel_id_apm
|
67
|
+
assert_equal '+10' , weather.auj_temp_matin
|
68
|
+
assert_equal '+14' , weather.auj_temp_apm
|
69
|
+
assert_equal '104' , weather.dem_ciel_id_matin
|
70
|
+
assert_equal '106' , weather.dem_ciel_id_apm
|
71
|
+
assert_equal '+14' , weather.dem_temp_matin
|
72
|
+
assert_equal '+13' , weather.dem_temp_apm
|
73
|
+
assert_equal '106' , weather.j2_mat_ciel_id
|
74
|
+
assert_equal '104' , weather.j2_apm_ciel_id
|
75
|
+
assert_equal '+7' , weather.j2_temp_matin
|
76
|
+
assert_equal '+11' , weather.j2_temp_apm
|
77
|
+
assert_equal '101' , weather.j3_mat_ciel_id
|
78
|
+
assert_equal '103' , weather.j3_apm_ciel_id
|
79
|
+
assert_equal '+12' , weather.j3_temp_matin
|
80
|
+
assert_equal '+14' , weather.j3_temp_apm
|
81
|
+
|
82
|
+
end
|
83
|
+
|
72
84
|
should 'change config url' do
|
73
85
|
|
74
86
|
config = SkiplanClient.configure('http://api.openweathermap.org/data/2.5/forecast/daily?q=tokyo&mode=xml&units=metric&cnt=1')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: skiplan_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SimonRonzani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|