sportdb 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,9 +14,7 @@ db/at/2012_13/cup.rb
14
14
  db/at/2012_13/cup.txt
15
15
  db/at/2012_13/cup_fixtures.rb
16
16
  db/at/badges.rb
17
- db/at/cities.rb
18
17
  db/at/teams.rb
19
- db/cities.rb
20
18
  db/cl/2011_12/cl.rb
21
19
  db/cl/2011_12/el.rb
22
20
  db/cl/2012_13/cl.rb
@@ -25,11 +23,9 @@ db/cl/teams.rb
25
23
  db/copa/sud_2012_13.rb
26
24
  db/copa/sud_2012_13.txt
27
25
  db/copa/teams.rb
28
- db/countries.rb
29
26
  db/de/2012_13/bl.rb
30
27
  db/de/2012_13/bl.txt
31
28
  db/de/2012_13/bl_fixtures.rb
32
- db/de/cities.rb
33
29
  db/de/teams.rb
34
30
  db/en/2012_13/pl.rb
35
31
  db/en/2012_13/pl.txt
@@ -68,6 +64,7 @@ lib/sportdb/models/city.rb
68
64
  lib/sportdb/models/country.rb
69
65
  lib/sportdb/models/event.rb
70
66
  lib/sportdb/models/event_team.rb
67
+ lib/sportdb/models/forward.rb
71
68
  lib/sportdb/models/game.rb
72
69
  lib/sportdb/models/group.rb
73
70
  lib/sportdb/models/group_team.rb
data/Rakefile CHANGED
@@ -18,7 +18,8 @@ Hoe.spec 'sportdb' do
18
18
  self.history_file = 'History.markdown'
19
19
 
20
20
  self.extra_deps = [
21
- ['activerecord', '~> 3.2'] # NB: will include activesupport,etc.
21
+ ['activerecord', '~> 3.2'], # NB: will include activesupport,etc.
22
+ ['worlddb', '~> 0.2.0']
22
23
  ### ['sqlite3', '~> 1.3'] # NB: install on your own; remove dependency
23
24
  ]
24
25
 
@@ -1,7 +1,6 @@
1
1
  ###
2
2
  # NB: for local testing run like:
3
3
  #
4
- # 1.8.x: ruby -Ilib -rrubygems lib/sportdb.rb
5
4
  # 1.9.x: ruby -Ilib lib/sportdb.rb
6
5
 
7
6
  # core and stlibs
@@ -16,14 +15,12 @@ require 'erb'
16
15
  # rubygems
17
16
 
18
17
  require 'active_record' ## todo: add sqlite3? etc.
18
+ require 'worlddb'
19
19
 
20
20
 
21
21
  # our own code
22
22
 
23
-
24
- module SportDB # forward reference; more to come later
25
- end
26
-
23
+ require 'sportdb/models/forward'
27
24
  require 'sportdb/models/badge'
28
25
  require 'sportdb/models/city'
29
26
  require 'sportdb/models/country'
@@ -100,10 +97,6 @@ module SportDB
100
97
  Group.delete_all
101
98
  GroupTeam.delete_all
102
99
  Round.delete_all
103
- Prop.delete_all
104
- Country.delete_all
105
- Region.delete_all
106
- City.delete_all
107
100
  Badge.delete_all
108
101
  League.delete_all
109
102
  Season.delete_all
@@ -11,6 +11,15 @@ class Opts
11
11
  @create == true
12
12
  end
13
13
 
14
+ def world=(boolean)
15
+ @world = boolean
16
+ end
17
+
18
+ def world?
19
+ return false if @world.nil? # default populate world tables flag is false
20
+ @world == true
21
+ end
22
+
14
23
 
15
24
  def generate=(boolean)
16
25
  @generate = boolean
@@ -23,20 +23,22 @@ class Runner
23
23
 
24
24
  cmd.banner = "Usage: sportdb [options]"
25
25
 
26
- cmd.on( '-e', '--event KEY', 'Event to Load or Generate' ) { |key| opts.event = key; }
27
- cmd.on( '-g', '--generate', 'Generate Fixtures from Template' ) { opts.generate = true }
26
+ cmd.on( '-e', '--event KEY', 'Event to load or generate' ) { |key| opts.event = key; }
27
+ cmd.on( '-g', '--generate', 'Generate fixtures from template' ) { opts.generate = true }
28
28
 
29
29
  ## todo: change to different flag?? use -c/--config ???
30
- cmd.on( '-c', '--create', 'Create DB Schema' ) { opts.create = true }
30
+ cmd.on( '-c', '--create', 'Create DB schema' ) { opts.create = true }
31
+
32
+ cmd.on( '--world', "Populate world tables with builtin data (version #{WorldDB::VERSION})" ) { opts.world = true }
31
33
 
32
34
  cmd.on( '--delete', 'Delete all records' ) { opts.delete = true }
33
35
 
34
- cmd.on( '--load', 'Use Loader for Builtin Sports Data' ) { opts.load = true }
36
+ cmd.on( '--load', 'Use loader for builtin sports data' ) { opts.load = true }
35
37
 
