has_addresses 0.0.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,114 +1,300 @@
1
- require 'open-uri'
2
- require 'cgi'
3
- require 'rexml/document'
4
-
5
1
  # Defined by the ISO 3166 standard. The ISO 3166 standard includes a
6
2
  # "Country Subdivision Code", giving a code for the names of the principal
7
3
  # administrative subdivisions of the countries coded in ISO 3166.
4
+ #
5
+ # Data is based on http://svn.debian.org/wsvn/pkg-isocodes/trunk/iso-codes/iso_3166/iso_3166.xml?op=file
6
+ #
7
+ # Countries are uniquely identified by their alpha 2 code. You can access
8
+ # countries like so:
9
+ #
10
+ # Country['US'] # => #<Country id: 840, alpha_2_code: "US", name: "United States", official_name: "United States of America", alpha_3_code: "USA">
11
+ # Country['CA'] # => #<Country id: 124, alpha_2_code: "CA", name: "Canada", official_name: "Canada", alpha_3_code: "CAN">
12
+ #
13
+ # == Identification
14
+ #
15
+ # Country ids are based on another ISO standard which assigns a numeric value
16
+ # to every country.
17
+ #
18
+ # == Regions
19
+ #
20
+ # Each country may or may not have a list of regions associated with it. It
21
+ # is largely based on the ISO standard for each country.
22
+ #
23
+ # == Performance
24
+ #
25
+ # If plugin reloading is enabled or this model is added to your app,
26
+ # consider marking the file as unloadable like so (in the environment):
27
+ #
28
+ # config.after_initialize do
29
+ # ActiveSupport::Dependencies.load_once_paths << "#{Rails.root}/vendor/plugins/has_addresses/app/models/country" # or "#{Rails.root}/app/models/country"
30
+ # end
31
+ #
32
+ # This will prevent the enumeration from being bootstrapped after every
33
+ # request when in development mode.
8
34
  class Country < ActiveRecord::Base
9
- # The url of the open source version of the ISO 3166 standard
10
- ISO_3166_URL = 'http://svn.debian.org/wsvn/pkg-isocodes/trunk/iso-codes/iso_3166/iso_3166.xml?op=file'
35
+ enumerate_by :alpha_2_code
11
36
 
12
- class << self
13
- # Creates a fixtures file containing all possible countries
14
- def create_fixtures(output_file_path = nil)
15
- output_file_path ||= 'db/bootstrap/countries.yml'
16
- output_file_path = File.join(RAILS_ROOT, output_file_path)
17
-
18
- FileUtils.mkdir_p(File.dirname(output_file_path))
19
- output_file = File.new(output_file_path, File::CREAT|File::TRUNC|File::RDWR)
20
- output = ''
21
-
22
- countries = download_all
23
- puts "Saving countries to #{output_file_path}..." if PluginAWeek::Has::Addresses.verbose
24
- countries.each do |country|
25
- record_name = country.name.gsub(' ', '_').gsub(/[^A-Za-z_]/, '').downcase
26
-
27
- output << "#{record_name}:\n"
28
- country.attributes.each do |attr, value|
29
- output << " #{attr}: #{value}\n" if value
30
- end
31
- end
32
-
33
- output_file << output.slice(0..output.length-2)
34
- output_file.close
35
-
36
- puts 'Done!' if PluginAWeek::Has::Addresses.verbose
37
- true
38
- end
39
-
40
- # Bootstraps the table by downloading the latest ISO 3166 standard and
41
- # saving each country to the database
42
- def bootstrap
43
- countries = download_all
44
-
45
- puts 'Loading countries into database...' if PluginAWeek::Has::Addresses.verbose
46
- delete_all
47
- countries.each {|country| country.save!}
48
-
49
- puts 'Done!' if PluginAWeek::Has::Addresses.verbose
50
- true
51
- end
52
-
53
- # Downloads the latest ISO 3166 standard and returns the data as a list of
54
- # countries
55
- def download_all
56
- # Download the standard
57
- puts 'Downloading ISO 3166 data...' if PluginAWeek::Has::Addresses.verbose
58
- iso_3166 = open(ISO_3166_URL).readlines * "\n"
59
- iso_3166 = CGI::unescapeHTML(/<pre>(.+)<\/pre>/im.match(iso_3166)[1].gsub('&nbsp;', ''))
60
-
61
- # Parse and load the countries
62
- puts 'Parsing countries...' if PluginAWeek::Has::Addresses.verbose
63
- countries = []
64
- REXML::Document.new(iso_3166).elements.each('*/iso_3166_entry') do |country|
65
- name = country.attributes['name'].to_s.gsub("'","\\'")
66
- official_name = country.attributes['official_name']
67
- official_name = official_name.to_s.gsub!("'", "\\'") if official_name
68
- alpha_2_code = country.attributes['alpha_2_code'].to_s.upcase
69
- alpha_3_code = country.attributes['alpha_3_code'].to_s.upcase
70
- country_id = country.attributes['numeric_code'].to_s.to_i
71
- record_name = name.gsub(' ', '_').gsub(/[^A-Za-z_]/, '').downcase
72
-
73
- country = new(
74
- :name => name,
75
- :official_name => official_name,
76
- :alpha_2_code => alpha_2_code,
77
- :alpha_3_code => alpha_3_code
78
- )
79
- country.id = country_id
80
- countries << country
81
- end
82
-
83
- countries
84
- end
85
- end
86
-
87
- has_many :regions
37
+ has_many :regions
38
+ has_many :addresses
88
39
 
89
- validates_presence_of :name,
90
- :alpha_2_code,
91
- :alpha_3_code
92
- validates_uniqueness_of :name,
93
- :alpha_2_code,
94
- :alpha_3_code
95
- validates_length_of :name,
96
- :within => 2..80
97
- validates_length_of :alpha_2_code,
98
- :is => 2
99
- validates_length_of :alpha_3_code,
100
- :is => 3
40
+ validates_presence_of :name, :official_name, :alpha_3_code
41
+ validates_length_of :alpha_2_code, :is => 2
42
+ validates_length_of :alpha_3_code, :is => 3
101
43
 
