worlddb 2.0.9 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +1 -1
  3. data/Manifest.txt +1 -38
  4. data/README.md +0 -67
  5. data/Rakefile +7 -11
  6. data/lib/worlddb.rb +8 -187
  7. data/lib/worlddb/cli/main.rb +3 -8
  8. data/lib/worlddb/{version.rb → cli/version.rb} +9 -7
  9. data/lib/worlddb/console.rb +5 -10
  10. metadata +10 -110
  11. data/.gemtest +0 -0
  12. data/lib/worlddb/deleter.rb +0 -32
  13. data/lib/worlddb/matcher.rb +0 -143
  14. data/lib/worlddb/models/city.rb +0 -240
  15. data/lib/worlddb/models/city_comp.rb +0 -27
  16. data/lib/worlddb/models/continent.rb +0 -41
  17. data/lib/worlddb/models/continent_comp.rb +0 -24
  18. data/lib/worlddb/models/country.rb +0 -328
  19. data/lib/worlddb/models/country_code.rb +0 -41
  20. data/lib/worlddb/models/country_comp.rb +0 -35
  21. data/lib/worlddb/models/forward.rb +0 -57
  22. data/lib/worlddb/models/lang.rb +0 -18
  23. data/lib/worlddb/models/lang_comp.rb +0 -23
  24. data/lib/worlddb/models/name.rb +0 -13
  25. data/lib/worlddb/models/place.rb +0 -16
  26. data/lib/worlddb/models/region.rb +0 -176
  27. data/lib/worlddb/models/region_comp.rb +0 -26
  28. data/lib/worlddb/models/tagdb/tag.rb +0 -16
  29. data/lib/worlddb/models/tagdb/tagging.rb +0 -15
  30. data/lib/worlddb/models/usage.rb +0 -17
  31. data/lib/worlddb/patterns.rb +0 -54
  32. data/lib/worlddb/reader.rb +0 -224
  33. data/lib/worlddb/reader_file.rb +0 -86
  34. data/lib/worlddb/reader_zip.rb +0 -160
  35. data/lib/worlddb/readers/city.rb +0 -81
  36. data/lib/worlddb/readers/country.rb +0 -78
  37. data/lib/worlddb/readers/lang.rb +0 -107
  38. data/lib/worlddb/readers/region.rb +0 -79
  39. data/lib/worlddb/readers/usage.rb +0 -98
  40. data/lib/worlddb/schema.rb +0 -202
  41. data/lib/worlddb/stats.rb +0 -31
  42. data/test/helper.rb +0 -29
  43. data/test/test_fixture_matchers.rb +0 -112
  44. data/test/test_model_city.rb +0 -60
  45. data/test/test_model_comp.rb +0 -48
  46. data/test/test_model_country.rb +0 -53
  47. data/test/test_model_region.rb +0 -50
  48. data/test/test_models.rb +0 -35