36
- cmd.on( '-o', '--output PATH', "Output Path (default is #{opts.output_path})" ) { |path| opts.output_path = path }
38
+ cmd.on( '-o', '--output PATH', "Output path (default is #{opts.output_path})" ) { |path| opts.output_path = path }
37
39
 
38
40
  ### todo: in future allow multiple search path??
39
- cmd.on( '-i', '--include PATH', "Data Path (default is #{opts.data_path})" ) { |path| opts.data_path = path }
41
+ cmd.on( '-i', '--include PATH', "Data path (default is #{opts.data_path})" ) { |path| opts.data_path = path }
40
42
 
41
43
  cmd.on( '-v', '--version', "Show version" ) do
42
44
  puts SportDB.banner
@@ -90,11 +92,21 @@ EOS
90
92
  ActiveRecord::Base.establish_connection( db_config )
91
93
 
92
94
  if opts.create?
93
- CreateDB.up
95
+ CreateDB.up # nb: includes WorldDB:CreateDB.up for tables -> countries,regions,cities,props
94
96
  end
95
97
 
96
98
  if opts.delete?
97
99
  SportDB.delete!
100
+ WorldDB.delete! # countries,regions,cities,props
101
+ end
102
+
103
+ if opts.world?
104
+ WorldDB.load([
105
+ 'countries',
106
+ 'cities',
107
+ 'at/cities',
108
+ 'de/cities'
109
+ ])
98
110
  end
99
111
 
100
112
  if opts.event.present?
@@ -1,50 +1,14 @@
1
- module SportDB::Models
2
1
 
3
- class City < ActiveRecord::Base
4
- self.table_name = 'cities'
2
+ ## todo: how to best extends city model?
5
3
 
6
- belongs_to :country, :class_name => 'Country', :foreign_key => 'country_id'
7
- belongs_to :region, :class_name => 'Region', :foreign_key => 'region_id'
8
-
9
- has_many :teams, :class_name => 'Team', :foreign_key => 'city_id'
10
-
11
-
12
- def self.create_from_ary!( cities, more_values={} )
13
- cities.each do |values|
14
-
15
- ## key & title & country required
16
- attr = {
17
- key: values[0]
18
- }
19
-
20
- ## title (split of optional synonyms)
21
- # e.g. FC Bayern Muenchen|Bayern Muenchen|Bayern
22
- titles = values[1].split('|')
23
-
24
- attr[ :title ] = titles[0]
25
- ## add optional synonyms
26
- attr[ :synonyms ] = titles[1..-1].join('|') if titles.size > 1
27
-
28
- attr = attr.merge( more_values )
29
-
30
- ## check for optional values
31
- values[2..-1].each do |value|
32
- if value.is_a? Country
33
- attr[ :country_id ] = value.id
34
- elsif value =~ /^region:/ ## region:
35
- value_region_key = value[7..-1] ## cut off region: prefix
36
- value_region = Region.find_by_key!( value_region_key )
37
- attr[ :region_id ] = value_region.id
38
- else
39
- # issue warning: unknown type for value
40
- end
41
- end
42
-
43
- City.create!( attr )
44
- end # each city
4
+ module WorldDB::Models
5
+ class City
6
+ has_many :teams, :class_name => 'Team', :foreign_key => 'city_id'
45
7
  end
46
-
47
- end # class Cities
8
+ end # module WorldDB::Models
48
9
 
49
10
 
50
- end # module Models::SportDB
11
+ ## moved to models/forward
12
+ # module SportDB::Models
13
+ # City = WorldDB::Models::City
14
+ # end # module SportDB::Models
@@ -1,29 +1,18 @@
1
- module SportDB::Models
1
+ # encoding: utf-8
2
2
 
3
+ ## todo: how to best extends country model?
3
4
 
4
- class Country < ActiveRecord::Base
5
- self.table_name = 'countries'
5
+ module WorldDB::Models
6
6
 
7
- has_many :regions, :class_name => 'Region', :foreign_key => 'country_id'
8
- has_many :cities, :class_name => 'City', :foreign_key => 'country_id'
9
- has_many :teams, :class_name => 'Team', :foreign_key => 'country_id'
10
- has_many :leagues, :class_name => 'League', :foreign_key => 'country_id'
7
+ class Country
8
+ has_many :teams, :class_name => 'Team', :foreign_key => 'country_id'
9
+ has_many :leagues, :class_name => 'League', :foreign_key => 'country_id'
10
+ end # class Country
11
11
 
12
- def self.create_from_ary!( countries )
13
- countries.each do |values|
14
-
15
- ## key & title required
16
- attr = {
17
- :key => values[0],
18
- :title => values[1],
19
- :tag => values[2]
20
- }
21
-
22
- Country.create!( attr )
23
- end # each country
24
- end
12
+ end # module WorldDB::Models
25
13
 
26
- end # class Country
27
14
 
