glysellin 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (173) hide show
  1. checksums.yaml +15 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +100 -0
  4. data/Rakefile +29 -0
  5. data/app/assets/javascripts/glysellin/address.coffee +38 -0
  6. data/app/assets/javascripts/glysellin/async-cart.coffee +139 -0
  7. data/app/assets/javascripts/glysellin/base.js +6 -0
  8. data/app/assets/javascripts/glysellin/cart.coffee +54 -0
  9. data/app/assets/javascripts/glysellin/main.coffee +0 -0
  10. data/app/assets/javascripts/glysellin/product.coffee +0 -0
  11. data/app/assets/stylesheets/glysellin/application.css +13 -0
  12. data/app/assets/stylesheets/glysellin/orders.css +4 -0
  13. data/app/assets/stylesheets/glysellin/products.css +4 -0
  14. data/app/controllers/glysellin/cart/addresses_controller.rb +17 -0
  15. data/app/controllers/glysellin/cart/discount_code_controller.rb +10 -0
  16. data/app/controllers/glysellin/cart/payment_method_controller.rb +17 -0
  17. data/app/controllers/glysellin/cart/products_controller.rb +37 -0
  18. data/app/controllers/glysellin/cart/shipping_method_controller.rb +18 -0
  19. data/app/controllers/glysellin/cart/state_controller.rb +15 -0
  20. data/app/controllers/glysellin/cart_controller.rb +53 -0
  21. data/app/controllers/glysellin/orders_controller.rb +53 -0
  22. data/app/controllers/glysellin/products_controller.rb +12 -0
  23. data/app/helpers/glysellin/application_helper.rb +4 -0
  24. data/app/helpers/glysellin/cart_helper.rb +21 -0
  25. data/app/helpers/glysellin/orders_helper.rb +35 -0
  26. data/app/helpers/glysellin/products_helper.rb +4 -0
  27. data/app/mailers/glysellin/order_admin_mailer.rb +17 -0
  28. data/app/mailers/glysellin/order_customer_mailer.rb +27 -0
  29. data/app/models/glysellin/address.rb +35 -0
  30. data/app/models/glysellin/brand.rb +14 -0
  31. data/app/models/glysellin/discount_code.rb +36 -0
  32. data/app/models/glysellin/discount_type.rb +9 -0
  33. data/app/models/glysellin/order.rb +243 -0
  34. data/app/models/glysellin/order_adjustment.rb +19 -0
  35. data/app/models/glysellin/order_item.rb +38 -0
  36. data/app/models/glysellin/orderer.rb +28 -0
  37. data/app/models/glysellin/payment.rb +46 -0
  38. data/app/models/glysellin/payment_method.rb +36 -0
  39. data/app/models/glysellin/product.rb +136 -0
  40. data/app/models/glysellin/product_image.rb +11 -0
  41. data/app/models/glysellin/product_property.rb +22 -0
  42. data/app/models/glysellin/product_property_type.rb +11 -0
  43. data/app/models/glysellin/product_type.rb +11 -0
  44. data/app/models/glysellin/shipping_method.rb +22 -0
  45. data/app/models/glysellin/taxonomy.rb +35 -0
  46. data/app/models/glysellin/variant.rb +100 -0
  47. data/app/views/glysellin/cart/_added_to_cart_warning.html.erb +21 -0
  48. data/app/views/glysellin/cart/_cart.html.erb +13 -0
  49. data/app/views/glysellin/cart/_navigation.html.erb +11 -0
  50. data/app/views/glysellin/cart/_products.html.erb +125 -0
  51. data/app/views/glysellin/cart/_recap.html.erb +16 -0
  52. data/app/views/glysellin/cart/recap/_addresses.html.erb +13 -0
  53. data/app/views/glysellin/cart/recap/_products.html.erb +63 -0
  54. data/app/views/glysellin/cart/show.html.erb +13 -0
  55. data/app/views/glysellin/cart/states/_addresses.html.erb +25 -0
  56. data/app/views/glysellin/cart/states/_choose_payment_method.html.erb +14 -0
  57. data/app/views/glysellin/cart/states/_choose_shipping_method.html.erb +14 -0
  58. data/app/views/glysellin/cart/states/_filled.html.erb +3 -0
  59. data/app/views/glysellin/cart/states/_init.html.erb +5 -0
  60. data/app/views/glysellin/cart/states/_ready.html.erb +1 -0
  61. data/app/views/glysellin/order_admin_mailer/_order_header.text.erb +5 -0
  62. data/app/views/glysellin/order_admin_mailer/send_check_order_created_email.text.erb +8 -0
  63. data/app/views/glysellin/order_admin_mailer/send_order_paid_email.text.erb +8 -0
  64. data/app/views/glysellin/order_customer_mailer/_order_footer.text.erb +3 -0
  65. data/app/views/glysellin/order_customer_mailer/_order_header.text.erb +5 -0
  66. data/app/views/glysellin/order_customer_mailer/send_order_created_email.text.erb +7 -0
  67. data/app/views/glysellin/order_customer_mailer/send_order_paid_email.text.erb +7 -0
  68. data/app/views/glysellin/order_customer_mailer/send_order_shipped_email.text.erb +8 -0
  69. data/app/views/glysellin/orders/_addresses_fields.html.erb +29 -0
  70. data/app/views/glysellin/orders/_order.html.erb +18 -0
  71. data/app/views/glysellin/orders/_payment_canceled.html.erb +13 -0
  72. data/app/views/glysellin/orders/_payment_successful.html.erb +6 -0
  73. data/app/views/glysellin/orders/payment_response.html.erb +5 -0
  74. data/app/views/glysellin/payment_methods/_paypal-integral.html.erb +22 -0
  75. data/app/views/glysellin/products/_add_to_cart.html.erb +16 -0
  76. data/app/views/glysellin/products/_item.html.erb +21 -0
  77. data/app/views/glysellin/products/filter.html.erb +0 -0
  78. data/app/views/glysellin/products/index.html.erb +3 -0
  79. data/app/views/glysellin/products/show.html.erb +3 -0
  80. data/app/views/glysellin/shared/_address.html.erb +11 -0
  81. data/app/views/glysellin/shared/_address.text.erb +7 -0
  82. data/app/views/glysellin/shared/_order.text.erb +56 -0
  83. data/app/views/glysellin/shared/mailer/_footer.text.erb +2 -0
  84. data/app/views/layouts/glysellin/application.html.erb +14 -0
  85. data/config/locales/glysellin.en.yml +113 -0
  86. data/config/locales/glysellin.fr.yml +119 -0
  87. data/db/migrate/20120206115004_create_glysellin_orders.rb +16 -0
  88. data/db/migrate/20120206115132_create_glysellin_customers.rb +8 -0
  89. data/db/migrate/20120206115657_create_glysellin_addresses.rb +22 -0
  90. data/db/migrate/20120206124505_create_glysellin_products.rb +20 -0
  91. data/db/migrate/20120206124545_create_glysellin_order_items.rb +15 -0
  92. data/db/migrate/20120206124630_create_glysellin_product_images.rb +10 -0
  93. data/db/migrate/20120206125210_add_attachment_image_to_product_image.rb +15 -0
  94. data/db/migrate/20120206130920_create_glysellin_payments.rb +13 -0
  95. data/db/migrate/20120206131042_create_glysellin_payment_methods.rb +10 -0
  96. data/db/migrate/20120207175050_create_glysellin_taxonomies.rb +11 -0
  97. data/db/migrate/20120207175158_create_products_taxonomies_table.rb +12 -0
  98. data/db/migrate/20120515143231_create_brands.rb +9 -0
  99. data/db/migrate/20120515143233_add_attachment_image_to_brands.rb +15 -0
  100. data/db/migrate/20120620151705_create_product_properties.rb +12 -0
  101. data/db/migrate/20130204121211_create_glysellin_discount_types.rb +10 -0
  102. data/db/migrate/20130204121228_create_glysellin_discount_codes.rb +15 -0
  103. data/db/migrate/20130204125310_create_glysellin_order_adjustments.rb +13 -0
  104. data/db/migrate/20130204202102_create_glysellin_shipping_methods.rb +12 -0
  105. data/db/migrate/20130204202109_add_shipping_method_id_to_glysellin_orders.rb +5 -0
  106. data/db/migrate/20130205110036_add_weight_to_glysellin_products.rb +5 -0
  107. data/db/migrate/20130205120541_add_weight_to_glysellin_order_items.rb +5 -0
  108. data/db/migrate/20130208162813_create_glysellin_variants.rb +17 -0
  109. data/db/migrate/20130208165020_create_glysellin_product_property_types.rb +7 -0
  110. data/db/migrate/20130211105557_add_type_id_to_glysellin_product_properties.rb +5 -0
  111. data/db/migrate/20130211112302_add_variant_id_to_glysellin_product_properties.rb +13 -0
  112. data/db/migrate/20130211152651_add_product_id_to_glysellin_variants.rb +5 -0
  113. data/db/migrate/20130212131658_add_weight_to_glysellin_variants.rb +5 -0
  114. data/db/migrate/20130212132253_remove_variant_columns_from_glysellin_products.rb +15 -0
  115. data/db/migrate/20130212154943_remove_eot_price_from_glysellin_products.rb +9 -0
  116. data/db/migrate/20130214184204_create_glysellin_product_types.rb +9 -0
  117. data/db/migrate/20130214184352_create_product_type_behavior.rb +15 -0
  118. data/db/migrate/20130221102200_add_unmarked_price_to_glysellin_variants.rb +5 -0
  119. data/db/migrate/20130311135842_add_addressable_to_glysellin_addresses.rb +6 -0
  120. data/db/migrate/20130314114048_change_addressable_associations_in_glysellin_addresses.rb +15 -0
  121. data/db/migrate/20130325113903_remove_address_ids_from_glysellin_orders.rb +11 -0
  122. data/db/seeds/shipping_carrier/rates/colissimo.csv +16 -0
  123. data/db/seeds/shipping_carrier/rates/lettre-max.csv +9 -0
  124. data/lib/active_model/model.rb +101 -0
  125. data/lib/generators/glysellin/install/USAGE +8 -0
  126. data/lib/generators/glysellin/install/install_generator.rb +50 -0
  127. data/lib/generators/glysellin/install/templates/initializer.rb +119 -0
  128. data/lib/generators/glysellin/install/templates/order_observer.rb +12 -0
  129. data/lib/generators/glysellin/install/utils.rb +11 -0
  130. data/lib/glysellin.rb +124 -0
  131. data/lib/glysellin/acts_as_sellable.rb +14 -0
  132. data/lib/glysellin/cart.rb +21 -0
  133. data/lib/glysellin/cart/address.rb +16 -0
  134. data/lib/glysellin/cart/adjustment.rb +17 -0
  135. data/lib/glysellin/cart/adjustment/base.rb +41 -0
  136. data/lib/glysellin/cart/adjustment/discount_code.rb +43 -0
  137. data/lib/glysellin/cart/adjustment/shipping_method.rb +31 -0
  138. data/lib/glysellin/cart/basket.rb +482 -0
  139. data/lib/glysellin/cart/customer.rb +36 -0
  140. data/lib/glysellin/cart/model_wrapper.rb +90 -0
  141. data/lib/glysellin/cart/nested_resource.rb +39 -0
  142. data/lib/glysellin/cart/payment_method.rb +8 -0
  143. data/lib/glysellin/cart/product.rb +16 -0
  144. data/lib/glysellin/cart/select.rb +31 -0
  145. data/lib/glysellin/cart/serializable.rb +30 -0
  146. data/lib/glysellin/cart/shipping_method.rb +8 -0
  147. data/lib/glysellin/discount_type_calculator.rb +7 -0
  148. data/lib/glysellin/discount_type_calculator/base.rb +30 -0
  149. data/lib/glysellin/discount_type_calculator/order_percentage.rb +16 -0
  150. data/lib/glysellin/engine.rb +14 -0
  151. data/lib/glysellin/engine/routes.rb +61 -0
  152. data/lib/glysellin/gateway.rb +16 -0
  153. data/lib/glysellin/gateway/atos.rb +111 -0
  154. data/lib/glysellin/gateway/base.rb +43 -0
  155. data/lib/glysellin/gateway/check.rb +34 -0
  156. data/lib/glysellin/gateway/paypal_integral.rb +71 -0
  157. data/lib/glysellin/helpers.rb +15 -0
  158. data/lib/glysellin/helpers/controller.rb +22 -0
  159. data/lib/glysellin/helpers/countries.rb +261 -0
  160. data/lib/glysellin/helpers/views.rb +28 -0
  161. data/lib/glysellin/product_methods.rb +66 -0
  162. data/lib/glysellin/products_list.rb +72 -0
  163. data/lib/glysellin/property_finder.rb +13 -0
  164. data/lib/glysellin/shipping_carrier.rb +14 -0
  165. data/lib/glysellin/shipping_carrier/base.rb +55 -0
  166. data/lib/glysellin/shipping_carrier/colissimo.rb +19 -0
  167. data/lib/glysellin/shipping_carrier/flat_rate.rb +19 -0
  168. data/lib/glysellin/shipping_carrier/free_shipping.rb +14 -0
  169. data/lib/glysellin/shipping_carrier/helpers/country_weight_table.rb +65 -0
  170. data/lib/glysellin/shipping_carrier/lettre_max.rb +19 -0
  171. data/lib/glysellin/version.rb +3 -0
  172. data/lib/tasks/glysellin_tasks.rake +37 -0
  173. metadata +341 -0
