country_state_select 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +4 -8
- data/README.md +1 -104
- data/app/controllers/country_state_select/cscs_controller.rb +12 -0
- data/config/routes.rb +6 -0
- data/country_state_select.gemspec +2 -2
- data/lib/country_state_select.rb +9 -15
- data/lib/country_state_select/cst_data.rb +17 -0
- data/lib/country_state_select/version.rb +1 -1
- data/test/dummy/app/views/users/_form.html.erb +3 -2
- data/vendor/assets/javascript/country_state_select.js.erb +38 -37
- metadata +31 -15
- data/lib/country_state_select/constant.rb +0 -145
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
N2MyZWRhYTJiYzhiNTI3MmQ2NjE5YjQ0NDI4ZDFhMzgyZjJiZGU0Zg==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 02bf73bd8a9196b44064226453776133072796c9
|
4
|
+
data.tar.gz: df815b26922b16949f4c47ed724b20a042a73ba9
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MGQzMGYwODdiMzk5ODEyZWFiMzcwM2ZjNzdkMmJiZGU1MTZlYTlmOGEzNmIz
|
11
|
-
OWM2ZDVmYzk1ZGZkZTA4NzAyMjAzMDI4ZmEyZmJhOGEzY2E0NzE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NzY2ZjVlNzYwZmY5NWRiODYxYWMyOWE5ZTNlYWU0YTdhMzk5ODM3NWU0MzUw
|
14
|
-
NDNkYzM0YmJmN2E3YWI3MDM0MzE0OGEyZjE4MWFjZGI5YTQ3N2JlOWQyOWM5
|
15
|
-
NjhmMWEyMjcwYzNmN2M0NWRmMTRkMDg0ZjdhYmE4NjBmZmYwYjA=
|
6
|
+
metadata.gz: 2fadfdc4f7209ad09cdd7a172b23789518cc0f33717ad4e6ce153562d2c51006c9988d48965ee22e63a54a795b19023ca72faacdea50f3326ff0942513bedcbc
|
7
|
+
data.tar.gz: f1b5ce31078cf6740469c7f79dd9250ec8013dd7fcc0b618f6f0d1a93bd6bde12be41d038503f0592a8d291f9a20e4e6bd080e09328d065a75f1003a3717d5db
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
##Country State Select
|
1
|
+
##Country State Select [![Build Status](https://travis-ci.org/arvindvyas/Country-State-Select.svg?branch=master)](https://travis-ci.org/arvindvyas/Country-State-Select) [![Code Climate](https://codeclimate.com/github/arvindvyas/Country-State-Select/badges/gpa.svg)](https://codeclimate.com/github/arvindvyas/Country-State-Select)
|
2
2
|
|
3
3
|
Country State Select is library which gives you all the country names and when you select any country then it also create the other select box with all the states name of that country
|
4
4
|
|
@@ -11,110 +11,7 @@ or Rails application. To install, simply add the following to your Gemfile.
|
|
11
11
|
|
12
12
|
Run bundle install and don't forget to restart your server after you install a new gem.
|
13
13
|
|
14
|
-
##Usage
|
15
14
|
|
16
|
-
It returns all the country name
|
17
|
-
|
18
|
-
CountryStateSelect::Constant::COUNTRIES
|
19
|
-
|
20
|
-
=> ["Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola",
|
21
|
-
"Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria",
|
22
|
-
................................]
|
23
|
-
|
24
|
-
It returns all the Indian states.
|
25
|
-
|
26
|
-
CountryStateSelect::Constant::INDIAN_STATES
|
27
|
-
|
28
|
-
It return all the USA states.
|
29
|
-
|
30
|
-
CountryStateSelect::Constant::USA_STATES
|
31
|
-
|
32
|
-
It returns all the Canadian states.
|
33
|
-
|
34
|
-
CountryStateSelect::CANADIAN_STATES
|
35
|
-
|
36
|
-
It returns all the UK states.
|
37
|
-
|
38
|
-
CountryStateSelect::UK_STATES
|
39
|
-
|
40
|
-
##Version History
|
41
|
-
|
42
|
-
1.0.1
|
43
|
-
|
44
|
-
Added method 'countries_except' inside this can put all the countries which you do not want in to the country select option just you have to fetch countries by
|
45
|
-
CountryStateSelect.countries_except('CountryName1','CountryName2'....)
|
46
|
-
|
47
|
-
1.0.0
|
48
|
-
|
49
|
-
It is the stable version which have all the feature
|
50
|
-
It also have support of chosen-rails
|
51
|
-
|
52
|
-
0.0.3 & 0.0.4
|
53
|
-
|
54
|
-
In both the version state field will not update if you will select the country
|
55
|
-
|
56
|
-
|
57
|
-
##Very easy to create select box just follow below steps
|
58
|
-
|
59
|
-
First put this to the application.js file to load the js file
|
60
|
-
|
61
|
-
//= require country_state_select
|
62
|
-
|
63
|
-
It will create for you a select option, just care about 'id' if you want to update your state field
|
64
|
-
|
65
|
-
<%= f.select :country_name, CountryStateSelect::Constant::COUNTRIES, {}, id: 'country_id' %>
|
66
|
-
|
67
|
-
Create your state like mention below, and take care about id of the select field if you will change this then it will now work as it should be
|
68
|
-
|
69
|
-
<%= f.text_field :state_name ,:id=> 'state_name'%>
|
70
|
-
|
71
|
-
If you want to store country id then use this select option it will store the country id inside the database if you want the state field update with this then you can put id field inside this also like we have mention in previous example
|
72
|
-
|
73
|
-
<%= f.select(:country_id, options_for_select(Array[*CountryStateSelect::Constant::COUNTRIES.collect {|v,i| [v,
|
74
|
-
CountryStateSelect::Constant::COUNTRIES.index(v)] }], :selected => f.object)) %>
|
75
|
-
|
76
|
-
If you want to fetch the country name By 'id' then you have to just write
|
77
|
-
|
78
|
-
<%= CountryStateSelect::Constant::COUNTRIES['PASS THE COUNTRY ID WHICH YOU SAVE HERE'] %>
|
79
|
-
|
80
|
-
|
81
|
-
NOTE :- It will update the state field when there will be India,United Kingdom,Canada and United States so except these country if you select other country then you have to manually enter the state name, we are working on this soon we will cover most of the country
|
82
|
-
|
83
|
-
##Configure if want country_state_select with chosen_rails
|
84
|
-
|
85
|
-
Include both the gem in your Gemfile
|
86
|
-
gem 'chosen-rails'
|
87
|
-
gem 'country_state_select'
|
88
|
-
|
89
|
-
Include 'chosen-jquery' inside your application.js file
|
90
|
-
//= require chosen-jquery
|
91
|
-
|
92
|
-
Include chosen inside stylesheet assets
|
93
|
-
*= require chosen
|
94
|
-
|
95
|
-
Enable chosen javascript
|
96
|
-
|
97
|
-
Create one coffee-script file eg scaffold.js.coffee
|
98
|
-
$(document).on 'ready page:load', ->
|
99
|
-
$('.chosen-select').change ->
|
100
|
-
if $('#state_name option').size() > 1
|
101
|
-
$("#state_name" ).chosen() //this will add the chosen-select in to the state select
|
102
|
-
$("#state_name_chosen").empty();
|
103
|
-
|
104
|
-
$('.chosen-select').chosen
|
105
|
-
allow_single_deselect: true
|
106
|
-
no_results_text: 'No results matched'
|
107
|
-
width: '280px'
|
108
|
-
|
109
|
-
And this file must be included in application.js
|
110
|
-
//= require chosen-jquery
|
111
|
-
//= require scaffold
|
112
|
-
above scaffold is required because we have put the js inside that if you put in other coffee file that that you have to include
|
113
|
-
|
114
|
-
And the country select option will be
|
115
|
-
<%= f.select :country_name, CountryStateSelect::Constant::COUNTRIES, {}, id: 'country_id', :class=>'chosen-select' %>
|
116
|
-
And the state input box will be
|
117
|
-
<%= f.text_field :state_name ,:id=>'state_name' %>
|
118
15
|
|
119
16
|
##Contributing to Country State Select
|
120
17
|
|
data/config/routes.rb
ADDED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Arvind Vyas"]
|
10
10
|
spec.email = ["arvindvyas07@gmail.com"]
|
11
11
|
spec.summary = %q{This is to list country and state.}
|
12
|
-
spec.description = %q{Can list out country and according to that can list
|
12
|
+
spec.description = %q{Can list out country and according to that can list state dynamically.}
|
13
13
|
spec.homepage = "https://github.com/arvindvyas/country_state_select.git"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_runtime_dependency 'rails', '>= 3.0'
|
22
|
-
|
22
|
+
spec.add_runtime_dependency 'city-state'
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.6"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
end
|
data/lib/country_state_select.rb
CHANGED
@@ -1,43 +1,37 @@
|
|
1
1
|
require "country_state_select/version"
|
2
|
-
|
3
|
-
require 'country_state_select/constant'
|
2
|
+
require 'country_state_select/cst_data'
|
4
3
|
|
5
4
|
module CountryStateSelect
|
6
|
-
include CountryStateSelect::
|
7
|
-
|
5
|
+
include CountryStateSelect::CstData
|
6
|
+
|
8
7
|
def self.countries
|
9
|
-
|
8
|
+
CountryStateSelect::CstData.countries
|
10
9
|
end
|
11
10
|
|
12
11
|
def self.india
|
13
|
-
|
12
|
+
CountryStateSelect::CstData.states("IN")
|
14
13
|
end
|
15
14
|
|
16
15
|
def self.us_states
|
17
|
-
|
16
|
+
CountryStateSelect::CstData.states("US")
|
18
17
|
end
|
19
18
|
|
20
19
|
def self.canadian_states
|
21
|
-
|
20
|
+
CountryStateSelect::CstData.states("CA")
|
22
21
|
end
|
23
22
|
|
24
23
|
def self.uk_states
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.all_states
|
29
|
-
INDIAN_STATES.merge(INDIAN_TERRIOTORY).merge(USA_STATE_LIST).merge(CANADIAN_STATES).merge(UK_STATES)
|
24
|
+
CountryStateSelect::CstData.states("GB")
|
30
25
|
end
|
31
26
|
|
32
27
|
#this method will provide the user to opetion to skip any countries in drop down list
|
33
28
|
def self.countries_except(*except)
|
34
29
|
countries = []
|
35
|
-
|
30
|
+
self.countries.each do |country|
|
36
31
|
countries<< country unless country.in?(except)
|
37
32
|
end
|
38
33
|
return countries
|
39
34
|
end
|
40
|
-
|
41
35
|
end
|
42
36
|
|
43
37
|
case ::Rails.version.to_s
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
# @author Arvind Vyas
|
5
|
+
|
6
|
+
module CountryStateSelect
|
7
|
+
require 'city-state'
|
8
|
+
module CstData
|
9
|
+
def self.countries
|
10
|
+
CS.countries
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.states(country)
|
14
|
+
CS.states(country)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -21,12 +21,13 @@
|
|
21
21
|
</div>
|
22
22
|
<div class="field">
|
23
23
|
<%= f.label :country_id %><br>
|
24
|
-
<%= f.select :country_name, CountryStateSelect.
|
24
|
+
<%= f.select :country_name, CountryStateSelect.countries.collect {|p| [ p[ 1], p[0] ] }, {}, id: 'country_id', :class=>'chosen-select' %>
|
25
25
|
|
26
26
|
</div>
|
27
27
|
<div class="field">
|
28
28
|
<%= f.label :state_name %><br>
|
29
|
-
<%= f.text_field :state_name ,:id=>
|
29
|
+
<%= f.text_field :state_name ,:id=>'state_name', class: 'chosen-select' %>
|
30
|
+
|
30
31
|
</div>
|
31
32
|
<div class="actions">
|
32
33
|
<%= f.submit %>
|
@@ -1,43 +1,44 @@
|
|
1
1
|
$(document).on('ready page:load', function () {
|
2
|
+
|
2
3
|
$("#country_id").change(function() {
|
3
|
-
var default_state = []
|
4
4
|
var country = $('#country_id option:selected').text()
|
5
|
-
var name = $("#state_name").attr("name");
|
6
|
-
var select = $('<select name='+ name +' id="state_name"></select>');
|
7
|
-
var indian_state =
|
8
|
-
<%= CountryStateSelect::Constant::INDIAN_STATES %>
|
9
|
-
var usa_state =
|
10
|
-
<%= CountryStateSelect::Constant::USA_STATES %>
|
11
|
-
var canadan_state =
|
12
|
-
<%= CountryStateSelect::Constant::CANADIAN_STATES %>
|
13
|
-
var uk_state =
|
14
|
-
<%= CountryStateSelect::Constant::UK_STATES %>
|
15
5
|
var options = '';
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
default:
|
31
|
-
default_state = []
|
32
|
-
}
|
33
|
-
|
34
|
-
if (default_state.length > 0) {
|
35
|
-
for(var val in default_state) {
|
36
|
-
$('<option />', {value: default_state[val], text: default_state[val]}).appendTo(select);
|
6
|
+
$('#state_name').html('');
|
7
|
+
find_csc('/find_states', $("#country_id").val());
|
8
|
+
});
|
9
|
+
var find_csc = function(url, id){
|
10
|
+
$.ajax({
|
11
|
+
url: url,
|
12
|
+
type: 'post',
|
13
|
+
dataType: 'json',
|
14
|
+
cache: false,
|
15
|
+
data: {
|
16
|
+
country_id: id
|
17
|
+
},
|
18
|
+
success:function(data) {
|
19
|
+
create_select(data) ;
|
37
20
|
}
|
38
|
-
}
|
39
|
-
|
21
|
+
});
|
22
|
+
}
|
23
|
+
var create_select = function(data){
|
24
|
+
if (data.length === 0){
|
25
|
+
$html = "<input id='state_name' name="+ name +" class="+class_name+" type='text' value='' />"
|
26
|
+
}else{
|
27
|
+
name = $('#state_name').attr('name');
|
28
|
+
class_name = $('#state_name').attr('class');
|
29
|
+
$html= '<select class='+class_name+' id="state_name" name='+name+' >'
|
30
|
+
$html+='<option selected=\"selected\" >'+data[0][1]+'</option>';
|
31
|
+
|
32
|
+
for ( var idcount = 1; idcount < data.length; idcount++) {
|
33
|
+
$html+='<option>'+data[idcount][1]+'</option>';
|
34
|
+
}
|
35
|
+
$html+='</select>';
|
40
36
|
}
|
41
|
-
|
42
|
-
|
43
|
-
|
37
|
+
|
38
|
+
$('#state_name').replaceWith($html);
|
39
|
+
if (class_name === 'chosen-select' && data.length >0){
|
40
|
+
$('.'+class_name+'').chosen();
|
41
|
+
}
|
42
|
+
|
43
|
+
}
|
44
|
+
});
|
metadata
CHANGED
@@ -1,73 +1,89 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: country_state_select
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arvind Vyas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: city-state
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - ~>
|
45
|
+
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
47
|
version: '1.6'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - ~>
|
52
|
+
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '1.6'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- -
|
59
|
+
- - ">="
|
46
60
|
- !ruby/object:Gem::Version
|
47
61
|
version: '0'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- -
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
|
-
description: Can list out country and according to that can list
|
69
|
+
description: Can list out country and according to that can list state dynamically.
|
56
70
|
email:
|
57
71
|
- arvindvyas07@gmail.com
|
58
72
|
executables: []
|
59
73
|
extensions: []
|
60
74
|
extra_rdoc_files: []
|
61
75
|
files:
|
62
|
-
- .gitignore
|
63
|
-
- .travis.yml
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
64
78
|
- Gemfile
|
65
79
|
- LICENSE.txt
|
66
80
|
- README.md
|
67
81
|
- Rakefile
|
82
|
+
- app/controllers/country_state_select/cscs_controller.rb
|
83
|
+
- config/routes.rb
|
68
84
|
- country_state_select.gemspec
|
69
85
|
- lib/country_state_select.rb
|
70
|
-
- lib/country_state_select/
|
86
|
+
- lib/country_state_select/cst_data.rb
|
71
87
|
- lib/country_state_select/engine.rb
|
72
88
|
- lib/country_state_select/engine3.rb
|
73
89
|
- lib/country_state_select/railtie.rb
|
@@ -156,17 +172,17 @@ require_paths:
|
|
156
172
|
- lib
|
157
173
|
required_ruby_version: !ruby/object:Gem::Requirement
|
158
174
|
requirements:
|
159
|
-
- -
|
175
|
+
- - ">="
|
160
176
|
- !ruby/object:Gem::Version
|
161
177
|
version: '0'
|
162
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
163
179
|
requirements:
|
164
|
-
- -
|
180
|
+
- - ">="
|
165
181
|
- !ruby/object:Gem::Version
|
166
182
|
version: '0'
|
167
183
|
requirements: []
|
168
184
|
rubyforge_project:
|
169
|
-
rubygems_version: 2.
|
185
|
+
rubygems_version: 2.4.5
|
170
186
|
signing_key:
|
171
187
|
specification_version: 4
|
172
188
|
summary: This is to list country and state.
|
@@ -1,145 +0,0 @@
|
|
1
|
-
#!/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
# @author Arvind Vyas
|
5
|
-
|
6
|
-
module CountryStateSelect
|
7
|
-
module Constant
|
8
|
-
|
9
|
-
# array containing all the countries name in alphabetical order
|
10
|
-
COUNTRIES = ["Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa", "Andorra", "Angola",
|
11
|
-
"Anguilla", "Antarctica", "Antigua And Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria",
|
12
|
-
"Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin",
|
13
|
-
"Bermuda", "Bhutan", "Bolivia, Plurinational State of", "Bonaire, Sint Eustatius and Saba", "Bosnia and Herzegovina",
|
14
|
-
"Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia",
|
15
|
-
"Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China",
|
16
|
-
"Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia", "Cuba",
|
17
|
-
"Cyprus", "Czech Republic", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece",
|
18
|
-
"Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Holy See (Vatican City State)",
|
19
|
-
"Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran, Islamic Republic of", "Iraq",
|
20
|
-
"Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya",
|
21
|
-
"Kiribati", "Korea, Democratic People's Republic of", "Korea, Republic of", "Kuwait", "Kyrgyzstan",
|
22
|
-
"Lao People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya",
|
23
|
-
"Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia, The Former Yugoslav Republic Of",
|
24
|
-
"Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique",
|
25
|
-
"Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Moldova, Republic of",
|
26
|
-
"Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru",
|
27
|
-
"Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau",
|
28
|
-
"Palestinian Territory, Occupied", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines",
|
29
|
-
"Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation",
|
30
|
-
"Rwanda", "Saint Barthelemy", "Saint Helena, Ascension and Tristan da Cunha", "Saint Kitts and Nevis", "Saint Lucia",
|
31
|
-
"Saint Martin (French Part)", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino",
|
32
|
-
"Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore",
|
33
|
-
"Sint Maarten (Dutch Part)", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa",
|
34
|
-
"South Georgia and the South Sandwich Islands", "South Sudan", "Spain", "Sri Lanka", "Sudan", "Suriname",
|
35
|
-
"Svalbard and Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Syrian Arab Republic",
|
36
|
-
"Taiwan, Province of China", "Tajikistan", "Tanzania, United Republic of", "Thailand", "Timor-Leste",
|
37
|
-
"Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan",
|
38
|
-
"Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom",
|
39
|
-
"United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu",
|
40
|
-
"Venezuela, Bolivarian Republic of", "Viet Nam", "Virgin Islands, British", "Virgin Islands, U.S.",
|
41
|
-
"Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe"].sort
|
42
|
-
|
43
|
-
#array containing all the Indian states except Indian Territory
|
44
|
-
INDIAN_STATES = [["Andhra Pradesh", "AP"], ["Arunachal Pradesh", "AR"], ["Assam", "AS"], ["Bihar", "BR"],
|
45
|
-
["Chhattisgarh", "CT"], ["Goa", "GA"], ["Gujarat", "GJ"], ["Haryana", "HR"],
|
46
|
-
["Himachal Pradesh", "HP"], ["Jammu & Kashmir", "JK"], ["Jharkhand", "JH"], ["Karnataka", "KA"],
|
47
|
-
["Kerala", "KL"], ["Madhya Pradesh", "MP"], ["Maharashtra", "MH"], ["Manipur", "MN"],
|
48
|
-
["Meghalaya", "ML"], ["Mizoram", "MZ"], ["Nagaland", "NL"], ["Odisha", "OR"], ["Punjab", "PB"],
|
49
|
-
["Rajasthan", "RJ"], ["Sikkim", "SK"], ["Tamil Nadu", "TN"], ["Tripura", "TR"], ["Uttarakhand", "UK"],
|
50
|
-
["Uttar Pradesh", "UP"], ["West Bengal", "WB"], ["Telangana", "TS"]].sort
|
51
|
-
|
52
|
-
#array containing all the Indian Territory
|
53
|
-
INDIAN_TERRIOTORY = [["Andaman & Nicobar", "AN"], ["Chandigarh", "CH"], ["Dadra and Nagar Haveli", "DN"],
|
54
|
-
["Daman & Diu", "DD"], ["Delhi", "DL"], ["Lakshadweep", "LD"], ["Puducherry", "PY"]].sort
|
55
|
-
|
56
|
-
#array containing us states
|
57
|
-
USA_STATES =[["Alabama", "AL"], ["Alaska", "AK"], ["Arizona", "AZ"], ["Arkansas", "AR"], ["California", "CA"],
|
58
|
-
["Colorado", "CO"], ["Connecticut", "CT"], ["Delaware", "DE"], ["District Of Columbia", "DC"],
|
59
|
-
["Florida", "FL"], ["Georgia", "GA"], ["Hawaii", "HI"], ["Idaho", "ID"], ["Illinois", "IL"],
|
60
|
-
["Indiana", "IN"], ["Iowa", "IA"], ["Kansas", "KS"], ["Kentucky", "KY"], ["Louisiana", "LA"],
|
61
|
-
["Maine", "ME"], ["Maryland", "MD"], ["Massachusetts", "MA"], ["Michigan", "MI"], ["Minnesota", "MN"],
|
62
|
-
["Mississippi", "MS"], ["Missouri", "MO"], ["Montana", "MT"], ["Nebraska", "NE"], ["Nevada", "NV"],
|
63
|
-
["New Hampshire", "NH"], ["New Jersey", "NJ"], ["New Mexico", "NM"], ["New York", "NY"],
|
64
|
-
["North Carolina", "NC"], ["North Dakota", "ND"], ["Ohio", "OH"], ["Oklahoma", "OK"], ["Oregon", "OR"],
|
65
|
-
["Pennsylvania", "PA"], ["Rhode Island", "RI"], ["South Carolina", "SC"], ["South Dakota", "SD"],
|
66
|
-
["Tennessee", "TN"], ["Texas", "TX"], ["Utah", "UT"], ["Vermont", "VT"], ["Virginia", "VA"],
|
67
|
-
["Washington", "WA"], ["West Virginia", "WV"], ["Wisconsin", "WI"], ["Wyoming", "WY"]].sort
|
68
|
-
|
69
|
-
#array containing Canadian states
|
70
|
-
CANADIAN_STATES = [["British Columbia", "BC"], ["Ontario", "ON"], ["Newfoundland and Labrador", "NL"],
|
71
|
-
["Nova Scotia", "NS"], ["Prince Edward Island", "PE"], ["New Brunswick", "NB"], ["Quebec", "QC"],
|
72
|
-
["Manitoba", "MB"], ["Saskatchewan", "SK"], ["Alberta", "AB"], ["Northwest Territories", "NT"],
|
73
|
-
["Nunavut", "NU"], ["Yukon Territory", "YT"]].sort
|
74
|
-
|
75
|
-
#array containing all the uk states
|
76
|
-
UK_STATES = [["Guernsey", "GSY"], ["Jersey", "JSY"], ["Barking and Dagenham", "BDG"], ["Barnet", "BNE"],
|
77
|
-
["Barnsley", "BNS"], ["Bath and North East Somerset", "BAS"], ["Bedfordshire", "BDF"],
|
78
|
-
["Bexley", "BEX"], ["Birmingham", "BIR"], ["Blackburn with Darwen", "BBD"], ["Blackpool", "BPL"],
|
79
|
-
["Bolton", "BOL"], ["Bournemouth", "BMH"], ["Bracknell Forest", "BRC"], ["Bradford", "BRD"],
|
80
|
-
["Brent", "BEN"], ["Brighton and Hove", "BNH"], ["Bristol", "BST"], ["Bromley", "BRY"],
|
81
|
-
["Buckinghamshire", "BKM"], ["Bury", "BUR"], ["Calderdale", "CLD"], ["Cambridgeshire", "CAM"],
|
82
|
-
["Camden", "CMD"], ["Cheshire", "CHS"], ["Cornwall", "CON"], ["Coventry (West Midlands district)", "COV"],
|
83
|
-
["Croydon", "CRY"], ["Cumbria", "CMA"], ["Darlington", "DAL"], ["Derbyshire", "DER"], ["Derbyshire", "DBY"],
|
84
|
-
["Devon", "DEV"], ["Doncaster", "DNC"], ["Dorset", "DOR"], ["Dudley (West Midlands district)", "DUD"],
|
85
|
-
["County Durham", "DUR"], ["Ealing", "EAL"], ["East Riding of Yorkshire", "ERY"], ["East Sussex", "ESX"],
|
86
|
-
["Enfield", "ENF"], ["Essex", "ESS"], ["Gateshead (Tyne & Wear district)", "GAT"], ["Gloucestershire", "GLS"],
|
87
|
-
["Greenwich", "GRE"], ["Hackney", "HCK"], ["Halton", "HAL"], ["Hammersmith and Fulham", "HMF"],
|
88
|
-
["Hampshire", "HAM"], ["Haringey", "HRY"], ["Harrow", "HRW"], ["Hartlepool", "HPL"], ["Havering", "HAV"],
|
89
|
-
["Herefordshire", "HEF"], ["Hertfordshire", "HRT"], ["Hillingdon", "HIL"], ["Hounslow", "HNS"],
|
90
|
-
["Isle of Wight", "IOW"], ["Isles of Scilly", "IOS"], ["Islington", "ISL"], ["Kensington and Chelsea", "KEC"],
|
91
|
-
["Kent", "KEN"], ["Kingston upon Hull City of", "KHL"], ["Kingston upon Thames", "KTT"], ["Kirklees", "KIR"],
|
92
|
-
["Knowsley", "KWL"], ["Lambeth", "LBH"], ["Lancashire", "LAN"], ["Leeds", "LDS"], ["Leicester", "LCE"],
|
93
|
-
["Leicestershire", "LEC"], ["Lewisham", "LEW"], ["Lincolnshire", "LIN"], ["Liverpool", "LIV"],
|
94
|
-
["London", "LND"], ["Luton", "LUT"], ["Manchester", "MAN"], ["Medway", "MDW"], ["Merton", "MRT"],
|
95
|
-
["Middlesbrough", "MDB"], ["Milton Keynes", "MIK"], ["Newcastle upon Tyne", "NET"], ["Newham", "NWM"],
|
96
|
-
["Norfolk", "NFK"], ["North East Lincolnshire", "NEL"], ["North Lincolnshire", "NLN"],
|
97
|
-
["North Somerset", "NSM"], ["North Tyneside", "NTY"], ["North Yorkshire", "NYK"], ["Northamptonshire", "NTH"],
|
98
|
-
["Northumberland", "NBL"], ["Nottingham", "NGM"], ["Nottinghamshire", "NTT"], ["Oldham", "OLD"],
|
99
|
-
["Oxfordshire", "OXF"], ["Peterborough", "PTE"], ["Plymouth", "PLY"], ["Poole", "POL"], ["Portsmouth", "POR"],
|
100
|
-
["Reading", "RDG"], ["Redbridge", "RDB"], ["Redcar and Cleveland", "RCC"], ["Richmond upon Thames", "RIC"],
|
101
|
-
["Rochdale", "RCH"], ["Rotherham", "ROT"], ["Rutland", "RUT"], ["St Helens", "SHN"], ["Salford", "SLF"],
|
102
|
-
["Sandwell", "SAW"], ["Sefton", "SFT"], ["Sheffield", "SHF"], ["Shropshire", "SHR"], ["Slough", "SLG"],
|
103
|
-
["Solihull", "SOL"], ["Somerset", "SOM"], ["South Gloucestershire", "SGC"], ["South Tyneside", "STY"],
|
104
|
-
["Southampton", "STH"], ["Southend-on-Sea", "SOS"], ["Southwark", "SWK"], ["Staffordshire", "STS"],
|
105
|
-
["Stockport", "SKP"], ["Stockton-on-Tees", "STT"], ["Stoke-on-Trent", "STE"], ["Suffolk", "SFK"],
|
106
|
-
["Sunderland", "SND"], ["Surrey", "SRY"], ["Sutton", "STN"], ["Swindon", "SWD"], ["Tameside", "TAM"],
|
107
|
-
["Telford and Wrekin", "TFW"], ["Thurrock", "THR"], ["Torbay", "TOB"], ["Tower Hamlets", "TWH"],
|
108
|
-
["Trafford", "TRF"], ["Wakefield", "WKF"], ["Walsall", "WLL"], ["Waltham Forest", "WFT"],
|
109
|
-
["Wandsworth", "WND"], ["Warrington", "WRT"], ["Warwickshire", "WAR"], ["West Berkshire", "WBK"],
|
110
|
-
["West Sussex", "WSX"], ["Westminster", "WSM"], ["Wigan", "WGN"], ["Wiltshire", "WIL"],
|
111
|
-
["Windsor and Maidenhead", "WNM"], ["Wirral", "WRL"], ["Wokingham", "WOK"], ["Wolverhampton", "WLV"],
|
112
|
-
["Worcestershire", "WOR"], ["York", "YOR"], ["County Antrim", "ANT"], ["Ards", "ARD"],
|
113
|
-
["County Armagh", "ARM"], ["Ballymena", "BLA"], ["Ballymoney", "BLY"], ["Banbridge", "BNB"],
|
114
|
-
["Belfast", "BFS"], ["Carrickfergus", "CKF"], ["Castlereagh", "CSR"], ["Coleraine", "CLR"],
|
115
|
-
["Cookstown", "CKT"], ["Craigavon", "CGV"], ["Derry", "DRY"], ["County Down", "DOW"],
|
116
|
-
["Dungannon and South Tyrone", "DGN"], ["Fermanagh", "FER"], ["Larne", "LRN"], ["Limavady", "LMV"],
|
117
|
-
["Lisburn", "LSB"], ["Magherafelt", "MFT"], ["Moyle", "MYL"], ["Newry and Mourne", "NYM"],
|
118
|
-
["Newtownabbey", "NTA"], ["North Down", "NDN"], ["Omagh", "OMH"], ["Strabane", "STB"], ["Aberdeen", "ABE"],
|
119
|
-
["Aberdeenshire", "ABD"], ["Angus", "ANS"], ["Argyll and Bute", "AGB"], ["Clackmannanshire", "CLK"],
|
120
|
-
["Dumfries & Galloway", "DGY"], ["Dundee", "DND"], ["East Ayrshire", "EAY"], ["East Dunbartonshire", "EDU"],
|
121
|
-
["East Lothian", "ELN"], ["East Renfrewshire", "ERW"], ["Edinburgh", "EDH"], ["Eilean Siar", "ELS"],
|
122
|
-
["Falkirk", "FAL"], ["Fife", "FIF"], ["Glasgow", "GLG"], ["Highlands", "HLD"], ["Inverclyde", "IVC"],
|
123
|
-
["North Ayrshire", "NAY"], ["North Lanarkshire", "NLK"], ["Orkney Islands", "ORK"], ["Perth and Kinross", "PKN"],
|
124
|
-
["Midlothian", "MLN"], ["Moray", "MRY"], ["Renfrewshire", "RFW"], ["Scottish Borders The", "SCB"],
|
125
|
-
["Shetland Islands", "ZET"], ["South Ayrshire", "SAY"], ["South Lanarkshire", "SLK"], ["Stirling", "STG"],
|
126
|
-
["West Dunbartonshire", "WDU"], ["West Lothian", "WLN"], ["Blaenau Gwent", "BGW"], ["Bridgend", "BGE"],
|
127
|
-
["Caerphilly", "CAY"], ["Cardiff", "CRF"], ["Carmarthenshire", "CMN"], ["Ceredigion", "CGN"],
|
128
|
-
["Conwy", "CWY"], ["Denbighshire", "DEN"], ["Flintshire", "FLN"], ["Gwynedd", "GWN"],
|
129
|
-
["Anglesey (Isle of)", "AGY"], ["Merthyr Tydfil", "MTY"], ["Monmouthshire", "MON"],
|
130
|
-
["Neath Port Talbot", "NTL"], ["Newport", "NWP"], ["Pembrokeshire", "PEM"], ["Powys", "POW"],
|
131
|
-
["Rhondda Cynon Taff", "RCT"], ["Swansea", "SWA"], ["Torfaen", "TOF"], ["Vale of Glamorgan", "VGL"],
|
132
|
-
["Wrexham", "WRX"], ["Alderney", "ALD"], ["Ayrshire", "AYR"], ["Banffshire", "BAN"], ["Berkshire", "BRK"],
|
133
|
-
["Berwickshire", "BEW"], ["Borders", "BOR"], ["Caithness", "CAI"], ["Central Scotland", "CEN"],
|
134
|
-
["Channel Islands", "CHI"], ["Clwyd", "CWD"], ["County Tyrone", "TYR"], ["Dunbartonshire", "DNB"],
|
135
|
-
["Dyfed", "DYD"], ["Glamorgan", "GLA"], ["Grampian", "GMP"], ["Gwent", "GNT"], ["Inverness-shire", "INV"],
|
136
|
-
["Isle of Man", "IOM"], ["Kincardineshire", "KCD"], ["Kinross-shire", "KRS"], ["Kirkcudbrightshire", "KKD"],
|
137
|
-
["Lanarkshire", "LKS"], ["Leicestershire", "LEI"], ["Londonderry", "LDY"], ["Manchester (Greater)", "GTM"],
|
138
|
-
["Merseyside", "MSY"], ["Middlesex", "MDX"], ["Moray", "MOR"], ["Nairnshire", "NAI"], ["Orkney", "OKI"],
|
139
|
-
["Peeblesshire", "PEE"], ["Perthshire", "PER"], ["Ross and Cromarty", "ROC"], ["Roxburghshire", "ROX"],
|
140
|
-
["Selkirkshire", "SEL"], ["Shetland", "SHI"], ["South Yorkshire", "SYK"], ["Stirlingshire", "STI"],
|
141
|
-
["Strathclyde", "STD"], ["Sutherland", "SUT"], ["Tayside", "TAY"], ["Tyne & Wear", "TWR"],
|
142
|
-
["West Midlands", "WMD"], ["West Sussex", "SXW"], ["West Yorkshire", "WYK"], ["Western Isles", "WIS"],
|
143
|
-
["Wigtownshire", "WIG"]].sort
|
144
|
-
end
|
145
|
-
end
|