28
-
29
- end # module Models::SportDB
15
+ ## moved to models/forward
16
+ # module SportDB::Models
17
+ # Country = WorldDB::Models::Country
18
+ # end # module SportDB::Models
@@ -0,0 +1,33 @@
1
+
2
+ ### forward references
3
+ ## require first to resolve circular references
4
+
5
+ module SportDB ; end
6
+
7
+ module SportDB::Models
8
+
9
+ ## todo: why? why not use include WorldDB::Models here???
10
+
11
+ Country = WorldDB::Models::Country
12
+ Region = WorldDB::Models::Region
13
+ City = WorldDB::Models::City
14
+ Prop = WorldDB::Models::Prop
15
+
16
+ ## nb: for now only team and league use worlddb tables
17
+ # e.g. with belongs_to assoc (country,region)
18
+
19
+ class Team < ActiveRecord::Base ; end
20
+ class League < ActiveRecord::Base ; end
21
+
22
+ end
23
+
24
+
25
+ module WorldDB::Models
26
+
27
+ # add alias? why? why not? # is there a better way?
28
+ # - just include SportDB::Models - why? why not?
29
+ # - just include once in loader??
30
+ Team = SportDB::Models::Team
31
+ League = SportDB::Models::League
32
+
33
+ end
@@ -10,7 +10,7 @@ class League < ActiveRecord::Base
10
10
  has_many :events
11
11
  has_many :seasons, :through => :events
12
12
 
13
- belongs_to :country, :class_name => 'Country', :foreign_key => 'country_id'
13
+ belongs_to :country, :class_name => 'WorldDB::Models::Country', :foreign_key => 'country_id'
14
14
 
15
15
 
16
16
  def self.create_from_ary!( leagues, more_values={} )
@@ -1,10 +1,7 @@
1
- module SportDB::Models
1
+ # encoding: utf-8
2
2
 
3
3
 
4
- class Prop < ActiveRecord::Base
5
-
6
- end # class Prop
7
-
8
-
9
-
10
- end # module SportDB::Models
4
+ ## moved to models/forward
5
+ # module SportDB::Models
6
+ # Prop = WorldDB::Models::Prop
7
+ # end # module SportDB::Models
@@ -1,38 +1,16 @@
1
- module SportDB::Models
1
+ # encoding: utf-8
2
2
 
3
- class Region < ActiveRecord::Base
3
+ ## todo: how to best extends country model?
4
4
 
5
- belongs_to :country, :class_name => 'Country', :foreign_key => 'country_id'
5
+ module WorldDB::Models
6
6
 
7
- has_many :cities, :class_name => 'City', :foreign_key => 'region_id'
8
- has_many :teams, :through => :cities
7
+ class Region
8
+ has_many :teams, :through => :cities
9
+ end # class Region
9
10
 
11
+ end # module WorldDB::Models
10
12
 
11
- def self.create_from_ary!( regions, more_values={} )
12
- regions.each do |values|
13
-
14
- ## key & title & country required
15
- attr = {
16
- key: values[0],
17
- title: values[1]
18
- }
19
-
20
- attr = attr.merge( more_values )
21
-
22
- ## check for optional values
23
- values[2..-1].each do |value|
24
- if value.is_a? Country
25
- attr[ :country_id ] = value.id
26
- else
27
- # issue warning: unknown type for value
28
- end
29
- end
30
-
31
- Region.create!( attr )
32
- end # each region
33
- end
34
-
35
- end # class Region
36
-
37
-
38
- end # module Models::SportDB
13
+ ## moved to models/forward
14
+ # module SportDB::Models
15
+ # Region = WorldDB::Models::Region
16
+ # end # module SportDB::Models
@@ -13,9 +13,9 @@ class Team < ActiveRecord::Base
13
13
 
14
14
  has_many :badges # Winner, 2nd, Cupsieger, Aufsteiger, Absteiger, etc.
15
15
 
16
- belongs_to :country, :class_name => 'Country', :foreign_key => 'country_id'
17
- belongs_to :city, :class_name => 'City', :foreign_key => 'city_id'
18
-
16
+ belongs_to :country, :class_name => 'WorldDB::Models::Country', :foreign_key => 'country_id'
17
+ belongs_to :city, :class_name => 'WorldDB::Models::City', :foreign_key => 'city_id'
18
+
19
19
 
20
20
  def self.create_from_ary!( teams, more_values={} )
21
21
  teams.each do |values|
@@ -8,40 +8,24 @@ class CreateDB
8
8
  # e.g. lets you use Team instead of Models::Team
9
9
  include SportDB::Models
10
10
 
11
-
11
+
12
12
  def self.up
13
+
14
+ WorldDB::CreateDB.up # tables countries,regions,cities,props
13
15
 
14
16
  ActiveRecord::Schema.define do
15
17
 
