worlddb 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ #### fix: move region tag n,ne, etc to regions
2
+ ## no need to duplicate here for every city
3
+
1
4
  assis brasil, Assis Brasil, region:ac,n
2
5
  brasileia, Brasileia, region:ac,n
3
6
  cruzeiro do sul, Cruzeiro Do Sul, region:ac,n
@@ -7,8 +7,8 @@
7
7
  # area (in sq km), pop(ulation)
8
8
 
9
9
  ca, Canada, CAN, 9984670, 34278406, north america|en|fr
10
- mx, Mexico, MEX, 1972550, 112322757, north america|en
11
- us, United States, USA, 9629091, 314167157, north america|es
10
+ mx, Mexico, MEX, 1972550, 112322757, north america|es
11
+ us, United States, USA, 9629091, 314167157, north america|en|es
12
12
 
13
13
  #####################
14
14
  ## central america & caribbean islands
@@ -1,6 +1,6 @@
1
1
 
2
2
 
3
- brussel, Brussel|Bruxelles [Brussels], region:br, 1_048_491, m:1_929_000 , # nl|fr|en
3
+ brussel, Brussel|Bruxelles [Brussels], region:bx, 1_048_491, m:1_929_000 , # nl|fr|en
4
4
  antwerp, Antwerpen|Anvers [Antwerp], region:an, 466_203, m:960_000
5
5
  ghent, Gent|Gand [Ghent], region:ov, 235_143
6
6
  charleroi, Charleroi, region:ht, 201_550
@@ -5,8 +5,9 @@
5
5
  #
6
6
  # NB: using iso three letter codes (cut off first letter is always V or W for NUTS1 region)
7
7
 
8
+ ## todo: check what code to use for bruxeelles -> br is taken by Babant Wallon
8
9
 
9
- br, Bruxelles|Brussel [Brussels (Capital Region)], 161
10
+ bx, Bruxelles|Brussel [Brussels (Capital Region)], 161
10
11
 
11
12
  an, Antwerpen [Antwerp], 2_867, flanders|nl
12
13
  li, Limburg, 2_422, flanders|nl
@@ -5,8 +5,8 @@
5
5
  ## - http://en.wikipedia.org/wiki/Largest_urban_areas_of_the_European_Union
6
6
 
7
7
 
8
- ruhr, Ruhrgebiet [Ruhr area], region:nw, m:7_304_000, metro , # includes essen, bochum, dortmund, gelsenkirchen
9
- koelnbonn, Köln/Bonn [Cologne-Bonn], region:nw, m:2_063_000, metro , # includes koeln, leverkusen, bergischgladbach, bonn
8
+ ruhr, Ruhrgebiet [Ruhr area], region:nw, m:7_304_000, metro # includes essen, bochum, dortmund, gelsenkirchen
9
+ koelnbonn, Köln/Bonn [Cologne-Bonn], region:nw, m:2_063_000, metro # includes koeln, leverkusen, bergischgladbach, bonn
10
10
 
11
11
 
12
12
  # Top 10 cities
@@ -15,7 +15,7 @@ berlin, Berlin, region:be, 3_501_872, m:3_453_000
15
15
  hamburg, Hamburg, region:hh, 1_798_836, m:1_794_000
16
16
  muenchen, München [Munich], region:by, 1_378_176, m:1_355_000
17
17
  koeln, Köln, region:nw, 1_017_155, metro:koelnbonn,
18
- frankfurt, Frankfurt, region:he, 691_518 m:2_300_000 , # frankfurt metro includes wiesbaden, darmstadt
18
+ frankfurt, Frankfurt, region:he, 691_518 m:2_300_000 # frankfurt metro includes wiesbaden, darmstadt
19
19
  stuttgart, Stuttgart, region:bw, 613_392, m:1_272_000
20
20
  duesseldorf, Düsseldorf, region:nw, 592_393
21
21
  dortmund, Dortmund, region:nw, 580_956, metro:ruhr
@@ -6,7 +6,7 @@ an, Andalucía|Andalusia, 87598
6
6
  ar, Aragón, 47720
7
7
  as, Asturias, 10604
8
8
  ib, Illes Balears|Balearic Islands, 4992
9
- pv, Pais Vasco|Basque Country 7235
9
+ pv, Pais Vasco|Basque Country, 7235
10
10
  cn, Canarias|Canary Islands, 7447
11
11
  cb, Cantábria, 5321
12
12
  cl, Castilla y León, 94225
@@ -17,7 +17,7 @@ ga, Galicia, 29574
17
17
  ri, La Rioja, 5045
18
18
  md, Madrid, 8028
19
19
  mc, Murcia, 11313
20
- na, Navarra 10390
20
+ na, Navarra, 10390
21
21
  vc, Valencia, 23255
22
22
 
23
23
  ## autonomous cities
@@ -55,6 +55,9 @@ AT = Country.find_by_key( 'at' )
55
55
  DE = Country.find_by_key( 'de' )
56
56
  EN = Country.find_by_key( 'en' )
57
57
 
58
+ GB = Country.find_by_key( 'gb' )
59
+ EU = Country.find_by_key( 'eu' )
60
+
58
61
  US = Country.find_by_key( 'us' )
