uncharted 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/.project +18 -0
- data/.yardoc/checksums +6 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +21 -0
- data/README.md +60 -0
- data/Rakefile +12 -0
- data/doc/.yardoc/checksums +0 -0
- data/doc/.yardoc/objects/root.dat +0 -0
- data/doc/.yardoc/proxy_types +0 -0
- data/doc/Uncharted/Country/Field.html +233 -0
- data/doc/Uncharted/Country.html +888 -0
- data/doc/Uncharted/Territory/Field.html +233 -0
- data/doc/Uncharted/Territory.html +809 -0
- data/doc/Uncharted.html +108 -0
- data/doc/_index.html +158 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +53 -0
- data/doc/css/style.css +320 -0
- data/doc/doc/_index.html +84 -0
- data/doc/doc/class_list.html +47 -0
- data/doc/doc/css/common.css +1 -0
- data/doc/doc/css/full_list.css +53 -0
- data/doc/doc/css/style.css +320 -0
- data/doc/doc/file_list.html +46 -0
- data/doc/doc/frames.html +13 -0
- data/doc/doc/index.html +84 -0
- data/doc/doc/js/app.js +205 -0
- data/doc/doc/js/full_list.js +150 -0
- data/doc/doc/js/jquery.js +16 -0
- data/doc/doc/method_list.html +46 -0
- data/doc/doc/top-level-namespace.html +93 -0
- data/doc/file.README.html +122 -0
- data/doc/file_list.html +49 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +122 -0
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +150 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +262 -0
- data/doc/top-level-namespace.html +120 -0
- data/lib/uncharted/adapters/mongoid.rb +35 -0
- data/lib/uncharted/country.rb +32 -0
- data/lib/uncharted/data/br.rb +33 -0
- data/lib/uncharted/data/countries.rb +256 -0
- data/lib/uncharted/territory.rb +58 -0
- data/lib/uncharted.rb +12 -0
- data/lib/version.rb +4 -0
- data/test/country_test.rb +40 -0
- data/test/mongoid_test.rb +17 -0
- data/test/test_helper.rb +5 -0
- data/test/uncharted_test.rb +8 -0
- data/uncharted.gemspec +28 -0
- metadata +139 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module Uncharted
|
|
4
|
+
|
|
5
|
+
class Country
|
|
6
|
+
|
|
7
|
+
class Field
|
|
8
|
+
include Mongoid::Fields::Serializable if defined? Mongoid
|
|
9
|
+
|
|
10
|
+
def deserialize(alpha2)
|
|
11
|
+
alpha2 && Uncharted::Country.find(alpha2)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def serialize(country)
|
|
15
|
+
country && country.alpha2
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class Territory
|
|
21
|
+
|
|
22
|
+
class Field
|
|
23
|
+
include Mongoid::Fields::Serializable if defined? Mongoid
|
|
24
|
+
|
|
25
|
+
def deserialize(code)
|
|
26
|
+
code && Uncharted::Territory.find(code)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def serialize(territory)
|
|
30
|
+
territory && territory.code
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Uncharted
|
|
2
|
+
|
|
3
|
+
class Country
|
|
4
|
+
|
|
5
|
+
attr_reader :alpha2, :alpha3, :name
|
|
6
|
+
|
|
7
|
+
def initialize(alpha2, alpha3 = nil, name = nil)
|
|
8
|
+
@alpha2 = alpha2
|
|
9
|
+
@alpha3 = alpha3
|
|
10
|
+
@name = name
|
|
11
|
+
self.class.countries[alpha2] = self
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def to_s
|
|
15
|
+
@alpha2
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.count
|
|
19
|
+
countries.count
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.find(code)
|
|
23
|
+
countries[code]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.countries
|
|
27
|
+
@countries ||= {}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'uncharted/territory'
|
|
4
|
+
|
|
5
|
+
module Uncharted
|
|
6
|
+
Territory.new('BR-AC', :state, 'Acre')
|
|
7
|
+
Territory.new('BR-AL', :state, 'Alagoas')
|
|
8
|
+
Territory.new('BR-AP', :state, 'Amapá')
|
|
9
|
+
Territory.new('BR-AM', :state, 'Amazonas')
|
|
10
|
+
Territory.new('BR-BA', :state, 'Bahia')
|
|
11
|
+
Territory.new('BR-CE', :state, 'Ceará')
|
|
12
|
+
Territory.new('BR-DF', :district, 'Distrito Federal')
|
|
13
|
+
Territory.new('BR-ES', :state, 'Espírito Santo')
|
|
14
|
+
Territory.new('BR-GO', :state, 'Goiás')
|
|
15
|
+
Territory.new('BR-MA', :state, 'Maranhão')
|
|
16
|
+
Territory.new('BR-MT', :state, 'Mato Grosso')
|
|
17
|
+
Territory.new('BR-MS', :state, 'Mato Grosso do Sul')
|
|
18
|
+
Territory.new('BR-MG', :state, 'Minas Gerais')
|
|
19
|
+
Territory.new('BR-PR', :state, 'Paraná')
|
|
20
|
+
Territory.new('BR-PB', :state, 'Paraíba')
|
|
21
|
+
Territory.new('BR-PA', :state, 'Pará')
|
|
22
|
+
Territory.new('BR-PE', :state, 'Pernambuco')
|
|
23
|
+
Territory.new('BR-PI', :state, 'Piauí')
|
|
24
|
+
Territory.new('BR-RJ', :state, 'Rio de Janeiro')
|
|
25
|
+
Territory.new('BR-RN', :state, 'Rio Grande do Norte')
|
|
26
|
+
Territory.new('BR-RS', :state, 'Rio Grande do Sul')
|
|
27
|
+
Territory.new('BR-RO', :state, 'Rondônia')
|
|
28
|
+
Territory.new('BR-RR', :state, 'Roraima')
|
|
29
|
+
Territory.new('BR-SC', :state, 'Santa Catarina')
|
|
30
|
+
Territory.new('BR-SE', :state, 'Sergipe')
|
|
31
|
+
Territory.new('BR-SP', :state, 'São Paulo')
|
|
32
|
+
Territory.new('BR-TO', :state, 'Tocantins')
|
|
33
|
+
end
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'uncharted/country'
|
|
4
|
+
|
|
5
|
+
module Uncharted
|
|
6
|
+
|
|
7
|
+
Country.new('AC', 'ASC', 'Ascension')
|
|
8
|
+
Country.new('AD', 'AND', 'Andorra')
|
|
9
|
+
Country.new('AE', 'ARE', 'United Arab Emirates')
|
|
10
|
+
Country.new('AF', 'AFG', 'Afghanistan')
|
|
11
|
+
Country.new('AG', 'ATG', 'Antigua and Barbuda')
|
|
12
|
+
Country.new('AI', 'AIA', 'Anguilla')
|
|
13
|
+
Country.new('AL', 'ALB', 'Albania')
|
|
14
|
+
Country.new('AM', 'ARM', 'Armenia')
|
|
15
|
+
Country.new('AN', 'ANT', 'Netherlands Antilles')
|
|
16
|
+
Country.new('AO', 'AGO', 'Angola')
|
|
17
|
+
Country.new('AQ', 'ATA', 'Antarctica')
|
|
18
|
+
Country.new('AR', 'ARG', 'Argentina')
|
|
19
|
+
Country.new('AS', 'ASM', 'American Samoa')
|
|
20
|
+
Country.new('AT', 'AUT', 'Austria')
|
|
21
|
+
Country.new('AU', 'AUS', 'Australia')
|
|
22
|
+
Country.new('AW', 'ABW', 'Aruba')
|
|
23
|
+
Country.new('AX', 'ALA', 'Aland')
|
|
24
|
+
Country.new('AZ', 'AZE', 'Azerbaijan')
|
|
25
|
+
Country.new('BA', 'BIH', 'Bosnia and Herzegovina')
|
|
26
|
+
Country.new('BB', 'BRB', 'Barbados')
|
|
27
|
+
Country.new('BD', 'BGD', 'Bangladesh')
|
|
28
|
+
Country.new('BE', 'BEL', 'Belgium')
|
|
29
|
+
Country.new('BF', 'BFA', 'Burkina Faso')
|
|
30
|
+
Country.new('BG', 'BGR', 'Bulgaria')
|
|
31
|
+
Country.new('BH', 'BHR', 'Bahrain')
|
|
32
|
+
Country.new('BI', 'BDI', 'Burundi')
|
|
33
|
+
Country.new('BJ', 'BEN', 'Benin')
|
|
34
|
+
Country.new('BM', 'BMU', 'Bermuda')
|
|
35
|
+
Country.new('BN', 'BRN', 'Brunei')
|
|
36
|
+
Country.new('BO', 'BOL', 'Bolivia')
|
|
37
|
+
Country.new('BR', 'BRA', 'Brazil')
|
|
38
|
+
Country.new('BS', 'BHS', 'Bahamas, The')
|
|
39
|
+
Country.new('BT', 'BTN', 'Bhutan')
|
|
40
|
+
Country.new('BV', 'BVT', 'Bouvet Island')
|
|
41
|
+
Country.new('BW', 'BWA', 'Botswana')
|
|
42
|
+
Country.new('BY', 'BLR', 'Belarus')
|
|
43
|
+
Country.new('BZ', 'BLZ', 'Belize')
|
|
44
|
+
Country.new('CA', 'CAN', 'Canada')
|
|
45
|
+
Country.new('CC', 'CCK', 'Cocos Islands')
|
|
46
|
+
Country.new('CD', 'COD', 'Congo DR')
|
|
47
|
+
Country.new('CF', 'CAF', 'Central Africa Republic')
|
|
48
|
+
Country.new('CG', 'COG', 'Congo-Brazzaville')
|
|
49
|
+
Country.new('CH', 'CHE', 'Switzerland')
|
|
50
|
+
Country.new('CI', 'CIV', 'Ivory Coast')
|
|
51
|
+
Country.new('CK', 'COK', 'Cook Islands')
|
|
52
|
+
Country.new('CL', 'CHL', 'Chile')
|
|
53
|
+
Country.new('CM', 'CMR', 'Cameroon')
|
|
54
|
+
Country.new('CN', 'CHN', 'China')
|
|
55
|
+
Country.new('CO', 'COL', 'Colombia')
|
|
56
|
+
Country.new('CR', 'CRI', 'Costa Rica')
|
|
57
|
+
Country.new('CS', 'SCG', 'Kosovo')
|
|
58
|
+
Country.new('CU', 'CUB', 'Cuba')
|
|
59
|
+
Country.new('CV', 'CPV', 'Cape Verde')
|
|
60
|
+
Country.new('CX', 'CXR', 'Christmas Island')
|
|
61
|
+
Country.new('CY', 'CYP', 'Cyprus')
|
|
62
|
+
Country.new('CZ', 'CZE', 'Czech Republic')
|
|
63
|
+
Country.new('DE', 'DEU', 'Germany')
|
|
64
|
+
Country.new('DJ', 'DJI', 'Djibouti')
|
|
65
|
+
Country.new('DK', 'DNK', 'Denmark')
|
|
66
|
+
Country.new('DM', 'DMA', 'Dominica')
|
|
67
|
+
Country.new('DO', 'DOM', 'Dominican Republic')
|
|
68
|
+
Country.new('DZ', 'DZA', 'Algeria')
|
|
69
|
+
Country.new('EC', 'ECU', 'Ecuador')
|
|
70
|
+
Country.new('EE', 'EST', 'Estonia')
|
|
71
|
+
Country.new('EG', 'EGY', 'Egypt')
|
|
72
|
+
Country.new('EH', 'ESH', 'Western Sahara')
|
|
73
|
+
Country.new('ER', 'ERI', 'Eritrea')
|
|
74
|
+
Country.new('ES', 'ESP', 'Spain')
|
|
75
|
+
Country.new('ET', 'ETH', 'Ethiopia')
|
|
76
|
+
Country.new('FI', 'FIN', 'Finland')
|
|
77
|
+
Country.new('FJ', 'FJI', 'Fiji')
|
|
78
|
+
Country.new('FK', 'FLK', 'Falkland Islands')
|
|
79
|
+
Country.new('FM', 'FSM', 'Micronesia')
|
|
80
|
+
Country.new('FO', 'FRO', 'Faroe Islands')
|
|
81
|
+
Country.new('FR', 'FRA', 'France')
|
|
82
|
+
Country.new('GA', 'GAB', 'Gabon')
|
|
83
|
+
Country.new('GB', 'GBR', 'United Kingdom')
|
|
84
|
+
Country.new('GD', 'GRD', 'Grenada')
|
|
85
|
+
Country.new('GE', 'GEO', 'Georgia')
|
|
86
|
+
Country.new('GF', 'GUF', 'French Guiana')
|
|
87
|
+
Country.new('GG', 'GGY', 'Guernsey')
|
|
88
|
+
Country.new('GH', 'GHA', 'Ghana')
|
|
89
|
+
Country.new('GI', 'GIB', 'Gibraltar')
|
|
90
|
+
Country.new('GL', 'GRL', 'Greenland')
|
|
91
|
+
Country.new('GM', 'GMB', 'Gambia, The')
|
|
92
|
+
Country.new('GN', 'GIN', 'Guinea')
|
|
93
|
+
Country.new('GP', 'GLP', 'Guadeloupe')
|
|
94
|
+
Country.new('GQ', 'GNQ', 'Equatorial Guinea')
|
|
95
|
+
Country.new('GR', 'GRC', 'Greece')
|
|
96
|
+
Country.new('GS', 'SGS', 'South Georgia and the South Sandwich Islands')
|
|
97
|
+
Country.new('GT', 'GTM', 'Guatemala')
|
|
98
|
+
Country.new('GU', 'GUM', 'Guam')
|
|
99
|
+
Country.new('GW', 'GNB', 'Guinea-Bissau')
|
|
100
|
+
Country.new('GY', 'GUY', 'Guyana')
|
|
101
|
+
Country.new('HK', 'HKG', 'Hong Kong')
|
|
102
|
+
Country.new('HM', 'HMD', 'Heard Island and McDonald Islands')
|
|
103
|
+
Country.new('HN', 'HND', 'Honduras')
|
|
104
|
+
Country.new('HR', 'HRV', 'Croatia')
|
|
105
|
+
Country.new('HT', 'HTI', 'Haiti')
|
|
106
|
+
Country.new('HU', 'HUN', 'Hungary')
|
|
107
|
+
Country.new('ID', 'IDN', 'Indonesia')
|
|
108
|
+
Country.new('IE', 'IRL', 'Ireland')
|
|
109
|
+
Country.new('IL', 'ISR', 'Israel')
|
|
110
|
+
Country.new('IM', 'IMN', 'Isle of Man')
|
|
111
|
+
Country.new('IN', 'IND', 'India')
|
|
112
|
+
Country.new('IO', 'IOT', 'British Indian Ocean Territory')
|
|
113
|
+
Country.new('IQ', 'IRQ', 'Iraq')
|
|
114
|
+
Country.new('IR', 'IRN', 'Iran')
|
|
115
|
+
Country.new('IS', 'ISL', 'Iceland')
|
|
116
|
+
Country.new('IT', 'ITA', 'Italy')
|
|
117
|
+
Country.new('JE', 'JEY', 'Jersey')
|
|
118
|
+
Country.new('JM', 'JAM', 'Jamaica')
|
|
119
|
+
Country.new('JO', 'JOR', 'Jordan')
|
|
120
|
+
Country.new('JP', 'JPN', 'Japan')
|
|
121
|
+
Country.new('KE', 'KEN', 'Kenya')
|
|
122
|
+
Country.new('KG', 'KGZ', 'Kyrgyzstan')
|
|
123
|
+
Country.new('KH', 'KHM', 'Cambodia')
|
|
124
|
+
Country.new('KI', 'KIR', 'Kiribati')
|
|
125
|
+
Country.new('KM', 'COM', 'Comoros')
|
|
126
|
+
Country.new('KN', 'KNA', 'Saint Kitts and Nevis')
|
|
127
|
+
Country.new('KP', 'PRK', 'North Korea')
|
|
128
|
+
Country.new('KR', 'KOR', 'South Korea')
|
|
129
|
+
Country.new('KW', 'KWT', 'Kuwait')
|
|
130
|
+
Country.new('KY', 'CYM', 'Cayman Islands')
|
|
131
|
+
Country.new('KZ', 'KAZ', 'Kazakhstan')
|
|
132
|
+
Country.new('LA', 'LAO', 'Laos')
|
|
133
|
+
Country.new('LB', 'LBN', 'Lebanon')
|
|
134
|
+
Country.new('LC', 'LCA', 'Saint Lucia')
|
|
135
|
+
Country.new('LI', 'LIE', 'Liechtenstein')
|
|
136
|
+
Country.new('LK', 'LKA', 'Sri Lanka')
|
|
137
|
+
Country.new('LR', 'LBR', 'Liberia')
|
|
138
|
+
Country.new('LS', 'LSO', 'Lesotho')
|
|
139
|
+
Country.new('LT', 'LTU', 'Lithuania')
|
|
140
|
+
Country.new('LU', 'LUX', 'Luxembourg')
|
|
141
|
+
Country.new('LV', 'LVA', 'Latvia')
|
|
142
|
+
Country.new('LY', 'LBY', 'Libya')
|
|
143
|
+
Country.new('MA', 'MAR', 'Morocco')
|
|
144
|
+
Country.new('MC', 'MCO', 'Monaco')
|
|
145
|
+
Country.new('MD', 'MDA', 'Moldova')
|
|
146
|
+
Country.new('ME', 'MNE', 'Montenegro')
|
|
147
|
+
Country.new('MG', 'MDG', 'Madagascar')
|
|
148
|
+
Country.new('MH', 'MHL', 'Marshall Islands')
|
|
149
|
+
Country.new('MK', 'MKD', 'Macedonia')
|
|
150
|
+
Country.new('ML', 'MLI', 'Mali')
|
|
151
|
+
Country.new('MM', 'MMR', 'Myanmar (Burma)')
|
|
152
|
+
Country.new('MN', 'MNG', 'Mongolia')
|
|
153
|
+
Country.new('MO', 'MAC', 'Macau')
|
|
154
|
+
Country.new('MP', 'MNP', 'Northern Mariana Islands')
|
|
155
|
+
Country.new('MQ', 'MTQ', 'Martinique')
|
|
156
|
+
Country.new('MR', 'MRT', 'Mauritania')
|
|
157
|
+
Country.new('MS', 'MSR', 'Montserrat')
|
|
158
|
+
Country.new('MT', 'MLT', 'Malta')
|
|
159
|
+
Country.new('MU', 'MUS', 'Mauritius')
|
|
160
|
+
Country.new('MV', 'MDV', 'Maldives')
|
|
161
|
+
Country.new('MW', 'MWI', 'Malawi')
|
|
162
|
+
Country.new('MX', 'MEX', 'Mexico')
|
|
163
|
+
Country.new('MY', 'MYS', 'Malaysia')
|
|
164
|
+
Country.new('MZ', 'MOZ', 'Mozambique')
|
|
165
|
+
Country.new('NA', 'NAM', 'Namibia')
|
|
166
|
+
Country.new('NC', 'NCL', 'New Caledonia')
|
|
167
|
+
Country.new('NE', 'NER', 'Niger')
|
|
168
|
+
Country.new('NF', 'NFK', 'Norfolk Island')
|
|
169
|
+
Country.new('NG', 'NGA', 'Nigeria')
|
|
170
|
+
Country.new('NI', 'NIC', 'Nicaragua')
|
|
171
|
+
Country.new('NL', 'NLD', 'Netherlands')
|
|
172
|
+
Country.new('NO', 'NOR', 'Norway')
|
|
173
|
+
Country.new('NP', 'NPL', 'Nepal')
|
|
174
|
+
Country.new('NR', 'NRU', 'Nauru')
|
|
175
|
+
Country.new('NU', 'NIU', 'Niue')
|
|
176
|
+
Country.new('NZ', 'NZL', 'New Zealand')
|
|
177
|
+
Country.new('OM', 'OMN', 'Oman')
|
|
178
|
+
Country.new('PA', 'PAN', 'Panama')
|
|
179
|
+
Country.new('PE', 'PER', 'Peru')
|
|
180
|
+
Country.new('PF', 'PYF', 'French Polynesia')
|
|
181
|
+
Country.new('PF', 'PYF', 'Clipperton Island')
|
|
182
|
+
Country.new('PG', 'PNG', 'Papua New Guinea')
|
|
183
|
+
Country.new('PH', 'PHL', 'Philippines')
|
|
184
|
+
Country.new('PK', 'PAK', 'Pakistan')
|
|
185
|
+
Country.new('PL', 'POL', 'Poland')
|
|
186
|
+
Country.new('PM', 'SPM', 'Saint Pierre and Miquelon')
|
|
187
|
+
Country.new('PN', 'PCN', 'Pitcairn Islands')
|
|
188
|
+
Country.new('PR', 'PRI', 'Puerto Rico')
|
|
189
|
+
Country.new('PS', 'PSE', 'Palestinian Territories')
|
|
190
|
+
Country.new('PT', 'PRT', 'Portugal')
|
|
191
|
+
Country.new('PW', 'PLW', 'Palau')
|
|
192
|
+
Country.new('PY', 'PRY', 'Paraguay')
|
|
193
|
+
Country.new('QA', 'QAT', 'Qatar')
|
|
194
|
+
Country.new('RE', 'REU', 'Reunion')
|
|
195
|
+
Country.new('RO', 'ROU', 'Romania')
|
|
196
|
+
Country.new('RS', 'SRB', 'Serbia')
|
|
197
|
+
Country.new('RU', 'RUS', 'Russia')
|
|
198
|
+
Country.new('RW', 'RWA', 'Rwanda')
|
|
199
|
+
Country.new('SA', 'SAU', 'Saudi Arabia')
|
|
200
|
+
Country.new('SB', 'SLB', 'Solomon Islands')
|
|
201
|
+
Country.new('SC', 'SYC', 'Seychelles')
|
|
202
|
+
Country.new('SD', 'SDN', 'Sudan')
|
|
203
|
+
Country.new('SE', 'SWE', 'Sweden')
|
|
204
|
+
Country.new('SG', 'SGP', 'Singapore')
|
|
205
|
+
Country.new('SH', 'SHN', 'Saint Helena')
|
|
206
|
+
Country.new('SI', 'SVN', 'Slovenia')
|
|
207
|
+
Country.new('SJ', 'SJM', 'Svalbard')
|
|
208
|
+
Country.new('SK', 'SVK', 'Slovakia')
|
|
209
|
+
Country.new('SL', 'SLE', 'Sierra Leone')
|
|
210
|
+
Country.new('SM', 'SMR', 'San Marino')
|
|
211
|
+
Country.new('SN', 'SEN', 'Senegal')
|
|
212
|
+
Country.new('SO', 'SOM', 'Somalia')
|
|
213
|
+
Country.new('SR', 'SUR', 'Suriname')
|
|
214
|
+
Country.new('ST', 'STP', 'Sao Tome and Principe')
|
|
215
|
+
Country.new('SV', 'SLV', 'El Salvador')
|
|
216
|
+
Country.new('SY', 'SYR', 'Syria')
|
|
217
|
+
Country.new('SZ', 'SWZ', 'Swaziland')
|
|
218
|
+
Country.new('TA', 'TAA', 'Tristan da Cunha')
|
|
219
|
+
Country.new('TC', 'TCA', 'Turks and Caicos Islands')
|
|
220
|
+
Country.new('TD', 'TCD', 'Chad')
|
|
221
|
+
Country.new('TF', 'ATF', 'French Southern and Antarctic Lands')
|
|
222
|
+
Country.new('TG', 'TGO', 'Togo')
|
|
223
|
+
Country.new('TH', 'THA', 'Thailand')
|
|
224
|
+
Country.new('TJ', 'TJK', 'Tajikistan')
|
|
225
|
+
Country.new('TK', 'TKL', 'Tokelau')
|
|
226
|
+
Country.new('TL', 'TLS', 'East Timor')
|
|
227
|
+
Country.new('TM', 'TKM', 'Turkmenistan')
|
|
228
|
+
Country.new('TN', 'TUN', 'Tunisia')
|
|
229
|
+
Country.new('TO', 'TON', 'Tonga')
|
|
230
|
+
Country.new('TR', 'TUR', 'Turkey')
|
|
231
|
+
Country.new('TT', 'TTO', 'Trinidad and Tobago')
|
|
232
|
+
Country.new('TV', 'TUV', 'Tuvalu')
|
|
233
|
+
Country.new('TW', 'TWN', 'Taiwan')
|
|
234
|
+
Country.new('TZ', 'TZA', 'Tanzania')
|
|
235
|
+
Country.new('UA', 'UKR', 'Ukraine')
|
|
236
|
+
Country.new('UG', 'UGA', 'Uganda')
|
|
237
|
+
Country.new('UM', 'UMI', 'Midway Islands')
|
|
238
|
+
Country.new('US', 'USA', 'United States')
|
|
239
|
+
Country.new('UY', 'URY', 'Uruguay')
|
|
240
|
+
Country.new('UZ', 'UZB', 'Uzbekistan')
|
|
241
|
+
Country.new('VA', 'VAT', 'Vatican City')
|
|
242
|
+
Country.new('VC', 'VCT', 'Saint Vincent and the Grenadines')
|
|
243
|
+
Country.new('VE', 'VEN', 'Venezuela')
|
|
244
|
+
Country.new('VG', 'VGB', 'British Virgin Islands')
|
|
245
|
+
Country.new('VI', 'VIR', 'U.S. Virgin Islands')
|
|
246
|
+
Country.new('VN', 'VNM', 'Vietnam')
|
|
247
|
+
Country.new('VU', 'VUT', 'Vanuatu')
|
|
248
|
+
Country.new('WF', 'WLF', 'Wallis and Futuna')
|
|
249
|
+
Country.new('WS', 'WSM', 'Samoa')
|
|
250
|
+
Country.new('YE', 'YEM', 'Yemen')
|
|
251
|
+
Country.new('YT', 'MYT', 'Mayotte')
|
|
252
|
+
Country.new('ZA', 'ZAF', 'South Africa')
|
|
253
|
+
Country.new('ZM', 'ZMB', 'Zambia')
|
|
254
|
+
Country.new('ZW', 'ZWE', 'Zimbabwe')
|
|
255
|
+
|
|
256
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'uncharted/country'
|
|
2
|
+
|
|
3
|
+
module Uncharted
|
|
4
|
+
|
|
5
|
+
class Country
|
|
6
|
+
|
|
7
|
+
def subdivisions
|
|
8
|
+
@subdivisions ||= {}
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def territories
|
|
12
|
+
subdivisions[:territory] || []
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def states
|
|
16
|
+
subdivisions[:state] || []
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def districts
|
|
20
|
+
subdivisions[:district] || []
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.subdivisions
|
|
24
|
+
Territory.subdivisions
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class Territory
|
|
30
|
+
|
|
31
|
+
attr_reader :abbr, :code, :country, :country_code, :name, :division
|
|
32
|
+
|
|
33
|
+
def initialize(code, division, name)
|
|
34
|
+
@code = code
|
|
35
|
+
@division = division
|
|
36
|
+
@name = name
|
|
37
|
+
@country_code, @abbr = code.split('-')
|
|
38
|
+
@country = Country.find(@country_code)
|
|
39
|
+
Territory.subdivisions[code] = self
|
|
40
|
+
@country.subdivisions[@division] ||= []
|
|
41
|
+
@country.subdivisions[@division] << self
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def to_s
|
|
45
|
+
@abbr
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.find(code)
|
|
49
|
+
subdivisions[code]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def self.subdivisions
|
|
53
|
+
@subdivisions ||= {}
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
data/lib/uncharted.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'uncharted/country'
|
|
4
|
+
require 'uncharted/territory'
|
|
5
|
+
|
|
6
|
+
require 'uncharted/data/countries'
|
|
7
|
+
require 'uncharted/data/br'
|
|
8
|
+
|
|
9
|
+
require 'uncharted/adapters/mongoid'
|
|
10
|
+
|
|
11
|
+
Country = Uncharted::Country
|
|
12
|
+
Territory = Uncharted::Territory
|
data/lib/version.rb
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
require 'uncharted'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class TestCountry < MiniTest::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
def setup
|
|
9
|
+
@br = Uncharted::Country.find('BR')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_country_lookup
|
|
13
|
+
assert @br, "BR must exist"
|
|
14
|
+
assert_equal 'BR', @br.alpha2
|
|
15
|
+
assert_equal 'BRA', @br.alpha3
|
|
16
|
+
assert_equal 'Brazil', @br.name
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_to_s
|
|
20
|
+
assert_equal 'BR', @br.to_s
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_territories
|
|
24
|
+
assert_equal 1, @br.districts.count
|
|
25
|
+
assert_equal 26, @br.states.count
|
|
26
|
+
assert @br.territories.empty?
|
|
27
|
+
|
|
28
|
+
assert_equal [:district, :state], @br.subdivisions.keys.sort
|
|
29
|
+
assert_equal 'Paraná', Uncharted::Territory.find('BR-PR').name
|
|
30
|
+
assert_equal 'PR', Uncharted::Territory.find('BR-PR').abbr
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_classes
|
|
34
|
+
assert_equal Country, Uncharted::Country
|
|
35
|
+
assert_equal Territory, Uncharted::Territory
|
|
36
|
+
assert_equal Country::Field, Uncharted::Country::Field
|
|
37
|
+
assert_equal Territory::Field, Uncharted::Territory::Field
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
require 'uncharted'
|
|
4
|
+
|
|
5
|
+
class TestMongoidAdapter < MiniTest::Unit::TestCase
|
|
6
|
+
|
|
7
|
+
def setup
|
|
8
|
+
@country_field = Uncharted::Country::Field.new
|
|
9
|
+
@territory_field = Uncharted::Territory::Field.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def test_country_adapter
|
|
13
|
+
assert_equal 'BR', @country_field.serialize(Uncharted::Country.find('BR'))
|
|
14
|
+
assert_equal 'BR-PR', @territory_field.serialize(Uncharted::Territory.find('BR-PR'))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
data/test/test_helper.rb
ADDED
data/uncharted.gemspec
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
4
|
+
|
|
5
|
+
require 'version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.name = "uncharted"
|
|
9
|
+
s.homepage = "http://github.com/cenize/uncharted"
|
|
10
|
+
s.summary = "ISO 3166 Countries & territories codes (NOT READY FOR USE YET!)"
|
|
11
|
+
s.description = "Provide ISO 3166 codes and english name for countries and their political divisions"
|
|
12
|
+
|
|
13
|
+
s.version = Uncharted::VERSION
|
|
14
|
+
s.platform = Gem::Platform::RUBY
|
|
15
|
+
s.authors = ["Gilson Ferraz"]
|
|
16
|
+
s.email = ["gferraz@cenize.com"]
|
|
17
|
+
|
|
18
|
+
s.files = `git ls-files`.split("\n")
|
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
|
21
|
+
|
|
22
|
+
s.required_ruby_version = '>= 1.9'
|
|
23
|
+
|
|
24
|
+
s.add_development_dependency 'minitest' # minitest latest gem
|
|
25
|
+
s.add_development_dependency 'purdytest' # colored tests for minitest https://github.com/tenderlove/purdytest
|
|
26
|
+
s.add_development_dependency 'ruby-prof'
|
|
27
|
+
|
|
28
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: uncharted
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.5
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Gilson Ferraz
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2011-08-31 00:00:00.000000000Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: minitest
|
|
16
|
+
requirement: &2152341020 !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ! '>='
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '0'
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: *2152341020
|
|
25
|
+
- !ruby/object:Gem::Dependency
|
|
26
|
+
name: purdytest
|
|
27
|
+
requirement: &2152338840 !ruby/object:Gem::Requirement
|
|
28
|
+
none: false
|
|
29
|
+
requirements:
|
|
30
|
+
- - ! '>='
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :development
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: *2152338840
|
|
36
|
+
- !ruby/object:Gem::Dependency
|
|
37
|
+
name: ruby-prof
|
|
38
|
+
requirement: &2152337320 !ruby/object:Gem::Requirement
|
|
39
|
+
none: false
|
|
40
|
+
requirements:
|
|
41
|
+
- - ! '>='
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: '0'
|
|
44
|
+
type: :development
|
|
45
|
+
prerelease: false
|
|
46
|
+
version_requirements: *2152337320
|
|
47
|
+
description: Provide ISO 3166 codes and english name for countries and their political
|
|
48
|
+
divisions
|
|
49
|
+
email:
|
|
50
|
+
- gferraz@cenize.com
|
|
51
|
+
executables: []
|
|
52
|
+
extensions: []
|
|
53
|
+
extra_rdoc_files: []
|
|
54
|
+
files:
|
|
55
|
+
- .gitignore
|
|
56
|
+
- .project
|
|
57
|
+
- .yardoc/checksums
|
|
58
|
+
- .yardoc/objects/root.dat
|
|
59
|
+
- .yardoc/proxy_types
|
|
60
|
+
- Gemfile
|
|
61
|
+
- Gemfile.lock
|
|
62
|
+
- README.md
|
|
63
|
+
- Rakefile
|
|
64
|
+
- doc/.yardoc/checksums
|
|
65
|
+
- doc/.yardoc/objects/root.dat
|
|
66
|
+
- doc/.yardoc/proxy_types
|
|
67
|
+
- doc/Uncharted.html
|
|
68
|
+
- doc/Uncharted/Country.html
|
|
69
|
+
- doc/Uncharted/Country/Field.html
|
|
70
|
+
- doc/Uncharted/Territory.html
|
|
71
|
+
- doc/Uncharted/Territory/Field.html
|
|
72
|
+
- doc/_index.html
|
|
73
|
+
- doc/class_list.html
|
|
74
|
+
- doc/css/common.css
|
|
75
|
+
- doc/css/full_list.css
|
|
76
|
+
- doc/css/style.css
|
|
77
|
+
- doc/doc/_index.html
|
|
78
|
+
- doc/doc/class_list.html
|
|
79
|
+
- doc/doc/css/common.css
|
|
80
|
+
- doc/doc/css/full_list.css
|
|
81
|
+
- doc/doc/css/style.css
|
|
82
|
+
- doc/doc/file_list.html
|
|
83
|
+
- doc/doc/frames.html
|
|
84
|
+
- doc/doc/index.html
|
|
85
|
+
- doc/doc/js/app.js
|
|
86
|
+
- doc/doc/js/full_list.js
|
|
87
|
+
- doc/doc/js/jquery.js
|
|
88
|
+
- doc/doc/method_list.html
|
|
89
|
+
- doc/doc/top-level-namespace.html
|
|
90
|
+
- doc/file.README.html
|
|
91
|
+
- doc/file_list.html
|
|
92
|
+
- doc/frames.html
|
|
93
|
+
- doc/index.html
|
|
94
|
+
- doc/js/app.js
|
|
95
|
+
- doc/js/full_list.js
|
|
96
|
+
- doc/js/jquery.js
|
|
97
|
+
- doc/method_list.html
|
|
98
|
+
- doc/top-level-namespace.html
|
|
99
|
+
- lib/uncharted.rb
|
|
100
|
+
- lib/uncharted/adapters/mongoid.rb
|
|
101
|
+
- lib/uncharted/country.rb
|
|
102
|
+
- lib/uncharted/data/br.rb
|
|
103
|
+
- lib/uncharted/data/countries.rb
|
|
104
|
+
- lib/uncharted/territory.rb
|
|
105
|
+
- lib/version.rb
|
|
106
|
+
- test/country_test.rb
|
|
107
|
+
- test/mongoid_test.rb
|
|
108
|
+
- test/test_helper.rb
|
|
109
|
+
- test/uncharted_test.rb
|
|
110
|
+
- uncharted.gemspec
|
|
111
|
+
homepage: http://github.com/cenize/uncharted
|
|
112
|
+
licenses: []
|
|
113
|
+
post_install_message:
|
|
114
|
+
rdoc_options: []
|
|
115
|
+
require_paths:
|
|
116
|
+
- lib
|
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
|
+
none: false
|
|
119
|
+
requirements:
|
|
120
|
+
- - ! '>='
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: '1.9'
|
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
|
+
none: false
|
|
125
|
+
requirements:
|
|
126
|
+
- - ! '>='
|
|
127
|
+
- !ruby/object:Gem::Version
|
|
128
|
+
version: '0'
|
|
129
|
+
requirements: []
|
|
130
|
+
rubyforge_project:
|
|
131
|
+
rubygems_version: 1.8.10
|
|
132
|
+
signing_key:
|
|
133
|
+
specification_version: 3
|
|
134
|
+
summary: ISO 3166 Countries & territories codes (NOT READY FOR USE YET!)
|
|
135
|
+
test_files:
|
|
136
|
+
- test/country_test.rb
|
|
137
|
+
- test/mongoid_test.rb
|
|
138
|
+
- test/test_helper.rb
|
|
139
|
+
- test/uncharted_test.rb
|