16
- create_table :countries do |t|
17
- t.string :title, :null => false
18
- t.string :tag, :null => false # short three letter tag (FIFA country code)
19
- t.string :key, :null => false
20
- t.timestamps
21
- end
22
-
23
- create_table :regions do |t|
24
- t.string :title, :null => false
25
- t.string :key, :null => false
26
- t.references :country, :null => false
27
- t.timestamps
28
- end
29
-
30
- create_table :cities do |t|
31
- t.string :title, :null => false
32
- t.string :key, :null => false
33
- t.string :synonyms # comma separated list of synonyms
34
- t.references :country, :null => false
35
- t.references :region # optional for now
36
- t.timestamps
37
- end
18
+ =begin
19
+ ## todo:fix - use if table.exists? why? why not?
38
20
 
39
21
  create_table :props do |t|
40
22
  t.string :key, :null => false
41
23
  t.string :value, :null => false
42
24
  t.timestamps
43
25
  end
44
-
26
+ =end
27
+
28
+
45
29
  create_table :teams do |t|
46
30
  t.string :title, :null => false
47
31
  t.string :title2
@@ -180,7 +164,7 @@ end
180
164
  end # block Schema.define
181
165
 
182
166
 
183
- Prop.create!( key: 'db.schema.version', value: SportDB::VERSION )
167
+ Prop.create!( key: 'db.schema.sport.version', value: SportDB::VERSION )
184
168
 
185
169
  end # method up
186
170
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module SportDB
3
- VERSION = '0.6.0'
3
+ VERSION = '0.7.0'
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 6
8
+ - 7
9
9
  - 0
10
- version: 0.6.0
10
+ version: 0.7.0
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-04 00:00:00 Z
18
+ date: 2012-11-07 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activerecord
@@ -33,9 +33,25 @@ dependencies:
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- name: rdoc
36
+ name: worlddb
37
37
  prerelease: false
38
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ hash: 23
44
+ segments:
45
+ - 0
46
+ - 2
47
+ - 0
48
+ version: 0.2.0
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: rdoc
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
39
55
  none: false
40
56
  requirements:
41
57
  - - ~>
@@ -46,11 +62,11 @@ dependencies:
46
62
  - 10
47
63
  version: "3.10"
48
64
  type: :development
49
- version_requirements: *id002
65
+ version_requirements: *id003
50
66
  - !ruby/object:Gem::Dependency
51
67
  name: hoe
52
68
  prerelease: false
53
- requirement: &id003 !ruby/object:Gem::Requirement
69
+ requirement: &id004 !ruby/object:Gem::Requirement
54
70
  none: false
55
71
  requirements:
56
72
  - - ~>
@@ -61,7 +77,7 @@ dependencies:
61
77
  - 0
62
78
  version: "3.0"
63
79
  type: :development
64
- version_requirements: *id003
80
+ version_requirements: *id004
65
81
  description: sportdb - sport.db command line tool
66
82
  email: opensport@googlegroups.com
67
83
  executables:
@@ -99,9 +115,7 @@ files:
99
115
  - db/at/2012_13/cup.txt
100
116
  - db/at/2012_13/cup_fixtures.rb
101
117
  - db/at/badges.rb
102
- - db/at/cities.rb
103
118
  - db/at/teams.rb
104
- - db/cities.rb
105
119
  - db/cl/2011_12/cl.rb
106
120
  - db/cl/2011_12/el.rb
107
121
  - db/cl/2012_13/cl.rb
@@ -110,11 +124,9 @@ files:
110
124
  - db/copa/sud_2012_13.rb
111
125
  - db/copa/sud_2012_13.txt
112
126
  - db/copa/teams.rb
113
- - db/countries.rb
114
127
  - db/de/2012_13/bl.rb
115
128
  - db/de/2012_13/bl.txt
116
129
  - db/de/2012_13/bl_fixtures.rb
117
- - db/de/cities.rb
118
130
  - db/de/teams.rb
119
131
  - db/en/2012_13/pl.rb
120
132
  - db/en/2012_13/pl.txt
@@ -153,6 +165,7 @@ files:
153
165
  - lib/sportdb/models/country.rb
154
166
  - lib/sportdb/models/event.rb
155
167
  - lib/sportdb/models/event_team.rb
168
+ - lib/sportdb/models/forward.rb
156
169
  - lib/sportdb/models/game.rb
157
170
  - lib/sportdb/models/group.rb
158
171
  - lib/sportdb/models/group_team.rb