59
62
  CA = Country.find_by_key( 'ca' )
60
63
  MX = Country.find_by_key( 'mx' )
@@ -67,6 +70,11 @@ VIE = City.find_by_key( 'wien' )
67
70
 
68
71
  ## todo: add some predefined tags (e.g. europe, america, g8, euro, etc.)
69
72
 
73
+ EURO = Tag.find_by_key( 'euro' )
74
+ EUROPE = Tag.find_by_key( 'europe' )
75
+ ASIA = Tag.find_by_key( 'asia' )
76
+ PACIFIC = Tag.find_by_key( 'pacific' )
77
+
70
78
 
71
79
  ## turn on activerecord logging to console
72
80
 
@@ -15,6 +15,17 @@ class City < ActiveRecord::Base
15
15
  validates :code, :format => { :with => /^[A-Z_]{3}$/, :message => 'expected three uppercase letters A-Z (and _)' }, :allow_nil => true
16
16
 
17
17
 
18
+ def title_w_synonyms
19
+ return title if synonyms.blank?
20
+
21
+ buf = ''
22
+ buf << title
23
+ buf << ' | '
24
+ buf << synonyms.split('|').join(' | ')
25
+ buf
26
+ end
27
+
28
+
18
29
  def self.create_from_ary!( cities, more_values={} )
19
30
  cities.each do |values|
20
31
 
@@ -7,6 +7,10 @@ class Country < ActiveRecord::Base
7
7
 
8
8
  has_many :regions, :class_name => 'Region', :foreign_key => 'country_id'
9
9
  has_many :cities, :class_name => 'City', :foreign_key => 'country_id'
10
+
11
+ ## self referencing hierachy within countries e.g. EU > GB > EN
12
+ belongs_to :parent, :class_name => 'Country', :foreign_key => 'country_id'
13
+ has_many :countries, :class_name => 'Country', :foreign_key => 'country_id'
10
14
 
11
15
  has_many :taggings, :as => :taggable
12
16
  has_many :tags, :through => :taggings
@@ -15,6 +19,17 @@ class Country < ActiveRecord::Base
15
19
  validates :code, :format => { :with => /^[A-Z_]{3}$/, :message => 'expected three uppercase letters A-Z (and _)' }
16
20
 
17
21
 
22
+ def title_w_synonyms
23
+ return title if synonyms.blank?
24
+
25
+ buf = ''
26
+ buf << title
27
+ buf << ' | '
28
+ buf << synonyms.split('|').join(' | ')
29
+ buf
30
+ end
31
+
32
+
18
33
  def self.create_from_ary!( countries )
19
34
  countries.each do |values|
20
35
 
@@ -12,6 +12,18 @@ class Region < ActiveRecord::Base
12
12
  validates :key, :format => { :with => /^[a-z]{2,}$/, :message => 'expected two or more lowercase letters a-z' }
13
13
  validates :code, :format => { :with => /^[A-Z_]{2,3}$/, :message => 'expected two or three uppercase letters A-Z (and _)' }, :allow_nil => true
14
14
 
15
+
16
+ def title_w_synonyms
17
+ return title if synonyms.blank?
18
+
19
+ buf = ''
20
+ buf << title
21
+ buf << ' | '
22
+ buf << synonyms.split('|').join(' | ')
23
+ buf
24
+ end
25
+
26
+
15
27
  def self.create_from_ary!( regions, more_values={} )
16
28
  regions.each do |values|
17
29
 
@@ -36,7 +36,15 @@ class ValuesReader
36
36
  next
37
37
  end
38
38
 
39
- # remove leading and trailing whitespace
39
+
40
+ # pass 1) remove possible trailing eol comment
41
+ ## e.g -> nyc, New York # Sample EOL Comment Here (with or without commas,,,,)
42
+ ## becomes -> nyc, New York
43
+
44
+ line = line.sub( /\s+#.+$/, '' )
45
+
46
+ # pass 2) remove leading and trailing whitespace
47
+
40
48
  line = line.strip
41
49
 
42
50
  puts "line: >>#{line}<<"
@@ -47,6 +55,7 @@ class ValuesReader
47
55
 
48
56
  values = values.map { |value| value.strip }
49
57
 
58
+ ##### todo remove support of comment column? (NB: must NOT include commas)
50
59
  # pass 2) remove comment columns
51
60
 
52
61
  values = values.select do |value|
@@ -57,14 +66,6 @@ class ValuesReader
57
66
  true
58
67
  end
59
68
  end
60
-
61
- # pass 3) remove comments inside columns
62
-
63
- values = values.map do |value|
64
- value = value.sub( /\s+#.+$/, '' )
65
- value
66
- end
67
-
68
69
 
69
70
  puts " values: >>#{values.join('<< >>')}<<"
70
71
 
@@ -1,5 +1,5 @@
1
1
 
2
2
  module WorldDB
3
- VERSION = '0.6.1'
3
+ VERSION = '0.6.2'
4
4
  end
5
5
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worlddb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 1
10
- version: 0.6.1
9
+ - 2
10
+ version: 0.6.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gerald Bauer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-11-24 00:00:00 Z
18
+ date: 2012-11-25 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activerecord