skiplan_client 0.2.3 → 0.2.4

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: 94773202512f28a9b5ec221e91ebb45151f3bb4d
4
- data.tar.gz: a8bfcec5b4e3959556bbbc4998475adb0410ad47
3
+ metadata.gz: c3b5e3eb3aee4a977eee4cbbc1a8fbeb96ca2717
4
+ data.tar.gz: 93e01c7036deecd5bb1dd5faa1c5580723b4b471
5
5
  SHA512:
6
- metadata.gz: fae8e1a71257d9ed055592f5bc7f8ec1a835027c5e79b5fa8084d710f0312dc22454afa416d54214daa2984e599288f0470f4cadee3589f75bbf6ad2b14afa30
7
- data.tar.gz: 3ea1a3c7d5a1c195a68c991e2f19ff5228d5b5dc4a1e2f39994269bd67d93516a71261f67c6f73fcb5b3aaf7229182dfbc92f64bfca7664d9fcbadcf61540f3b
6
+ metadata.gz: 2902eb1ddab5f7849a023ed8ea87ea4521f5dcfc3cf6aa19bd1b84192efb89c4ca04e8bf8a65b704870f9d62cee636937e31fbb3a83730ca4837c1a3136e8167
7
+ data.tar.gz: 1590c29da44bebe320760f0cb985e4f9d0b48bd79c103872918404413ecbcfa454c9e857eafd64a45b39ce2884807243f9725fa33b48691dfbd9987cc497e625
@@ -49,18 +49,27 @@ module SkiplanClient
49
49
 
50
50
  def self.texts
51
51
  xml = Nokogiri::XML(open(@config[:base_url]))
52
+ {
53
+ fr: SkiplanClient.localized_texts(xml, 'fr'),
54
+ en: SkiplanClient.localized_texts(xml, 'en')
55
+ }
56
+ end
57
+
58
+ private
59
+
60
+ def self.localized_texts(xml, locale)
52
61
  text_messages = {}
53
62
 
54
- today_forecast = xml.xpath('//BULLETINS//JOUR//LANGUE[@val="fr"]')
63
+ today_forecast = xml.xpath('//BULLETINS//JOUR//LANGUE[@val="' + locale + '"]')
55
64
  text_messages['today_forecast'] = Hash.from_xml(today_forecast.to_s)['LANGUE']
56
65
 
57
- tomorrow_forecast = xml.xpath('//BULLETINS//LENDEMAIN//LANGUE[@val="fr"]')
66
+ tomorrow_forecast = xml.xpath('//BULLETINS//LENDEMAIN//LANGUE[@val="' + locale + '"]')
58
67
  text_messages['tomorrow_forecast'] = Hash.from_xml(tomorrow_forecast.to_s)['LANGUE']
59
68
 
60
- forecasts_comment = xml.xpath('//BULLETINS//COMMENTAIRES//LANGUE[@val="fr"]')
69
+ forecasts_comment = xml.xpath('//BULLETINS//COMMENTAIRES//LANGUE[@val="' + locale + '"]')
61
70
  text_messages['forecasts_comment'] = Hash.from_xml(forecasts_comment.to_s)['LANGUE']
62
71
 
63
- ski_area_comment = xml.xpath('//INDICES//COMMENTAIRES//LANGUE[@val="fr"]')
72
+ ski_area_comment = xml.xpath('//INDICES//COMMENTAIRES//LANGUE[@val="' + locale + '"]')
64
73
  text_messages['ski_area'] = Hash.from_xml(ski_area_comment.to_s)['LANGUE']
65
74
 
66
75
  conditions_comment = xml.xpath('//INDICES//ETAT_ROUTE')
@@ -1,3 +1,3 @@
1
1
  module SkiplanClient
2
- VERSION = '0.2.3'
2
+ VERSION = '0.2.4'
3
3
  end
@@ -85,11 +85,17 @@ class SkiplanClientTest < Test::Unit::TestCase
85
85
  should 'retrieve forecasts text messages' do
86
86
  texts = SkiplanClient.texts
87
87
 
