civitas 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +38 -0
- data/LICENSE.txt +22 -0
- data/README.md +173 -0
- data/Rakefile +2 -0
- data/civitas.gemspec +32 -0
- data/lib/civitas/version.rb +3 -0
- data/lib/civitas.rb +353 -0
- data/lib/db/GeoLite2-City-Locations-en.csv +114875 -0
- data/lib/db/cities.us +22186 -0
- data/lib/db/countries.yml +252 -0
- data/lib/db/states-replace.yml +3 -0
- data/lib/db/states.us +52 -0
- data/spec/city_state_spec.rb +31 -0
- data/spec/spec_helper.rb +1 -0
- metadata +113 -0
@@ -0,0 +1,252 @@
|
|
1
|
+
---
|
2
|
+
:AD: Andorra
|
3
|
+
:AE: United Arab Emirates
|
4
|
+
:AF: Afghanistan
|
5
|
+
:AG: Antigua and Barbuda
|
6
|
+
:AI: Anguilla
|
7
|
+
:AL: Albania
|
8
|
+
:AM: Armenia
|
9
|
+
:AO: Angola
|
10
|
+
:AQ: Antarctica
|
11
|
+
:AR: Argentina
|
12
|
+
:AS: American Samoa
|
13
|
+
:AT: Austria
|
14
|
+
:AU: Australia
|
15
|
+
:AW: Aruba
|
16
|
+
:AX: Åland
|
17
|
+
:AZ: Azerbaijan
|
18
|
+
:BA: Bosnia and Herzegovina
|
19
|
+
:BB: Barbados
|
20
|
+
:BD: Bangladesh
|
21
|
+
:BE: Belgium
|
22
|
+
:BF: Burkina Faso
|
23
|
+
:BG: Bulgaria
|
24
|
+
:BH: Bahrain
|
25
|
+
:BI: Burundi
|
26
|
+
:BJ: Benin
|
27
|
+
:BL: Saint Barthélemy
|
28
|
+
:BM: Bermuda
|
29
|
+
:BN: Brunei
|
30
|
+
:BO: Bolivia
|
31
|
+
:BQ: Bonaire
|
32
|
+
:BR: Brazil
|
33
|
+
:BS: Bahamas
|
34
|
+
:BT: Bhutan
|
35
|
+
:BV: Bouvet Island
|
36
|
+
:BW: Botswana
|
37
|
+
:BY: Belarus
|
38
|
+
:BZ: Belize
|
39
|
+
:CA: Canada
|
40
|
+
:CC: Cocos [Keeling] Islands
|
41
|
+
:CD: DR Congo
|
42
|
+
:CF: Central African Republic
|
43
|
+
:CG: Congo Republic
|
44
|
+
:CH: Switzerland
|
45
|
+
:CI: Ivory Coast
|
46
|
+
:CK: Cook Islands
|
47
|
+
:CL: Chile
|
48
|
+
:CM: Cameroon
|
49
|
+
:CN: China
|
50
|
+
:CO: Colombia
|
51
|
+
:COUNTRY_ISO_CODE: country_name
|
52
|
+
:CR: Costa Rica
|
53
|
+
:CU: Cuba
|
54
|
+
:CV: Cabo Verde
|
55
|
+
:CW: Curaçao
|
56
|
+
:CX: Christmas Island
|
57
|
+
:CY: Cyprus
|
58
|
+
:CZ: Czechia
|
59
|
+
:DE: Germany
|
60
|
+
:DJ: Djibouti
|
61
|
+
:DK: Denmark
|
62
|
+
:DM: Dominica
|
63
|
+
:DO: Dominican Republic
|
64
|
+
:DZ: Algeria
|
65
|
+
:EC: Ecuador
|
66
|
+
:EE: Estonia
|
67
|
+
:EG: Egypt
|
68
|
+
:EH: Western Sahara
|
69
|
+
:ER: Eritrea
|
70
|
+
:ES: Spain
|
71
|
+
:ET: Ethiopia
|
72
|
+
:FI: Finland
|
73
|
+
:FJ: Fiji
|
74
|
+
:FK: Falkland Islands
|
75
|
+
:FM: Federated States of Micronesia
|
76
|
+
:FO: Faroe Islands
|
77
|
+
:FR: France
|
78
|
+
:GA: Gabon
|
79
|
+
:GB: United Kingdom
|
80
|
+
:GD: Grenada
|
81
|
+
:GE: Georgia
|
82
|
+
:GF: French Guiana
|
83
|
+
:GG: Guernsey
|
84
|
+
:GH: Ghana
|
85
|
+
:GI: Gibraltar
|
86
|
+
:GL: Greenland
|
87
|
+
:GM: Gambia
|
88
|
+
:GN: Guinea
|
89
|
+
:GP: Guadeloupe
|
90
|
+
:GQ: Equatorial Guinea
|
91
|
+
:GR: Greece
|
92
|
+
:GS: South Georgia and the South Sandwich Islands
|
93
|
+
:GT: Guatemala
|
94
|
+
:GU: Guam
|
95
|
+
:GW: Guinea-Bissau
|
96
|
+
:GY: Guyana
|
97
|
+
:HK: Hong Kong
|
98
|
+
:HM: Heard Island and McDonald Islands
|
99
|
+
:HN: Honduras
|
100
|
+
:HR: Croatia
|
101
|
+
:HT: Haiti
|
102
|
+
:HU: Hungary
|
103
|
+
:ID: Indonesia
|
104
|
+
:IE: Ireland
|
105
|
+
:IL: Israel
|
106
|
+
:IM: Isle of Man
|
107
|
+
:IN: India
|
108
|
+
:IO: British Indian Ocean Territory
|
109
|
+
:IQ: Iraq
|
110
|
+
:IR: Iran
|
111
|
+
:IS: Iceland
|
112
|
+
:IT: Italy
|
113
|
+
:JE: Jersey
|
114
|
+
:JM: Jamaica
|
115
|
+
:JO: Hashemite Kingdom of Jordan
|
116
|
+
:JP: Japan
|
117
|
+
:KE: Kenya
|
118
|
+
:KG: Kyrgyzstan
|
119
|
+
:KH: Cambodia
|
120
|
+
:KI: Kiribati
|
121
|
+
:KM: Comoros
|
122
|
+
:KN: St Kitts and Nevis
|
123
|
+
:KP: North Korea
|
124
|
+
:KR: South Korea
|
125
|
+
:KW: Kuwait
|
126
|
+
:KY: Cayman Islands
|
127
|
+
:KZ: Kazakhstan
|
128
|
+
:LA: Laos
|
129
|
+
:LB: Lebanon
|
130
|
+
:LC: Saint Lucia
|
131
|
+
:LI: Liechtenstein
|
132
|
+
:LK: Sri Lanka
|
133
|
+
:LR: Liberia
|
134
|
+
:LS: Lesotho
|
135
|
+
:LT: Republic of Lithuania
|
136
|
+
:LU: Luxembourg
|
137
|
+
:LV: Latvia
|
138
|
+
:LY: Libya
|
139
|
+
:MA: Morocco
|
140
|
+
:MC: Monaco
|
141
|
+
:MD: Republic of Moldova
|
142
|
+
:ME: Montenegro
|
143
|
+
:MF: Saint Martin
|
144
|
+
:MG: Madagascar
|
145
|
+
:MH: Marshall Islands
|
146
|
+
:MK: North Macedonia
|
147
|
+
:ML: Mali
|
148
|
+
:MM: Myanmar
|
149
|
+
:MN: Mongolia
|
150
|
+
:MO: Macao
|
151
|
+
:MP: Northern Mariana Islands
|
152
|
+
:MQ: Martinique
|
153
|
+
:MR: Mauritania
|
154
|
+
:MS: Montserrat
|
155
|
+
:MT: Malta
|
156
|
+
:MU: Mauritius
|
157
|
+
:MV: Maldives
|
158
|
+
:MW: Malawi
|
159
|
+
:MX: Mexico
|
160
|
+
:MY: Malaysia
|
161
|
+
:MZ: Mozambique
|
162
|
+
:NA: Namibia
|
163
|
+
:NC: New Caledonia
|
164
|
+
:NE: Niger
|
165
|
+
:NF: Norfolk Island
|
166
|
+
:NG: Nigeria
|
167
|
+
:NI: Nicaragua
|
168
|
+
:NL: Netherlands
|
169
|
+
:NO: Norway
|
170
|
+
:NP: Nepal
|
171
|
+
:NR: Nauru
|
172
|
+
:NU: Niue
|
173
|
+
:NZ: New Zealand
|
174
|
+
:OM: Oman
|
175
|
+
:PA: Panama
|
176
|
+
:PE: Peru
|
177
|
+
:PF: French Polynesia
|
178
|
+
:PG: Papua New Guinea
|
179
|
+
:PH: Philippines
|
180
|
+
:PK: Pakistan
|
181
|
+
:PL: Poland
|
182
|
+
:PM: Saint Pierre and Miquelon
|
183
|
+
:PN: Pitcairn Islands
|
184
|
+
:PR: Puerto Rico
|
185
|
+
:PS: Palestine
|
186
|
+
:PT: Portugal
|
187
|
+
:PW: Palau
|
188
|
+
:PY: Paraguay
|
189
|
+
:QA: Qatar
|
190
|
+
:RE: Réunion
|
191
|
+
:RO: Romania
|
192
|
+
:RS: Serbia
|
193
|
+
:RU: Russia
|
194
|
+
:RW: Rwanda
|
195
|
+
:SA: Saudi Arabia
|
196
|
+
:SB: Solomon Islands
|
197
|
+
:SC: Seychelles
|
198
|
+
:SD: Sudan
|
199
|
+
:SE: Sweden
|
200
|
+
:SG: Singapore
|
201
|
+
:SH: Saint Helena
|
202
|
+
:SI: Slovenia
|
203
|
+
:SJ: Svalbard and Jan Mayen
|
204
|
+
:SK: Slovakia
|
205
|
+
:SL: Sierra Leone
|
206
|
+
:SM: San Marino
|
207
|
+
:SN: Senegal
|
208
|
+
:SO: Somalia
|
209
|
+
:SR: Suriname
|
210
|
+
:SS: South Sudan
|
211
|
+
:ST: São Tomé and Príncipe
|
212
|
+
:SV: El Salvador
|
213
|
+
:SX: Sint Maarten
|
214
|
+
:SY: Syria
|
215
|
+
:SZ: Eswatini
|
216
|
+
:TC: Turks and Caicos Islands
|
217
|
+
:TD: Chad
|
218
|
+
:TF: French Southern Territories
|
219
|
+
:TG: Togo
|
220
|
+
:TH: Thailand
|
221
|
+
:TJ: Tajikistan
|
222
|
+
:TK: Tokelau
|
223
|
+
:TL: East Timor
|
224
|
+
:TM: Turkmenistan
|
225
|
+
:TN: Tunisia
|
226
|
+
:TO: Tonga
|
227
|
+
:TR: Turkey
|
228
|
+
:TT: Trinidad and Tobago
|
229
|
+
:TV: Tuvalu
|
230
|
+
:TW: Taiwan
|
231
|
+
:TZ: Tanzania
|
232
|
+
:UA: Ukraine
|
233
|
+
:UG: Uganda
|
234
|
+
:UM: U.S. Minor Outlying Islands
|
235
|
+
:US: United States
|
236
|
+
:UY: Uruguay
|
237
|
+
:UZ: Uzbekistan
|
238
|
+
:VA: Vatican City
|
239
|
+
:VC: Saint Vincent and the Grenadines
|
240
|
+
:VE: Venezuela
|
241
|
+
:VG: British Virgin Islands
|
242
|
+
:VI: U.S. Virgin Islands
|
243
|
+
:VN: Vietnam
|
244
|
+
:VU: Vanuatu
|
245
|
+
:WF: Wallis and Futuna
|
246
|
+
:WS: Samoa
|
247
|
+
:XK: Kosovo
|
248
|
+
:YE: Yemen
|
249
|
+
:YT: Mayotte
|
250
|
+
:ZA: South Africa
|
251
|
+
:ZM: Zambia
|
252
|
+
:ZW: Zimbabwe
|
data/lib/db/states.us
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
---
|
2
|
+
:AK: Alaska
|
3
|
+
:AL: Alabama
|
4
|
+
:AR: Arkansas
|
5
|
+
:AZ: Arizona
|
6
|
+
:CA: California
|
7
|
+
:CO: Colorado
|
8
|
+
:CT: Connecticut
|
9
|
+
:DC: District of Columbia
|
10
|
+
:DE: Delaware
|
11
|
+
:FL: Florida
|
12
|
+
:GA: Georgia
|
13
|
+
:HI: Hawaii
|
14
|
+
:IA: Iowa
|
15
|
+
:ID: Idaho
|
16
|
+
:IL: Illinois
|
17
|
+
:IN: Indiana
|
18
|
+
:KS: Kansas
|
19
|
+
:KY: Kentucky
|
20
|
+
:LA: Louisiana
|
21
|
+
:MA: Massachusetts
|
22
|
+
:MD: Maryland
|
23
|
+
:ME: Maine
|
24
|
+
:MI: Michigan
|
25
|
+
:MN: Minnesota
|
26
|
+
:MO: Missouri
|
27
|
+
:MS: Mississippi
|
28
|
+
:MT: Montana
|
29
|
+
:NC: North Carolina
|
30
|
+
:ND: North Dakota
|
31
|
+
:NE: Nebraska
|
32
|
+
:NH: New Hampshire
|
33
|
+
:NJ: New Jersey
|
34
|
+
:NM: New Mexico
|
35
|
+
:NV: Nevada
|
36
|
+
:NY: New York
|
37
|
+
:OH: Ohio
|
38
|
+
:OK: Oklahoma
|
39
|
+
:OR: Oregon
|
40
|
+
:PA: Pennsylvania
|
41
|
+
:RI: Rhode Island
|
42
|
+
:SC: South Carolina
|
43
|
+
:SD: South Dakota
|
44
|
+
:TN: Tennessee
|
45
|
+
:TX: Texas
|
46
|
+
:UT: Utah
|
47
|
+
:VA: Virginia
|
48
|
+
:VT: Vermont
|
49
|
+
:WA: Washington
|
50
|
+
:WI: Wisconsin
|
51
|
+
:WV: West Virginia
|
52
|
+
:WY: Wyoming
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CS do
|
4
|
+
# Testing the countries method
|
5
|
+
it 'returns a list of countries' do
|
6
|
+
countries = CS.countries
|
7
|
+
expect(countries).to be_an(Hash)
|
8
|
+
expect(countries).not_to be_empty
|
9
|
+
end
|
10
|
+
|
11
|
+
# Testing the states method for a given country
|
12
|
+
it 'returns states for a given country' do
|
13
|
+
states = CS.states(:US)
|
14
|
+
expect(states).to be_an(Hash)
|
15
|
+
expect(states).not_to be_empty
|
16
|
+
end
|
17
|
+
|
18
|
+
# Testing the cities method for a given state and country
|
19
|
+
it 'returns cities for a given state and country' do
|
20
|
+
cities = CS.cities(:CA, :US)
|
21
|
+
expect(cities).to be_an(Array)
|
22
|
+
expect(cities).not_to be_empty
|
23
|
+
end
|
24
|
+
|
25
|
+
# Testing the get method
|
26
|
+
it 'returns countries, states, or cities based on parameters' do
|
27
|
+
expect(CS.get).to eq(CS.countries)
|
28
|
+
expect(CS.get(:US)).to eq(CS.states(:US))
|
29
|
+
expect(CS.get(:US, :CA)).to eq(CS.cities(:CA, :US))
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'civitas'
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: civitas
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Loureiro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-02-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubyzip
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.3'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '11.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '11.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.10'
|
69
|
+
description: Useful to make forms and validations. It uses MaxMind database.
|
70
|
+
email:
|
71
|
+
- loureirorg@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- CHANGELOG.md
|
77
|
+
- LICENSE.txt
|
78
|
+
- README.md
|
79
|
+
- Rakefile
|
80
|
+
- civitas.gemspec
|
81
|
+
- lib/civitas.rb
|
82
|
+
- lib/civitas/version.rb
|
83
|
+
- lib/db/GeoLite2-City-Locations-en.csv
|
84
|
+
- lib/db/cities.us
|
85
|
+
- lib/db/countries.yml
|
86
|
+
- lib/db/states-replace.yml
|
87
|
+
- lib/db/states.us
|
88
|
+
- spec/city_state_spec.rb
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
homepage: https://github.com/duduribeiro/civitas
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.6.0
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubygems_version: 3.3.26
|
110
|
+
signing_key:
|
111
|
+
specification_version: 4
|
112
|
+
summary: Simple list of cities and states of the world
|
113
|
+
test_files: []
|