@@ -0,0 +1,43 @@
1
+ module Glysellin
2
+
3
+ def self.gateways
4
+ Hash[Gateway.gateways_list.map {|g| [g[:name], g[:gateway]]}]
5
+ end
6
+
7
+ module Gateway
8
+ extend AbstractController::Rendering
9
+
10
+ # List of available gateways in the app
11
+ mattr_accessor :gateways_list
12
+ @@gateways_list = []
13
+
14
+ class Base
15
+ class << self
16
+ attr_accessor :gateway_name
17
+
18
+ mattr_accessor :activate_logger
19
+ @@activate_logger = false
20
+
21
+ def log message
22
+ if @@activate_logger
23
+ Rails.logger.info(
24
+ "[Glysellin - #{ self.class.gateway_name }] :: #{ message }"
25
+ )
26
+ end
27
+ end
28
+
29
+ def register name, gateway
30
+ Gateway.gateways_list << {:name => name, :gateway => gateway}
31
+ @gateway_name = name.split('_').map(&:capitalize).join(" ")
32
+ end
33
+
34
+ def config
35
+ yield self
36
+ end
37
+ end
38
+
39
+ # Defer #log to ::log class method
40
+ def log(msg) self.class.log(msg) end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,34 @@
1
+ module Glysellin
2
+ module Gateway
3
+ class Check < Glysellin::Gateway::Base
4
+ register 'check', self
5
+
6
+ mattr_accessor :checks_order
7
+ @@checks_order = ""
8
+ mattr_accessor :checks_destination
9
+ @@checks_destination = ""
10
+
11
+ mattr_accessor :check_payment_description
12
+ @@check_payment_description = lambda { |order| I18n.t('glysellin.labels.payment_methods.check.send_your_check_text', :order_ref => order.ref, :check_order => @@checks_order, :check_destination => @@checks_destination).html_safe }
13
+
14
+ attr_accessor :errors, :order
15
+
16
+ def initialize order
17
+ @order = order
18
+ @errors = []
19
+ end
20
+
21
+ def render_request_button
22
+ { :text => @@check_payment_description.call(@order) }
23
+ end
24
+
25
+ def process_payment! post_data
26
+ true
27
+ end
28
+
29
+ def response
30
+ { :nothing => true }
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,71 @@
1
+ require 'money'
2
+ require 'active_merchant'
3
+ require 'active_merchant/billing/integrations/action_view_helper'
4
+
5
+ ActionView::Base.send(:include, ActiveMerchant::Billing::Integrations::ActionViewHelper)
6
+
7
+ module Glysellin
8
+ module Gateway
9
+ class PaypalIntegral < Glysellin::Gateway::Base
10
+ include ActiveMerchant::Billing::Integrations
11
+ register 'paypal-integral', self
12
+
13
+ mattr_accessor :account
14
+ @@account = ''
15
+
16
+ # Production mode by default
17
+ mattr_accessor :test
18
+ @@test = false
19
+
20
+ attr_accessor :errors, :order
21
+
22
+ def initialize order
23
+ @order = order
24
+ @errors = []
25
+ end
26
+
27
+ # Switch between test and prod modes for ActiveMerchant Paypal
28
+ class << self
29
+ def test=(val)
30
+ ActiveMerchant::Billing::Base.mode = val ? :test : :production
31
+ @@test = val
32
+ end
33
+ end
34
+
35
+ def render_request_button
36
+ {
37
+ :partial => 'glysellin/payment_methods/paypal-integral',
38
+ :locals => { :order => @order }
39
+ }
40
+ end
41
+
42
+ # Launch payment processing
43
+ def process_payment! post_data
44
+ notification = Paypal::Notification.new(post_data)
45
+ log "Processing payment from #{ post_data }"
46
+ if notification.acknowledge
47
+ begin
48
+ if notification.complete?
49
+ @order.paid!
50
+ else
51
+ error = "Failed to verify Paypal's notification, please investigate"
52
+ @errors.push(error)
53
+ false
54
+ end
55
+ rescue => e
56
+ raise
57
+ ensure
58
+ @order.save
59
+ end
60
+ else
61
+ false
62
+ end
63
+ end
64
+
65
+ # The response returned within "render" method in the OrdersController#gateway_response method
66
+ def response
67
+ {:nothing => true}
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,15 @@
1
+ require "glysellin/helpers/controller"
2
+ require "glysellin/helpers/countries"
3
+ require "glysellin/helpers/views"
4
+
5
+ module Glysellin
6
+ module Helpers
7
+ class << self
8
+ def include!
9
+ [Controller, Countries, Views].each do |mod|
10
+ ActionController::Base.send(:include, mod)
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ module Glysellin
2
+ module Helpers
3
+ module Controller
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ helper_method :current_cart
8
+ end
9
+
10
+ protected
11
+
12
+ def current_cart
13
+ @cart ||= Glysellin::Cart.new(session["glysellin.cart"])
14
+ end
15
+
16
+ def reset_cart!
17
+ @cart = Cart.new
18
+ session.delete("glysellin.cart")
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,261 @@
1
+ # encoding: utf-8
2
+ module Glysellin
3
+ module Helpers
4
+ module Countries
5
+ extend ActiveSupport::Concern
6
+
7
+ COUNTRIES_LIST = {
8
+ "AF"=>"Afghanistan",
9
+ "AL"=>"Albania",
10
+ "DZ"=>"Algeria",
11
+ "AS"=>"American Samoa",
12
+ "AD"=>"Andorra",
13
+ "AO"=>"Angola",
14
+ "AI"=>"Anguilla",
15
+ "AQ"=>"Antarctica",
16
+ "AG"=>"Antigua & Barbuda",
17
+ "AR"=>"Argentina",
18
+ "AM"=>"Armenia",
19
+ "AW"=>"Aruba",
20
+ "AU"=>"Australia",
21
+ "AT"=>"Austria",
22
+ "AZ"=>"Azerbaijan",
23
+ "BS"=>"Bahama",
24
+ "BH"=>"Bahrain",
25
+ "BD"=>"Bangladesh",
26
+ "BB"=>"Barbados",
27
+ "BY"=>"Belarus",
28
+ "BE"=>"Belgium",
29
+ "BZ"=>"Belize",
30
+ "BJ"=>"Benin",
31
+ "BM"=>"Bermuda",
32
+ "BT"=>"Bhutan",
33
+ "BO"=>"Bolivia",
34
+ "BA"=>"Bosnia and Herzegovina",
35
+ "BW"=>"Botswana",
36
+ "BV"=>"Bouvet Island",
37
+ "BR"=>"Brazil",
38
+ "IO"=>"British Indian Ocean Territory",
39
+ "VG"=>"British Virgin Islands",
40
+ "BN"=>"Brunei Darussalam",
41
+ "BG"=>"Bulgaria",
42
+ "BF"=>"Burkina Faso",
43
+ "BI"=>"Burundi",
44
+ "KH"=>"Cambodia",
45
+ "CM"=>"Cameroon",
46
+ "CA"=>"Canada",
47
+ "CV"=>"Cape Verde",
48
+ "KY"=>"Cayman Islands",
49
+ "CF"=>"Central African Republic",
50
+ "TD"=>"Chad",
51
+ "CL"=>"Chile",
52
+ "CN"=>"China",
53
+ "CX"=>"Christmas Island",
54
+ "CC"=>"Cocos (Keeling) Islands",
55
+ "CO"=>"Colombia",
56
+ "KM"=>"Comoros",
57
+ "CG"=>"Congo",
58
+ "CK"=>"Cook Iislands",
59
+ "CR"=>"Costa Rica",
60
+ "HR"=>"Croatia",
61
+ "CU"=>"Cuba",
62
+ "CY"=>"Cyprus",
63
+ "CZ"=>"Czech Republic",
64
+ "CI"=>"Côte D'ivoire (Ivory Coast)",
65
+ "DK"=>"Denmark",
66
+ "DJ"=>"Djibouti",
67
+ "DM"=>"Dominica",
68
+ "DO"=>"Dominican Republic",
69
+ "TP"=>"East Timor",
70
+ "EC"=>"Ecuador",
71
+ "EG"=>"Egypt",
72
+ "SV"=>"El Salvador",
73
+ "GQ"=>"Equatorial Guinea",
74
+ "ER"=>"Eritrea",
75
+ "EE"=>"Estonia",
76
+ "ET"=>"Ethiopia",
77
+ "FK"=>"Falkland Islands (Malvinas)",
78
+ "FO"=>"Faroe Islands",
79
+ "FJ"=>"Fiji",
80
+ "FI"=>"Finland",
81
+ "FR"=>"France",
82
+ "FX"=>"France, Métropolitain",
83
+ "GF"=>"French Guiana",
84
+ "PF"=>"French Polynesia",
85
+ "TF"=>"French Southern Territories",
86
+ "GA"=>"Gabon",
87
+ "GM"=>"Gambia",
88
+ "GE"=>"Georgia",
89
+ "DE"=>"Germany",
90
+ "GH"=>"Ghana",
91
+ "GI"=>"Gibraltar",
92
+ "GR"=>"Greece",
93
+ "GL"=>"Greenland",
94
+ "GD"=>"Grenada",
95
+ "GP"=>"Guadeloupe",
96
+ "GU"=>"Guam",
97
+ "GT"=>"Guatemala",
98
+ "GN"=>"Guinea",
99
+ "GW"=>"Guinea-Bissau",
100
+ "GY"=>"Guyana",
101
+ "HT"=>"Haiti",
102
+ "HM"=>"Heard & McDonald Islands",
103
+ "HN"=>"Honduras",
104
+ "HK"=>"Hong Kong",
105
+ "HU"=>"Hungary",
106
+ "IS"=>"Iceland",
107
+ "IN"=>"India",
108
+ "ID"=>"Indonesia",
109
+ "IQ"=>"Iraq",
110
+ "IE"=>"Ireland",
111
+ "IR"=>"Islamic Republic of Iran",
112
+ "IL"=>"Israel",
113
+ "IT"=>"Italy",
114
+ "JM"=>"Jamaica",
115
+ "JP"=>"Japan",
116
+ "JO"=>"Jordan",
117
+ "KZ"=>"Kazakhstan",
118
+ "KE"=>"Kenya",
119
+ "KI"=>"Kiribati",
120
+ "KP"=>"Korea, Democratic People's Republic of",
121
+ "KR"=>"Korea, Republic of",
122
+ "KW"=>"Kuwait",
123
+ "KG"=>"Kyrgyzstan",
124
+ "LA"=>"Lao People's Democratic Republic",
125
+ "LV"=>"Latvia",
126
+ "LB"=>"Lebanon",
127
+ "LS"=>"Lesotho",
128
+ "LR"=>"Liberia",
129
+ "LY"=>"Libyan Arab Jamahiriya",
130
+ "LI"=>"Liechtenstein",
131
+ "LT"=>"Lithuania",
132
+ "LU"=>"Luxembourg",
133
+ "MO"=>"Macau",
134
+ "MG"=>"Madagascar",
135
+ "MW"=>"Malawi",
136
+ "MY"=>"Malaysia",
137
+ "MV"=>"Maldives",
138
+ "ML"=>"Mali",
139
+ "MT"=>"Malta",
140
+ "MH"=>"Marshall Islands",
141
+ "MQ"=>"Martinique",
142
+ "MR"=>"Mauritania",
143
+ "MU"=>"Mauritius",
144
+ "YT"=>"Mayotte",
145
+ "MX"=>"Mexico",
146
+ "FM"=>"Micronesia",
147
+ "MD"=>"Moldova, Republic of",
148
+ "MC"=>"Monaco",
149
+ "MN"=>"Mongolia",
150
+ "MS"=>"Monserrat",
151
+ "MA"=>"Morocco",
152
+ "MZ"=>"Mozambique",
153
+ "MM"=>"Myanmar",
154
+ "NA"=>"Namibia",
155
+ "NR"=>"Nauru",
156
+ "NP"=>"Nepal",
157
+ "NL"=>"Netherlands",
158
+ "AN"=>"Netherlands Antilles",
159
+ "NC"=>"New Caledonia",
160
+ "NZ"=>"New Zealand",
161
+ "NI"=>"Nicaragua",
162
+ "NE"=>"Niger",
163
+ "NG"=>"Nigeria",
164
+ "NU"=>"Niue",
165
+ "NF"=>"Norfolk Island",
166
+ "MP"=>"Northern Mariana Islands",
167
+ "NO"=>"Norway",
168
+ "OM"=>"Oman",
169
+ "PK"=>"Pakistan",
170
+ "PW"=>"Palau",
171
+ "PA"=>"Panama",
172
+ "PG"=>"Papua New Guinea",
173
+ "PY"=>"Paraguay",
174
+ "PE"=>"Peru",
175
+ "PH"=>"Philippines",
176
+ "PN"=>"Pitcairn",
177
+ "PL"=>"Poland",
178
+ "PT"=>"Portugal",
179
+ "PR"=>"Puerto Rico",
180
+ "QA"=>"Qatar",
181
+ "RO"=>"Romania",
182
+ "RU"=>"Russian Federation",
183
+ "RW"=>"Rwanda",
184
+ "RE"=>"Réunion",
185
+ "LC"=>"Saint Lucia",
186
+ "WS"=>"Samoa",
187
+ "SM"=>"San Marino",
188
+ "ST"=>"Sao Tome & Principe",
189
+ "SA"=>"Saudi Arabia",
190
+ "SN"=>"Senegal",
191
+ "SC"=>"Seychelles",
192
+ "SL"=>"Sierra Leone",
193
+ "SG"=>"Singapore",
194
+ "SK"=>"Slovakia",
195
+ "SI"=>"Slovenia",
196
+ "SB"=>"Solomon Islands",
197
+ "SO"=>"Somalia",
198
+ "ZA"=>"South Africa",
199
+ "GS"=>"South Georgia and the South Sandwich Islands",
200
+ "ES"=>"Spain",
201
+ "LK"=>"Sri Lanka",
202
+ "SH"=>"St. Helena",
203
+ "KN"=>"St. Kitts and Nevis",
204
+ "PM"=>"St. Pierre & Miquelon",
205
+ "VC"=>"St. Vincent & the Grenadines",
206
+ "SD"=>"Sudan",
207
+ "SR"=>"Suriname",
208
+ "SJ"=>"Svalbard & Jan Mayen Islands",
209
+ "SZ"=>"Swaziland",
210
+ "SE"=>"Sweden",
211
+ "CH"=>"Switzerland",
212
+ "SY"=>"Syrian Arab Republic",
213
+ "TW"=>"Taiwan, Province of China",
214
+ "TJ"=>"Tajikistan",
215
+ "TZ"=>"Tanzania, United Republic of",
216
+ "TH"=>"Thailand",
217
+ "TG"=>"Togo",
218
+ "TK"=>"Tokelau",
219
+ "TO"=>"Tonga",
220
+ "TT"=>"Trinidad & Tobago",
221
+ "TN"=>"Tunisia",
222
+ "TR"=>"Turkey",
223
+ "TM"=>"Turkmenistan",
224
+ "TC"=>"Turks & Caicos Islands",
225
+ "TV"=>"Tuvalu",
226
+ "UG"=>"Uganda",
227
+ "UA"=>"Ukraine",
228
+ "AE"=>"United Arab Emirates",
229
+ "GB"=>"United Kingdom (Great Britain)",
230
+ "UM"=>"United States Minor Outlying Islands",
231
+ "VI"=>"United States Virgin Islands",
232
+ "US"=>"United States of America",
233
+ "UY"=>"Uruguay",
234
+ "UZ"=>"Uzbekistan",
235
+ "VU"=>"Vanuatu",
236
+ "VA"=>"Vatican City State (Holy See)",
237
+ "VE"=>"Venezuela",
238
+ "VN"=>"Viet Nam",
239
+ "WF"=>"Wallis & Futuna Islands",
240
+ "EH"=>"Western Sahara",
241
+ "YE"=>"Yemen",
242
+ "YU"=>"Yugoslavia",
243
+ "ZR"=>"Zaire",
244
+ "ZM"=>"Zambia",
245
+ "ZW"=>"Zimbabwe"
246
+ }
247
+
248
+ included do
249
+ helper_method :countries_option_list, :country_from_code
250
+ end
251
+
252
+ def countries_option_list
253
+ COUNTRIES_LIST.map { |code, country| [country, code] }
254
+ end
255
+
256
+ def country_from_code code
257
+ COUNTRIES_LIST[code.to_s.upcase]
258
+ end
259
+ end
260
+ end
261
+ end