102
44
  alias_attribute :abbreviation_2, :alpha_2_code
103
45
  alias_attribute :abbreviation_3, :alpha_3_code
104
46
 
105
- # The official name of the country
106
- def official_name
107
- read_attribute(:official_name) || name
47
+ def initialize(attributes = nil) #:nodoc:
48
+ super
49
+ self.official_name ||= name unless attributes && attributes.include?(:official_name)
108
50
  end
109
51
 
110
- # Returns the name of the country
111
- def to_s #:nodoc
112
- name
113
- end
52
+ fast_bootstrap(
53
+ {:id => 4, :name => "Afghanistan", :official_name => "Islamic Republic of Afghanistan", :alpha_2_code => 'AF', :alpha_3_code => 'AFG'},
54
+ {:id => 8, :name => "Albania", :official_name => "Republic of Albania", :alpha_2_code => 'AL', :alpha_3_code => 'ALB'},
55
+ {:id => 10, :name => "Antarctica", :alpha_2_code => 'AQ', :alpha_3_code => 'ATA'},
56
+ {:id => 12, :name => "Algeria", :official_name => "People's Democratic Republic of Algeria", :alpha_2_code => 'DZ', :alpha_3_code => 'DZA'},
57
+ {:id => 16, :name => "American Samoa", :alpha_2_code => 'AS', :alpha_3_code => 'ASM'},
58
+ {:id => 20, :name => "Andorra", :official_name => "Principality of Andorra", :alpha_2_code => 'AD', :alpha_3_code => 'AND'},
59
+ {:id => 24, :name => "Angola", :official_name => "Republic of Angola", :alpha_2_code => 'AO', :alpha_3_code => 'AGO'},
60
+ {:id => 28, :name => "Antigua and Barbuda", :alpha_2_code => 'AG', :alpha_3_code => 'ATG'},
61
+ {:id => 31, :name => "Azerbaijan", :official_name => "Republic of Azerbaijan", :alpha_2_code => 'AZ', :alpha_3_code => 'AZE'},
62
+ {:id => 32, :name => "Argentina", :official_name => "Argentine Republic", :alpha_2_code => 'AR', :alpha_3_code => 'ARG'},
63
+ {:id => 36, :name => "Australia", :alpha_2_code => 'AU', :alpha_3_code => 'AUS'},
64
+ {:id => 40, :name => "Austria", :official_name => "Republic of Austria", :alpha_2_code => 'AT', :alpha_3_code => 'AUT'},
65
+ {:id => 44, :name => "Bahamas", :official_name => "Commonwealth of the Bahamas", :alpha_2_code => 'BS', :alpha_3_code => 'BHS'},
66
+ {:id => 48, :name => "Bahrain", :official_name => "Kingdom of Bahrain", :alpha_2_code => 'BH', :alpha_3_code => 'BHR'},
67
+ {:id => 50, :name => "Bangladesh", :official_name => "People's Republic of Bangladesh", :alpha_2_code => 'BD', :alpha_3_code => 'BGD'},
68
+ {:id => 51, :name => "Armenia", :official_name => "Republic of Armenia", :alpha_2_code => 'AM', :alpha_3_code => 'ARM'},
69
+ {:id => 52, :name => "Barbados", :alpha_2_code => 'BB', :alpha_3_code => 'BRB'},
70
+ {:id => 56, :name => "Belgium", :official_name => "Kingdom of Belgium", :alpha_2_code => 'BE', :alpha_3_code => 'BEL'},
71
+ {:id => 60, :name => "Bermuda", :alpha_2_code => 'BM', :alpha_3_code => 'BMU'},
72
+ {:id => 64, :name => "Bhutan", :official_name => "Kingdom of Bhutan", :alpha_2_code => 'BT', :alpha_3_code => 'BTN'},
73
+ {:id => 68, :name => "Bolivia", :official_name => "Republic of Bolivia", :alpha_2_code => 'BO', :alpha_3_code => 'BOL'},
74
+ {:id => 70, :name => "Bosnia and Herzegovina", :official_name => "Republic of Bosnia and Herzegovina", :alpha_2_code => 'BA', :alpha_3_code => 'BIH'},
75
+ {:id => 72, :name => "Botswana", :official_name => "Republic of Botswana", :alpha_2_code => 'BW', :alpha_3_code => 'BWA'},
76
+ {:id => 74, :name => "Bouvet Island", :alpha_2_code => 'BV', :alpha_3_code => 'BVT'},
77
+ {:id => 76, :name => "Brazil", :official_name => "Federative Republic of Brazil", :alpha_2_code => 'BR', :alpha_3_code => 'BRA'},
78
+ {:id => 84, :name => "Belize", :alpha_2_code => 'BZ', :alpha_3_code => 'BLZ'},
79
+ {:id => 86, :name => "British Indian Ocean Territory", :alpha_2_code => 'IO', :alpha_3_code => 'IOT'},
80
+ {:id => 90, :name => "Solomon Islands", :alpha_2_code => 'SB', :alpha_3_code => 'SLB'},
81
+ {:id => 92, :name => "Virgin Islands, British", :official_name => "British Virgin Islands", :alpha_2_code => 'VG', :alpha_3_code => 'VGB'},
82
+ {:id => 96, :name => "Brunei Darussalam", :alpha_2_code => 'BN', :alpha_3_code => 'BRN'},
83
+ {:id => 100, :name => "Bulgaria", :official_name => "Republic of Bulgaria", :alpha_2_code => 'BG', :alpha_3_code => 'BGR'},
84
+ {:id => 104, :name => "Myanmar", :official_name => "Union of Myanmar", :alpha_2_code => 'MM', :alpha_3_code => 'MMR'},
85
+ {:id => 108, :name => "Burundi", :official_name => "Republic of Burundi", :alpha_2_code => 'BI', :alpha_3_code => 'BDI'},
86
+ {:id => 112, :name => "Belarus", :official_name => "Republic of Belarus", :alpha_2_code => 'BY', :alpha_3_code => 'BLR'},
87
+ {:id => 116, :name => "Cambodia", :official_name => "Kingdom of Cambodia", :alpha_2_code => 'KH', :alpha_3_code => 'KHM'},
88
+ {:id => 120, :name => "Cameroon", :official_name => "Republic of Cameroon", :alpha_2_code => 'CM', :alpha_3_code => 'CMR'},
89
+ {:id => 124, :name => "Canada", :alpha_2_code => 'CA', :alpha_3_code => 'CAN'},
90
+ {:id => 132, :name => "Cape Verde", :official_name => "Republic of Cape Verde", :alpha_2_code => 'CV', :alpha_3_code => 'CPV'},
91
+ {:id => 136, :name => "Cayman Islands", :alpha_2_code => 'KY', :alpha_3_code => 'CYM'},
92
+ {:id => 140, :name => "Central African Republic", :alpha_2_code => 'CF', :alpha_3_code => 'CAF'},
93
+ {:id => 144, :name => "Sri Lanka", :official_name => "Democratic Socialist Republic of Sri Lanka", :alpha_2_code => 'LK', :alpha_3_code => 'LKA'},
94
+ {:id => 148, :name => "Chad", :official_name => "Republic of Chad", :alpha_2_code => 'TD', :alpha_3_code => 'TCD'},
95
+ {:id => 152, :name => "Chile", :official_name => "Republic of Chile", :alpha_2_code => 'CL', :alpha_3_code => 'CHL'},
96
+ {:id => 156, :name => "China", :official_name => "People's Republic of China", :alpha_2_code => 'CN', :alpha_3_code => 'CHN'},
97
+ {:id => 158, :name => "Taiwan", :official_name => "Taiwan, Province of China", :alpha_2_code => 'TW', :alpha_3_code => 'TWN'},
98
+ {:id => 162, :name => "Christmas Island", :alpha_2_code => 'CX', :alpha_3_code => 'CXR'},
99
+ {:id => 166, :name => "Cocos (Keeling) Islands", :alpha_2_code => 'CC', :alpha_3_code => 'CCK'},
100
+ {:id => 170, :name => "Colombia", :official_name => "Republic of Colombia", :alpha_2_code => 'CO', :alpha_3_code => 'COL'},
101
+ {:id => 174, :name => "Comoros", :official_name => "Union of the Comoros", :alpha_2_code => 'KM', :alpha_3_code => 'COM'},
102
+ {:id => 175, :name => "Mayotte", :alpha_2_code => 'YT', :alpha_3_code => 'MYT'},
103
+ {:id => 178, :name => "Congo", :official_name => "Republic of the Congo", :alpha_2_code => 'CG', :alpha_3_code => 'COG'},
104
+ {:id => 180, :name => "Congo, Democratic Republic of", :official_name => "Congo, The Democratic Republic of the", :alpha_2_code => 'CD', :alpha_3_code => 'COD'},
105
+ {:id => 184, :name => "Cook Islands", :alpha_2_code => 'CK', :alpha_3_code => 'COK'},
106
+ {:id => 188, :name => "Costa Rica", :official_name => "Republic of Costa Rica", :alpha_2_code => 'CR', :alpha_3_code => 'CRI'},
107
+ {:id => 191, :name => "Croatia", :official_name => "Republic of Croatia", :alpha_2_code => 'HR', :alpha_3_code => 'HRV'},
108
+ {:id => 192, :name => "Cuba", :official_name => "Republic of Cuba", :alpha_2_code => 'CU', :alpha_3_code => 'CUB'},
109
+ {:id => 196, :name => "Cyprus", :official_name => "Republic of Cyprus", :alpha_2_code => 'CY', :alpha_3_code => 'CYP'},
110
+ {:id => 203, :name => "Czech Republic", :alpha_2_code => 'CZ', :alpha_3_code => 'CZE'},
111
+ {:id => 204, :name => "Benin", :official_name => "Republic of Benin", :alpha_2_code => 'BJ', :alpha_3_code => 'BEN'},
112
+ {:id => 208, :name => "Denmark", :official_name => "Kingdom of Denmark", :alpha_2_code => 'DK', :alpha_3_code => 'DNK'},
113
+ {:id => 212, :name => "Dominica", :official_name => "Commonwealth of Dominica", :alpha_2_code => 'DM', :alpha_3_code => 'DMA'},
114
+ {:id => 214, :name => "Dominican Republic", :alpha_2_code => 'DO', :alpha_3_code => 'DOM'},
115
+ {:id => 218, :name => "Ecuador", :official_name => "Republic of Ecuador", :alpha_2_code => 'EC', :alpha_3_code => 'ECU'},
116
+ {:id => 222, :name => "El Salvador", :official_name => "Republic of El Salvador", :alpha_2_code => 'SV', :alpha_3_code => 'SLV'},
117
+ {:id => 226, :name => "Equatorial Guinea", :official_name => "Republic of Equatorial Guinea", :alpha_2_code => 'GQ', :alpha_3_code => 'GNQ'},
118
+ {:id => 231, :name => "Ethiopia", :official_name => "Federal Democratic Republic of Ethiopia", :alpha_2_code => 'ET', :alpha_3_code => 'ETH'},
119
+ {:id => 232, :name => "Eritrea", :alpha_2_code => 'ER', :alpha_3_code => 'ERI'},
120
+ {:id => 233, :name => "Estonia", :official_name => "Republic of Estonia", :alpha_2_code => 'EE', :alpha_3_code => 'EST'},
121
+ {:id => 234, :name => "Faroe Islands", :alpha_2_code => 'FO', :alpha_3_code => 'FRO'},
122
+ {:id => 238, :name => "Falkland Islands", :official_name => "Falkland Islands (Malvinas)", :alpha_2_code => 'FK', :alpha_3_code => 'FLK'},
123
+ {:id => 239, :name => "South Georgia", :official_name => "South Georgia and the South Sandwich Islands", :alpha_2_code => 'GS', :alpha_3_code => 'SGS'},
124
+ {:id => 242, :name => "Fiji", :official_name => "Republic of the Fiji Islands", :alpha_2_code => 'FJ', :alpha_3_code => 'FJI'},
125
+ {:id => 246, :name => "Finland", :official_name => "Republic of Finland", :alpha_2_code => 'FI', :alpha_3_code => 'FIN'},
126
+ {:id => 248, :name => "Åland Islands", :alpha_2_code => 'AX', :alpha_3_code => 'ALA'},
127
+ {:id => 250, :name => "France", :official_name => "French Republic", :alpha_2_code => 'FR', :alpha_3_code => 'FRA'},
128
+ {:id => 254, :name => "French Guiana", :alpha_2_code => 'GF', :alpha_3_code => 'GUF'},
129
+ {:id => 258, :name => "French Polynesia", :alpha_2_code => 'PF', :alpha_3_code => 'PYF'},
130
+ {:id => 260, :name => "French Southern Territories", :alpha_2_code => 'TF', :alpha_3_code => 'ATF'},
131
+ {:id => 262, :name => "Djibouti", :official_name => "Republic of Djibouti", :alpha_2_code => 'DJ', :alpha_3_code => 'DJI'},
132
+ {:id => 266, :name => "Gabon", :official_name => "Gabonese Republic", :alpha_2_code => 'GA', :alpha_3_code => 'GAB'},
133
+ {:id => 268, :name => "Georgia", :alpha_2_code => 'GE', :alpha_3_code => 'GEO'},
134
+ {:id => 270, :name => "Gambia", :official_name => "Republic of the Gambia", :alpha_2_code => 'GM', :alpha_3_code => 'GMB'},
135
+ {:id => 275, :name => "Palestinian Territories", :official_name => "Occupied Palestinian Territory", :alpha_2_code => 'PS', :alpha_3_code => 'PSE'},
136
+ {:id => 276, :name => "Germany", :official_name => "Federal Republic of Germany", :alpha_2_code => 'DE', :alpha_3_code => 'DEU'},
137
+ {:id => 288, :name => "Ghana", :official_name => "Republic of Ghana", :alpha_2_code => 'GH', :alpha_3_code => 'GHA'},
138
+ {:id => 292, :name => "Gibraltar", :alpha_2_code => 'GI', :alpha_3_code => 'GIB'},
139
+ {:id => 296, :name => "Kiribati", :official_name => "Republic of Kiribati", :alpha_2_code => 'KI', :alpha_3_code => 'KIR'},
140
+ {:id => 300, :name => "Greece", :official_name => "Hellenic Republic", :alpha_2_code => 'GR', :alpha_3_code => 'GRC'},
141
+ {:id => 304, :name => "Greenland", :alpha_2_code => 'GL', :alpha_3_code => 'GRL'},
142
+ {:id => 308, :name => "Grenada", :alpha_2_code => 'GD', :alpha_3_code => 'GRD'},
143
+ {:id => 312, :name => "Guadeloupe", :alpha_2_code => 'GP', :alpha_3_code => 'GLP'},
144
+ {:id => 316, :name => "Guam", :alpha_2_code => 'GU', :alpha_3_code => 'GUM'},
145
+ {:id => 320, :name => "Guatemala", :official_name => "Republic of Guatemala", :alpha_2_code => 'GT', :alpha_3_code => 'GTM'},
146
+ {:id => 324, :name => "Guinea", :official_name => "Republic of Guinea", :alpha_2_code => 'GN', :alpha_3_code => 'GIN'},
147
+ {:id => 328, :name => "Guyana", :official_name => "Republic of Guyana", :alpha_2_code => 'GY', :alpha_3_code => 'GUY'},
148
+ {:id => 332, :name => "Haiti", :official_name => "Republic of Haiti", :alpha_2_code => 'HT', :alpha_3_code => 'HTI'},
149
+ {:id => 334, :name => "Heard and McDonald Islands", :official_name => "Heard Island and McDonald ", :alpha_2_code => 'HM', :alpha_3_code => 'HMD'},
150
+ {:id => 336, :name => "Holy See (Vatican City State)", :alpha_2_code => 'VA', :alpha_3_code => 'VAT'},
151
+ {:id => 340, :name => "Honduras", :official_name => "Republic of Honduras", :alpha_2_code => 'HN', :alpha_3_code => 'HND'},
152
+ {:id => 344, :name => "Hong Kong", :official_name => "Hong Kong Special Administrative Region of China", :alpha_2_code => 'HK', :alpha_3_code => 'HKG'},
153
+ {:id => 348, :name => "Hungary", :official_name => "Republic of Hungary", :alpha_2_code => 'HU', :alpha_3_code => 'HUN'},
154
+ {:id => 352, :name => "Iceland", :official_name => "Republic of Iceland", :alpha_2_code => 'IS', :alpha_3_code => 'ISL'},
155
+ {:id => 356, :name => "India", :official_name => "Republic of India", :alpha_2_code => 'IN', :alpha_3_code => 'IND'},
156
+ {:id => 360, :name => "Indonesia", :official_name => "Republic of Indonesia", :alpha_2_code => 'ID', :alpha_3_code => 'IDN'},
157
+ {:id => 364, :name => "Iran", :official_name => "Islamic Republic of Iran", :alpha_2_code => 'IR', :alpha_3_code => 'IRN'},
158
+ {:id => 368, :name => "Iraq", :official_name => "Republic of Iraq", :alpha_2_code => 'IQ', :alpha_3_code => 'IRQ'},
159
+ {:id => 372, :name => "Ireland", :alpha_2_code => 'IE', :alpha_3_code => 'IRL'},
160
+ {:id => 376, :name => "Israel", :official_name => "State of Israel", :alpha_2_code => 'IL', :alpha_3_code => 'ISR'},
161
+ {:id => 380, :name => "Italy", :official_name => "Italian Republic", :alpha_2_code => 'IT', :alpha_3_code => 'ITA'},
162
+ {:id => 384, :name => "Côte d'Ivoire", :official_name => "Republic of Côte d'Ivoire", :alpha_2_code => 'CI', :alpha_3_code => 'CIV'},
163
+ {:id => 388, :name => "Jamaica", :alpha_2_code => 'JM', :alpha_3_code => 'JAM'},
164
+ {:id => 392, :name => "Japan", :alpha_2_code => 'JP', :alpha_3_code => 'JPN'},
165
+ {:id => 398, :name => "Kazakhstan", :official_name => "Republic of Kazakhstan", :alpha_2_code => 'KZ', :alpha_3_code => 'KAZ'},
166
+ {:id => 400, :name => "Jordan", :official_name => "Hashemite Kingdom of Jordan", :alpha_2_code => 'JO', :alpha_3_code => 'JOR'},
167
+ {:id => 404, :name => "Kenya", :official_name => "Republic of Kenya", :alpha_2_code => 'KE', :alpha_3_code => 'KEN'},
168
+ {:id => 408, :name => "North Korea", :official_name => "Democratic People's Republic of Korea", :alpha_2_code => 'KP', :alpha_3_code => 'PRK'},
169
+ {:id => 410, :name => "South Korea", :official_name => "Republic of Korea", :alpha_2_code => 'KR', :alpha_3_code => 'KOR'},
170
+ {:id => 414, :name => "Kuwait", :official_name => "State of Kuwait", :alpha_2_code => 'KW', :alpha_3_code => 'KWT'},
171
+ {:id => 417, :name => "Kyrgyzstan", :official_name => "Kyrgyz Republic", :alpha_2_code => 'KG', :alpha_3_code => 'KGZ'},
172
+ {:id => 418, :name => "Laos", :official_name => "Lao People's Democratic Republic", :alpha_2_code => 'LA', :alpha_3_code => 'LAO'},
173
+ {:id => 422, :name => "Lebanon", :official_name => "Lebanese Republic", :alpha_2_code => 'LB', :alpha_3_code => 'LBN'},
174
+ {:id => 426, :name => "Lesotho", :official_name => "Kingdom of Lesotho", :alpha_2_code => 'LS', :alpha_3_code => 'LSO'},
175
+ {:id => 428, :name => "Latvia", :official_name => "Republic of Latvia", :alpha_2_code => 'LV', :alpha_3_code => 'LVA'},
176
+ {:id => 430, :name => "Liberia", :official_name => "Republic of Liberia", :alpha_2_code => 'LR', :alpha_3_code => 'LBR'},
177
+ {:id => 434, :name => "Libya", :official_name => "Socialist People's Libyan Arab Jamahiriya", :alpha_2_code => 'LY', :alpha_3_code => 'LBY'}, # Libyan Arab Jamahiriya
178
+ {:id => 438, :name => "Liechtenstein", :official_name => "Principality of Liechtenstein", :alpha_2_code => 'LI', :alpha_3_code => 'LIE'},
179
+ {:id => 440, :name => "Lithuania", :official_name => "Republic of Lithuania", :alpha_2_code => 'LT', :alpha_3_code => 'LTU'},
180
+ {:id => 442, :name => "Luxembourg", :official_name => "Grand Duchy of Luxembourg", :alpha_2_code => 'LU', :alpha_3_code => 'LUX'},
181
+ {:id => 446, :name => "Macao", :official_name => "Macao Special Administrative Region of China", :alpha_2_code => 'MO', :alpha_3_code => 'MAC'},
182
+ {:id => 450, :name => "Madagascar", :official_name => "Republic of Madagascar", :alpha_2_code => 'MG', :alpha_3_code => 'MDG'},
183
+ {:id => 454, :name => "Malawi", :official_name => "Republic of Malawi", :alpha_2_code => 'MW', :alpha_3_code => 'MWI'},
184
+ {:id => 458, :name => "Malaysia", :alpha_2_code => 'MY', :alpha_3_code => 'MYS'},
185
+ {:id => 462, :name => "Maldives", :official_name => "Republic of Maldives", :alpha_2_code => 'MV', :alpha_3_code => 'MDV'},
186
+ {:id => 466, :name => "Mali", :official_name => "Republic of Mali", :alpha_2_code => 'ML', :alpha_3_code => 'MLI'},
187
+ {:id => 470, :name => "Malta", :official_name => "Republic of Malta", :alpha_2_code => 'MT', :alpha_3_code => 'MLT'},
188
+ {:id => 474, :name => "Martinique", :alpha_2_code => 'MQ', :alpha_3_code => 'MTQ'},
189
+ {:id => 478, :name => "Mauritania", :official_name => "Islamic Republic of Mauritania", :alpha_2_code => 'MR', :alpha_3_code => 'MRT'},
190
+ {:id => 480, :name => "Mauritius", :official_name => "Republic of Mauritius", :alpha_2_code => 'MU', :alpha_3_code => 'MUS'},
191
+ {:id => 484, :name => "Mexico", :official_name => "United Mexican States", :alpha_2_code => 'MX', :alpha_3_code => 'MEX'},
192
+ {:id => 492, :name => "Monaco", :official_name => "Principality of Monaco", :alpha_2_code => 'MC', :alpha_3_code => 'MCO'},
193
+ {:id => 498, :name => "Moldova", :official_name => "Republic of Moldova", :alpha_2_code => 'MD', :alpha_3_code => 'MDA'},
194
+ {:id => 496, :name => "Mongolia", :alpha_2_code => 'MN', :alpha_3_code => 'MNG'},
195
+ {:id => 499, :name => "Montenegro", :official_name => "Republic of Montenegro", :alpha_2_code => 'ME', :alpha_3_code => 'MNE'},
196
+ {:id => 500, :name => "Montserrat", :alpha_2_code => 'MS', :alpha_3_code => 'MSR'},
197
+ {:id => 504, :name => "Morocco", :official_name => "Kingdom of Morocco", :alpha_2_code => 'MA', :alpha_3_code => 'MAR'},
198
+ {:id => 508, :name => "Mozambique", :official_name => "Republic of Mozambique", :alpha_2_code => 'MZ', :alpha_3_code => 'MOZ'},
199
+ {:id => 512, :name => "Oman", :official_name => "Sultanate of Oman", :alpha_2_code => 'OM', :alpha_3_code => 'OMN'},
200
+ {:id => 516, :name => "Namibia", :official_name => "Republic of Namibia", :alpha_2_code => 'NA', :alpha_3_code => 'NAM'},
201
+ {:id => 520, :name => "Nauru", :official_name => "Republic of Nauru", :alpha_2_code => 'NR', :alpha_3_code => 'NRU'},
202
+ {:id => 524, :name => "Nepal", :official_name => "Kingdom of Nepal", :alpha_2_code => 'NP', :alpha_3_code => 'NPL'},
203
+ {:id => 528, :name => "Netherlands", :official_name => "Kingdom of the Netherlands", :alpha_2_code => 'NL', :alpha_3_code => 'NLD'},
204
+ {:id => 530, :name => "Netherlands Antilles", :alpha_2_code => 'AN', :alpha_3_code => 'ANT'},
205
+ {:id => 533, :name => "Aruba", :alpha_2_code => 'AW', :alpha_3_code => 'ABW'},
206
+ {:id => 540, :name => "New Caledonia", :alpha_2_code => 'NC', :alpha_3_code => 'NCL'},
207
+ {:id => 548, :name => "Vanuatu", :official_name => "Republic of Vanuatu", :alpha_2_code => 'VU', :alpha_3_code => 'VUT'},
208
+ {:id => 554, :name => "New Zealand", :alpha_2_code => 'NZ', :alpha_3_code => 'NZL'},
209
+ {:id => 558, :name => "Nicaragua", :official_name => "Republic of Nicaragua", :alpha_2_code => 'NI', :alpha_3_code => 'NIC'},
210
+ {:id => 562, :name => "Niger", :official_name => "Republic of the Niger", :alpha_2_code => 'NE', :alpha_3_code => 'NER'},
211
+ {:id => 566, :name => "Nigeria", :official_name => "Federal Republic of Nigeria", :alpha_2_code => 'NG', :alpha_3_code => 'NGA'},
212
+ {:id => 570, :name => "Niue", :official_name => "Republic of Niue", :alpha_2_code => 'NU', :alpha_3_code => 'NIU'},
213
+ {:id => 574, :name => "Norfolk Island", :alpha_2_code => 'NF', :alpha_3_code => 'NFK'},
214
+ {:id => 578, :name => "Norway", :official_name => "Kingdom of Norway", :alpha_2_code => 'NO', :alpha_3_code => 'NOR'},
215
+ {:id => 580, :name => "Northern Mariana Islands", :official_name => "Commonwealth of the Northern Mariana Islands", :alpha_2_code => 'MP', :alpha_3_code => 'MNP'},
216
+ {:id => 581, :name => "U.S. Minor Outlying Islands", :official_name => "United States Minor Outlying Islands", :alpha_2_code => 'UM', :alpha_3_code => 'UMI'},
217
+ {:id => 583, :name => "Micronesia", :official_name => "Federated States of Micronesia", :alpha_2_code => 'FM', :alpha_3_code => 'FSM'},
218
+ {:id => 584, :name => "Marshall Islands", :official_name => "Republic of the Marshall Islands", :alpha_2_code => 'MH', :alpha_3_code => 'MHL'},
219
+ {:id => 585, :name => "Palau", :official_name => "Republic of Palau", :alpha_2_code => 'PW', :alpha_3_code => 'PLW'},
220
+ {:id => 586, :name => "Pakistan", :official_name => "Islamic Republic of Pakistan", :alpha_2_code => 'PK', :alpha_3_code => 'PAK'},
221
+ {:id => 591, :name => "Panama", :official_name => "Republic of Panama", :alpha_2_code => 'PA', :alpha_3_code => 'PAN'},
222
+ {:id => 598, :name => "Papua New Guinea", :alpha_2_code => 'PG', :alpha_3_code => 'PNG'},
223
+ {:id => 600, :name => "Paraguay", :official_name => "Republic of Paraguay", :alpha_2_code => 'PY', :alpha_3_code => 'PRY'},
224
+ {:id => 604, :name => "Peru", :official_name => "Republic of Peru", :alpha_2_code => 'PE', :alpha_3_code => 'PER'},
225
+ {:id => 608, :name => "Philippines", :official_name => "Republic of the Philippines", :alpha_2_code => 'PH', :alpha_3_code => 'PHL'},
226
+ {:id => 612, :name => "Pitcairn", :alpha_2_code => 'PN', :alpha_3_code => 'PCN'},
227
+ {:id => 616, :name => "Poland", :official_name => "Republic of Poland", :alpha_2_code => 'PL', :alpha_3_code => 'POL'},
228
+ {:id => 620, :name => "Portugal", :official_name => "Portuguese Republic", :alpha_2_code => 'PT', :alpha_3_code => 'PRT'},
229
+ {:id => 624, :name => "Guinea-Bissau", :official_name => "Republic of Guinea-Bissau", :alpha_2_code => 'GW', :alpha_3_code => 'GNB'},
230
+ {:id => 626, :name => "Timor-Leste", :official_name => "Democratic Republic of Timor-Leste", :alpha_2_code => 'TL', :alpha_3_code => 'TLS'},
231
+ {:id => 630, :name => "Puerto Rico", :alpha_2_code => 'PR', :alpha_3_code => 'PRI'},
232
+ {:id => 634, :name => "Qatar", :official_name => "State of Qatar", :alpha_2_code => 'QA', :alpha_3_code => 'QAT'},
233
+ {:id => 638, :name => "Reunion", :alpha_2_code => 'RE', :alpha_3_code => 'REU'},
234
+ {:id => 642, :name => "Romania", :alpha_2_code => 'RO', :alpha_3_code => 'ROU'},
235
+ {:id => 643, :name => "Russian Federation", :alpha_2_code => 'RU', :alpha_3_code => 'RUS'},
236
+ {:id => 646, :name => "Rwanda", :official_name => "Rwandese Republic", :alpha_2_code => 'RW', :alpha_3_code => 'RWA'},
237
+ {:id => 652, :name => "Saint Barthélemy", :alpha_2_code => 'BL', :alpha_3_code => 'BLM'},
238
+ {:id => 654, :name => "St. Helena", :official_name => "Saint Helena", :alpha_2_code => 'SH', :alpha_3_code => 'SHN'},
239
+ {:id => 659, :name => "St. Kitts and Nevis", :official_name => "Saint Kitts and Nevis", :alpha_2_code => 'KN', :alpha_3_code => 'KNA'},
240
+ {:id => 660, :name => "Anguilla", :alpha_2_code => 'AI', :alpha_3_code => 'AIA'},
241
+ {:id => 662, :name => "St. Lucia", :official_name => "Saint Lucia", :alpha_2_code => 'LC', :alpha_3_code => 'LCA'},
242
+ {:id => 663, :name => "St. Martin (French part)", :official_name => "Saint Martin (French part)", :alpha_2_code => 'MF', :alpha_3_code => 'MAF'},
243
+ {:id => 666, :name => "St. Pierre and Miquelon", :official_name => "Saint Pierre and Miquelon", :alpha_2_code => 'PM', :alpha_3_code => 'SPM'},
244
+ {:id => 670, :name => "St. Vincent and the Grenadines", :official_name => "Saint Vincent and the Grenadines", :alpha_2_code => 'VC', :alpha_3_code => 'VCT'},
245
+ {:id => 674, :name => "San Marino", :official_name => "Republic of San Marino", :alpha_2_code => 'SM', :alpha_3_code => 'SMR'},
246
+ {:id => 678, :name => "Sao Tome and Principe", :official_name => "Democratic Republic of Sao Tome and Principe", :alpha_2_code => 'ST', :alpha_3_code => 'STP'},
247
+ {:id => 682, :name => "Saudi Arabia", :official_name => "Kingdom of Saudi Arabia", :alpha_2_code => 'SA', :alpha_3_code => 'SAU'},
248
+ {:id => 686, :name => "Senegal", :official_name => "Republic of Senegal", :alpha_2_code => 'SN', :alpha_3_code => 'SEN'},
249
+ {:id => 688, :name => "Serbia", :official_name => "Republic of Serbia", :alpha_2_code => 'RS', :alpha_3_code => 'SRB'},
250
+ {:id => 690, :name => "Seychelles", :official_name => "Republic of Seychelles", :alpha_2_code => 'SC', :alpha_3_code => 'SYC'},
251
+ {:id => 694, :name => "Sierra Leone", :official_name => "Republic of Sierra Leone", :alpha_2_code => 'SL', :alpha_3_code => 'SLE'},
252
+ {:id => 702, :name => "Singapore", :official_name => "Republic of Singapore", :alpha_2_code => 'SG', :alpha_3_code => 'SGP'},
253
+ {:id => 703, :name => "Slovakia", :official_name => "Slovak Republic", :alpha_2_code => 'SK', :alpha_3_code => 'SVK'},
254
+ {:id => 704, :name => "Viet Nam", :official_name => "Socialist Republic of Viet Nam", :alpha_2_code => 'VN', :alpha_3_code => 'VNM'},
255
+ {:id => 705, :name => "Slovenia", :official_name => "Republic of Slovenia", :alpha_2_code => 'SI', :alpha_3_code => 'SVN'},
256
+ {:id => 706, :name => "Somalia", :official_name => "Somali Republic", :alpha_2_code => 'SO', :alpha_3_code => 'SOM'},
257
+ {:id => 710, :name => "South Africa", :official_name => "Republic of South Africa", :alpha_2_code => 'ZA', :alpha_3_code => 'ZAF'},
258
+ {:id => 716, :name => "Zimbabwe", :official_name => "Republic of Zimbabwe", :alpha_2_code => 'ZW', :alpha_3_code => 'ZWE'},
259
+ {:id => 724, :name => "Spain", :official_name => "Kingdom of Spain", :alpha_2_code => 'ES', :alpha_3_code => 'ESP'},
260
+ {:id => 732, :name => "Western Sahara", :alpha_2_code => 'EH', :alpha_3_code => 'ESH'},
261
+ {:id => 736, :name => "Sudan", :official_name => "Republic of the Sudan", :alpha_2_code => 'SD', :alpha_3_code => 'SDN'},
262
+ {:id => 740, :name => "Suriname", :official_name => "Republic of Suriname", :alpha_2_code => 'SR', :alpha_3_code => 'SUR'},
263
+ {:id => 744, :name => "Svalbard and Jan Mayen", :alpha_2_code => 'SJ', :alpha_3_code => 'SJM'},
264
+ {:id => 748, :name => "Swaziland", :official_name => "Kingdom of Swaziland", :alpha_2_code => 'SZ', :alpha_3_code => 'SWZ'},
265
+ {:id => 752, :name => "Sweden", :official_name => "Kingdom of Sweden", :alpha_2_code => 'SE', :alpha_3_code => 'SWE'},
266
+ {:id => 756, :name => "Switzerland", :official_name => "Swiss Confederation", :alpha_2_code => 'CH', :alpha_3_code => 'CHE'},
267
+ {:id => 760, :name => "Syrian Arab Republic", :alpha_2_code => 'SY', :alpha_3_code => 'SYR'},
268
+ {:id => 762, :name => "Tajikistan", :official_name => "Republic of Tajikistan", :alpha_2_code => 'TJ', :alpha_3_code => 'TJK'},
269
+ {:id => 764, :name => "Thailand", :official_name => "Kingdom of Thailand", :alpha_2_code => 'TH', :alpha_3_code => 'THA'},
270
+ {:id => 768, :name => "Togo", :official_name => "Togolese Republic", :alpha_2_code => 'TG', :alpha_3_code => 'TGO'},
271
+ {:id => 772, :name => "Tokelau", :alpha_2_code => 'TK', :alpha_3_code => 'TKL'},
272
+ {:id => 776, :name => "Tonga", :official_name => "Kingdom of Tonga", :alpha_2_code => 'TO', :alpha_3_code => 'TON'},
273
+ {:id => 780, :name => "Trinidad and Tobago", :official_name => "Republic of Trinidad and Tobago", :alpha_2_code => 'TT', :alpha_3_code => 'TTO'},
274
+ {:id => 784, :name => "United Arab Emirates", :alpha_2_code => 'AE', :alpha_3_code => 'ARE'},
275
+ {:id => 788, :name => "Tunisia", :official_name => "Republic of Tunisia", :alpha_2_code => 'TN', :alpha_3_code => 'TUN'},
276
+ {:id => 792, :name => "Turkey", :official_name => "Republic of Turkey", :alpha_2_code => 'TR', :alpha_3_code => 'TUR'},
277
+ {:id => 795, :name => "Turkmenistan", :alpha_2_code => 'TM', :alpha_3_code => 'TKM'},
278
+ {:id => 796, :name => "Turks and Caicos Islands", :alpha_2_code => 'TC', :alpha_3_code => 'TCA'},
279
+ {:id => 798, :name => "Tuvalu", :alpha_2_code => 'TV', :alpha_3_code => 'TUV'},
280
+ {:id => 800, :name => "Uganda", :official_name => "Republic of Uganda", :alpha_2_code => 'UG', :alpha_3_code => 'UGA'},
281
+ {:id => 804, :name => "Ukraine", :alpha_2_code => 'UA', :alpha_3_code => 'UKR'},
282
+ {:id => 807, :name => "Macedonia", :official_name => "The Former Yugoslav Republic of Macedonia", :alpha_2_code => 'MK', :alpha_3_code => 'MKD'},
283
+ {:id => 818, :name => "Egypt", :official_name => "Arab Republic of Egypt", :alpha_2_code => 'EG', :alpha_3_code => 'EGY'},
284
+ {:id => 826, :name => "United Kingdom", :official_name => "United Kingdom of Great Britain and Northern Ireland", :alpha_2_code => 'GB', :alpha_3_code => 'GBR'},
285
+ {:id => 831, :name => "Guernsey", :alpha_2_code => 'GG', :alpha_3_code => 'GGY'},
286
+ {:id => 833, :name => "Isle of Man", :alpha_2_code => 'IM', :alpha_3_code => 'IMN'},
287
+ {:id => 832, :name => "Jersey", :alpha_2_code => 'JE', :alpha_3_code => 'JEY'},
288
+ {:id => 834, :name => "Tanzania", :official_name => "United Republic of Tanzania", :alpha_2_code => 'TZ', :alpha_3_code => 'TZA'},
289
+ {:id => 840, :name => "United States", :official_name => "United States of America", :alpha_2_code => 'US', :alpha_3_code => 'USA'},
290
+ {:id => 850, :name => "Virgin Islands, U.S.", :official_name => "Virgin Islands of the United States", :alpha_2_code => 'VI', :alpha_3_code => 'VIR'},
291
+ {:id => 854, :name => "Burkina Faso", :alpha_2_code => 'BF', :alpha_3_code => 'BFA'},
292
+ {:id => 858, :name => "Uruguay", :official_name => "Eastern Republic of Uruguay", :alpha_2_code => 'UY', :alpha_3_code => 'URY'},
293
+ {:id => 860, :name => "Uzbekistan", :official_name => "Republic of Uzbekistan", :alpha_2_code => 'UZ', :alpha_3_code => 'UZB'},
294
+ {:id => 862, :name => "Venezuela", :official_name => "Bolivarian Republic of Venezuela", :alpha_2_code => 'VE', :alpha_3_code => 'VEN'},
295
+ {:id => 876, :name => "Wallis and Futuna", :alpha_2_code => 'WF', :alpha_3_code => 'WLF'},
296
+ {:id => 882, :name => "Samoa", :official_name => "Independent State of Samoa", :alpha_2_code => 'WS', :alpha_3_code => 'WSM'},
297
+ {:id => 887, :name => "Yemen", :official_name => "Republic of Yemen", :alpha_2_code => 'YE', :alpha_3_code => 'YEM'},
298
+ {:id => 894, :name => "Zambia", :official_name => "Republic of Zambia", :alpha_2_code => 'ZM', :alpha_3_code => 'ZMB'}
299
+ )
114
300
  end