@@ -1,53 +0,0 @@
1
- # encoding: utf-8
2
-
3
- at = Country.find_by_key!( 'at' )
4
-
5
-
6
- ## 9 Bundeslaender
7
-
8
- regions_at = [
9
- ['wien', 'Wien'], # Wien
10
- ['noe', 'NÖ'], # Niederösterreich
11
- ['ooe', 'OÖ'], # Oberösterreich
12
- ['bgld', 'Bgld.'], # Burgenland
13
- ['stmk', 'Stmk.'], # Steiermark
14
- ['sbg', 'Sbg.'], # Salzburg
15
- ['ktn', 'Ktn.'], # Kärnten
16
- ['tirol', 'Tirol'], # Tirol
17
- ['vbg', 'Vbg.'] # Vorarlberg
18
- ]
19
-
20
- Region.create_from_ary!( regions_at, country: at )
21
-
22
- cities_at = [
23
- ['wien', 'Wien|Vienna', 'region:wien'],
24
-
25
- ['stpoelten', 'St. Pölten', 'region:noe'],
26
- ['moedling', 'Mödling|Moedling', 'region:noe'],
27
- ['wrneustadt', 'Wiener Neustadt|Wr. Neustadt', 'region:noe'],
28
- ['horn', 'Horn', 'region:noe'],
29
-
30
- ['linz', 'Linz', 'region:ooe'],
31
- ['ried', 'Ried', 'region:ooe'],
32
-
33
- ['mattersburg', 'Mattersburg', 'region:bgld'],
34
-
35
- ['graz', 'Graz', 'region:stmk'],
36
- ['hartberg', 'Hartberg', 'region:stmk'],
37
- ['kapfenberg', 'Kapfenberg', 'region:stmk'],
38
-
39
- ['salzburg', 'Salzburg', 'region:sbg'],
40
- ['groedig', 'Grödig', 'region:sbg'],
41
-
42
- ['wolfsberg', 'Wolfsberg', 'region:ktn'],
43
-
44
- ['innsbruck', 'Innsbruck', 'region:tirol'],
45
-
46
- ['altach', 'Altach', 'region:vbg'],
47
- ['lustenau', 'Lustenau', 'region:vbg']
48
- ]
49
-
50
- City.create_from_ary!( cities_at, country: at )
51
-
52
-
53
- Prop.create!( key: 'db.at.cities.version', value: '1' )
@@ -1,263 +0,0 @@
1
- # encoding: utf-8
2
-
3
-
4
- cities_en = [
5
- ['manchester', 'Manchester'],
6
- ['london', 'London'],
7
- ['liverpool', 'Liverpool'],
8
- ['birmingham', 'Birmingham'], # e.g.Aston Villa
9
- ['westbrom', 'West Bromwich'],
10
- ['newcastle', 'Newcastle upon Tyne'],
11
- ['stoke', 'Stoke-on-Trent'],
12
- ['sunderland', 'Sunderland'],
13
- ['wigan', 'Wigan'],
14
- ['southampton', 'Southampton'],
15
- ['reading', 'Reading'],
16
- ['norwich', 'Norwich'],
17
- ['swansea', 'Swansea']
18
- ]
19
-
20
- en = Country.find_by_key!( 'en' )
21
- City.create_from_ary!( cities_en, country: en )
22
-
23
-
24
- cities_es = [
25
- ['bilbao', 'Bilbao'],
26
- ['valencia', 'Valencia'],
27
- ['barcelona', 'Barcelona'],
28
- ['madrid', 'Madrid'],
29
- ['malaga', 'Málaga']
30
- ]
31
-
32
- es = Country.find_by_key!( 'es' )
33
- City.create_from_ary!( cities_es, country: es )
34
-
35
-
36
- cities_fr = [
37
- ['lille', 'Lille'],
38
- ['paris', 'Paris'],
39
- ['marseille', 'Marseille'],
40
- ['montpellier', 'Montpellier']
41
- ]
42
-
43
- fr = Country.find_by_key!( 'fr' )
44
- City.create_from_ary!( cities_fr, country: fr )
45
-
46
-
47
- cities_it = [
48
- ['turin', 'Turin'],
49
- ['milano', 'Mailand|Milano'],
50
- ['napoli', 'Neapel|Napoli']
51
- ]
52
-
53
- it = Country.find_by_key!( 'it' )
54
- City.create_from_ary!( cities_it, country: it )
55
-
56
-
57
- cities_pt = [
58
- ['porto', 'Porto'],
59
- ['braga', 'Braga'],
60
- ['lisboa', 'Lissabon|Lisboa']
61
- ]
62
-
63
- pt = Country.find_by_key!( 'pt' )
64
- City.create_from_ary!( cities_pt, country: pt )
65
-
66
-
67
- cities_ru = [
68
- ['moskva', 'Moskau|Moskva'],
69
- ['stpetersburg','St. Petersburg']
70
- ]
71
-
72
- ru = Country.find_by_key!( 'ru' )
73
- City.create_from_ary!( cities_ru, country: ru )
74
-
75
-
76
- cities_be = [
77
- ['brussel', 'Brüssel|Brussel|Bruxelles|Brussels'] # de|nl|fr|en - RCA Anderlecht
78
- ]
79
-
80
- be = Country.find_by_key!( 'be' )
81
- City.create_from_ary!( cities_be, country: be )
82
-
83
-
84
- cities_ua = [
85
- ['kiev', 'Kiew|Kiev|Kyiv' ],
86
- ['donetsk', 'Donezk|Donetsk'],
87
- ['kharkov', 'Kharkiv|Kharkov']
88
- ]
89
-
90
- ua = Country.find_by_key!( 'ua' )
91
- City.create_from_ary!( cities_ua, country: ua )
92
-
93
-
94
- cities_nl = [
95
- ['amsterdam','Amsterdam'],
96
- ['alkmaar','Alkmaar'] ## region: North Holland
97
- ]
98
-
99
- nl = Country.find_by_key!( 'nl' )
100
- City.create_from_ary!( cities_nl, country: nl )
101
-
102
-
103
- cities_hr = [
104
- ['zagreb','Zagreb']
105
- ]
106
-
107
- hr = Country.find_by_key!( 'hr' )
108
- City.create_from_ary!( cities_hr, country: hr )
109
-
110
-
111
- cities_gr = [
112
- ['piraeus','Piräus|Piraeus']
113
- ]
114
-
115
- gr = Country.find_by_key!( 'gr' )
116
- City.create_from_ary!( cities_gr, country: gr )
117
-
118
-
119
- cities_dk = [
120
- ['farum','Farum'] ## region: North Zealand ??
121
- ]
122
-
123
- dk = Country.find_by_key!( 'dk' )
124
- City.create_from_ary!( cities_dk, country: dk )
125
-
126
-
127
- cities_by = [
128
- ['borisov','Borissow|Borisov|Barysaw']
129
- ]
130
-
131
- by = Country.find_by_key!( 'by' )
132
- City.create_from_ary!( cities_by, country: by )
133
-
134
-
135
- cities_sc = [
136
- ['glasgow','Glasgow']
137
- ]
138
-
139
- sc = Country.find_by_key!( 'sc' )
140
- City.create_from_ary!( cities_sc, country: sc )
141
-
142
-
143
- cities_tr = [
144
- ['istanbul','Istanbul']
145
- ]
146
-
147
- tr = Country.find_by_key!( 'tr' )
148
- City.create_from_ary!( cities_tr, country: tr )
149
-
150
-
151
- cities_ro = [
152
- ['cluj','Cluj']
153
- ]
154
-
155
- ro = Country.find_by_key!( 'ro' )
156
- City.create_from_ary!( cities_ro, country: ro )
157
-
158
-
159
- cities_ch = [
160
- ['basel','Basel']
161
- ]
162
-
163
- ch = Country.find_by_key!( 'ch' )
164
- City.create_from_ary!( cities_ch, country: ch )
165
-
166
-
167
- cities_cy = [
168
- ['nikosia','Nikosia|Nicosia']
169
- ]
170
-
171
- cy = Country.find_by_key!( 'cy' )
172
- City.create_from_ary!( cities_cy, country: cy )
173
-
174
-
175
-
176
- cities_mx = [
177
- ['mexico', 'México' ],
178
- ['cancun', 'Cancún' ],
179
- ['guadalajara', 'Guadalajara' ],
180
- ['tuxtla', 'Tuxtla Gutiérrez' ],
181
- ['leon', 'León' ],
182
- ['morelia', 'Morelia' ],
183
- ['monterrey', 'Monterrey' ],
184
- ['pachuca', 'Pachuca' ],
185
- ['puebla', 'Puebla' ],
186
- ['queretaro', 'Querétaro' ],
187
- ['sanluispotosi', 'San Luis Potosì' ],
188
- ['torreon', 'Torreón' ],
189
- ['tijuana', 'Tijuana' ],
190
- ['toluca', 'Toluca' ],
191
- ['sannicolas', 'San Nicolás de los Garza' ]
192
- ]
193
-
194
- mx = Country.find_by_key!( 'mx' )
195
- City.create_from_ary!( cities_mx, country: mx )
196
-
197
-
198
- regions_ca = [
199
- ['on', 'Ontario'],
200
- ['qc', 'Quebec'],
201
- ['ns', 'Nova Scotia'],
202
- ['nb', 'New Brunswick'],
203
- ['mb', 'Manitoba'],
204
- ['bc', 'British Columbia'],
205
- ['pe', 'Prince Edward Island'],
206
- ['sk', 'Saskatchewan'],
207
- ['ab', 'Alberta'],
208
- ['nl', 'Newfoundland and Labrador']
209
- ]
210
-
211
- cities_ca = [
212
- ['montreal', 'Montreal', 'region:qc'],
213
- ['ottawa', 'Ottawa', 'region:on'],
214
- ['toronto', 'Toronto', 'region:on'],
215
- ['winnipeg', 'Winnipeg', 'region:mb'],
216
- ['calgary', 'Calgary', 'region:ab'],
217
- ['edmonton', 'Edmonton', 'region:ab'],
218
- ['vancouver', 'Vancouver', 'region:bc']
219
- ]
220
-
221
- ca = Country.find_by_key!( 'ca' )
222
- Region.create_from_ary!( regions_ca, country: ca )
223
- City.create_from_ary!( cities_ca, country: ca )
224
-
225
-
226
- regions_us = [
227
- ['ca', 'California'],
228
- ['ny', 'New York'],
229
- ['ma', 'Massachusetts'],
230
- ['pa', 'Pennsylvania'],
231
- ['il', 'Illinois'],
232
- ['oh', 'Ohio'],
233
- ['mi', 'Michigan'],
234
- ['tn', 'Tennessee'],
235
- ['tx', 'Texas'],
236
- ['az', 'Arizona']
237
- ]
238
-
239
- cities_us = [
240
- ['newyork', 'New York', 'region:ny'],
241
- ['buffalo', 'Buffalo', 'region:ny'],
242
- ['philadelphia', 'Philadelphia', 'region:pa'],
243
- ['boston', 'Boston', 'region:ma'],
244
- ['chicago', 'Chicago', 'region:il'],
245
- ['columbus', 'Columbus', 'region:oh'],
246
- ['detroit', 'Detroit', 'region:mi'],
247
- ['nashville', 'Nashville', 'region:tn'],
248
- ['dallas', 'Dallas', 'region:tx'],
249
- ['phoenix', 'Phoenix', 'region:az'],
250
- ['losangeles', 'Los Angeles', 'region:ca'],
251
- ['sanjose', 'San Jose', 'region:ca'],
252
- ['anaheim', 'Anaheim', 'region:ca'],
253
- ['stlouis', 'St. Louis'],
254
- ['pittsburgh', 'Pittsburgh'],
255
- ['washington', 'Washington']
256
- ]
257
-
258
- us = Country.find_by_key!( 'us' )
259
- Region.create_from_ary!( regions_us, country: us )
260
- City.create_from_ary!( cities_us, country: us )
261
-
262
-
263
- Prop.create!( key: 'db.cities.version', value: '1' )
@@ -1,109 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ## NB: for keys use internet domain/iso two letter code
4
- #
5
- # more info about iso country codes:
6
- # -> http://en.wikipedia.org/wiki/ISO_3166-1
7
- # two letter codes -> http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
8
- # three letter codes -> http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
9
- #
10
- # for three letter codes use fifa code or iso code
11
- # - fifa three letter country codes
12
- # -> http://en.wikipedia.org/wiki/List_of_FIFA_country_codes
13
- # -> differences (fifa,ioc,iso) -> http://en.wikipedia.org/wiki/Comparison_of_IOC,_FIFA,_and_ISO_3166_country_codes
14
-
15
-
16
- countries = [
17
-
18
- ####################
19
- ### europe
20
-
21
- ## [ 'ad', 'Andorra', 'AND' ],
22
- ## [ 'al', 'Albanien', 'ALB' ],
23
- ## [ 'am', 'Armenien', 'ARM' ],
24
- [ 'at', 'Österreich', 'AUT' ],
25
- [ 'be', 'Belgien', 'BEL' ],
26
- ## [ 'bg', 'Bulgarien', 'BUL' ], # NB: ISO (BGR) <> FIFA (BUL)
27
- [ 'by', 'Weißrussland', 'BLR' ],
28
- [ 'ch', 'Schweiz', 'SUI' ], # NB: ISO (CHE) <> FIFA (SUI)
29
- [ 'cy', 'Zypern', 'CYP' ],
30
- [ 'cz', 'Tschechien', 'CZE' ],
31
- [ 'de', 'Deutschland', 'GER' ], # NB: ISO (DEU) <> FIFA (GER)
32
- [ 'dk', 'Dänemark', 'DEN' ], # NB: ISO (DNK) <> FIFA (DEN)
33
- [ 'en', 'England', 'ENG' ], # NB: FIFA (ENG); not a valid iso country n internet domain / it's uk - what to use - anything better?
34
- [ 'es', 'Spanien', 'ESP' ],
35
- [ 'fi', 'Finnland', 'FIN' ],
36
- [ 'fo', 'Färöer', 'FRO' ],
37
- [ 'fr', 'Frankreich', 'FRA' ],
38
- [ 'ge', 'Georgien', 'GEO' ],
39
- [ 'gr', 'Griechenland', 'GRE' ], # NB: ISO (GRC) <> FIFA (GRE)
40
- [ 'hr', 'Kroatien', 'CRO' ], # NB: ISO (HRV) <> FIFA (CRO); local name: Hrvatska
41
- ## [ 'hu', 'Ungarn', 'HUN' ],
42
- [ 'ie', 'Irland', 'IRL' ],
43
- [ 'it', 'Italien', 'ITA' ],
44
- [ 'kz', 'Kasachstan', 'KAZ' ],
45
- ## [ 'mt', 'Malta', 'MLT' ],
46
- [ 'nl', 'Niederlande', 'NED' ], # NB: ISO (NLD) <> FIFA (NED)
47
- [ 'pl', 'Polen', 'POL' ],
48
- [ 'pt', 'Portugal', 'POR' ], # NB: ISO (PRT) <> FIFA (POR)
49
- [ 'ro', 'Rumänien', 'ROU' ],
50
- [ 'rs', 'Serbien', 'SRB' ],
51
- [ 'ru', 'Russland', 'RUS' ],
52
- [ 'sc', 'Schottland', 'SCO' ], # NB: FIFA (SCO); not a valid iso country/internet domain - it's uk - what to use - anything better?
53
- [ 'se', 'Schweden', 'SWE' ],
54
- [ 'si', 'Slowenien', 'SVN' ],
55
- [ 'sk', 'Slowakei', 'SVK' ],
56
- [ 'tr', 'Türkei', 'TUR' ],
57
- [ 'ua', 'Ukraine', 'UKR' ],
58
-
59
- ##############
60
- ## south america
61
-
62
- [ 'ar', 'Argentinien', 'ARG' ],
63
- [ 'br', 'Brasilien', 'BRA' ],
64
- [ 'cl', 'Chile', 'CHI' ],
65
- [ 'py', 'Paraguay', 'PAR' ],
66
- [ 'uy', 'Uruguay', 'URU' ],
67
- [ 'ec', 'Ecuador', 'ECU' ],
68
- [ 'co', 'Colombia', 'COL' ],
69
-
70
- #####################
71
- #### north/central america & caribbean islands
72
-
73
- [ 'ca', 'Kanada', 'CAN' ],
74
- [ 'mx', 'Mexiko', 'MEX' ],
75
- [ 'us', 'United States', 'USA' ],
76
- [ 'hn', 'Honduras', 'HON' ],
77
- [ 'cr', 'Costa Rica', 'CRC' ],
78
- [ 'sv', 'El Salvador', 'SLV' ],
79
- [ 'gy', 'Guyana', 'GUY' ],
80
-
81
- ########################
82
- ## africa
83
-
84
- [ 'dz', 'Algerien', 'ALG' ],
85
- [ 'ci', 'Elfenbeinküste', 'CIV' ],
86
- [ 'gh', 'Ghana', 'GHA' ],
87
- [ 'cm', 'Kamerun', 'CMR' ],
88
- [ 'ng', 'Nigeria', 'NGA' ],
89
- [ 'za', 'Südafrika', 'RSA' ],
90
-
91
- #############################
92
- ## asia w/ australia
93
-
94
- [ 'au', 'Australien', 'AUS' ],
95
- [ 'jp', 'Japan', 'JPN' ],
96
- [ 'kp', 'Nordkorea', 'PRK' ],
97
- [ 'kr', 'Südkorea', 'KOR' ],
98
-
99
- ###############################
100
- ## oceania
101
-
102
- [ 'nz', 'Neuseeland', 'NZL' ]
103
- ]
104
-
105
-
106
- Country.create_from_ary!( countries )
107
-
108
-
109
- Prop.create!( key: 'db.countries.version', value: '1' )
@@ -1,51 +0,0 @@
1
- # encoding: utf-8
2
-
3
- de = Country.find_by_key!( 'de' )
4
-
5
- regions_de = [
6
- ['bw', 'Baden-Württemberg'],
7
- ['by', 'Bayern'],
8
- ['be', 'Berlin'],
9
- ['bb', 'Brandenburg'],
10
- ['hb', 'Bremen'],
11
- ['hh', 'Hamburg'],
12
- ['he', 'Hessen'],
13
- ['mv', 'Mecklenburg-Vorpommern'],
14
- ['ni', 'Niedersachsen'],
15
- ['nw', 'Nordrhein-Westfalen'],
16
- ['rp', 'Rheinland-Pfalz'],
17
- ['sl', 'Saarland'],
18
- ['sn', 'Sachsen'],
19
- ['st', 'Sachsen-Anhalt'],
20
- ['sh', 'Schleswig-Holstein'],
21
- ['th', 'Thüringen']
22
- ]
23
-
24
- Region.create_from_ary!( regions_de, country: de )
25
-
26
-
27
- cities_de = [
28
- ['muenchen', 'München', 'region:by'],
29
- ['nuernberg', 'Nürnberg', 'region:by'],
30
- ['augsburg', 'Augsburg', 'region:by'],
31
- ['fuerth', 'Fürth', 'region:by'],
32
- ['stuttgart', 'Stuttgart', 'region:bw'],
33
- ['hoffenheim', 'Hoffenheim', 'region:bw'],
34
- ['freiburg', 'Freiburg', 'region:bw'],
35
- ['hannover', 'Hannover', 'region:ni'],
36
- ['wolfsburg', 'Wolfsburg', 'region:ni'],
37
- ['gelsenkirchen', 'Gelsenkirchen', 'region:nw'],
38
- ['dortmund', 'Dortmund', 'region:nw'],
39
- ['leverkusen', 'Leverkusen', 'region:nw'],
40
- ['duesseldorf', 'Düsseldorf', 'region:nw'],
41
- ['mgladbach', "Mönchengladbach|M'gladbach", 'region:nw' ],
42
- ['frankfurt', 'Frankfurt', 'region:he'],
43
- ['mainz', 'Mainz', 'region:rp'],
44
- ['hamburg', 'Hamburg', 'region:hh'],
45
- ['bremen', 'Bremen', 'region:hb']
46
- ]
47
-
48
- City.create_from_ary!( cities_de, country: de )
49
-
50
-
51
- Prop.create!( key: 'db.de.cities.version', value: '1' )