validates_countrycode 0.1.0
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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/validates_countrycode.rb +281 -0
- data/lib/validates_countrycode/version.rb +3 -0
- data/validates_countrycode.gemspec +40 -0
- metadata +122 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0af7548978bd517ff44d374294b5a564787920f3a48f47b8738c8bd12d715312
|
4
|
+
data.tar.gz: 773646c571190fd15339b2e6f7c78d64d3ddb192a4cdbda439dd7bbe28f54533
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a664edb52ce83419dd8905e54112f5c8f971ff23448210d5d0a05035126568dc1dbbd7426af565bce3cd012ffc020763abdbae8da0dee72b34e13a677aaedbbc
|
7
|
+
data.tar.gz: 586607dc401e350576dcb5eae22a6cc7baec663f3879fb932d847e8b4f86a0f8dfde91375b1976b0d8dbfdf68a3e28e499efbc7e9e7c2abb059a3bb63afa52ac
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at frederik@progras.dk. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Frederik Spang
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# validates_countrycode
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'validates_countrycode'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install validates_countrycode
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Development
|
24
|
+
|
25
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
26
|
+
|
27
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/validates_countrycode. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
36
|
+
|
37
|
+
## Code of Conduct
|
38
|
+
|
39
|
+
Everyone interacting in the ValidatesCountrycode project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/validates_countrycode/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "validates_countrycode"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,281 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "validates_countrycode/version"
|
3
|
+
|
4
|
+
module ValidatesCountrycode
|
5
|
+
|
6
|
+
# rubocop:disable ClassLength
|
7
|
+
# Validates a country-code against existing country codes, such as US, BE, DK etc.
|
8
|
+
#
|
9
|
+
# @author Frederik Spang Thomsen
|
10
|
+
class Validator < ActiveModel::EachValidator
|
11
|
+
# Adds
|
12
|
+
def validate_each(record, attribute, value)
|
13
|
+
unless self.class.country_codes[value.to_s.upcase].present?
|
14
|
+
record.errors[attribute] << record.errors.generate_message(attribute, :invalid)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns matching country_codes
|
19
|
+
#
|
20
|
+
# @example Using country codes with symbol key
|
21
|
+
# CountryCodeValidator.country_codes[:DK] # => "DENMARK"
|
22
|
+
# @example Using country codes with string key
|
23
|
+
# CountryCodeValidator.country_codes['DK'] # => "DENMARK"
|
24
|
+
# @return [ActiveSupport::HashWithIndifferentAccess] with KEY => COUNTRY
|
25
|
+
def self.country_codes
|
26
|
+
{
|
27
|
+
AF: 'AFGHANISTAN',
|
28
|
+
AX: 'ÅLAND ISLANDS',
|
29
|
+
AL: 'ALBANIA',
|
30
|
+
DZ: 'ALGERIA',
|
31
|
+
AS: 'AMERICAN SAMOA',
|
32
|
+
AD: 'ANDORRA',
|
33
|
+
AO: 'ANGOLA',
|
34
|
+
AI: 'ANGUILLA',
|
35
|
+
AQ: 'ANTARCTICA',
|
36
|
+
AG: 'ANTIGUA AND BARBUDA',
|
37
|
+
AR: 'ARGENTINA',
|
38
|
+
AM: 'ARMENIA',
|
39
|
+
AW: 'ARUBA',
|
40
|
+
AU: 'AUSTRALIA',
|
41
|
+
AT: 'AUSTRIA',
|
42
|
+
AZ: 'AZERBAIJAN',
|
43
|
+
BS: 'BAHAMAS',
|
44
|
+
BH: 'BAHRAIN',
|
45
|
+
BD: 'BANGLADESH',
|
46
|
+
BB: 'BARBADOS',
|
47
|
+
BY: 'BELARUS',
|
48
|
+
BE: 'BELGIUM',
|
49
|
+
BZ: 'BELIZE',
|
50
|
+
BJ: 'BENIN',
|
51
|
+
BM: 'BERMUDA',
|
52
|
+
BT: 'BHUTAN',
|
53
|
+
BO: 'BOLIVIA, PLURINATIONAL STATE OF',
|
54
|
+
BQ: 'BONAIRE, SINT EUSTATIUS AND SABA',
|
55
|
+
BA: 'BOSNIA AND HERZEGOVINA',
|
56
|
+
BW: 'BOTSWANA',
|
57
|
+
BV: 'BOUVET ISLAND',
|
58
|
+
BR: 'BRAZIL',
|
59
|
+
IO: 'BRITISH INDIAN OCEAN TERRITORY',
|
60
|
+
BN: 'BRUNEI DARUSSALAM',
|
61
|
+
BG: 'BULGARIA',
|
62
|
+
BF: 'BURKINA FASO',
|
63
|
+
BI: 'BURUNDI',
|
64
|
+
KH: 'CAMBODIA',
|
65
|
+
CM: 'CAMEROON',
|
66
|
+
CA: 'CANADA',
|
67
|
+
CV: 'CAPE VERDE',
|
68
|
+
KY: 'CAYMAN ISLANDS',
|
69
|
+
CF: 'CENTRAL AFRICAN REPUBLIC',
|
70
|
+
TD: 'CHAD',
|
71
|
+
CL: 'CHILE',
|
72
|
+
CN: 'CHINA',
|
73
|
+
CX: 'CHRISTMAS ISLAND',
|
74
|
+
CC: 'COCOS (KEELING) ISLANDS',
|
75
|
+
CO: 'COLOMBIA',
|
76
|
+
KM: 'COMOROS',
|
77
|
+
CG: 'CONGO',
|
78
|
+
CD: 'CONGO, THE DEMOCRATIC REPUBLIC OF THE',
|
79
|
+
CK: 'COOK ISLANDS',
|
80
|
+
CR: 'COSTA RICA',
|
81
|
+
CI: "CÔTE D'IVOIRE",
|
82
|
+
HR: 'CROATIA',
|
83
|
+
CU: 'CUBA',
|
84
|
+
CW: 'CURAÇAO',
|
85
|
+
CY: 'CYPRUS',
|
86
|
+
CZ: 'CZECH REPUBLIC',
|
87
|
+
DK: 'DENMARK',
|
88
|
+
DJ: 'DJIBOUTI',
|
89
|
+
DM: 'DOMINICA',
|
90
|
+
DO: 'DOMINICAN REPUBLIC',
|
91
|
+
EC: 'ECUADOR',
|
92
|
+
EG: 'EGYPT',
|
93
|
+
SV: 'EL SALVADOR',
|
94
|
+
GQ: 'EQUATORIAL GUINEA',
|
95
|
+
ER: 'ERITREA',
|
96
|
+
EE: 'ESTONIA',
|
97
|
+
ET: 'ETHIOPIA',
|
98
|
+
FK: 'FALKLAND ISLANDS (MALVINAS)',
|
99
|
+
FO: 'FAROE ISLANDS',
|
100
|
+
FJ: 'FIJI',
|
101
|
+
FI: 'FINLAND',
|
102
|
+
FR: 'FRANCE',
|
103
|
+
GF: 'FRENCH GUIANA',
|
104
|
+
PF: 'FRENCH POLYNESIA',
|
105
|
+
TF: 'FRENCH SOUTHERN TERRITORIES',
|
106
|
+
GA: 'GABON',
|
107
|
+
GM: 'GAMBIA',
|
108
|
+
GE: 'GEORGIA',
|
109
|
+
DE: 'GERMANY',
|
110
|
+
GH: 'GHANA',
|
111
|
+
GI: 'GIBRALTAR',
|
112
|
+
GR: 'GREECE',
|
113
|
+
GL: 'GREENLAND',
|
114
|
+
GD: 'GRENADA',
|
115
|
+
GP: 'GUADELOUPE',
|
116
|
+
GU: 'GUAM',
|
117
|
+
GT: 'GUATEMALA',
|
118
|
+
GG: 'GUERNSEY',
|
119
|
+
GN: 'GUINEA',
|
120
|
+
GW: 'GUINEA-BISSAU',
|
121
|
+
GY: 'GUYANA',
|
122
|
+
HT: 'HAITI',
|
123
|
+
HM: 'HEARD ISLAND AND MCDONALD ISLANDS',
|
124
|
+
VA: 'HOLY SEE (VATICAN CITY STATE)',
|
125
|
+
HN: 'HONDURAS',
|
126
|
+
HK: 'HONG KONG',
|
127
|
+
HU: 'HUNGARY',
|
128
|
+
IS: 'ICELAND',
|
129
|
+
IN: 'INDIA',
|
130
|
+
ID: 'INDONESIA',
|
131
|
+
IR: 'IRAN, ISLAMIC REPUBLIC OF',
|
132
|
+
IQ: 'IRAQ',
|
133
|
+
IE: 'IRELAND',
|
134
|
+
IM: 'ISLE OF MAN',
|
135
|
+
IL: 'ISRAEL',
|
136
|
+
IT: 'ITALY',
|
137
|
+
JM: 'JAMAICA',
|
138
|
+
JP: 'JAPAN',
|
139
|
+
JE: 'JERSEY',
|
140
|
+
JO: 'JORDAN',
|
141
|
+
KZ: 'KAZAKHSTAN',
|
142
|
+
KE: 'KENYA',
|
143
|
+
KI: 'KIRIBATI',
|
144
|
+
KP: "KOREA, DEMOCRATIC PEOPLE'S REPUBLIC OF",
|
145
|
+
KR: 'KOREA, REPUBLIC OF',
|
146
|
+
KW: 'KUWAIT',
|
147
|
+
KG: 'KYRGYZSTAN',
|
148
|
+
LA: "LAO PEOPLE'S DEMOCRATIC REPUBLIC",
|
149
|
+
LV: 'LATVIA',
|
150
|
+
LB: 'LEBANON',
|
151
|
+
LS: 'LESOTHO',
|
152
|
+
LR: 'LIBERIA',
|
153
|
+
LY: 'LIBYA',
|
154
|
+
LI: 'LIECHTENSTEIN',
|
155
|
+
LT: 'LITHUANIA',
|
156
|
+
LU: 'LUXEMBOURG',
|
157
|
+
MO: 'MACAO',
|
158
|
+
MK: 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF',
|
159
|
+
MG: 'MADAGASCAR',
|
160
|
+
MW: 'MALAWI',
|
161
|
+
MY: 'MALAYSIA',
|
162
|
+
MV: 'MALDIVES',
|
163
|
+
ML: 'MALI',
|
164
|
+
MT: 'MALTA',
|
165
|
+
MH: 'MARSHALL ISLANDS',
|
166
|
+
MQ: 'MARTINIQUE',
|
167
|
+
MR: 'MAURITANIA',
|
168
|
+
MU: 'MAURITIUS',
|
169
|
+
YT: 'MAYOTTE',
|
170
|
+
MX: 'MEXICO',
|
171
|
+
FM: 'MICRONESIA, FEDERATED STATES OF',
|
172
|
+
MD: 'MOLDOVA, REPUBLIC OF',
|
173
|
+
MC: 'MONACO',
|
174
|
+
MN: 'MONGOLIA',
|
175
|
+
ME: 'MONTENEGRO',
|
176
|
+
MS: 'MONTSERRAT',
|
177
|
+
MA: 'MOROCCO',
|
178
|
+
MZ: 'MOZAMBIQUE',
|
179
|
+
MM: 'MYANMAR',
|
180
|
+
NA: 'NAMIBIA',
|
181
|
+
NR: 'NAURU',
|
182
|
+
NP: 'NEPAL',
|
183
|
+
NL: 'NETHERLANDS',
|
184
|
+
NC: 'NEW CALEDONIA',
|
185
|
+
NZ: 'NEW ZEALAND',
|
186
|
+
NI: 'NICARAGUA',
|
187
|
+
NE: 'NIGER',
|
188
|
+
NG: 'NIGERIA',
|
189
|
+
NU: 'NIUE',
|
190
|
+
NF: 'NORFOLK ISLAND',
|
191
|
+
MP: 'NORTHERN MARIANA ISLANDS',
|
192
|
+
NO: 'NORWAY',
|
193
|
+
OM: 'OMAN',
|
194
|
+
PK: 'PAKISTAN',
|
195
|
+
PW: 'PALAU',
|
196
|
+
PS: 'PALESTINE, STATE OF',
|
197
|
+
PA: 'PANAMA',
|
198
|
+
PG: 'PAPUA NEW GUINEA',
|
199
|
+
PY: 'PARAGUAY',
|
200
|
+
PE: 'PERU',
|
201
|
+
PH: 'PHILIPPINES',
|
202
|
+
PN: 'PITCAIRN',
|
203
|
+
PL: 'POLAND',
|
204
|
+
PT: 'PORTUGAL',
|
205
|
+
PR: 'PUERTO RICO',
|
206
|
+
QA: 'QATAR',
|
207
|
+
RE: 'RÉUNION',
|
208
|
+
RO: 'ROMANIA',
|
209
|
+
RU: 'RUSSIAN FEDERATION',
|
210
|
+
RW: 'RWANDA',
|
211
|
+
BL: 'SAINT BARTHÉLEMY',
|
212
|
+
SH: 'SAINT HELENA, ASCENSION AND TRISTAN DA CUNHA',
|
213
|
+
KN: 'SAINT KITTS AND NEVIS',
|
214
|
+
LC: 'SAINT LUCIA',
|
215
|
+
MF: 'SAINT MARTIN (FRENCH PART)',
|
216
|
+
PM: 'SAINT PIERRE AND MIQUELON',
|
217
|
+
VC: 'SAINT VINCENT AND THE GRENADINES',
|
218
|
+
WS: 'SAMOA',
|
219
|
+
SM: 'SAN MARINO',
|
220
|
+
ST: 'SAO TOME AND PRINCIPE',
|
221
|
+
SA: 'SAUDI ARABIA',
|
222
|
+
SN: 'SENEGAL',
|
223
|
+
RS: 'SERBIA',
|
224
|
+
SC: 'SEYCHELLES',
|
225
|
+
SL: 'SIERRA LEONE',
|
226
|
+
SG: 'SINGAPORE',
|
227
|
+
SX: 'SINT MAARTEN (DUTCH PART)',
|
228
|
+
SK: 'SLOVAKIA',
|
229
|
+
SI: 'SLOVENIA',
|
230
|
+
SB: 'SOLOMON ISLANDS',
|
231
|
+
SO: 'SOMALIA',
|
232
|
+
ZA: 'SOUTH AFRICA',
|
233
|
+
GS: 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS',
|
234
|
+
SS: 'SOUTH SUDAN',
|
235
|
+
ES: 'SPAIN',
|
236
|
+
LK: 'SRI LANKA',
|
237
|
+
SD: 'SUDAN',
|
238
|
+
SR: 'SURINAME',
|
239
|
+
SJ: 'SVALBARD AND JAN MAYEN',
|
240
|
+
SZ: 'SWAZILAND',
|
241
|
+
SE: 'SWEDEN',
|
242
|
+
CH: 'SWITZERLAND',
|
243
|
+
SY: 'SYRIAN ARAB REPUBLIC',
|
244
|
+
TW: 'TAIWAN, PROVINCE OF CHINA',
|
245
|
+
TJ: 'TAJIKISTAN',
|
246
|
+
TZ: 'TANZANIA, UNITED REPUBLIC OF',
|
247
|
+
TH: 'THAILAND',
|
248
|
+
TL: 'TIMOR-LESTE',
|
249
|
+
TG: 'TOGO',
|
250
|
+
TK: 'TOKELAU',
|
251
|
+
TO: 'TONGA',
|
252
|
+
TT: 'TRINIDAD AND TOBAGO',
|
253
|
+
TN: 'TUNISIA',
|
254
|
+
TR: 'TURKEY',
|
255
|
+
TM: 'TURKMENISTAN',
|
256
|
+
TC: 'TURKS AND CAICOS ISLANDS',
|
257
|
+
TV: 'TUVALU',
|
258
|
+
UG: 'UGANDA',
|
259
|
+
UA: 'UKRAINE',
|
260
|
+
AE: 'UNITED ARAB EMIRATES',
|
261
|
+
GB: 'UNITED KINGDOM',
|
262
|
+
US: 'UNITED STATES',
|
263
|
+
UM: 'UNITED STATES MINOR OUTLYING ISLANDS',
|
264
|
+
UY: 'URUGUAY',
|
265
|
+
UZ: 'UZBEKISTAN',
|
266
|
+
VU: 'VANUATU',
|
267
|
+
VE: 'VENEZUELA, BOLIVARIAN REPUBLIC OF',
|
268
|
+
VN: 'VIETNAM',
|
269
|
+
VG: 'VIRGIN ISLANDS, BRITISH',
|
270
|
+
VI: 'VIRGIN ISLANDS, U.S.',
|
271
|
+
WF: 'WALLIS AND FUTUNA',
|
272
|
+
EH: 'WESTERN SAHARA',
|
273
|
+
YE: 'YEMEN',
|
274
|
+
ZM: 'ZAMBIA',
|
275
|
+
ZW: 'ZIMBABWE'
|
276
|
+
}.with_indifferent_access
|
277
|
+
end
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
ActiveModel::Validations::ZipcodeValidator = ValidatesCountrycode::Validator
|
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "validates_countrycode/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "validates_countrycode"
|
8
|
+
spec.version = ValidatesCountrycode::VERSION
|
9
|
+
spec.authors = ["Frederik Spang"]
|
10
|
+
spec.email = ["frederik@progras.dk"]
|
11
|
+
|
12
|
+
spec.summary = %q{The purpose of this gem is to validate countrycodes in ISO 3166-1 alpha-2 format}
|
13
|
+
spec.homepage = "https://github.com/prograsdk/validates_countrycode"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
spec.metadata["source_code_uri"] = "https://github.com/prograsdk/validates_countrycode"
|
21
|
+
else
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
"public gem pushes."
|
24
|
+
end
|
25
|
+
|
26
|
+
# Specify which files should be added to the gem when it is released.
|
27
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
28
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
29
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
30
|
+
end
|
31
|
+
spec.bindir = "exe"
|
32
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
33
|
+
spec.require_paths = ["lib"]
|
34
|
+
|
35
|
+
spec.add_dependency 'active_support', '< 3', '> 6'
|
36
|
+
|
37
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
38
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
39
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: validates_countrycode
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Frederik Spang
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-08-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: active_support
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "<"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3'
|
20
|
+
- - ">"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "<"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3'
|
30
|
+
- - ">"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: bundler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.16'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.16'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '10.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '10.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rspec
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '3.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '3.0'
|
75
|
+
description:
|
76
|
+
email:
|
77
|
+
- frederik@progras.dk
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- ".gitignore"
|
83
|
+
- ".rspec"
|
84
|
+
- ".travis.yml"
|
85
|
+
- CODE_OF_CONDUCT.md
|
86
|
+
- Gemfile
|
87
|
+
- LICENSE.txt
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
90
|
+
- bin/console
|
91
|
+
- bin/setup
|
92
|
+
- lib/validates_countrycode.rb
|
93
|
+
- lib/validates_countrycode/version.rb
|
94
|
+
- validates_countrycode.gemspec
|
95
|
+
homepage: https://github.com/prograsdk/validates_countrycode
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata:
|
99
|
+
allowed_push_host: https://rubygems.org
|
100
|
+
source_code_uri: https://github.com/prograsdk/validates_countrycode
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 2.7.7
|
118
|
+
signing_key:
|
119
|
+
specification_version: 4
|
120
|
+
summary: The purpose of this gem is to validate countrycodes in ISO 3166-1 alpha-2
|
121
|
+
format
|
122
|
+
test_files: []
|