swissmatch-location 0.1.1.201304 → 0.1.2.201304
Sign up to get free protection for your applications and to get access to all the features.
@@ -272,8 +272,7 @@ module SwissMatch
|
|
272
272
|
raise "Must load cantons first" unless cantons
|
273
273
|
raise "Must load communities first" unless communities
|
274
274
|
|
275
|
-
|
276
|
-
community_mapping = {}
|
275
|
+
community_mapping = Hash.new { |h,k| h[k] = [] }
|
277
276
|
self_delivered = []
|
278
277
|
others = []
|
279
278
|
zip1_file = Dir.enum_for(:glob, "#{@data_directory}/plz_p1_*.txt").last
|
@@ -289,27 +288,26 @@ module SwissMatch
|
|
289
288
|
communities_data[1].map!(&:to_i)
|
290
289
|
communities_data[2].map!(&:to_i)
|
291
290
|
communities_data.transpose.each do |data|
|
292
|
-
|
293
|
-
end
|
294
|
-
|
295
|
-
temporary.each do |key,coms|
|
296
|
-
# compact, because some communities already no longer exist, so by_community_numbers can
|
297
|
-
# contain nils which must be removed
|
298
|
-
community_mapping[key] = Communities.new(communities.by_community_numbers(*coms.uniq.sort).compact)
|
291
|
+
community_mapping[data.last(2)] << data.at(0)
|
299
292
|
end
|
300
293
|
|
301
294
|
temporary = {}
|
302
295
|
load_table(zip1_file, :zip_1).each do |row|
|
303
|
-
onrp
|
304
|
-
code
|
305
|
-
addon
|
306
|
-
delivery_by
|
307
|
-
delivery_by
|
308
|
-
language
|
309
|
-
language_alternative
|
310
|
-
name_short
|
311
|
-
name
|
312
|
-
|
296
|
+
onrp = row.at(0).to_i
|
297
|
+
code = row.at(2).to_i
|
298
|
+
addon = row.at(3).to_i
|
299
|
+
delivery_by = row.at(10).to_i
|
300
|
+
delivery_by = case delivery_by when 0 then nil; when onrp then :self; else delivery_by; end
|
301
|
+
language = LanguageCodes[row.at(7).to_i]
|
302
|
+
language_alternative = LanguageCodes[row.at(8).to_i]
|
303
|
+
name_short = Name.new(row.at(4), language)
|
304
|
+
name = Name.new(row.at(5), language)
|
305
|
+
largest_community_number = row.at(11).to_i
|
306
|
+
# compact, because some communities already no longer exist, so by_community_numbers can
|
307
|
+
# contain nils which must be removed
|
308
|
+
community_numbers = (community_mapping[[code, addon]]|[largest_community_number]).sort
|
309
|
+
communities = Communities.new(communities.by_community_numbers(*community_numbers).compact)
|
310
|
+
data = [
|
313
311
|
onrp, # ordering_number
|
314
312
|
row.at(1).to_i, # type
|
315
313
|
code,
|
@@ -325,8 +323,8 @@ module SwissMatch
|
|
325
323
|
language_alternative,
|
326
324
|
row.at(9) == "1", # sortfile_member
|
327
325
|
delivery_by, # delivery_by
|
328
|
-
communities.by_community_number(
|
329
|
-
|
326
|
+
communities.by_community_number(largest_community_number), # community_number
|
327
|
+
communities,
|
330
328
|
Date.civil(*row.at(12).match(/^(\d{4})(\d\d)(\d\d)$/).captures.map(&:to_i)) # valid_from
|
331
329
|
]
|
332
330
|
temporary[onrp] = data
|
data/swissmatch-location.gemspec
CHANGED
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: swissmatch-location
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.2.201304
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Stefan Rusterholz
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubyzip
|