@@ -1,81 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module WorldDb
4
-
5
- class CityReader
6
-
7
- include LogUtils::Logging
8
-
9
- ## make models available by default with namespace
10
- # e.g. lets you use Usage instead of Model::Usage
11
- include Models
12
-
13
- ## value helpers e.g. is_year?, is_taglist? etc.
14
- include TextUtils::ValueHelper
15
-
16
-
17
- def self.from_zip( zip_file, entry_path, more_attribs={} )
18
- ## get text content from zip
19
-
20
- entry = zip_file.find_entry( entry_path )
21
-
22
- ## todo/fix: add force encoding to utf-8 ??
23
- ## check!!!
24
- ## clean/prepprocess lines
25
- ## e.g. CR/LF (/r/n) to LF (e.g. /n)
26
- text = entry.get_input_stream().read()
27
-
28
- ## NOTE: needs logger ref; only available in instance methods; use global logger for now
29
- logger = LogUtils::Logger.root
30
- logger.debug "text.encoding.name (before): #{text.encoding.name}"
31
- #####
32
- # NB: ASCII-8BIT == BINARY == Encoding Unknown; Raw Bytes Here
33
- ## NB:
34
- # for now "hardcoded" to utf8 - what else can we do?
35
- # - note: force_encoding will NOT change the chars only change the assumed encoding w/o translation
36
- text = text.force_encoding( Encoding::UTF_8 )
37
- logger.debug "text.encoding.name (after): #{text.encoding.name}"
38
-
39
- ## todo:
40
- # NB: for convenience: convert fancy unicode dashes/hyphens to plain ascii hyphen-minus
41
- ## text = TextUtils.convert_unicode_dashes_to_plain_ascii( text, path: path )
42
-
43
- self.from_string( text, more_attribs )
44
- end
45
-
46
-
47
- def self.from_file( path, more_attribs={} )
48
- ## note: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
49
- ## - see textutils/utils.rb
50
- text = File.read_utf8( path )
51
- self.from_string( text, more_attribs )
52
- end
53
-
54
- def self.from_string( text, more_attribs={} )
55
- CityReader.new( text, more_attribs )
56
- end
57
-
58
-
59
- def skip_tags?() @skip_tags == true; end
60
- def strict?() @strict == true; end
61
-
62
- def initialize( text, more_attribs={} )
63
- ## todo/fix: how to add opts={} ???
64
-
65
- @text = text
66
- @more_attribs = more_attribs
67
- end
68
-
69
-
70
- def read()
71
- reader = ValuesReader.from_string( @text, @more_attribs )
72
-
73
- reader.each_line do |attribs, values|
74
- opts = { skip_tags: skip_tags? }
75
- City.create_or_update_from_attribs( attribs, values, opts )
76
- end
77
- end
78
-
79
- end # class CityReader
80
- end # module WorldDb
81
-
@@ -1,78 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module WorldDb
4
-
5
- class CountryReader
6
-
7
- include LogUtils::Logging
8
-
9
- ## make models available by default with namespace
10
- # e.g. lets you use Usage instead of Model::Usage
11
- include Models
12
-
13
- ## value helpers e.g. is_year?, is_taglist? etc.
14
- include TextUtils::ValueHelper
15
-
16
-
17
- def self.from_zip( zip_file, entry_path, more_attribs={} )
18
- ## get text content from zip
19
-
20
- entry = zip_file.find_entry( entry_path )
21
-
22
- ## todo/fix: add force encoding to utf-8 ??
23
- ## check!!!
24
- ## clean/prepprocess lines
25
- ## e.g. CR/LF (/r/n) to LF (e.g. /n)
26
- text = entry.get_input_stream().read()
27
-
28
- ## NOTE: needs logger ref; only available in instance methods; use global logger for now
29
- logger = LogUtils::Logger.root
30
- logger.debug "text.encoding.name (before): #{text.encoding.name}"
31
- #####
32
- # NB: ASCII-8BIT == BINARY == Encoding Unknown; Raw Bytes Here
33
- ## NB:
34
- # for now "hardcoded" to utf8 - what else can we do?
35
- # - note: force_encoding will NOT change the chars only change the assumed encoding w/o translation
36
- text = text.force_encoding( Encoding::UTF_8 )
37
- logger.debug "text.encoding.name (after): #{text.encoding.name}"
38
-
39
- ## todo:
40
- # NB: for convenience: convert fancy unicode dashes/hyphens to plain ascii hyphen-minus
41
- ## text = TextUtils.convert_unicode_dashes_to_plain_ascii( text, path: path )
42
-
43
- self.from_string( text, more_attribs )
44
- end
45
-
46
- def self.from_file( path, more_attribs={} )
47
- ## note: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
48
- ## - see textutils/utils.rb
49
- text = File.read_utf8( path )
50
- self.from_string( text, more_attribs )
51
- end
52
-
53
- def self.from_string( text, more_attribs={} )
54
- CountryReader.new( text, more_attribs )
55
- end
56
-
57
-
58
- def skip_tags?() @skip_tags == true; end
59
- def strict?() @strict == true; end
60
-
61
- def initialize( text, more_attribs={} )
62
- ## todo/fix: how to add opts={} ???
63
-
64
- @text = text
65
- @more_attribs = more_attribs
66
- end
67
-
68
- def read()
69
- reader = ValuesReader.from_string( @text, @more_attribs )
70
-
71
- reader.each_line do |attribs, values|
72
- opts = { skip_tags: skip_tags? }
73
- Country.create_or_update_from_attribs( attribs, values, opts )
74
- end
75
- end
76
-
77
- end # class CountryReader
78
- end # module WorldDb
@@ -1,107 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module WorldDb
4
-
5
- class LangReader
6
-
7
- include LogUtils::Logging
8
-
9
- ## make models available by default with namespace
10
- # e.g. lets you use Usage instead of Model::Usage
11
- include Models
12
-
13
- ## value helpers e.g. is_year?, is_taglist? etc.
14
- include TextUtils::ValueHelper
15
-
16
-
17
- ## todo: add opts={} etc.
18
- def self.from_zip( zip_file, entry_path )
19
- ## get text content from zip
20
-
21
- entry = zip_file.find_entry( entry_path )
22
-
23
- ## todo/fix: add force encoding to utf-8 ??
24
- ## check!!!
25
- ## clean/prepprocess lines
26
- ## e.g. CR/LF (/r/n) to LF (e.g. /n)
27
- text = entry.get_input_stream().read()
28
-
29
- ## NOTE: needs logger ref; only available in instance methods; use global logger for now
30
- logger = LogUtils::Logger.root
31
- logger.debug "text.encoding.name (before): #{text.encoding.name}"
32
- #####
33
- # NB: ASCII-8BIT == BINARY == Encoding Unknown; Raw Bytes Here
34
- ## NB:
35
- # for now "hardcoded" to utf8 - what else can we do?
36
- # - note: force_encoding will NOT change the chars only change the assumed encoding w/o translation
37
- text = text.force_encoding( Encoding::UTF_8 )
38
- logger.debug "text.encoding.name (after): #{text.encoding.name}"
39
-
40
- ## todo:
41
- # NB: for convenience: convert fancy unicode dashes/hyphens to plain ascii hyphen-minus
42
- ## text = TextUtils.convert_unicode_dashes_to_plain_ascii( text, path: path )
43
-
44
- self.from_string( text )
45
- end
46
-
47
- def self.from_file( path, opts={} )
48
- ## note: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
49
- ## - see textutils/utils.rb
50
- text = File.read_utf8( path )
51
- self.from_string( text, opts )
52
- end
53
-
54
- def self.from_string( text, opts={} )
55
- LangReader.new( text, opts )
56
- end
57
-
58
-
59
- def skip_tags?() @skip_tags == true; end
60
- def strict?() @strict == true; end
61
-
62
- def initialize( text, opts={} )
63
- @text = text
64
-
65
- ## option: do NOT generate/add any tags for countries/regions/cities
66
- @skip_tags = opts[:skip_tags].present? ? true : false
67
- ## option: for now issue warning on update, that is, if key/record (country,region,city) already exists
68
- @strict = opts[:strict].present? ? true : false
69
- end
70
-
71
- def read()
72
- reader = HashReader.from_string( @text )
73
-
74
- reader.each do |key, value|
75
-
76
- ### fix:
77
- ## move to Lang.read() for (re)use
78
-
79
- logger.debug "adding lang >>#{key}<< >>#{value}<<..."
80
-
81
- lang_key = key.strip
82
- lang_title = value.strip
83
-
84
- lang_attribs = {}
85
-
86
- ## check if it exists
87
- lang = Lang.find_by_key( lang_key )
88
- if lang.present?
89
- logger.debug "update lang #{lang.id}-#{lang.key}:"
90
- else
91
- logger.debug "create lang:"
92
- lang = Lang.new
93
- lang_attribs[ :key ] = lang_key
94
- end
95
-
96
- lang_attribs[ :title ] = lang_title
97
-
98
- logger.debug lang_attribs.to_json
99
-
100
- lang.update_attributes!( lang_attribs )
101
- end # each key,value
102
-
103
- end # method load_langs
104
-
105
-
106
- end # class LangReader
107
- end # module WorldDb
@@ -1,79 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module WorldDb
4
-
5
- class RegionReader
6
-
7
- include LogUtils::Logging
8
-
9
- ## make models available by default with namespace
10
- # e.g. lets you use Usage instead of Model::Usage
11
- include Models
12
-
13
- ## value helpers e.g. is_year?, is_taglist? etc.
14
- include TextUtils::ValueHelper
15
-
16
-
17
- def self.from_zip( zip_file, entry_path, more_attribs={} )
18
- ## get text content from zip
19
-
20
- entry = zip_file.find_entry( entry_path )
21
-
22
- ## todo/fix: add force encoding to utf-8 ??
23
- ## check!!!
24
- ## clean/prepprocess lines
25
- ## e.g. CR/LF (/r/n) to LF (e.g. /n)
26
- text = entry.get_input_stream().read()
27
-
28
- ## NOTE: needs logger ref; only available in instance methods; use global logger for now
29
- logger = LogUtils::Logger.root
30
- logger.debug "text.encoding.name (before): #{text.encoding.name}"
31
- #####
32
- # NB: ASCII-8BIT == BINARY == Encoding Unknown; Raw Bytes Here
33
- ## NB:
34
- # for now "hardcoded" to utf8 - what else can we do?
35
- # - note: force_encoding will NOT change the chars only change the assumed encoding w/o translation
36
- text = text.force_encoding( Encoding::UTF_8 )
37
- logger.debug "text.encoding.name (after): #{text.encoding.name}"
38
-
39
- ## todo:
40
- # NB: for convenience: convert fancy unicode dashes/hyphens to plain ascii hyphen-minus
41
- ## text = TextUtils.convert_unicode_dashes_to_plain_ascii( text, path: path )
42
-
43
- self.from_string( text, more_attribs )
44
- end
45
-
46
- def self.from_file( path, more_attribs={} )
47
- ## note: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
48
- ## - see textutils/utils.rb
49
- text = File.read_utf8( path )
50
- self.from_string( text, more_attribs )
51
- end
52
-
53
- def self.from_string( text, more_attribs={} )
54
- RegionReader.new( text, more_attribs )
55
- end
56
-
57
-
58
- def skip_tags?() @skip_tags == true; end
59
- def strict?() @strict == true; end
60
-
61
- def initialize( text, more_attribs={} )
62
- ## todo/fix: how to add opts={} ???
63
-
64
- @text = text
65
- @more_attribs = more_attribs
66
- end
67
-
68
-
69
- def read()
70
- reader = ValuesReader.from_string( @text, @more_attribs )
71
-
72
- reader.each_line do |attribs, values|
73
- opts = { skip_tags: skip_tags? }
74
- Region.create_or_update_from_attribs( attribs, values, opts )
75
- end
76
- end
77
-
78
- end # class RegionReader
79
- end # module WorldDb
@@ -1,98 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- module WorldDb
4
-
5
- class UsageReader
6
-
7
- include LogUtils::Logging
8
-
9
- ## make models available by default with namespace
10
- # e.g. lets you use Usage instead of Model::Usage
11
- include Models
12
-
13
- ## value helpers e.g. is_year?, is_taglist? etc.
14
- include TextUtils::ValueHelper
15
-
16
- ## todo: add opts
17
- def self.from_zip( zip_file, entry_path )
18
- ## get text content from zip
19
-
20
- entry = zip_file.find_entry( entry_path )
21
-
22
- ## todo/fix: add force encoding to utf-8 ??
23
- ## check!!!
24
- ## clean/prepprocess lines
25
- ## e.g. CR/LF (/r/n) to LF (e.g. /n)
26
- text = entry.get_input_stream().read()
27
-
28
- ## NOTE: needs logger ref; only available in instance methods; use global logger for now
29
- logger = LogUtils::Logger.root
30
- logger.debug "text.encoding.name (before): #{text.encoding.name}"
31
- #####
32
- # NB: ASCII-8BIT == BINARY == Encoding Unknown; Raw Bytes Here
33
- ## NB:
34
- # for now "hardcoded" to utf8 - what else can we do?
35
- # - note: force_encoding will NOT change the chars only change the assumed encoding w/o translation
36
- text = text.force_encoding( Encoding::UTF_8 )
37
- logger.debug "text.encoding.name (after): #{text.encoding.name}"
38
-
39
- ## todo:
40
- # NB: for convenience: convert fancy unicode dashes/hyphens to plain ascii hyphen-minus
41
- ## text = TextUtils.convert_unicode_dashes_to_plain_ascii( text, path: path )
42
-
43
- self.from_string( text )
44
- end
45
-
46
- def self.from_file( path, opts={} )
47
- ## note: assume/enfore utf-8 encoding (with or without BOM - byte order mark)
48
- ## - see textutils/utils.rb
49
- text = File.read_utf8( path )
50
- self.from_string( text, opts )
51
- end
52
-
53
- def self.from_string( text, opts={} )
54
- UsageReader.new( text, opts )
55
- end
56
-
57
-
58
- def skip_tags?() @skip_tags == true; end
59
- def strict?() @strict == true; end
60
-
61
- def initialize( text, opts={} )
62
- @text = text
63
-
64
- ## option: do NOT generate/add any tags for countries/regions/cities
65
- @skip_tags = opts[:skip_tags].present? ? true : false
66
- ## option: for now issue warning on update, that is, if key/record (country,region,city) already exists
67
- @strict = opts[:strict].present? ? true : false
68
- end
69
-
70
- def read()
71
- reader = HashReader.from_string( @text )
72
-
73
- reader.each do |key, value|
74
-
75
- ### fix:
76
- ## move to Usage.read() for (re)use
77
-
78
- logger.debug " adding langs >>#{value}<<to country >>#{key}<<"
79
-
80
- country = Country.find_by_key!( key )
81
-
82
- lang_keys = value.split(',')
83
- lang_keys.each do |lang_key|
84
-
85
- ### remove (optional comment) from key (e.g. carribean (islands))
86
- lang_key = lang_key.gsub( /\(.+\)/, '' )
87
- ## remove leading n trailing space
88
- lang_key = lang_key.strip
89
-
90
- lang = Lang.find_by_key!( lang_key )
91
- Usage.create!( country_id: country.id, lang_id: lang.id, official: true, minor: false )
92
- end
93
- end
94
- end
95
-
96
-
97
- end # class UsageReader
98
- end # module WorldDb
@@ -1,202 +0,0 @@
1
-
2
- module WorldDb
3
-
4
- class CreateDb
5
-
6
- def up
7
-
8
- ActiveRecord::Schema.define do
9
-
10
- create_table :places do |t|
11
- t.string :name, null: false
12
- t.string :kind, null: false # -- kind/feature (note: type reserved for activerecord sti)
13
- #####
14
- # continent:
15
- # CONT - continent (use CNTI or CENT why??)
16
- # country:
17
- # SUPR - supra (e.g. European Union)
18
- # CNTY - country
19
- # TERR - terr
20
- # region:
21
- # ADM1 - e.g. region/state/province
22
- # ADM2 - e.g. county/district/
23
- # ADM3 - e.g.
24
- # city:
25
- # MTRO - metro
26
- # CITY - city/town/
27
- # DIST - district/
28
- #
29
- # add new table for zones (e.g. informal regions e.g. tourism, wine regions, etc.) ??
30
- # why? why not??
31
-
32
-
33
- t.float :lat # optional for now (latitude)
34
- t.float :lng # optional for now (longitude)
35
-
36
- ## todo: add parent for hierachy ?? or keep it in country/region/city etc. table ??
37
-
38
- ## timestamp at last
39
- t.timestamps
40
- end
41
-
42
-
43
- #############
44
- # todo: use many-to-many assoc w/ join table for name and place ???
45
- # why? why not?
46
- # - wien -> city n region n metro ? collect more samples of names used more than once
47
-
48
- ### alternative names for places
49
- create_table :names do |t|
50
- t.string :name, null: false
51
- t.references :place, null: false
52
- ### todo/fix: add lang_id to reference lang from lang table!!! (for now make it a duplicate; e.g. keep stirng lang for now)
53
- t.string :lang, null: false, default: 'en' # default to english for now (or use unknown/undeterminded/unspecified???)
54
-
55
- ## todo: add kind/type ? e.g. postal for postal code ??
56
- ## or wikipedia for wikipedia? or use separate table ?? (linkable/links) etc.??
57
-
58
- ## timestamp at last
59
- t.timestamps
60
- end
61
-
62
-
63
-
64
- create_table :continents do |t|
65
- t.string :name, null: false
66
- t.string :slug, null: false # auto-generate default
67
- t.string :key, null: false
68
- t.references :place, null: false
69
- t.string :alt_names # comma separated list of alternate names (synonyms)
70
-
71
- ## timestamp at last
72
- t.timestamps
73
- end
74
-
75
- add_index :continents, :key, unique: true
76
-
77
-
78
- create_table :country_codes do |t|
79
- t.string :name, null: false
80
- t.string :kind, null: false # e.g. ALPHA2,NUM,FIFA,IOC,FIPS,NET,etc.
81
- t.references :country, null: false
82
- end
83
-
84
- add_index :country_codes, [:name, :kind], unique: true
85
-
86
-
87
- create_table :countries do |t|
88
- t.string :name, null: false
89
- t.string :slug, null: false # auto-generate default
90
- t.string :key, null: false
91
- t.references :place, null: false
92
- t.string :code, null: false # short three letter code (FIFA country code e.g. ITA)
93
- t.string :alt_names # comma separated list of alternate names (synonyms)
94
- t.string :hist_names # comma separated list of historic names (no longer in use)
95
- t.integer :pop, null: false # population count
96
- t.integer :area, null: false # area in square km (sq. km)
97
- t.references :continent
98
- t.references :country # for supra(nationals) n depend(encies)
99
-
100
- ## flags (use single int named flags - why? why not?
101
- t.boolean :s, null: false, default: false # supra(national) flag e.g. eu
102
- t.boolean :c, null: false, default: false # country flag (is this needed?)
103
- t.boolean :d, null: false, default: false # dependency flag
104
-
105
- t.boolean :m, null: false, default: false # misc(ellaneous) flag
106
- # misc use for territories w/ shared or disputed claims
107
- # e.g. Antartica/Western Sahara/Paracel Islands/Spratly Islands/etc.
108
-
109
- # extras - country codes
110
- t.string :motor # optional motor (vehicle) licene plate code (bumper sticker)
111
- t.string :alpha2 # optional iso two letter country code
112
- t.string :alpha3 # optional iso three letter country code
113
- t.string :num # optional iso numeric country code - NOTE: same numeric code as string!!! e.g. 043 etc.
114
- t.string :fifa # optional fifa country code
115
- t.string :ioc
116
- t.string :fips
117
- t.string :net # optional internet top level domain (tld)
118
-
119
- t.string :wikipedia # optional wikipedia page name -- en.wikipedia.org/wiki/<name>
120
-
121
- ## timestamp at last
122
- t.timestamps
123
- end
124
-
125
-
126
- add_index :countries, :key, unique: true
127
- add_index :countries, :code, unique: true
128
-
129
-
130
- ######
131
- # NB: rename to adms/admins ??
132
- #
133
- # used for state/provice/land/regioni/etc.
134
- create_table :regions do |t|
135
- t.string :name, null: false
136
- t.string :key, null: false
137
- t.references :place, null: false
138
- t.string :code # short two or three letter code e.g. NY, OAX, etc.
139
- t.string :abbr # optional conventional abbrevation (e.g. Stmk., Gto., etc.)
140
- t.string :iso # iso code
141
- t.string :nuts # nuts code (europe/eu only)
142
- t.string :alt_names # comma separated list of alternate names (synonyms)
143
- t.references :country, null: false
144
- t.integer :pop # optional population count
145
- t.integer :area # optional area in square km (sq. km)
146
- t.timestamps
147
- end
148
-
149
- add_index :regions, [:key, :country_id], unique: true
150
-
151
-
152
- create_table :cities do |t|
153
- t.string :name, null: false
154
- t.string :key, null: false
155
- t.references :place, null: false
156
- t.string :code # short three letter code (ITAT/airport code e.g. NYC or VIE)
157
- t.string :alt_names # comma separated list of alternate names (synonyms)
158
- t.references :country, null: false
159
- t.references :region # optional for now
160
- t.references :city # optional parent (e.g. metro for city, or city for district)
161
- t.integer :pop # optional population count (city proper)
162
- t.integer :popm # optional population count (metropolitan/aglomeration)
163
- t.integer :area # optional area in square km (sq. km)
164
-
165
- ## t.float :lat # optional for now -- FIX: remove?? moved to places
166
- ## t.float :lng # optional for now -- FIX: remove?? moved to places
167
-
168
- ## flags (use single int named flags - why? why not?
169
- t.boolean :m, null: false, default: false # metro flag
170
- t.boolean :c, null: false, default: false # city flag (is this needed?)
171
- t.boolean :d, null: false, default: false # district flag
172
-
173
- ### t.boolean :capital, null: false, default: false # is national captial?
174
-
175
- t.timestamps
176
- end
177
-
178
-
179
- create_table :langs do |t| # langs == languages (e.g. en/English, de/Deutsch, etc.)
180
- t.string :key, null: false
181
- t.string :name, null: false
182
- t.timestamps
183
- end
184
-
185
-
186
- create_table :usages do |t| # join table for countries_langs
187
- t.references :country, null: false
188
- t.references :lang, null: false
189
- t.boolean :official, null: false, default: true # is_official language in country
190
- t.boolean :minor, null: false, default: false # spoken by minority
191
- t.float :percent # usage in percent e.g. 90.0, 0.55, etc.
192
- t.timestamps
193
- end
194
-
195
- end # block Schema.define
196
-
197
- end # method up
198
-
199
-
200
- end # class CreateDb
201
-
202
- end # module WorldDb