skiplan_client 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
- require "bundler/gem_tasks"
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.verbose = true
6
+ t.pattern = '**/*_test.rb'
7
+ end
@@ -278,16 +278,8 @@
278
278
  <SKI_AURORE etat="0"/>
279
279
  <KM_SKATING ouvert="0"/>
280
280
  <COMMENTAIRES>
281
- <LANGUE val="en"><![CDATA[SKI AREA IS CLOSED FOR THE SEASON 2013/2014.
282
-
283
- Col de la Colombi??re closed.
284
- Road D12 is closed between St Pierre en Faucigny and Petit-Bornand les Gli??res from 31/03 to 15/06/14 for work. Deviation from Annecy.
285
- Ski lifts opening and slopes access may change at any time depending on weather conditions and various maintenance operations. Outside opening hours, the ski area is strictly prohibited.]]></LANGUE>
286
- <LANGUE val="fr"><![CDATA[LE DOMAINE SKIABLE EST FERM?? POUR LA SAISON 2013/2014.
287
-
288
- Col de la Colombi??re ferm??.
289
- Attention, fermeture de la D12 entre St Pierre en Faucigny et Petit-Bornand les Gli??res du 31/03 au 15/06/14 pour travaux. D??viation par Annecy.
290
- L'ouverture des remont??es m??caniques et l'acc??s aux pistes peuvent ??voluer en fonction des conditions m??t??orologiques et des op??rations d'entretien et de maintenance. En dehors des heures d'ouverture, le domaine skiable est strictement interdit.]]></LANGUE>
281
+ <LANGUE val="en"><![CDATA[SKI AREA IS CLOSED FOR THE SEASON 2013/2014.]]></LANGUE>
282
+ <LANGUE val="fr"><![CDATA[LE DOMAINE SKIABLE EST FERME POUR LA SAISON 2013/2014.]]></LANGUE>
291
283
  </COMMENTAIRES>
292
284
  <PISTES total="44" total_periode="44" total_periode_hpf="44" ouvertes_previsions="0" ouvertes="0" previsions="0" fermees="44" lng_total="0.0" lng_ouverts="0.0"/>
293
285
  <PISTES_VERTES total="12" total_periode="12" total_periode_hpf="12" ouvertes_previsions="0" ouvertes="0" previsions="0" fermees="12" lng_total="0.0" lng_ouverts="0.0"/>
@@ -5,7 +5,7 @@ class Metrics
5
5
 
6
6
  include AttributeHelper
7
7
 
