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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2RmOTg0YmVjOTY2NmU0ODUwMmY5NGUyZTQ2MzIwNjBjOGFjNGY1MA==
4
+ Y2M1OWQxZjdkMDk5NTg1NTU1MTM2NzI4YjgxNjMwMzMzODYwYzljNA==
5
5
  data.tar.gz: !binary |-
6
- YTdkMDFkZmYyMGVjZTk5NmNlYjg3NDYyZmZmOTQ2Mjc5N2NlODg1Yw==
6
+ YWM4MjRiMGM0ZTFlY2M5OWU0MjJmODEwNTM0YTVmN2U0NDA2ZGI2NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZGI2NzE3MzgxODJkMzliMTFmM2UzOGY1MDlkYTYyNzk4YjVlOTZkMTJhYTlk
10
- OTUzZTY5NzA0Y2EzNWI1ZDQyYWJmYmZiMDg0MGNiYWRlNjA3ODYwZjg2MzI1
11
- MmNmODQyNTg5MjMyNTA5ZGU4YzIwYTAzYjJkYWEwZTVjNjQ4YTE=
9
+ ODQ5ZWZjODgwOTM5MGQ2OTA2ZDA3OTUyNmVlODhlMGRiZmE0N2I5MzVhZDE2
10
+ NmNlZTRiZTU2MzZiZWM4OWEyMjllYjFlNmFmMDZjODExYzQyNzQ1N2M2NjYw
11
+ YTVlNzAwZDNjM2NmZWIzZDJiNDI4N2I1NGU2MDQ5NTM1OTE3ODE=
12
12
  data.tar.gz: !binary |-
13
- OGZhNmEwN2UxMDEwNzUwOWQwZTg0OTllMDA4YTBiNDI0MTEyMjhhZmY4N2Fi
14
- MDBkYWY2Y2Y3YzI2NDhlZDczYWQzM2FhZTIzOGE4MWYwZDhlNmRmMjY4MTNh
15
- ZWQ3MzVmOWY4OTdjYzFlMzk4YTRkMjQ5NDM2MmNlNDFlMzJjYzE=
13
+ YTAwNGM5ODcwMzhkZDA0NzViODg5MDM2YjgxNDBiM2ZmNmI2NGYxZDc0YjIx
14
+ ODdlNmJkODI5NjI2NDkzZjhiNjUyZTg5ZDc3N2NiYzk0MDBkMzhlZTc2YWMy
15
+ ODI1MzhlNGI4NTNjMGRmODc0MTE3NjgzMzNmNTFlYjczMTA0Nzg=
@@ -1,3 +1,3 @@
1
1
  module SkiplanClient
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -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
- ciel_id_auj_mat = xml.xpath('//ZONE[@nom="CHINAILLON"]/CIEL_ID').text
22
- ciel_id_auj_apm = xml.xpath('//ZONE[@nom="CHINAILLON"]/CIEL_ID_APM').text
23
- auj_temp_matin = xml.xpath('//ZONE[@nom="CHINAILLON"]/TEMPERATURE').text
24
- auj_temp_apm = xml.xpath('//ZONE[@nom="CHINAILLON"]/TEMPERATURE_APM').text
25
- auj_temp_rst = xml.xpath('//ZONE[@nom="CHINAILLON"]/TEMPERATURE_RESSENTIE').text
26
- auj_vent_kmh = xml.xpath('//ZONE[@nom="CHINAILLON"]/VENT').text
27
- auj_vent_dir = xml.xpath('//ZONE[@nom="CHINAILLON"]/DIRECTION').text
28
- auj_vit_rafales = xml.xpath('//ZONE[@nom="CHINAILLON"]/RAFALES').text
29
- auj_visibilite = xml.xpath('//ZONE[@nom="CHINAILLON"]/VISIBILITE').text
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
- ciel_id_dem_mat = xml.xpath('//ZONE[@nom="J+1"]/CIEL_ID').text
32
- ciel_id_dem_apm = xml.xpath('//ZONE[@nom="J+1"]/CIEL_ID_APM').text
33
- dem_temp_matin = xml.xpath('//ZONE[@nom="J+1"]/TEMPERATURE').text
34
- dem_temp_apm = xml.xpath('//ZONE[@nom="J+1"]/TEMPERATURE_APM').text
35
- dem_vent_kmh = xml.xpath('//ZONE[@nom="J+1"]/VENT').text
36
- dem_vent_dir = xml.xpath('//ZONE[@nom="J+1"]/DIRECTION').text
37
- dem_vit_rafales = xml.xpath('//ZONE[@nom="J+1"]/RAFALES').text
38
- dem_visibilite = xml.xpath('//ZONE[@nom="J+1"]/VISIBILITE').text
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
- j2_mat_ciel_id = xml.xpath('//ZONE[@nom="J+2"]/CIEL_ID').text
41
- j2_apm_ciel_id = xml.xpath('//ZONE[@nom="J+2"]/CIEL_ID_APM').text
42
- j2_temp_matin = xml.xpath('//ZONE[@nom="J+2"]/TEMPERATURE').text
43
- j2_temp_apm = xml.xpath('//ZONE[@nom="J+2"]/TEMPERATURE_APM').text
44
- j2_vent_kmh = xml.xpath('//ZONE[@nom="J+2"]/VENT').text
45
- j2_vent_dir = xml.xpath('//ZONE[@nom="J+2"]/DIRECTION').text
46
- j2_vit_rafales = xml.xpath('//ZONE[@nom="J+2"]/RAFALES').text
47
- j2_visibilite = xml.xpath('//ZONE[@nom="J+2"]/VISIBILITE').text
48
- j3_mat_ciel_id = xml.xpath('//ZONE[@nom="J+3"]/CIEL_ID').text
49
- j3_apm_ciel_id = xml.xpath('//ZONE[@nom="J+3"]/CIEL_ID_APM').text
50
- j3_temp_matin = xml.xpath('//ZONE[@nom="J+3"]/TEMPERATURE').text
51
- j3_temp_apm = xml.xpath('//ZONE[@nom="J+3"]/TEMPERATURE_APM').text
52
- j3_vent_kmh = xml.xpath('//ZONE[@nom="J+3"]/VENT').text
53
- j3_vent_dir = xml.xpath('//ZONE[@nom="J+3"]/DIRECTION').text
54
- j3_vit_rafales = xml.xpath('//ZONE[@nom="J+3"]/RAFALES').text
55
- j3_visibilite = xml.xpath('//ZONE[@nom="J+3"]/VISIBILITE').text
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 'test nokogiri open and xpath text function' do
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
- config = SkiplanClient.configure('C:\Users\Simon\Desktop\Stage\GitHub\skiplan_client\data\lumi_response.xml')
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.5
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 00:00:00.000000000 Z
11
+ date: 2014-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler