skiplan_client 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,12 @@
1
- class Skiplan
2
-
3
- attr_accessor :forecasts, :text_messages, :metrics, :zones
4
-
5
- def initialize
6
- @forecasts = {}
7
- @metrics = {}
8
- @zones = {}
9
- @text_messages = {}
10
- end
1
+ class Skiplan
2
+
3
+ attr_accessor :forecasts, :text_messages, :metrics, :zones, :updated_at
4
+
5
+ def initialize(updated_at)
6
+ @updated_at = updated_at
7
+ @forecasts = {}
8
+ @metrics = {}
9
+ @zones = {}
10
+ @text_messages = {}
11
+ end
11
12
  end
@@ -1,3 +1,3 @@
1
- module SkiplanClient
2
- VERSION = '0.2.4'
3
- end
1
+ module SkiplanClient
2
+ VERSION = '0.2.5'
3
+ end
@@ -1,35 +1,35 @@
1
- require 'skiplan_client/attribute_helper'
2
-
3
- class Zone
4
-
5
- include AttributeHelper
6
-
7
- def initialize(attributes)
8
- normalized_attrs = attributes.dup
9
- normalized_attrs['REMONTEE'] = [normalized_attrs['REMONTEE']] if normalized_attrs['REMONTEE'].is_a?(Hash)
10
- normalized_attrs['PISTE'] = [normalized_attrs['PISTE']] if normalized_attrs['PISTE'].is_a?(Hash)
11
- normalized_attrs['Liaison'] = [normalized_attrs['Liaison']] if normalized_attrs['Liaison'].is_a?(Hash)
12
- self.attributes = normalized_attrs
13
- end
14
-
15
- def name
16
- @nom
17
- end
18
-
19
- def skilifts
20
- @REMONTEE
21
- end
22
-
23
- def slopes
24
- @PISTE
25
- end
26
-
27
- def connections
28
- @Liaison
29
- end
30
-
31
- def ratio(array_field = [])
32
- open_entries = array_field.select {|r| r['etat'] == 'O'}
33
- "#{open_entries.length}/#{array_field.length}"
34
- end
1
+ require 'skiplan_client/attribute_helper'
2
+
3
+ class Zone
4
+
5
+ include AttributeHelper
6
+
7
+ def initialize(attributes)
8
+ normalized_attrs = attributes.dup
9
+ normalized_attrs['REMONTEE'] = [normalized_attrs['REMONTEE']] if normalized_attrs['REMONTEE'].is_a?(Hash)
10
+ normalized_attrs['PISTE'] = [normalized_attrs['PISTE']] if normalized_attrs['PISTE'].is_a?(Hash)
11
+ normalized_attrs['Liaison'] = [normalized_attrs['Liaison']] if normalized_attrs['Liaison'].is_a?(Hash)
12
+ self.attributes = normalized_attrs
13
+ end
14
+
15
+ def name
16
+ @nom
17
+ end
18
+
19
+ def skilifts
20
+ @REMONTEE
21
+ end
22
+
23
+ def slopes
24
+ @PISTE
25
+ end
26
+
27
+ def connections
28
+ @Liaison
29
+ end
30
+
31
+ def ratio(array_field = [])
32
+ open_entries = array_field.select {|r| r['etat'] == 'O'}
33
+ "#{open_entries.length}/#{array_field.length}"
34
+ end
35
35
  end
