namxam-carmen 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/MIT-LICENSE +21 -0
- data/README.rdoc +59 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/carmen.gemspec +64 -0
- data/data/countries.yml +487 -0
- data/data/states/au.yml +17 -0
- data/data/states/br.yml +55 -0
- data/data/states/ca.yml +27 -0
- data/data/states/cu.yml +31 -0
- data/data/states/de.yml +33 -0
- data/data/states/dk.yml +11 -0
- data/data/states/it.yml +207 -0
- data/data/states/mx.yml +65 -0
- data/data/states/ua.yml +51 -0
- data/data/states/us.yml +124 -0
- data/lib/carmen.rb +132 -0
- data/lib/carmen/action_view_helpers.rb +68 -0
- data/rails/init.rb +2 -0
- data/test/carmen_test.rb +89 -0
- data/test/carmen_view_helper_test.rb +43 -0
- metadata +89 -0
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'active_support'
|
3
|
+
require 'action_view'
|
4
|
+
require 'action_controller'
|
5
|
+
require 'action_view/test_case'
|
6
|
+
require 'mocha'
|
7
|
+
require File.join(File.dirname(__FILE__), '../lib/carmen')
|
8
|
+
require File.join(File.dirname(__FILE__), '../lib/carmen/action_view_helpers')
|
9
|
+
|
10
|
+
class CarmenViewHelperTest < ActionView::TestCase
|
11
|
+
|
12
|
+
include ActionView::Helpers::FormOptionsHelper
|
13
|
+
|
14
|
+
def setup
|
15
|
+
@address = stub(:state => 'IL', :country => 'US', :to_s => 'address')
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_state_select_for_us
|
19
|
+
@address.stubs(:state => 'nil')
|
20
|
+
assert_equal US_STATE_SELECT_HTML.chomp, state_select(@address, :state, 'US')
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_state_select_for_canada
|
24
|
+
@address.stubs(:state => 'nil')
|
25
|
+
assert_equal CANADA_STATE_SELECT_HTML.chomp, state_select(@address, :state, 'CA')
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_country_options_for_select_with_priorities
|
29
|
+
assert_equal COUNTRY_SELECT_OPTIONS_HTML.chomp, country_options_for_select('US', 'US')
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_selected_option
|
33
|
+
@address.stubs(:state => 'ON')
|
34
|
+
assert_match /<option value="ON" selected="selected">Ontario<\/option>/, state_select(@address, :state, 'CA')
|
35
|
+
end
|
36
|
+
|
37
|
+
COUNTRY_SELECT_OPTIONS_HTML = "<option value=\"US\" selected=\"selected\">United States</option>\n<option value=\"\" disabled=\"disabled\">-------------</option>\n<option value=\"AF\">Afghanistan</option>\n<option value=\"AX\">Aland Islands</option>\n<option value=\"AL\">Albania</option>\n<option value=\"DZ\">Algeria</option>\n<option value=\"AS\">American Samoa</option>\n<option value=\"AD\">Andorra</option>\n<option value=\"AO\">Angola</option>\n<option value=\"AI\">Anguilla</option>\n<option value=\"AQ\">Antarctica</option>\n<option value=\"AG\">Antigua and Barbuda</option>\n<option value=\"AR\">Argentina</option>\n<option value=\"AM\">Armenia</option>\n<option value=\"AW\">Aruba</option>\n<option value=\"AU\">Australia</option>\n<option value=\"AT\">Austria</option>\n<option value=\"AZ\">Azerbaijan</option>\n<option value=\"BS\">Bahamas</option>\n<option value=\"BH\">Bahrain</option>\n<option value=\"BD\">Bangladesh</option>\n<option value=\"BB\">Barbados</option>\n<option value=\"BY\">Belarus</option>\n<option value=\"BE\">Belgium</option>\n<option value=\"BZ\">Belize</option>\n<option value=\"BJ\">Benin</option>\n<option value=\"BM\">Bermuda</option>\n<option value=\"BT\">Bhutan</option>\n<option value=\"BO\">Bolivia</option>\n<option value=\"BA\">Bosnia and Herzegovina</option>\n<option value=\"BW\">Botswana</option>\n<option value=\"BV\">Bouvet Island</option>\n<option value=\"BR\">Brazil</option>\n<option value=\"IO\">British Indian Ocean Territory</option>\n<option value=\"BN\">Brunei Darussalam</option>\n<option value=\"BG\">Bulgaria</option>\n<option value=\"BF\">Burkina Faso</option>\n<option value=\"BI\">Burundi</option>\n<option value=\"KH\">Cambodia</option>\n<option value=\"CM\">Cameroon</option>\n<option value=\"CA\">Canada</option>\n<option value=\"CV\">Cape Verde</option>\n<option value=\"KY\">Cayman Islands</option>\n<option value=\"CF\">Central African Republic</option>\n<option value=\"TD\">Chad</option>\n<option value=\"CL\">Chile</option>\n<option value=\"CN\">China</option>\n<option value=\"CX\">Christmas Island</option>\n<option value=\"CC\">Cocos (Keeling) Islands</option>\n<option value=\"CO\">Colombia</option>\n<option value=\"KM\">Comoros</option>\n<option value=\"CG\">Congo</option>\n<option value=\"CD\">Congo, the Democratic Republic of the</option>\n<option value=\"CK\">Cook Islands</option>\n<option value=\"CR\">Costa Rica</option>\n<option value=\"CI\">Cote D'ivoire</option>\n<option value=\"HR\">Croatia</option>\n<option value=\"CU\">Cuba</option>\n<option value=\"CY\">Cyprus</option>\n<option value=\"CZ\">Czech Republic</option>\n<option value=\"DK\">Denmark</option>\n<option value=\"DJ\">Djibouti</option>\n<option value=\"DM\">Dominica</option>\n<option value=\"DO\">Dominican Republic</option>\n<option value=\"EC\">Ecuador</option>\n<option value=\"EG\">Egypt</option>\n<option value=\"SV\">El Salvador</option>\n<option value=\"GQ\">Equatorial Guinea</option>\n<option value=\"ER\">Eritrea</option>\n<option value=\"EE\">Estonia</option>\n<option value=\"ET\">Ethiopia</option>\n<option value=\"FK\">Falkland Islands (Malvinas)</option>\n<option value=\"FO\">Faroe Islands</option>\n<option value=\"FJ\">Fiji</option>\n<option value=\"FI\">Finland</option>\n<option value=\"FR\">France</option>\n<option value=\"GF\">French Guiana</option>\n<option value=\"PF\">French Polynesia</option>\n<option value=\"TF\">French Southern Territories</option>\n<option value=\"GA\">Gabon</option>\n<option value=\"GM\">Gambia</option>\n<option value=\"GE\">Georgia</option>\n<option value=\"DE\">Germany</option>\n<option value=\"GH\">Ghana</option>\n<option value=\"GI\">Gibraltar</option>\n<option value=\"GR\">Greece</option>\n<option value=\"GL\">Greenland</option>\n<option value=\"GD\">Grenada</option>\n<option value=\"GP\">Guadeloupe</option>\n<option value=\"GU\">Guam</option>\n<option value=\"GT\">Guatemala</option>\n<option value=\"GG\">Guernsey</option>\n<option value=\"GN\">Guinea</option>\n<option value=\"GW\">Guinea-Bissau</option>\n<option value=\"GY\">Guyana</option>\n<option value=\"HT\">Haiti</option>\n<option value=\"HM\">Heard Island and Mcdonald Islands</option>\n<option value=\"VA\">Holy See (Vatican City State)</option>\n<option value=\"HN\">Honduras</option>\n<option value=\"HK\">Hong Kong</option>\n<option value=\"HU\">Hungary</option>\n<option value=\"IS\">Iceland</option>\n<option value=\"IN\">India</option>\n<option value=\"ID\">Indonesia</option>\n<option value=\"IR\">Iran, Islamic Republic of</option>\n<option value=\"IQ\">Iraq</option>\n<option value=\"IE\">Ireland</option>\n<option value=\"IM\">Isle of Man</option>\n<option value=\"IL\">Israel</option>\n<option value=\"IT\">Italy</option>\n<option value=\"JM\">Jamaica</option>\n<option value=\"JP\">Japan</option>\n<option value=\"JE\">Jersey</option>\n<option value=\"JO\">Jordan</option>\n<option value=\"KZ\">Kazakhstan</option>\n<option value=\"KE\">Kenya</option>\n<option value=\"KI\">Kiribati</option>\n<option value=\"KP\">Korea, Democratic People's Republic of</option>\n<option value=\"KR\">Korea, Republic of</option>\n<option value=\"KW\">Kuwait</option>\n<option value=\"KG\">Kyrgyzstan</option>\n<option value=\"LA\">Lao People's Democratic Republic</option>\n<option value=\"LV\">Latvia</option>\n<option value=\"LB\">Lebanon</option>\n<option value=\"LS\">Lesotho</option>\n<option value=\"LR\">Liberia</option>\n<option value=\"LY\">Libyan Arab Jamahiriya</option>\n<option value=\"LI\">Liechtenstein</option>\n<option value=\"LT\">Lithuania</option>\n<option value=\"LU\">Luxembourg</option>\n<option value=\"MO\">Macao</option>\n<option value=\"MK\">Macedonia, the Former Yugoslav Republic of</option>\n<option value=\"MG\">Madagascar</option>\n<option value=\"MW\">Malawi</option>\n<option value=\"MY\">Malaysia</option>\n<option value=\"MV\">Maldives</option>\n<option value=\"ML\">Mali</option>\n<option value=\"MT\">Malta</option>\n<option value=\"MH\">Marshall Islands</option>\n<option value=\"MQ\">Martinique</option>\n<option value=\"MR\">Mauritania</option>\n<option value=\"MU\">Mauritius</option>\n<option value=\"YT\">Mayotte</option>\n<option value=\"MX\">Mexico</option>\n<option value=\"FM\">Micronesia, Federated States of</option>\n<option value=\"MD\">Moldova, Republic of</option>\n<option value=\"MC\">Monaco</option>\n<option value=\"MN\">Mongolia</option>\n<option value=\"MS\">Montserrat</option>\n<option value=\"MA\">Morocco</option>\n<option value=\"MZ\">Mozambique</option>\n<option value=\"MM\">Myanmar</option>\n<option value=\"NA\">Namibia</option>\n<option value=\"NR\">Nauru</option>\n<option value=\"NP\">Nepal</option>\n<option value=\"NL\">Netherlands</option>\n<option value=\"AN\">Netherlands Antilles</option>\n<option value=\"NC\">New Caledonia</option>\n<option value=\"NZ\">New Zealand</option>\n<option value=\"NI\">Nicaragua</option>\n<option value=\"NE\">Niger</option>\n<option value=\"NG\">Nigeria</option>\n<option value=\"NU\">Niue</option>\n<option value=\"NF\">Norfolk Island</option>\n<option value=\"MP\">Northern Mariana Islands</option>\n<option value=\"NO\">Norway</option>\n<option value=\"OM\">Oman</option>\n<option value=\"PK\">Pakistan</option>\n<option value=\"PW\">Palau</option>\n<option value=\"PS\">Palestinian Territory, Occupied</option>\n<option value=\"PA\">Panama</option>\n<option value=\"PG\">Papua New Guinea</option>\n<option value=\"PY\">Paraguay</option>\n<option value=\"PE\">Peru</option>\n<option value=\"PH\">Philippines</option>\n<option value=\"PN\">Pitcairn</option>\n<option value=\"PL\">Poland</option>\n<option value=\"PT\">Portugal</option>\n<option value=\"PR\">Puerto Rico</option>\n<option value=\"QA\">Qatar</option>\n<option value=\"RE\">Reunion</option>\n<option value=\"RO\">Romania</option>\n<option value=\"RU\">Russian Federation</option>\n<option value=\"RW\">Rwanda</option>\n<option value=\"SH\">Saint Helena</option>\n<option value=\"KN\">Saint Kitts and Nevis</option>\n<option value=\"LC\">Saint Lucia</option>\n<option value=\"PM\">Saint Pierre and Miquelon</option>\n<option value=\"VC\">Saint Vincent and the Grenadines</option>\n<option value=\"WS\">Samoa</option>\n<option value=\"SM\">San Marino</option>\n<option value=\"ST\">Sao Tome and Principe</option>\n<option value=\"SA\">Saudi Arabia</option>\n<option value=\"SN\">Senegal</option>\n<option value=\"CS\">Serbia and Montenegro</option>\n<option value=\"SC\">Seychelles</option>\n<option value=\"SL\">Sierra Leone</option>\n<option value=\"SG\">Singapore</option>\n<option value=\"SK\">Slovakia</option>\n<option value=\"SI\">Slovenia</option>\n<option value=\"SB\">Solomon Islands</option>\n<option value=\"SO\">Somalia</option>\n<option value=\"ZA\">South Africa</option>\n<option value=\"GS\">South Georgia and the South Sandwich Islands</option>\n<option value=\"ES\">Spain</option>\n<option value=\"LK\">Sri Lanka</option>\n<option value=\"SD\">Sudan</option>\n<option value=\"SR\">Suriname</option>\n<option value=\"SJ\">Svalbard and Jan Mayen</option>\n<option value=\"SZ\">Swaziland</option>\n<option value=\"SE\">Sweden</option>\n<option value=\"CH\">Switzerland</option>\n<option value=\"SY\">Syrian Arab Republic</option>\n<option value=\"TW\">Taiwan, Province of China</option>\n<option value=\"TJ\">Tajikistan</option>\n<option value=\"TZ\">Tanzania, United Republic of</option>\n<option value=\"TH\">Thailand</option>\n<option value=\"TL\">Timor-Leste</option>\n<option value=\"TG\">Togo</option>\n<option value=\"TK\">Tokelau</option>\n<option value=\"TO\">Tonga</option>\n<option value=\"TT\">Trinidad and Tobago</option>\n<option value=\"TN\">Tunisia</option>\n<option value=\"TR\">Turkey</option>\n<option value=\"TM\">Turkmenistan</option>\n<option value=\"TC\">Turks and Caicos Islands</option>\n<option value=\"TV\">Tuvalu</option>\n<option value=\"UG\">Uganda</option>\n<option value=\"UA\">Ukraine</option>\n<option value=\"AE\">United Arab Emirates</option>\n<option value=\"GB\">United Kingdom</option>\n<option value=\"US\">United States</option>\n<option value=\"UM\">United States Minor Outlying Islands</option>\n<option value=\"UY\">Uruguay</option>\n<option value=\"UZ\">Uzbekistan</option>\n<option value=\"VU\">Vanuatu</option>\n<option value=\"VE\">Venezuela</option>\n<option value=\"VN\">Viet Nam</option>\n<option value=\"VG\">Virgin Islands, British</option>\n<option value=\"VI\">Virgin Islands, U.S.</option>\n<option value=\"WF\">Wallis and Futuna</option>\n<option value=\"EH\">Western Sahara</option>\n<option value=\"YE\">Yemen</option>\n<option value=\"ZM\">Zambia</option>\n<option value=\"ZW\">Zimbabwe</option>"
|
38
|
+
|
39
|
+
US_STATE_SELECT_HTML = "<select id=\"address_state\" name=\"address[state]\"><option value=\"AL\">Alabama</option>\n<option value=\"AK\">Alaska</option>\n<option value=\"AZ\">Arizona</option>\n<option value=\"AR\">Arkansas</option>\n<option value=\"CA\">California</option>\n<option value=\"CO\">Colorado</option>\n<option value=\"CT\">Connecticut</option>\n<option value=\"DE\">Delaware</option>\n<option value=\"DC\">District Of Columbia</option>\n<option value=\"FL\">Florida</option>\n<option value=\"GA\">Georgia</option>\n<option value=\"HI\">Hawaii</option>\n<option value=\"ID\">Idaho</option>\n<option value=\"IL\">Illinois</option>\n<option value=\"IN\">Indiana</option>\n<option value=\"IA\">Iowa</option>\n<option value=\"KS\">Kansas</option>\n<option value=\"KY\">Kentucky</option>\n<option value=\"LA\">Louisiana</option>\n<option value=\"ME\">Maine</option>\n<option value=\"MD\">Maryland</option>\n<option value=\"MA\">Massachusetts</option>\n<option value=\"MI\">Michigan</option>\n<option value=\"MN\">Minnesota</option>\n<option value=\"MS\">Mississippi</option>\n<option value=\"MO\">Missouri</option>\n<option value=\"MT\">Montana</option>\n<option value=\"NE\">Nebraska</option>\n<option value=\"NV\">Nevada</option>\n<option value=\"NH\">New Hampshire</option>\n<option value=\"NJ\">New Jersey</option>\n<option value=\"NM\">New Mexico</option>\n<option value=\"NY\">New York</option>\n<option value=\"NC\">North Carolina</option>\n<option value=\"ND\">North Dakota</option>\n<option value=\"OH\">Ohio</option>\n<option value=\"OK\">Oklahoma</option>\n<option value=\"OR\">Oregon</option>\n<option value=\"PA\">Pennsylvania</option>\n<option value=\"RI\">Rhode Island</option>\n<option value=\"SC\">South Carolina</option>\n<option value=\"SD\">South Dakota</option>\n<option value=\"TN\">Tennessee</option>\n<option value=\"TX\">Texas</option>\n<option value=\"UT\">Utah</option>\n<option value=\"VT\">Vermont</option>\n<option value=\"VA\">Virginia</option>\n<option value=\"WA\">Washington</option>\n<option value=\"WV\">West Virginia</option>\n<option value=\"WI\">Wisconsin</option>\n<option value=\"WY\">Wyoming</option>\n<option value=\"FM\">Federated States of Micronesia</option>\n<option value=\"GU\">Guam</option>\n<option value=\"MH\">Marshall Islands</option>\n<option value=\"MP\">Northern Mariana Islands</option>\n<option value=\"PW\">Palau</option>\n<option value=\"PR\">Puerto Rico</option>\n<option value=\"VI\">Virgin Islands</option>\n<option value=\"AA\">Armed Forces Americas (except Canada)</option>\n<option value=\"AE\">Armed Forces Europe, Armed Forces Canada, Armed Forces Africa, or Armed Forces Middle East</option>\n<option value=\"AP\">Armed Forces Pacific</option></select>"
|
40
|
+
|
41
|
+
CANADA_STATE_SELECT_HTML = "<select id=\"address_state\" name=\"address[state]\"><option value=\"AB\">Alberta</option>\n<option value=\"BC\">British Columbia</option>\n<option value=\"MB\">Manitoba</option>\n<option value=\"NB\">New Brunswick</option>\n<option value=\"NL\">Newfoundland and Labrador</option>\n<option value=\"NT\">Northwest Territories</option>\n<option value=\"NS\">Nova Scotia</option>\n<option value=\"NU\">Nunavut</option>\n<option value=\"ON\">Ontario</option>\n<option value=\"PE\">Prince Edward Island</option>\n<option value=\"QC\">Quebec</option>\n<option value=\"SK\">Saskatchewan</option>\n<option value=\"YT\">Yukon</option></select>"
|
42
|
+
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: namxam-carmen
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Jim Benton
|
13
|
+
- Maximilian Schulz
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-02-23 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: |-
|
23
|
+
A fork of the carmen gem by Jim Benton. This fork allows you to
|
24
|
+
switch between different locales (Currently english and german).
|
25
|
+
A collection of geographis country and state names for Ruby.
|
26
|
+
Also includes replacements for Rails' country_select and state_select plugins.
|
27
|
+
email: max@jungeelite.de
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- .gitignore
|
36
|
+
- MIT-LICENSE
|
37
|
+
- README.rdoc
|
38
|
+
- Rakefile
|
39
|
+
- VERSION
|
40
|
+
- carmen.gemspec
|
41
|
+
- data/countries.yml
|
42
|
+
- data/states/au.yml
|
43
|
+
- data/states/br.yml
|
44
|
+
- data/states/ca.yml
|
45
|
+
- data/states/cu.yml
|
46
|
+
- data/states/de.yml
|
47
|
+
- data/states/dk.yml
|
48
|
+
- data/states/it.yml
|
49
|
+
- data/states/mx.yml
|
50
|
+
- data/states/ua.yml
|
51
|
+
- data/states/us.yml
|
52
|
+
- lib/carmen.rb
|
53
|
+
- lib/carmen/action_view_helpers.rb
|
54
|
+
- rails/init.rb
|
55
|
+
- test/carmen_test.rb
|
56
|
+
- test/carmen_view_helper_test.rb
|
57
|
+
has_rdoc: true
|
58
|
+
homepage: http://github.com/namxam/carmen
|
59
|
+
licenses: []
|
60
|
+
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options:
|
63
|
+
- --charset=UTF-8
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
80
|
+
requirements: []
|
81
|
+
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 1.3.6
|
84
|
+
signing_key:
|
85
|
+
specification_version: 3
|
86
|
+
summary: A collection of geographis country and state names for Ruby
|
87
|
+
test_files:
|
88
|
+
- test/carmen_test.rb
|
89
|
+
- test/carmen_view_helper_test.rb
|