sitra_client 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -24,8 +24,21 @@ class TouristicObject
|
|
24
24
|
'TERRITOIRE' => '@informationsTerritoire'
|
25
25
|
}
|
26
26
|
|
27
|
+
DEFAULT_LIBELLE = :libelleFr
|
28
|
+
|
29
|
+
PHONE = 201
|
30
|
+
EMAIL = 204
|
31
|
+
WEBSITE = 205
|
32
|
+
|
27
33
|
def initialize(hash)
|
28
34
|
self.attributes = hash
|
35
|
+
@libelle = DEFAULT_LIBELLE
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_locale(locale)
|
39
|
+
unless locale.nil?
|
40
|
+
@libelle = "libelle#{locale.capitalize}".to_sym
|
41
|
+
end
|
29
42
|
end
|
30
43
|
|
31
44
|
def id
|
@@ -37,24 +50,28 @@ class TouristicObject
|
|
37
50
|
end
|
38
51
|
|
39
52
|
def title
|
40
|
-
@nom[
|
53
|
+
@nom[@libelle] || @nom[DEFAULT_LIBELLE]
|
41
54
|
end
|
42
55
|
|
43
56
|
def description
|
44
|
-
|
57
|
+
if @presentation[:descriptifCourt]
|
58
|
+
@presentation[:descriptifCourt][@libelle] || @presentation[:descriptifCourt][DEFAULT_LIBELLE]
|
59
|
+
end
|
45
60
|
end
|
46
61
|
|
47
62
|
def details
|
48
|
-
|
63
|
+
if @presentation[:descriptifDetaille]
|
64
|
+
@presentation[:descriptifDetaille][@libelle] || @presentation[:descriptifDetaille][DEFAULT_LIBELLE]
|
65
|
+
end
|
49
66
|
end
|
50
67
|
|
51
|
-
def contact(
|
68
|
+
def contact(types_ids = [])
|
52
69
|
contact_details = {}
|
53
70
|
contact_entries = @informations[:moyensCommunication].nil? ? [] : @informations[:moyensCommunication]
|
54
71
|
contact_entries.each do |c|
|
55
|
-
|
56
|
-
|
57
|
-
contact_details[
|
72
|
+
if types_ids.include?(c[:type][:id])
|
73
|
+
label = c[:type][@libelle]
|
74
|
+
contact_details[label] = c[:coordonnee]
|
58
75
|
end
|
59
76
|
end
|
60
77
|
contact_details
|
@@ -74,7 +91,7 @@ class TouristicObject
|
|
74
91
|
|
75
92
|
def service_provider
|
76
93
|
if @informationsActivite && @informationsActivite[:commerceEtServicePrestataire]
|
77
|
-
@informationsActivite[:commerceEtServicePrestataire][:nom][
|
94
|
+
@informationsActivite[:commerceEtServicePrestataire][:nom][@libelle]
|
78
95
|
elsif @informationsFeteEtManifestation
|
79
96
|
@informationsFeteEtManifestation[:nomLieu]
|
80
97
|
else
|
@@ -106,7 +123,7 @@ class TouristicObject
|
|
106
123
|
|
107
124
|
def horaires
|
108
125
|
if @ouverture && @ouverture[:periodeEnClair]
|
109
|
-
@ouverture[:periodeEnClair][
|
126
|
+
@ouverture[:periodeEnClair][@libelle]
|
110
127
|
end
|
111
128
|
end
|
112
129
|
|
@@ -115,7 +132,7 @@ class TouristicObject
|
|
115
132
|
if @descriptionTarif[:gratuit]
|
116
133
|
return 'gratuit'
|
117
134
|
elsif @descriptionTarif[:tarifsEnClair]
|
118
|
-
@descriptionTarif[:tarifsEnClair][
|
135
|
+
@descriptionTarif[:tarifsEnClair][@libelle]
|
119
136
|
end
|
120
137
|
end
|
121
138
|
end
|
@@ -123,21 +140,21 @@ class TouristicObject
|
|
123
140
|
def population
|
124
141
|
eligible_populations = []
|
125
142
|
if @prestations && @prestations[:typesClientele]
|
126
|
-
eligible_populations += @prestations[:typesClientele].collect {|t| t[
|
143
|
+
eligible_populations += @prestations[:typesClientele].collect {|t| t[@libelle]}
|
127
144
|
end
|
128
145
|
eligible_populations.uniq
|
129
146
|
end
|
130
147
|
|
131
148
|
def adapted_tourism
|
132
|
-
@prestations && @prestations[:tourismesAdaptes] && @prestations[:tourismesAdaptes].collect {|t| t[
|
149
|
+
@prestations && @prestations[:tourismesAdaptes] && @prestations[:tourismesAdaptes].collect {|t| t[@libelle]}
|
133
150
|
end
|
134
151
|
|
135
152
|
def environments
|
136
|
-
@localisation && @localisation[:environnements] && @localisation[:environnements].collect {|e| e[
|
153
|
+
@localisation && @localisation[:environnements] && @localisation[:environnements].collect {|e| e[@libelle]}
|
137
154
|
end
|
138
155
|
|
139
156
|
def additional_criteria
|
140
|
-
@presentation && @presentation[:typologiesPromoSitra] && @presentation[:typologiesPromoSitra].collect {|t| t[
|
157
|
+
@presentation && @presentation[:typologiesPromoSitra] && @presentation[:typologiesPromoSitra].collect {|t| t[@libelle]}
|
141
158
|
end
|
142
159
|
|
143
160
|
private
|
data/lib/sitra_client/version.rb
CHANGED
@@ -32,15 +32,15 @@ class TouristicObjectTest < Test::Unit::TestCase
|
|
32
32
|
hash_result = {
|
33
33
|
:informations => {
|
34
34
|
:moyensCommunication => [
|
35
|
-
{:type => {:libelleFr => "Téléphone"}, :coordonnee => "0123456789"},
|
36
|
-
{:type => {:libelleFr => "Mél"}, :coordonnee => "my@email.fr"},
|
37
|
-
{:type => {:libelleFr => "Fax"}, :coordonnee => "9876543201"}
|
35
|
+
{:type => {:libelleFr => "Téléphone", :id => 201}, :coordonnee => "0123456789"},
|
36
|
+
{:type => {:libelleFr => "Mél", :id => 204}, :coordonnee => "my@email.fr"},
|
37
|
+
{:type => {:libelleFr => "Fax", :id => 202}, :coordonnee => "9876543201"}
|
38
38
|
]
|
39
39
|
}
|
40
40
|
}
|
41
41
|
touristic_object = TouristicObject.new(hash_result)
|
42
42
|
|
43
|
-
assert_equal({'Téléphone' => '0123456789', 'Mél' => 'my@email.fr'}, touristic_object.contact([
|
43
|
+
assert_equal({'Téléphone' => '0123456789', 'Mél' => 'my@email.fr'}, touristic_object.contact([201, 204]))
|
44
44
|
end
|
45
45
|
|
46
46
|
should 'populate image details' do
|
@@ -153,4 +153,18 @@ class TouristicObjectTest < Test::Unit::TestCase
|
|
153
153
|
assert_equal "my_service", touristic_object.information[:commerceEtServicePrestataire][:nom][:libelleFr]
|
154
154
|
end
|
155
155
|
|
156
|
+
should 'default to fr locale' do
|
157
|
+
hash_result = {:presentation => {:descriptifCourt => {:libelleFr => "my_description_fr", :libelleEn => "my_description_en"}}}
|
158
|
+
touristic_object = TouristicObject.new(hash_result)
|
159
|
+
|
160
|
+
assert_equal 'my_description_fr', touristic_object.description
|
161
|
+
end
|
162
|
+
|
163
|
+
should 'use provided locale when available' do
|
164
|
+
hash_result = {:presentation => {:descriptifCourt => {:libelleFr => "my_description_fr", :libelleEn => "my_description_en"}}}
|
165
|
+
touristic_object = TouristicObject.new(hash_result)
|
166
|
+
touristic_object.set_locale('en')
|
167
|
+
|
168
|
+
assert_equal 'my_description_en', touristic_object.description
|
169
|
+
end
|
156
170
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitra_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.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-07-
|
12
|
+
date: 2014-07-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|