@@ -1,27 +1,27 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'skiplan_client/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "skiplan_client"
8
- spec.version = SkiplanClient::VERSION
9
- spec.authors = ["SimonRonzani", "jeanbaptistevilain"]
10
- spec.email = ["ronzani.simon@gmail.com"]
11
- spec.description = "SkiPlan API client gem"
12
- spec.summary = "A simple Ruby wrapper for the SkiPlan XML api"
13
- spec.homepage = "https://github.com/jeanbaptistevilain/skiplan_client"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "test-unit"
24
- spec.add_development_dependency "shoulda-context"
25
- spec.add_runtime_dependency "rails"
26
- spec.add_runtime_dependency "nokogiri"
27
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'skiplan_client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "skiplan_client"
8
+ spec.version = SkiplanClient::VERSION
9
+ spec.authors = ["SimonRonzani", "jeanbaptistevilain"]
10
+ spec.email = ["jeanbaptistevilain@gmail.com"]
11
+ spec.description = "SkiPlan API client gem"
12
+ spec.summary = "A simple Ruby wrapper for the SkiPlan XML api"
13
+ spec.homepage = "https://github.com/jeanbaptistevilain/skiplan_client"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "test-unit"
24
+ spec.add_development_dependency "shoulda-context"
25
+ spec.add_runtime_dependency "rails"
26
+ spec.add_runtime_dependency "nokogiri"
27
+ end
@@ -1,38 +1,38 @@
1
- # encoding : UTF-8
2
- require 'rubygems'
3
- require 'test/unit'
4
- require 'shoulda-context'
5
- require 'skiplan_client/forecast'
6
-
7
- class ForecastTest < Test::Unit::TestCase
8
-
9
- should 'populate forecast with attributes values' do
10
- forecast = Forecast.new({'datemaj' => '03/07/2014 17:01:18',
11
- 'TEMPERATURE' => '+10',
12
- 'TEMPERATURE_APM' => '+14',
13
- 'TEMPERATURE_RESSENTIE' => '+4',
14
- 'VENT' => '4',
15
- 'DIRECTION' => 'S',
16
- 'CIEL_ID' => '101',
17
- 'CIEL_ID_APM' => '101',
18
- 'VALRISQUE' => '3',
19
- 'CUMUL' => '100',
20
- 'NEIGE' => '20',
21
- 'DERNIERE_CHUTE' => '22/04/2014 08:31',
22
- 'VISIBILITE' => '100'})
23
-
24
- assert_equal '03/07/2014 17:01:18', forecast.updated_at
25
- assert_equal '101', forecast.weather_am
26
- assert_equal '101', forecast.weather_pm
27
- assert_equal '+10', forecast.temp_am
28
- assert_equal '+14', forecast.temp_pm
29
- assert_equal '+4', forecast.temp_felt
30
- assert_equal '4', forecast.wind_speed
31
- assert_equal 'S', forecast.wind_dir
32
- assert_equal '3', forecast.avalanche
33
- assert_equal '100', forecast.snow_height
34
- assert_equal '22/04/2014 08:31', forecast.last_fall
35
- assert_equal '20', forecast.fresh_snow
36
- assert_equal '100', forecast.visibility
37
- end
1
+ # encoding : UTF-8
2
+ require 'rubygems'
3
+ require 'test/unit'
4
+ require 'shoulda-context'
5
+ require 'skiplan_client/forecast'
6
+
7
+ class ForecastTest < Test::Unit::TestCase
8
+
9
+ should 'populate forecast with attributes values' do
10
+ forecast = Forecast.new({'datemaj' => '03/07/2014 17:01:18',
11
+ 'TEMPERATURE' => '+10',
12
+ 'TEMPERATURE_APM' => '+14',
13
+ 'TEMPERATURE_RESSENTIE' => '+4',
14
+ 'VENT' => '4',
15
+ 'DIRECTION' => 'S',
16
+ 'CIEL_ID' => '101',
17
+ 'CIEL_ID_APM' => '101',
18
+ 'VALRISQUE' => '3',
19
+ 'CUMUL' => '100',
20
+ 'NEIGE' => '20',
21
+ 'DERNIERE_CHUTE' => '22/04/2014 08:31',
22
+ 'VISIBILITE' => '100'})
23
+
24
+ assert_equal '03/07/2014 17:01:18', forecast.updated_at
25
+ assert_equal '101', forecast.weather_am
26
+ assert_equal '101', forecast.weather_pm
27
+ assert_equal '+10', forecast.temp_am
28
+ assert_equal '+14', forecast.temp_pm
29
+ assert_equal '+4', forecast.temp_felt
30
+ assert_equal '4', forecast.wind_speed
31
+ assert_equal 'S', forecast.wind_dir
32
+ assert_equal '3', forecast.avalanche
33
+ assert_equal '100', forecast.snow_height
34
+ assert_equal '22/04/2014 08:31', forecast.last_fall
35
+ assert_equal '20', forecast.fresh_snow
36
+ assert_equal '100', forecast.visibility
37
+ end
38
38
  end