88
- assert_equal 'Pluie. Vent faible variable.', texts['today_forecast']
89
- assert_equal 'Beau temps sec et ensoleillé. Vent faible variable.', texts['tomorrow_forecast']
90
- assert_equal 'Col de la Colombière ouvert.', texts['forecasts_comment']
91
- assert_equal 'LE DOMAINE SKIABLE EST FERME POUR LA SAISON 2013/2014.', texts['ski_area']
92
- assert_equal 'Routes degagees, circulation normale', texts['conditions']
93
- assert_equal 'Non defini', texts['roads']
88
+ assert_equal 'Pluie. Vent faible variable.', texts[:fr]['today_forecast']
89
+ assert_equal 'Beau temps sec et ensoleillé. Vent faible variable.', texts[:fr]['tomorrow_forecast']
90
+ assert_equal 'Col de la Colombière ouvert.', texts[:fr]['forecasts_comment']
91
+ assert_equal 'LE DOMAINE SKIABLE EST FERME POUR LA SAISON 2013/2014.', texts[:fr]['ski_area']
92
+ assert_equal 'Routes degagees, circulation normale', texts[:fr]['conditions']
93
+ assert_equal 'Non defini', texts[:fr]['roads']
94
+ assert_equal 'Rain and snow. Variable winds, light at most places.', texts[:en]['today_forecast']
95
+ assert_equal 'Dry and mostly sunny. Variable winds, light at most places.', texts[:en]['tomorrow_forecast']
96
+ assert_equal 'Col de la Colombière open.', texts[:en]['forecasts_comment']
97
+ assert_equal 'SKI AREA IS CLOSED FOR THE SEASON 2013/2014.', texts[:en]['ski_area']
98
+ assert_equal 'Routes degagees, circulation normale', texts[:en]['conditions']
99
+ assert_equal 'Non defini', texts[:en]['roads']
94
100
  end
95
101
  end
@@ -8,7 +8,10 @@ class ZoneTest < Test::Unit::TestCase
8
8
 
9
9
  setup do
10
10
  attributes = {'nom' => 'ALPIN CHINAILLON',
11
- 'REMONTEE' => [{'nom' => 'TS LA FLORIA', 'etat' => 'O', 'type' => 'TS', 'msg' => 'Fermee pour la saison', 'heuredeb' => '09:00', 'heurefin' => '16:45'},
11
+ 'REMONTEE' => [{
12
+ 'nom' => 'TS LA FLORIA', 'etat' => 'O', 'type' => 'TS', 'msg' => 'Fermee pour la saison', 'heuredeb' => '09:00', 'heurefin' => '16:45',
13
+ 'MSG_ASSOCIE' => ['message fr', 'message en']
14
+ },
12
15
  {'nom' => 'TK LE STADE', 'etat' => 'F', 'type' => 'TK', 'msg' => 'Fermee pour la saison', 'heuredeb' => '09:00', 'heurefin' => '16:00'}],
13
16
  'PISTE' => [{'nom' => 'LA SERPENTINE', 'etat' => 'F', 'type' => 'A', 'msg' => 'Piste de retour au Village', 'niveau' => 'V', 'entretien_num' => '1'},
14
17
  {'nom' => 'LE VENAY', 'etat' => 'O', 'type' => 'A', 'msg' => '', 'niveau' => 'V', 'entretien_num' => '0'}],
@@ -20,7 +23,10 @@ class ZoneTest < Test::Unit::TestCase
20
23
 
21
24
  should 'retrieve the data for a given zone' do
22
25
  assert_equal 'ALPIN CHINAILLON', @zone.name
23
- assert_equal [{'nom' => 'TS LA FLORIA', 'etat' => 'O', 'type' => 'TS', 'msg' => 'Fermee pour la saison', 'heuredeb' => '09:00', 'heurefin' => '16:45'},
26
+ assert_equal [{
27
+ 'nom' => 'TS LA FLORIA', 'etat' => 'O', 'type' => 'TS', 'msg' => 'Fermee pour la saison', 'heuredeb' => '09:00', 'heurefin' => '16:45',
28
+ 'MSG_ASSOCIE' => ['message fr', 'message en']
29
+ },
24
30
  {'nom' => 'TK LE STADE', 'etat' => 'F', 'type' => 'TK', 'msg' => 'Fermee pour la saison', 'heuredeb' => '09:00', 'heurefin' => '16:00'}], @zone.skilifts
25
31
  assert_equal [{'nom' => 'LA SERPENTINE', 'etat' => 'F', 'type' => 'A', 'msg' => 'Piste de retour au Village', 'niveau' => 'V', 'entretien_num' => '1'},
26
32
  {'nom' => 'LE VENAY', 'etat' => 'O', 'type' => 'A', 'msg' => '', 'niveau' => 'V', 'entretien_num' => '0'}], @zone.slopes
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.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - SimonRonzani
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-03 00:00:00.000000000 Z
12
+ date: 2015-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler