apidae 0.3.6 → 0.4.0
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 +4 -4
- data/app/models/apidae/object.rb +47 -32
- data/db/migrate/20180417164604_add_location_data_to_apidae_objects.rb +5 -0
- data/db/migrate/20180417165744_remove_address_from_apidae_objects.rb +5 -0
- data/db/migrate/20180417171344_remove_lat_lng_from_apidae_objects.rb +6 -0
- data/db/migrate/20180418141248_add_description_data_to_apidae_objects.rb +5 -0
- data/db/migrate/20180418141305_remove_desc_columns_from_apidae_objects.rb +6 -0
- data/lib/apidae/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60148050e39da7ee11f5ad3b5763f8974359e97c
|
4
|
+
data.tar.gz: 676823e12e5f3672229f13c2b5f6fff6ec83ddf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd2224c5903a85ea614d39f360c27d02fb1d71fd40de52bd62101f84feb8d62c898736da212abf136287b7290685edf025fd4c2e358670953107b1376a15e5ad
|
7
|
+
data.tar.gz: 503d4a38cbcf23e52a101ead6eedcbb901566143e75bb04cf1e9f3b93c999871b686bfc924bcce5266e67e7f84116858a20dbd939ca8ac68a5a8e983b97acc98
|
data/app/models/apidae/object.rb
CHANGED
@@ -6,13 +6,15 @@ module Apidae
|
|
6
6
|
has_many :apidae_selection_objects, class_name: 'Apidae::SelectionObject', foreign_key: :apidae_object_id
|
7
7
|
has_many :selections, class_name: 'Apidae::Selection', source: :apidae_selection, through: :apidae_selection_objects
|
8
8
|
|
9
|
+
store_accessor :description_data, :short_desc, :long_desc, :theme_desc
|
9
10
|
store_accessor :pictures_data, :pictures
|
10
11
|
store_accessor :attachments_data, :attachments
|
11
|
-
store_accessor :type_data, :categories, :themes, :capacity, :classification, :labels, :chains, :area, :track
|
12
|
+
store_accessor :type_data, :categories, :themes, :capacity, :classification, :labels, :chains, :area, :track,
|
13
|
+
:products, :audience, :animals, :extra, :duration
|
12
14
|
store_accessor :entity_data, :entity_id, :entity_name
|
13
15
|
store_accessor :contact, :telephone, :email, :website
|
14
|
-
store_accessor :address, :
|
15
|
-
store_accessor :openings_data, :openings_desc, :openings
|
16
|
+
store_accessor :location_data, :address, :place, :latitude, :longitude, :access
|
17
|
+
store_accessor :openings_data, :openings_desc, :openings, :time_periods
|
16
18
|
store_accessor :rates_data, :rates_desc, :rates, :payment_methods
|
17
19
|
store_accessor :service_data, :services, :equipments, :comfort, :activities
|
18
20
|
store_accessor :tags_data, :promo, :internal
|
@@ -67,13 +69,10 @@ module Apidae
|
|
67
69
|
apidae_obj.apidae_type = object_data[:type]
|
68
70
|
apidae_obj.apidae_subtype = node_id(object_data[type_fields[:node]], type_fields[:subtype])
|
69
71
|
apidae_obj.title = node_value(object_data, :nom)
|
70
|
-
apidae_obj.
|
71
|
-
apidae_obj.long_desc = node_value(object_data[:presentation], :descriptifDetaille)
|
72
|
+
apidae_obj.description_data = parse_desc_data(object_data[:presentation])
|
72
73
|
apidae_obj.contact = contact(object_data[:informations])
|
73
|
-
apidae_obj.
|
74
|
+
apidae_obj.location_data = parse_location_data(object_data[:localisation], object_data[type_fields[:node]])
|
74
75
|
apidae_obj.town = town(object_data[:localisation][:adresse])
|
75
|
-
apidae_obj.latitude = latitude(object_data[:localisation])
|
76
|
-
apidae_obj.longitude = longitude(object_data[:localisation])
|
77
76
|
apidae_obj.openings_data = parse_openings(object_data[:ouverture])
|
78
77
|
apidae_obj.rates_data = parse_rates(object_data[:descriptionTarif])
|
79
78
|
apidae_obj.reservation = parse_reservation(object_data[:reservation])
|
@@ -87,6 +86,16 @@ module Apidae
|
|
87
86
|
apidae_obj.save!
|
88
87
|
end
|
89
88
|
|
89
|
+
def self.parse_desc_data(data_hash)
|
90
|
+
unless data_hash.blank?
|
91
|
+
{
|
92
|
+
short_desc: node_value(data_hash, :descriptifCourt),
|
93
|
+
long_desc: node_value(data_hash, :descriptifDetaille),
|
94
|
+
theme_desc: data_hash[:descriptifsThematises].blank? ? [] : Hash[data_hash[:descriptifsThematises].map {|th| [node_id(th, :theme), node_value(th, :description)]}]
|
95
|
+
}
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
90
99
|
def self.pictures_urls(pictures_array)
|
91
100
|
pics_data = []
|
92
101
|
unless pictures_array.blank?
|
@@ -135,37 +144,37 @@ module Apidae
|
|
135
144
|
contact_details
|
136
145
|
end
|
137
146
|
|
138
|
-
def self.
|
139
|
-
computed_address = []
|
140
|
-
unless address_hash.blank?
|
141
|
-
computed_address << address_hash[:adresse1] unless address_hash[:adresse1].blank?
|
142
|
-
computed_address << address_hash[:adresse2] unless address_hash[:adresse2].blank?
|
143
|
-
computed_address << address_hash[:adresse3] unless address_hash[:adresse3].blank?
|
144
|
-
end
|
145
|
-
{address_fields: computed_address, place: type_data_hash[:nomLieu]}
|
146
|
-
end
|
147
|
-
|
148
|
-
def self.town(address_hash = {})
|
149
|
-
(!address_hash.blank? && address_hash[:commune]) ? Town.find_by_apidae_id(address_hash[:commune][:id]) : nil
|
150
|
-
end
|
151
|
-
|
152
|
-
def self.latitude(location_hash)
|
147
|
+
def self.parse_location_data(location_hash, type_data_hash)
|
153
148
|
unless location_hash.blank?
|
149
|
+
address_hash = location_hash[:adresse]
|
150
|
+
computed_address = []
|
151
|
+
unless address_hash.blank?
|
152
|
+
computed_address << address_hash[:adresse1] unless address_hash[:adresse1].blank?
|
153
|
+
computed_address << address_hash[:adresse2] unless address_hash[:adresse2].blank?
|
154
|
+
computed_address << address_hash[:adresse3] unless address_hash[:adresse3].blank?
|
155
|
+
end
|
156
|
+
loc_data = {address: computed_address, place: type_data_hash[:nomLieu]}
|
154
157
|
geoloc_details = location_hash[:geolocalisation]
|
155
|
-
|
158
|
+
if geoloc_details && geoloc_details[:valide] && geoloc_details[:geoJson]
|
159
|
+
loc_data[:latitude] = geoloc_details[:geoJson][:coordinates][1]
|
160
|
+
loc_data[:longitude] = geoloc_details[:geoJson][:coordinates][0]
|
161
|
+
end
|
162
|
+
loc_data[:access] = node_value(geoloc_details, :complement) if geoloc_details
|
163
|
+
loc_data
|
156
164
|
end
|
157
165
|
end
|
158
166
|
|
159
|
-
def self.
|
160
|
-
|
161
|
-
geoloc_details = location_hash[:geolocalisation]
|
162
|
-
(geoloc_details && geoloc_details[:valide] && geoloc_details[:geoJson]) ? geoloc_details[:geoJson][:coordinates][0] : nil
|
163
|
-
end
|
167
|
+
def self.town(address_hash = {})
|
168
|
+
(!address_hash.blank? && address_hash[:commune]) ? Town.find_by_apidae_id(address_hash[:commune][:id]) : nil
|
164
169
|
end
|
165
170
|
|
166
171
|
def self.parse_openings(openings_hash)
|
167
172
|
if openings_hash && openings_hash[:periodeEnClair]
|
168
|
-
{
|
173
|
+
{
|
174
|
+
openings_desc: openings_hash[:periodeEnClair][:libelleFr],
|
175
|
+
openings: openings_hash[:periodesOuvertures],
|
176
|
+
time_periods: lists_ids(openings_hash[:indicationsPeriode])
|
177
|
+
}
|
169
178
|
end
|
170
179
|
end
|
171
180
|
|
@@ -181,8 +190,9 @@ module Apidae
|
|
181
190
|
def self.parse_type_data(apidae_obj, data_hash, prestations_hash)
|
182
191
|
if data_hash
|
183
192
|
apidae_obj.apidae_subtype = lists_ids(data_hash[:typesManifestation]).first if apidae_obj.apidae_type == FEM
|
193
|
+
apidae_obj.apidae_subtype = node_id(data_hash, :rubrique) if apidae_obj.apidae_type == EQU
|
184
194
|
{
|
185
|
-
categories: lists_ids(data_hash[:categories]),
|
195
|
+
categories: lists_ids(data_hash[:categories], data_hash[:typesDetailles]),
|
186
196
|
themes: lists_ids(data_hash[:themes]),
|
187
197
|
capacity: data_hash[:capacite],
|
188
198
|
classification: nodes_ids(data_hash[:classement], data_hash[:classementPrefectoral], data_hash[:classification]) +
|
@@ -190,7 +200,12 @@ module Apidae
|
|
190
200
|
labels: lists_ids(data_hash[:labels], prestations_hash[:labelsTourismeHandicap]),
|
191
201
|
chains: lists_ids(data_hash[:chaines]) + nodes_ids(data_hash[:chaineEtLabel]),
|
192
202
|
area: apidae_obj.apidae_type == DOS ? data_hash.except(:classification) : nil,
|
193
|
-
track: apidae_obj.apidae_type == EQU ? data_hash[:itineraire] : nil
|
203
|
+
track: apidae_obj.apidae_type == EQU ? data_hash[:itineraire] : nil,
|
204
|
+
products: lists_ids(data_hash[:typesProduit]),
|
205
|
+
audience: lists_ids(prestations_hash[:typesClientele]),
|
206
|
+
animals: prestations_hash[:animauxAcceptes] == 'ACCEPTES',
|
207
|
+
extra: node_value(prestations_hash, :complementAccueil),
|
208
|
+
duration: data_hash[:dureeSeance]
|
194
209
|
}
|
195
210
|
end
|
196
211
|
end
|
data/lib/apidae/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apidae
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean-Baptiste Vilain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -137,6 +137,11 @@ files:
|
|
137
137
|
- db/migrate/20180314093512_add_tags_data_to_apidae_objects.rb
|
138
138
|
- db/migrate/20180314132631_add_meta_data_to_apidae_objects.rb
|
139
139
|
- db/migrate/20180319143954_remove_apidae_id_unicity.rb
|
140
|
+
- db/migrate/20180417164604_add_location_data_to_apidae_objects.rb
|
141
|
+
- db/migrate/20180417165744_remove_address_from_apidae_objects.rb
|
142
|
+
- db/migrate/20180417171344_remove_lat_lng_from_apidae_objects.rb
|
143
|
+
- db/migrate/20180418141248_add_description_data_to_apidae_objects.rb
|
144
|
+
- db/migrate/20180418141305_remove_desc_columns_from_apidae_objects.rb
|
140
145
|
- lib/apidae.rb
|
141
146
|
- lib/apidae/engine.rb
|
142
147
|
- lib/apidae/version.rb
|