worlddb 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/worlddb/models/city.rb +30 -39
- data/lib/worlddb/models/country.rb +23 -23
- data/lib/worlddb/models/region.rb +10 -9
- data/lib/worlddb/version.rb +1 -1
- metadata +11 -11
data/lib/worlddb/models/city.rb
CHANGED
@@ -110,47 +110,38 @@ class City < ActiveRecord::Base
|
|
110
110
|
new_attributes[ :c ] = true # assume city type by default (use metro,district to change in fixture)
|
111
111
|
|
112
112
|
## check for optional values
|
113
|
-
|
114
|
-
### fix: todo: use matcher from ValueHelper !!!!!
|
115
113
|
|
116
114
|
values.each_with_index do |value,index|
|
117
|
-
if value
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
elsif value
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
new_attributes[ :region_id ] = value_region.id
|
147
|
-
elsif value =~ /^[A-Z]{2,3}$/ ## assume two or three-letter code
|
115
|
+
if match_region_for_country( value, new_attributes[:country_id] ) do |region|
|
116
|
+
new_attributes[ :region_id ] = region.id
|
117
|
+
end
|
118
|
+
elsif match_country( value ) do |country|
|
119
|
+
new_attributes[ :country_id ] = country.id
|
120
|
+
end
|
121
|
+
elsif match_metro( value ) do |city|
|
122
|
+
new_attributes[ :city_id ] = city.id
|
123
|
+
end
|
124
|
+
elsif match_metro_pop( value ) do |num| # m:
|
125
|
+
new_attributes[ :popm ] = num
|
126
|
+
new_attributes[ :m ] = true # auto-mark city as m|metro too
|
127
|
+
end
|
128
|
+
elsif match_metro_flag( value ) do |_| # metro(politan area)
|
129
|
+
new_attributes[ :c ] = false # turn off default c|city flag; make it m|metro only
|
130
|
+
new_attributes[ :m ] = true
|
131
|
+
end
|
132
|
+
elsif match_city( value ) do |city| # parent city for district
|
133
|
+
new_attributes[ :city_id ] = city.id
|
134
|
+
new_attributes[ :c ] = false # turn off default c|city flag; make it d|district only
|
135
|
+
new_attributes[ :d ] = true
|
136
|
+
end
|
137
|
+
elsif match_km_squared( value ) do |num| # allow numbers like 453 km²
|
138
|
+
value_numbers << num
|
139
|
+
end
|
140
|
+
elsif match_number( value ) do |num| # numeric (nb: can use any _ or spaces inside digits e.g. 1_000_000 or 1 000 000)
|
141
|
+
value_numbers << num
|
142
|
+
end
|
143
|
+
elsif value =~ /^[A-Z]{3}$/ ## assume three-letter code
|
148
144
|
new_attributes[ :code ] = value
|
149
|
-
elsif value =~ /^([0-9][0-9 _]+[0-9]|[0-9]{1,2})(?:\s*(?:km2|km²)\s*)$/
|
150
|
-
## allow numbers like 453 km²
|
151
|
-
value_numbers << value.gsub( 'km2', '').gsub( 'km²', '' ).gsub(/[ _]/, '').to_i
|
152
|
-
elsif value =~ /^([0-9][0-9 _]+[0-9])|([0-9]{1,2})$/ ## numeric (nb: can use any _ or spaces inside digits e.g. 1_000_000 or 1 000 000)
|
153
|
-
value_numbers << value.gsub(/[ _]/, '').to_i
|
154
145
|
elsif (values.size==(index+1)) && is_taglist?( value ) # tags must be last entry
|
155
146
|
logger.debug " found tags: >>#{value}<<"
|
156
147
|
value_tag_keys += find_tags( value )
|
@@ -163,7 +154,7 @@ class City < ActiveRecord::Base
|
|
163
154
|
if value_numbers.size > 0
|
164
155
|
new_attributes[ :pop ] = value_numbers[0] # assume first number is pop for cities
|
165
156
|
new_attributes[ :area ] = value_numbers[1]
|
166
|
-
end
|
157
|
+
end
|
167
158
|
|
168
159
|
rec = City.find_by_key( new_attributes[ :key ] )
|
169
160
|
|
@@ -92,33 +92,33 @@ class Country < ActiveRecord::Base
|
|
92
92
|
|
93
93
|
|
94
94
|
new_attributes[ :c ] = true # assume country type by default (use supra,depend to change)
|
95
|
-
|
95
|
+
|
96
96
|
## check for optional values
|
97
97
|
values.each_with_index do |value,index|
|
98
|
-
if value
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
elsif value
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
98
|
+
if match_supra_flag( value ) do |_| # supra(national)
|
99
|
+
new_attributes[ :c ] = false # turn off default c|country flag; make it s|supra only
|
100
|
+
new_attributes[ :s ] = true
|
101
|
+
## auto-add tag supra
|
102
|
+
value_tag_keys << 'supra'
|
103
|
+
end
|
104
|
+
elsif match_supra( value ) do |country| # supra:
|
105
|
+
new_attributes[ :country_id ] = country.id
|
106
|
+
end
|
107
|
+
elsif match_country( value ) do |country| # country:
|
108
|
+
new_attributes[ :country_id ] = country.id
|
109
|
+
new_attributes[ :c ] = false # turn off default c|country flag; make it d|depend only
|
110
|
+
new_attributes[ :d ] = true
|
111
|
+
## auto-add tag supra
|
112
|
+
value_tag_keys << 'territory' # rename tag to dependency? why? why not?
|
113
|
+
end
|
114
|
+
elsif match_km_squared( value ) do |num| # allow numbers like 453 km²
|
115
|
+
value_numbers << num
|
116
|
+
end
|
117
|
+
elsif match_number( value ) do |num| # numeric (nb: can use any _ or spaces inside digits e.g. 1_000_000 or 1 000 000)
|
118
|
+
value_numbers << num
|
119
|
+
end
|
115
120
|
elsif value =~ /^[A-Z]{2,3}$/ ## assume two or three-letter code
|
116
121
|
new_attributes[ :code ] = value
|
117
|
-
elsif value =~ /^([0-9][0-9 _]+[0-9]|[0-9]{1,2})(?:\s*(?:km2|km²)\s*)$/
|
118
|
-
## allow numbers like 453 km²
|
119
|
-
value_numbers << value.gsub( 'km2', '').gsub( 'km²', '' ).gsub(/[ _]/, '').to_i
|
120
|
-
elsif value =~ /^([0-9][0-9 _]+[0-9])|([0-9]{1,2})$/ ## numeric (nb: can use any _ or spaces inside digits e.g. 1_000_000 or 1 000 000)
|
121
|
-
value_numbers << value.gsub(/[ _]/, '').to_i
|
122
122
|
elsif (values.size==(index+1)) && is_taglist?( value ) # tags must be last entry
|
123
123
|
logger.debug " found tags: >>#{value}<<"
|
124
124
|
value_tag_keys += find_tags( value )
|
@@ -61,17 +61,17 @@ class Region < ActiveRecord::Base
|
|
61
61
|
|
62
62
|
## check for optional values
|
63
63
|
values.each_with_index do |value,index|
|
64
|
-
if value
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
if match_country( value ) do |country| # country:
|
65
|
+
new_attributes[ :country_id ] = country.id
|
66
|
+
end
|
67
|
+
elsif match_km_squared( value ) do |num| # allow numbers like 453 km²
|
68
|
+
value_numbers << num
|
69
|
+
end
|
70
|
+
elsif match_number( value ) do |num| # numeric (nb: can use any _ or spaces inside digits e.g. 1_000_000 or 1 000 000)
|
71
|
+
value_numbers << num
|
72
|
+
end
|
68
73
|
elsif value =~ /^[A-Z]{2,3}$/ ## assume two or three-letter code
|
69
74
|
new_attributes[ :code ] = value
|
70
|
-
elsif value =~ /^([0-9][0-9 _]+[0-9]|[0-9]{1,2})(?:\s*(?:km2|km²)\s*)$/
|
71
|
-
## allow numbers like 453 km²
|
72
|
-
value_numbers << value.gsub( 'km2', '').gsub( 'km²', '' ).gsub(/[ _]/, '').to_i
|
73
|
-
elsif value =~ /^([0-9][0-9 _]+[0-9])|([0-9]{1,2})$/ ## numeric (nb: can use any _ or spaces inside digits e.g. 1_000_000 or 1 000 000)
|
74
|
-
value_numbers << value.gsub(/[ _]/, '').to_i
|
75
75
|
elsif (values.size==(index+1)) && is_taglist?( value ) # tags must be last entry
|
76
76
|
logger.debug " found tags: >>#{value}<<"
|
77
77
|
value_tag_keys += find_tags( value )
|
@@ -113,6 +113,7 @@ class Region < ActiveRecord::Base
|
|
113
113
|
country_id: rec.country_id )
|
114
114
|
|
115
115
|
### todo/fix: add captial ref to country/region
|
116
|
+
## todo/fix: use update_from_title and only allow one capital city
|
116
117
|
|
117
118
|
|
118
119
|
##################
|
data/lib/worlddb/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: worlddb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-05-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: textutils
|
16
|
-
requirement: &
|
16
|
+
requirement: &78717170 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.6'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *78717170
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: commander
|
27
|
-
requirement: &
|
27
|
+
requirement: &78716950 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 4.1.3
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *78716950
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: activerecord
|
38
|
-
requirement: &
|
38
|
+
requirement: &78716740 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.2'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *78716740
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rdoc
|
49
|
-
requirement: &
|
49
|
+
requirement: &78716520 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '3.10'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *78716520
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: hoe
|
60
|
-
requirement: &
|
60
|
+
requirement: &78716300 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: '3.3'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *78716300
|
69
69
|
description: worlddb - world.db command line tool
|
70
70
|
email: opensport@googlegroups.com
|
71
71
|
executables:
|