@@ -1,99 +1,99 @@
1
- # encoding : UTF-8
2
- require 'rubygems'
3
- require 'test/unit'
4
- require 'shoulda-context'
5
- require 'skiplan_client/metrics'
6
-
7
- class MetricsTest < Test::Unit::TestCase
8
-
9
- setup do
10
- attributes = {'ETAT_ROUTE' => {'lib' => "Routes dégagées, circulation normale"},
11
- 'ETAT_CHAUSSEE' => {'val' => '0', 'lib' => "Dégagées et sèches"},
12
- 'SKI_NUIT' => {'etat' => '1'},
13
- 'KM_SKATING' => {'ouvert' => '10'},
14
- 'SKI_ALPIN'=>{'total'=>'44', 'total_periode'=>'44', 'total_periode_hpf'=>'44', 'ouvertes_previsions'=>'0', 'ouvertes'=>'10', 'previsions'=>'0', 'fermees'=>'44', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0'},
15
- 'SKI_ALPIN_VERTES'=>{'total'=>'12', 'total_periode'=>'12', 'total_periode_hpf'=>'12', 'ouvertes_previsions'=>'0', 'ouvertes'=>'2', 'previsions'=>'0', 'fermees'=>'12', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0'},
16
- 'SKI_ALPIN_BLEUES'=>{'total'=>'15', 'total_periode'=>'15', 'total_periode_hpf'=>'15', 'ouvertes_previsions'=>'0', 'ouvertes'=>'3', 'previsions'=>'0', 'fermees'=>'15', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0'},
17
- 'SKI_ALPIN_ROUGES'=>{'total'=>'14', 'total_periode'=>'14', 'total_periode_hpf'=>'14', 'ouvertes_previsions'=>'0', 'ouvertes'=>'4', 'previsions'=>'0', 'fermees'=>'14', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0'},
18
- 'SKI_ALPIN_NOIRES'=>{'total'=>'3', 'total_periode'=>'3', 'total_periode_hpf'=>'3', 'ouvertes_previsions'=>'0', 'ouvertes'=>'1', 'previsions'=>'0', 'fermees'=>'3', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0'},
19
- 'SKI_NORDIQUE'=>{'total'=>'17', 'total_periode'=>'17', 'total_periode_hpf'=>'17', 'ouvertes_previsions'=>'0', 'ouvertes'=>'6', 'previsions'=>'0', 'fermees'=>'17', 'lng_total'=>'67.9', 'lng_ouverts'=>'0.0'},
20
- 'SKI_NORDIQUE_VERTES'=>{'total'=>'7', 'total_periode'=>'7', 'total_periode_hpf'=>'7', 'ouvertes_previsions'=>'0', 'ouvertes'=>'2', 'previsions'=>'0', 'fermees'=>'7', 'lng_total'=>'5.9', 'lng_ouverts'=>'0.0'},
21
- 'SKI_NORDIQUE_BLEUES'=>{'total'=>'4', 'total_periode'=>'4', 'total_periode_hpf'=>'4', 'ouvertes_previsions'=>'0', 'ouvertes'=>'3', 'previsions'=>'0', 'fermees'=>'4', 'lng_total'=>'20.9', 'lng_ouverts'=>'0.0'},
22
- 'SKI_NORDIQUE_ROUGES'=>{'total'=>'3', 'total_periode'=>'3', 'total_periode_hpf'=>'3', 'ouvertes_previsions'=>'0', 'ouvertes'=>'1', 'previsions'=>'0', 'fermees'=>'3', 'lng_total'=>'18.5', 'lng_ouverts'=>'0.0'},
23
- 'SKI_NORDIQUE_NOIRES'=>{'total'=>'3', 'total_periode'=>'3', 'total_periode_hpf'=>'3', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'3', 'lng_total'=>'22.6', 'lng_ouverts'=>'0.0'},
24
- 'REMONTEES' => {'total'=>'32', 'total_periode'=>'32', 'total_periode_hpf'=>'32', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'32'},
25
- 'PIETONS'=>{'total'=>'12', 'total_periode'=>'12', 'total_periode_hpf'=>'12', 'ouvertes_previsions'=>'9', 'ouvertes'=>'9', 'previsions'=>'0', 'fermees'=>'3', 'lng_total'=>'47.5', 'lng_ouverts'=>'35.0'},
26
- 'RAQUETTES'=>{'total'=>'14', 'total_periode'=>'14', 'total_periode_hpf'=>'14', 'ouvertes_previsions'=>'0', 'ouvertes'=>'1', 'previsions'=>'0', 'fermees'=>'14', 'lng_total'=>'61.0', 'lng_ouverts'=>'0.0'},
27
- 'LUGE'=>{'total'=>'4', 'total_periode'=>'4', 'total_periode_hpf'=>'4', 'ouvertes_previsions'=>'0', 'ouvertes'=>'2', 'previsions'=>'0', 'fermees'=>'4', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0'},
28
- 'SNOWPARK'=>{'total'=>'8', 'total_periode'=>'8', 'total_periode_hpf'=>'8', 'ouvertes_previsions'=>'0', 'ouvertes'=>'3', 'previsions'=>'0', 'fermees'=>'8', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0',
29
- 'BIGAIR'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
30
- 'BOX'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
31
- 'CHILLZONE'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
32
- 'HALFPIPE'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
33
- 'HIP'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
34
- 'AIRBAG'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
35
- 'KICKER'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
36
- 'QUATERPIPE'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
37
- 'RAIL'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
38
- 'STEPUP'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
39
- 'WATERSLIDE'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
40
- 'WHOOPS'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
41
- 'BOARDERCROSS'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
42
- 'VIDEOZONE'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
43
- 'SPEEDZONE'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'}}}
44
- @metrics = Metrics.new(attributes)
45
- end
46
-
47
- should 'return metrics for alpine slopes' do
48
- assert_equal '10/44', @metrics.alpine[:total]
49
- assert_equal '2/12', @metrics.alpine[:green]
50
- assert_equal '3/15', @metrics.alpine[:blue]
51
- assert_equal '4/14', @metrics.alpine[:red]
52
- assert_equal '1/3', @metrics.alpine[:black]
53
- end
54
-
55
- should 'return metrics for nordic slopes' do
56
- assert_equal '6/17', @metrics.nordic[:total]
57
- assert_equal '2/7', @metrics.nordic[:green]
58
- assert_equal '3/4', @metrics.nordic[:blue]
59
- assert_equal '1/3', @metrics.nordic[:red]
60
- assert_equal '0/3', @metrics.nordic[:black]
61
- assert_equal '0/67.9km', @metrics.nordic[:km]
62
- end
63
-
64
- should 'return metrics for pedestrians' do
65
- assert_equal '35/47.5km', @metrics.pedestrian[:total]
66
- end
67
-
68
- should 'return metrics for snowshoes' do
69
- assert_equal '0/61km', @metrics.snowshoes[:total]
70
- end
71
-
72
- should 'return metrics for sledges' do
73
- assert_equal '2/4', @metrics.sledge[:total]
74
- end
75
-
76
- should 'return metrics for snowparks' do
77
- assert_equal '3/8', @metrics.snowpark[:total]
78
- end
79
-
80
- should 'return metrics for skilifts' do
81
- assert_equal '0/32', @metrics.skilifts[:total]
82
- end
83
-
84
- should 'return night ski availability for current day' do
85
- assert_equal true, @metrics.night_ski
86
- end
87
-
88
- should 'return skating km available' do
89
- assert_equal '10', @metrics.skating
90
- end
91
-
92
- should 'return a detailed status for the driving conditions' do
93
- assert_equal 'Routes dégagées, circulation normale', @metrics.driving_conditions
94
- end
95
-
96
- should 'return a detailed status for the roads' do
97
- assert_equal 'Dégagées et sèches', @metrics.roads
98
- end
1
+ # encoding : UTF-8
2
+ require 'rubygems'
3
+ require 'test/unit'
4
+ require 'shoulda-context'
5
+ require 'skiplan_client/metrics'
6
+
7
+ class MetricsTest < Test::Unit::TestCase
8
+
9
+ setup do
10
+ attributes = {'ETAT_ROUTE' => {'lib' => "Routes dégagées, circulation normale"},
11
+ 'ETAT_CHAUSSEE' => {'val' => '0', 'lib' => "Dégagées et sèches"},
12
+ 'SKI_NUIT' => {'etat' => '1'},
13
+ 'KM_SKATING' => {'ouvert' => '10'},
14
+ 'SKI_ALPIN'=>{'total'=>'44', 'total_periode'=>'44', 'total_periode_hpf'=>'44', 'ouvertes_previsions'=>'0', 'ouvertes'=>'10', 'previsions'=>'0', 'fermees'=>'44', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0'},
15
+ 'SKI_ALPIN_VERTES'=>{'total'=>'12', 'total_periode'=>'12', 'total_periode_hpf'=>'12', 'ouvertes_previsions'=>'0', 'ouvertes'=>'2', 'previsions'=>'0', 'fermees'=>'12', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0'},
16
+ 'SKI_ALPIN_BLEUES'=>{'total'=>'15', 'total_periode'=>'15', 'total_periode_hpf'=>'15', 'ouvertes_previsions'=>'0', 'ouvertes'=>'3', 'previsions'=>'0', 'fermees'=>'15', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0'},
17
+ 'SKI_ALPIN_ROUGES'=>{'total'=>'14', 'total_periode'=>'14', 'total_periode_hpf'=>'14', 'ouvertes_previsions'=>'0', 'ouvertes'=>'4', 'previsions'=>'0', 'fermees'=>'14', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0'},
18
+ 'SKI_ALPIN_NOIRES'=>{'total'=>'3', 'total_periode'=>'3', 'total_periode_hpf'=>'3', 'ouvertes_previsions'=>'0', 'ouvertes'=>'1', 'previsions'=>'0', 'fermees'=>'3', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0'},
19
+ 'SKI_NORDIQUE'=>{'total'=>'17', 'total_periode'=>'17', 'total_periode_hpf'=>'17', 'ouvertes_previsions'=>'0', 'ouvertes'=>'6', 'previsions'=>'0', 'fermees'=>'17', 'lng_total'=>'67.9', 'lng_ouverts'=>'0.0'},
20
+ 'SKI_NORDIQUE_VERTES'=>{'total'=>'7', 'total_periode'=>'7', 'total_periode_hpf'=>'7', 'ouvertes_previsions'=>'0', 'ouvertes'=>'2', 'previsions'=>'0', 'fermees'=>'7', 'lng_total'=>'5.9', 'lng_ouverts'=>'0.0'},
21
+ 'SKI_NORDIQUE_BLEUES'=>{'total'=>'4', 'total_periode'=>'4', 'total_periode_hpf'=>'4', 'ouvertes_previsions'=>'0', 'ouvertes'=>'3', 'previsions'=>'0', 'fermees'=>'4', 'lng_total'=>'20.9', 'lng_ouverts'=>'0.0'},
22
+ 'SKI_NORDIQUE_ROUGES'=>{'total'=>'3', 'total_periode'=>'3', 'total_periode_hpf'=>'3', 'ouvertes_previsions'=>'0', 'ouvertes'=>'1', 'previsions'=>'0', 'fermees'=>'3', 'lng_total'=>'18.5', 'lng_ouverts'=>'0.0'},
23
+ 'SKI_NORDIQUE_NOIRES'=>{'total'=>'3', 'total_periode'=>'3', 'total_periode_hpf'=>'3', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'3', 'lng_total'=>'22.6', 'lng_ouverts'=>'0.0'},
24
+ 'REMONTEES' => {'total'=>'32', 'total_periode'=>'32', 'total_periode_hpf'=>'32', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'32'},
25
+ 'PIETONS'=>{'total'=>'12', 'total_periode'=>'12', 'total_periode_hpf'=>'12', 'ouvertes_previsions'=>'9', 'ouvertes'=>'9', 'previsions'=>'0', 'fermees'=>'3', 'lng_total'=>'47.5', 'lng_ouverts'=>'35.0'},
26
+ 'RAQUETTES'=>{'total'=>'14', 'total_periode'=>'14', 'total_periode_hpf'=>'14', 'ouvertes_previsions'=>'0', 'ouvertes'=>'1', 'previsions'=>'0', 'fermees'=>'14', 'lng_total'=>'61.0', 'lng_ouverts'=>'0.0'},
27
+ 'LUGE'=>{'total'=>'4', 'total_periode'=>'4', 'total_periode_hpf'=>'4', 'ouvertes_previsions'=>'0', 'ouvertes'=>'2', 'previsions'=>'0', 'fermees'=>'4', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0'},
28
+ 'SNOWPARK'=>{'total'=>'8', 'total_periode'=>'8', 'total_periode_hpf'=>'8', 'ouvertes_previsions'=>'0', 'ouvertes'=>'3', 'previsions'=>'0', 'fermees'=>'8', 'lng_total'=>'0.0', 'lng_ouverts'=>'0.0',
29
+ 'BIGAIR'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
30
+ 'BOX'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
31
+ 'CHILLZONE'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
32
+ 'HALFPIPE'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
33
+ 'HIP'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
34
+ 'AIRBAG'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
35
+ 'KICKER'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
36
+ 'QUATERPIPE'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
37
+ 'RAIL'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
38
+ 'STEPUP'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
39
+ 'WATERSLIDE'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
40
+ 'WHOOPS'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
41
+ 'BOARDERCROSS'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
42
+ 'VIDEOZONE'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'},
43
+ 'SPEEDZONE'=>{'total'=>'0', 'total_periode'=>'0', 'total_periode_hpf'=>'0', 'ouvertes_previsions'=>'0', 'ouvertes'=>'0', 'previsions'=>'0', 'fermees'=>'0'}}}
44
+ @metrics = Metrics.new(attributes)
45
+ end
46
+
47
+ should 'return metrics for alpine slopes' do
48
+ assert_equal '10/44', @metrics.alpine[:total]
49
+ assert_equal '2/12', @metrics.alpine[:green]
50
+ assert_equal '3/15', @metrics.alpine[:blue]
51
+ assert_equal '4/14', @metrics.alpine[:red]
52
+ assert_equal '1/3', @metrics.alpine[:black]
53
+ end
54
+
55
+ should 'return metrics for nordic slopes' do
56
+ assert_equal '6/17', @metrics.nordic[:total]
57
+ assert_equal '2/7', @metrics.nordic[:green]
58
+ assert_equal '3/4', @metrics.nordic[:blue]
59
+ assert_equal '1/3', @metrics.nordic[:red]
60
+ assert_equal '0/3', @metrics.nordic[:black]
61
+ assert_equal '0/67.9km', @metrics.nordic[:km]
62
+ end
63
+
64
+ should 'return metrics for pedestrians' do
65
+ assert_equal '35/47.5km', @metrics.pedestrian[:total]
66
+ end
67
+
68
+ should 'return metrics for snowshoes' do
69
+ assert_equal '0/61km', @metrics.snowshoes[:total]
70
+ end
71
+
72
+ should 'return metrics for sledges' do
73
+ assert_equal '2/4', @metrics.sledge[:total]
74
+ end
75
+
76
+ should 'return metrics for snowparks' do
77
+ assert_equal '3/8', @metrics.snowpark[:total]
78
+ end
79
+
80
+ should 'return metrics for skilifts' do
81
+ assert_equal '0/32', @metrics.skilifts[:total]
82
+ end
83
+
84
+ should 'return night ski availability for current day' do
85
+ assert_equal true, @metrics.night_ski
86
+ end
87
+
88
+ should 'return skating km available' do
89
+ assert_equal '10', @metrics.skating
90
+ end
91
+
92
+ should 'return a detailed status for the driving conditions' do
93
+ assert_equal 'Routes dégagées, circulation normale', @metrics.driving_conditions
94
+ end
95
+
96
+ should 'return a detailed status for the roads' do
97
+ assert_equal 'Dégagées et sèches', @metrics.roads
98
+ end
99
99
  end
@@ -1,101 +1,103 @@
1
- # encoding : UTF-8
2
- require 'test/unit'
3
- require 'shoulda-context'
4
- require 'skiplan_client'
5
- require 'skiplan_client/skiplan'
6
-
7
- class SkiplanClientTest < Test::Unit::TestCase
8
-
9
- setup do
10
- if Dir.pwd.include?('test')
11
- SkiplanClient.configure('../../data/lumi_response.xml')
12
- else
13
- SkiplanClient.configure('data/lumi_response.xml')
14
- end
15
- end
16
-
17
- should 'retrieve weather data' do
18
- weather = SkiplanClient.weather('CHINAILLON')
19
-
20
- today_forecast = weather.forecasts['CHINAILLON']
21
- assert_equal '101' , today_forecast.weather_am
22
- assert_equal '101' , today_forecast.weather_pm
23
- assert_equal '+12' , today_forecast.temp_am
24
- assert_equal '+20' , today_forecast.temp_pm
25
- assert_equal '+4' , today_forecast.temp_felt
26
- assert_equal '4' , today_forecast.wind_speed
27
- assert_equal 'SE' , today_forecast.wind_dir
28
-
29
- tomorrow_forecast = weather.forecasts['J+1']
30
- assert_equal '104' , tomorrow_forecast.weather_am
31
- assert_equal '106' , tomorrow_forecast.weather_pm
32
- assert_equal '+17' , tomorrow_forecast.temp_am
33
- assert_equal '+21' , tomorrow_forecast.temp_pm
34
- assert_equal '7' , tomorrow_forecast.wind_speed
35
- assert_equal 'SO' , tomorrow_forecast.wind_dir
36
-
37
- j2_forecast = weather.forecasts['J+2']
38
- assert_equal '106' , j2_forecast.weather_am
39
- assert_equal '104' , j2_forecast.weather_pm
40
- assert_equal '+12' , j2_forecast.temp_am
41
- assert_equal '+18' , j2_forecast.temp_pm
42
- assert_equal '7' , j2_forecast.wind_speed
43
- assert_equal 'O' , j2_forecast.wind_dir
44
-
45
- j3_forecast = weather.forecasts['J+3']
46
- assert_equal '101' , j3_forecast.weather_am
47
- assert_equal '103' , j3_forecast.weather_pm
48
- assert_equal '+16' , j3_forecast.temp_am
49
- assert_equal '+20' , j3_forecast.temp_pm
50
- assert_equal '7' , j3_forecast.wind_speed
51
- assert_equal 'O' , j3_forecast.wind_dir
52
- end
53
-
54
- should 'retrieve metrics data' do
55
- metrics = SkiplanClient.ski_area.metrics['GRAND BORNAND']
56
-
57
- assert_equal '0/44', metrics.alpine[:total]
58
- assert_equal '0/17', metrics.nordic[:total]
59
- assert_equal '35/47.5km', metrics.pedestrian[:total]
60
- assert_equal '0/61km', metrics.snowshoes[:total]
61
- assert_equal '0/4', metrics.sledge[:total]
62
- assert_equal '0/8', metrics.snowpark[:total]
63
- end
64
-
65
- should 'retrieve zones data' do
66
- zones = SkiplanClient.ski_area.zones
67
-
68
- assert_equal 10, zones.length
69
- assert_equal 'ALPIN CHINAILLON', zones.keys[0]
70
-
71
- ac_zone = zones['ALPIN CHINAILLON']
72
- assert_equal 10, ac_zone.skilifts.count
73
- assert_equal 16, ac_zone.slopes.count
74
- assert_equal 1, ac_zone.connections.count
75
-
76
- single_entry_zone = zones['PIETONS']
77
- assert_equal 1, single_entry_zone.slopes.count
78
- end
79
-
80
- should 'change config url' do
81
- config = SkiplanClient.configure('my_new_url')
82
- assert_equal 'my_new_url', config
83
- end
84
-
85
- should 'retrieve forecasts text messages' do
86
- texts = SkiplanClient.texts
87
-
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']
100
- end
1
+ # encoding : UTF-8
2
+ require 'test/unit'
3
+ require 'shoulda-context'
4
+ require 'skiplan_client'
5
+ require 'skiplan_client/skiplan'
6
+
7
+ class SkiplanClientTest < Test::Unit::TestCase
8
+
9
+ setup do
10
+ if Dir.pwd.include?('test')
11
+ SkiplanClient.configure('../../data/lumi_response.xml')
12
+ else
13
+ SkiplanClient.configure('data/lumi_response.xml')
14
+ end
15
+ end
16
+
17
+ should 'retrieve weather data' do
18
+ weather = SkiplanClient.weather('CHINAILLON')
19
+
20
+ today_forecast = weather.forecasts['CHINAILLON']
21
+ assert_equal '101' , today_forecast.weather_am
22
+ assert_equal '101' , today_forecast.weather_pm
23
+ assert_equal '+12' , today_forecast.temp_am
24
+ assert_equal '+20' , today_forecast.temp_pm
25
+ assert_equal '+4' , today_forecast.temp_felt
26
+ assert_equal '4' , today_forecast.wind_speed
27
+ assert_equal 'SE' , today_forecast.wind_dir
28
+
29
+ tomorrow_forecast = weather.forecasts['J+1']
30
+ assert_equal '104' , tomorrow_forecast.weather_am
31
+ assert_equal '106' , tomorrow_forecast.weather_pm
32
+ assert_equal '+17' , tomorrow_forecast.temp_am
33
+ assert_equal '+21' , tomorrow_forecast.temp_pm
34
+ assert_equal '7' , tomorrow_forecast.wind_speed
35
+ assert_equal 'SO' , tomorrow_forecast.wind_dir
36
+
37
+ j2_forecast = weather.forecasts['J+2']
38
+ assert_equal '106' , j2_forecast.weather_am
39
+ assert_equal '104' , j2_forecast.weather_pm
40
+ assert_equal '+12' , j2_forecast.temp_am
41
+ assert_equal '+18' , j2_forecast.temp_pm
42
+ assert_equal '7' , j2_forecast.wind_speed
43
+ assert_equal 'O' , j2_forecast.wind_dir
44
+
45
+ j3_forecast = weather.forecasts['J+3']
46
+ assert_equal '101' , j3_forecast.weather_am
47
+ assert_equal '103' , j3_forecast.weather_pm
48
+ assert_equal '+16' , j3_forecast.temp_am
49
+ assert_equal '+20' , j3_forecast.temp_pm
50
+ assert_equal '7' , j3_forecast.wind_speed
51
+ assert_equal 'O' , j3_forecast.wind_dir
52
+
53
+ assert_equal '03/07/2014 17:01', weather.updated_at
54
+ end
55
+
56
+ should 'retrieve metrics data' do
57
+ metrics = SkiplanClient.ski_area.metrics['GRAND BORNAND']
58
+
59
+ assert_equal '0/44', metrics.alpine[:total]
60
+ assert_equal '0/17', metrics.nordic[:total]
61
+ assert_equal '35/47.5km', metrics.pedestrian[:total]
62
+ assert_equal '0/61km', metrics.snowshoes[:total]
63
+ assert_equal '0/4', metrics.sledge[:total]
64
+ assert_equal '0/8', metrics.snowpark[:total]
65
+ end
66
+
67
+ should 'retrieve zones data' do
68
+ zones = SkiplanClient.ski_area.zones
69
+
70
+ assert_equal 10, zones.length
71
+ assert_equal 'ALPIN CHINAILLON', zones.keys[0]
72
+
73
+ ac_zone = zones['ALPIN CHINAILLON']
74
+ assert_equal 10, ac_zone.skilifts.count
75
+ assert_equal 16, ac_zone.slopes.count
76
+ assert_equal 1, ac_zone.connections.count
77
+
78
+ single_entry_zone = zones['PIETONS']
79
+ assert_equal 1, single_entry_zone.slopes.count
80
+ end
81
+
82
+ should 'change config url' do
83
+ config = SkiplanClient.configure('my_new_url')
84
+ assert_equal 'my_new_url', config
85
+ end
86
+
87
+ should 'retrieve forecasts text messages' do
88
+ texts = SkiplanClient.texts
89
+
90
+ assert_equal 'Pluie. Vent faible variable.', texts[:fr]['today_forecast']
91
+ assert_equal 'Beau temps sec et ensoleillé. Vent faible variable.', texts[:fr]['tomorrow_forecast']
92
+ assert_equal 'Col de la Colombière ouvert.', texts[:fr]['forecasts_comment']
93
+ assert_equal 'LE DOMAINE SKIABLE EST FERME POUR LA SAISON 2013/2014.', texts[:fr]['ski_area']
94
+ assert_equal 'Routes degagees, circulation normale', texts[:fr]['conditions']
95
+ assert_equal 'Non defini', texts[:fr]['roads']
96
+ assert_equal 'Rain and snow. Variable winds, light at most places.', texts[:en]['today_forecast']
97
+ assert_equal 'Dry and mostly sunny. Variable winds, light at most places.', texts[:en]['tomorrow_forecast']
98
+ assert_equal 'Col de la Colombière open.', texts[:en]['forecasts_comment']
99
+ assert_equal 'SKI AREA IS CLOSED FOR THE SEASON 2013/2014.', texts[:en]['ski_area']
100
+ assert_equal 'Routes degagees, circulation normale', texts[:en]['conditions']
101
+ assert_equal 'Non defini', texts[:en]['roads']
102
+ end
101
103
  end