8
- METRICS = ['ETAT_CHAUSSEE', 'ETAT_ROUTE', 'SKI_NUIT', 'KM_SKATING', 'SKI_ALPIN', 'SKI_ALPIN_VERTES', 'SKI_ALPIN_BLEUES', 'SKI_ALPIN_ROUGES',
8
+ METRICS = ['ETAT_CHAUSSEE', 'ETAT_ROUTE', 'SKI_NUIT', 'KM_SKATING', 'COMMENTAIRES', 'SKI_ALPIN', 'SKI_ALPIN_VERTES', 'SKI_ALPIN_BLEUES', 'SKI_ALPIN_ROUGES',
9
9
  'SKI_ALPIN_NOIRES', 'SKI_NORDIQUE', 'SKI_NORDIQUE_VERTES', 'SKI_NORDIQUE_BLEUES', 'SKI_NORDIQUE_ROUGES', 'SKI_NORDIQUE_NOIRES',
10
10
  'REMONTEES', 'PIETONS', 'RAQUETTES', 'LUGE', 'SNOWPARK']
11
11
 
@@ -1,10 +1,10 @@
1
1
  class Skiplan
2
2
 
3
- attr_accessor :forecasts, :text_forecasts, :metrics, :zones
3
+ attr_accessor :forecasts, :text_messages, :metrics, :zones
4
4
 
5
5
  def initialize
6
6
  @forecasts = {}
7
7
  @zones = {}
8
- @text_forecasts = {}
8
+ @text_messages = {}
9
9
  end
10
10
  end
@@ -1,3 +1,3 @@
1
1
  module SkiplanClient
2
- VERSION = "0.1.4"
2
+ VERSION = '0.1.5'
3
3
  end
@@ -41,8 +41,14 @@ module SkiplanClient
41
41
  weather.zones[z['nom']] = Zone.new(Hash.from_xml(z.to_s)['SECTEUR'])
42
42
  end
43
43
 
44
- text_forecasts = xml.xpath('//BULLETINS//JOUR//LANGUE[@val="fr"]')
45
- weather.text_forecasts = Hash.from_xml(text_forecasts.to_s)['LANGUE']
44
+ today_forecast = xml.xpath('//BULLETINS//JOUR//LANGUE[@val="fr"]')
45
+ weather.text_messages['today_forecast'] = Hash.from_xml(today_forecast.to_s)['LANGUE']
46
+
47
+ forecasts_comment = xml.xpath('//BULLETINS//COMMENTAIRES//LANGUE[@val="fr"]')
48
+ weather.text_messages['forecasts_comment'] = Hash.from_xml(forecasts_comment.to_s)['LANGUE']
49
+
50
+ slopes_comment = xml.xpath('//INDICES//COMMENTAIRES//LANGUE[@val="fr"]')
51
+ weather.text_messages['slopes_comment'] = Hash.from_xml(slopes_comment.to_s)['LANGUE']
46
52
 
47
53
  weather
48
54
  end
@@ -8,9 +8,15 @@ require 'skiplan_client/skiplan'
8
8
 
9
9
  class SkiplanClientTest < Test::Unit::TestCase
10
10
 
11
- should 'retrieve weather data' do
11
+ setup do
12
+ if Dir.pwd.include?('test')
13
+ SkiplanClient.configure('../../data/lumi_response.xml')
14
+ else
15
+ SkiplanClient.configure('data/lumi_response.xml')
16
+ end
17
+ end
12
18
 
13
- SkiplanClient.configure('../../data/lumi_response.xml')
19
+ should 'retrieve weather data' do
14
20
  weather = SkiplanClient.get_weather('CHINAILLON')
15
21
 
16
22
  today_forecast = weather.forecasts['j']
@@ -48,7 +54,6 @@ class SkiplanClientTest < Test::Unit::TestCase
48
54
  end
49
55
 
50
56
  should 'retrieve metrics data' do
51
- SkiplanClient.configure('../../data/lumi_response.xml')
52
57
  metrics = SkiplanClient.get_weather('CHINAILLON').metrics
53
58
 
54
59
  assert_equal '0/44', metrics.alpine[:total]
@@ -60,7 +65,6 @@ class SkiplanClientTest < Test::Unit::TestCase
60
65
  end
61
66
 
62
67
  should 'retrieve zones data' do
63
- SkiplanClient.configure('../../data/lumi_response.xml')
64
68
  zones = SkiplanClient.get_weather('CHINAILLON').zones
65
69
 
66
70
  assert_equal 10, zones.length
@@ -76,10 +80,11 @@ class SkiplanClientTest < Test::Unit::TestCase
76
80
  assert_equal 'my_new_url', config
77
81
  end
78
82
 
79
- should 'retrieve text forecasts' do
80
- SkiplanClient.configure('../../data/lumi_response.xml')
81
- text_forecasts = SkiplanClient.get_weather('CHINAILLON').text_forecasts
83
+ should 'retrieve text messages' do
84
+ text_forecasts = SkiplanClient.get_weather('CHINAILLON').text_messages
82
85
 
83
- assert_equal 'Pluie. Vent faible variable.', text_forecasts
86
+ assert_equal 'Pluie. Vent faible variable.', text_forecasts['today_forecast']
87
+ assert_equal 'Col de la Colombière ouvert.', text_forecasts['forecasts_comment']
88
+ assert_equal 'LE DOMAINE SKIABLE EST FERME POUR LA SAISON 2013/2014.', text_forecasts['slopes_comment']
84
89
  end
85
90
  end
@@ -9,9 +9,9 @@ class ZoneTest < Test::Unit::TestCase
9
9
 
10
10
  setup do
11
11
  attributes = {'nom' => 'ALPIN CHINAILLON',
12
- 'REMONTEE' => [{'nom' => 'TS LA FLORIA', 'etat' => 'O', 'type' => 'TS', 'msg' => 'Fermee pour la saison'},
13
- {'nom' => 'TK LE STADE', 'etat' => 'F', 'type' => 'TK', 'msg' => 'Fermee pour la saison'}],
14
- 'PISTE' => [{'nom' => 'LA SERPENTINE', 'etat' => 'F', 'type' => 'A', 'msg' => '', 'niveau' => 'V'},
12
+ 'REMONTEE' => [{'nom' => 'TS LA FLORIA', 'etat' => 'O', 'type' => 'TS', 'msg' => 'Fermee pour la saison', 'heuredeb' => '09:00', 'heurefin' => '16:45'},
13
+ {'nom' => 'TK LE STADE', 'etat' => 'F', 'type' => 'TK', 'msg' => 'Fermee pour la saison', 'heuredeb' => '09:00', 'heurefin' => '16:00'}],
14
+ 'PISTE' => [{'nom' => 'LA SERPENTINE', 'etat' => 'F', 'type' => 'A', 'msg' => 'Piste de retour au Village', 'niveau' => 'V'},
15
15
  {'nom' => 'LE VENAY', 'etat' => 'O', 'type' => 'A', 'msg' => '', 'niveau' => 'V'}]
16
16
  }
17
17
  @zone = Zone.new(attributes)
@@ -19,9 +19,9 @@ class ZoneTest < Test::Unit::TestCase
19
19
 
20
20
  should 'retrieve the data for a given zone' do
21
21
  assert_equal 'ALPIN CHINAILLON', @zone.name
22
- assert_equal [{'nom' => 'TS LA FLORIA', 'etat' => 'O', 'type' => 'TS', 'msg' => 'Fermee pour la saison'},
23
- {'nom' => 'TK LE STADE', 'etat' => 'F', 'type' => 'TK', 'msg' => 'Fermee pour la saison'}], @zone.skilifts
24
- assert_equal [{'nom' => 'LA SERPENTINE', 'etat' => 'F', 'type' => 'A', 'msg' => '', 'niveau' => 'V'},
22
+ assert_equal [{'nom' => 'TS LA FLORIA', 'etat' => 'O', 'type' => 'TS', 'msg' => 'Fermee pour la saison', 'heuredeb' => '09:00', 'heurefin' => '16:45'},
23
+ {'nom' => 'TK LE STADE', 'etat' => 'F', 'type' => 'TK', 'msg' => 'Fermee pour la saison', 'heuredeb' => '09:00', 'heurefin' => '16:00'}], @zone.skilifts
24
+ assert_equal [{'nom' => 'LA SERPENTINE', 'etat' => 'F', 'type' => 'A', 'msg' => 'Piste de retour au Village', 'niveau' => 'V'},
25
25
  {'nom' => 'LE VENAY', 'etat' => 'O', 'type' => 'A', 'msg' => '', 'niveau' => 'V'}], @zone.slopes
26
26
  end
27
27
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skiplan_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-19 00:00:00.000000000 Z
12
+ date: 2015-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler