carmen 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +7 -0
- data/Gemfile +3 -0
- data/README.rdoc +49 -34
- data/Rakefile +1 -0
- data/VERSION +1 -1
- data/carmen.gemspec +39 -33
- data/data/states/in.yml +71 -0
- data/lib/carmen.rb +6 -2
- metadata +30 -13
- data/rails/init.rb +0 -2
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
CHANGED
@@ -1,29 +1,30 @@
|
|
1
|
+
|
1
2
|
= Carmen- A simple collection of geographic names and abbreviations for Ruby
|
2
3
|
|
3
4
|
This library will work as a drop in replacement for the official Rails country_select and its various forks. The idea is to provide a single library for all geographic naming concerns, and unify them under a consistent API.
|
4
5
|
|
5
|
-
States are supported for the following countries: Australia, Brazil, Canada, Cuba, Denmark, Germany, Italy, Mexico, New Zealand, Norway, Spain, Ukraine, and United States.
|
6
|
+
States are supported for the following countries: Australia, Brazil, Canada, Cuba, Denmark, Germany, India, Italy, Mexico, New Zealand, Norway, Spain, Ukraine, and United States.
|
6
7
|
|
7
8
|
== Installation
|
8
9
|
|
9
10
|
gem install carmen
|
10
|
-
|
11
|
+
|
11
12
|
If you're in Rails 2.3 or earlier, place this in your environment.rb:
|
12
13
|
|
13
14
|
config.gem 'carmen'
|
14
|
-
|
15
|
+
|
15
16
|
If you're in Rails 3, put this in your Gemfile:
|
16
17
|
|
17
18
|
gem "carmen"
|
18
19
|
|
19
20
|
|
20
21
|
== Get a list of all countries
|
21
|
-
|
22
|
+
|
22
23
|
Carmen.countries => […, ['Germany', 'DE'], …, ['United States', 'US'], …]
|
23
24
|
Carmen.countries(:locale => 'de') => […, ['Deutschland', 'DE'], …, ['Vereinigte Staaten von Amerika', 'US'], …]
|
24
25
|
|
25
26
|
== State list retrieval
|
26
|
-
|
27
|
+
|
27
28
|
Carmen::states('US') => [['Alabama', 'AL'], ['Arkansas', 'AR'], ... ]
|
28
29
|
Carmen::states => [['Alabama', 'AL'], ['Arkansas', 'AR'], ... ] # uses default country
|
29
30
|
Carmen::state_names('US') => ['Alabama', 'Arkansas', ... ]
|
@@ -36,7 +37,7 @@ If you're in Rails 3, put this in your Gemfile:
|
|
36
37
|
Carmen::state_code('Illinois') => 'IL'
|
37
38
|
Carmen::state_code('Manitoba', 'CA') => 'MB'
|
38
39
|
Carmen::state_name('AZ') => 'Arizona'
|
39
|
-
|
40
|
+
|
40
41
|
|
41
42
|
== Default Country
|
42
43
|
|
@@ -48,7 +49,7 @@ Methods that take a country code argument will use the default country if none i
|
|
48
49
|
|
49
50
|
This fork lets you exclude specific countries and/or states from Carmen. Simply set the appropriate class variables and the exclusion will take effect.
|
50
51
|
|
51
|
-
== Excluding Countries
|
52
|
+
== Excluding Countries
|
52
53
|
|
53
54
|
Countries to exclude are specified as an array of country codes:
|
54
55
|
|
@@ -57,7 +58,7 @@ Countries to exclude are specified as an array of country codes:
|
|
57
58
|
== Excluding States
|
58
59
|
|
59
60
|
States to exclude are specified via a hash, with keys being the country's code, and values being the states to exclude from that country:
|
60
|
-
|
61
|
+
|
61
62
|
Carmen.excluded_states = { 'US' => [ 'AA', 'AP', 'PW', ... ], 'DE' => [ 'BW', 'TH' ], ... }
|
62
63
|
|
63
64
|
== Localization
|
@@ -65,7 +66,7 @@ States to exclude are specified via a hash, with keys being the country's code,
|
|
65
66
|
You can switch between different localizations of the countries list, by setting the locale value (default is :en):
|
66
67
|
|
67
68
|
Carmen.default_locale = :de
|
68
|
-
|
69
|
+
|
69
70
|
Methods that return country names also take an optional options hash as the last argument, which can be use to override the default locale for a single call:
|
70
71
|
|
71
72
|
Carmen::country_name('US') => 'United States'
|
@@ -78,16 +79,27 @@ Currently included localizations are: English (:en), German (:de)
|
|
78
79
|
|
79
80
|
* Many countries, such as Spain, have additional levels beneath 'state' that we would ideally support. Thanks to Alberto Molpeceres for bringing this to my attention.
|
80
81
|
* Split the Rails-specific view helpers out into a separate gem (carmen-rails)
|
82
|
+
* Move regex matching into an optional module.
|
81
83
|
|
82
84
|
== Changelog
|
83
|
-
|
84
|
-
*
|
85
|
-
*
|
86
|
-
*
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
*
|
85
|
+
=== 0.2.6
|
86
|
+
* Suppress a deprecation warning in Rails 3 (anupamc)
|
87
|
+
* Remove init.rb altogether and use requires under Rails
|
88
|
+
* Added Indian states and union territories (orthodoc)
|
89
|
+
=== 0.2.5
|
90
|
+
* Data corrections (mikepinde)
|
91
|
+
=== 0.2.4
|
92
|
+
* Fixed autoloading under Rails 3
|
93
|
+
=== 0.2.2
|
94
|
+
* Added state and country exclusion (kalafut)
|
95
|
+
=== 0.2.1
|
96
|
+
* Added regions for New Zealand (yehezkielbs)
|
97
|
+
=== 0.2.0
|
98
|
+
* Merge in Maximilian Schulz's locale fork, refactor internals to better support locales, and update documentation.
|
99
|
+
* Remove Carmen::STATES and Carmen::COUNTRIES constants in favor of module instance variables and proper accessors.
|
100
|
+
* Add a test_helper and remove dependency on RubyGems.
|
101
|
+
=== 0.1.3
|
102
|
+
* DEPRECATE Carmen::COUNTRIES in favor of Carmen.countries
|
91
103
|
|
92
104
|
|
93
105
|
== Development notes
|
@@ -99,22 +111,25 @@ The plugin does not require rubygems anywhere in the test or libraries, so if yo
|
|
99
111
|
|
100
112
|
These fine characters have contributed state lists, patches, or reported bugs:
|
101
113
|
|
102
|
-
Jose Angel Cortinas (jacortinas)
|
103
|
-
Domizio Demichelis (ddnexus)
|
104
|
-
Thiago Jackiw (railsfreaks)
|
105
|
-
Russ Johnson (russjohnson)
|
106
|
-
Henrik Hodne (dvyjones)
|
107
|
-
Yuval Kordov (uberllama)
|
108
|
-
Alberto Molpeceres (molpe)
|
109
|
-
Dimas Priyanto (dimaspriyanto)
|
110
|
-
Wojtek Ogrodowczyk (sharnik)
|
111
|
-
Tobias Schmidt (grobie)
|
112
|
-
Maximilian Schulz (namxam)
|
113
|
-
Mani Tadayon (bowsersenior)
|
114
|
-
Andriy Tyurnikov (andriytyurnikov)
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
114
|
+
* Jose Angel Cortinas (jacortinas)
|
115
|
+
* Domizio Demichelis (ddnexus)
|
116
|
+
* Thiago Jackiw (railsfreaks)
|
117
|
+
* Russ Johnson (russjohnson)
|
118
|
+
* Henrik Hodne (dvyjones)
|
119
|
+
* Yuval Kordov (uberllama)
|
120
|
+
* Alberto Molpeceres (molpe)
|
121
|
+
* Dimas Priyanto (dimaspriyanto)
|
122
|
+
* Wojtek Ogrodowczyk (sharnik)
|
123
|
+
* Tobias Schmidt (grobie)
|
124
|
+
* Maximilian Schulz (namxam)
|
125
|
+
* Mani Tadayon (bowsersenior)
|
126
|
+
* Andriy Tyurnikov (andriytyurnikov)
|
127
|
+
* Anupam Choudhury (anupamc)
|
128
|
+
* Biswajit Dutta Baruah (orthodoc)
|
129
|
+
* lonestarsoftware
|
130
|
+
* mikepinde
|
131
|
+
* kalafut
|
132
|
+
* yehezkielbs
|
119
133
|
|
120
134
|
If I missed your name in this list, please let me know and I will add it. I tried to find everyone that has sent in patches or found bugs, but I may have missed a few folks.
|
135
|
+
|
data/Rakefile
CHANGED
@@ -11,6 +11,7 @@ begin
|
|
11
11
|
gem.email = "jim@autonomousmachine.com"
|
12
12
|
gem.homepage = "http://github.com/jim/carmen"
|
13
13
|
gem.authors = ["Jim Benton"]
|
14
|
+
gem.add_development_dependency 'jeweler', '1.4'
|
14
15
|
gem.add_development_dependency "mocha"
|
15
16
|
gem.add_development_dependency "rails"
|
16
17
|
gem.add_development_dependency "hanna"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
data/carmen.gemspec
CHANGED
@@ -1,58 +1,61 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{carmen}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jim Benton"]
|
12
|
-
s.date = %q{2011-
|
12
|
+
s.date = %q{2011-03-11}
|
13
13
|
s.description = %q{A collection of geographic country and state names for Ruby. Also includes replacements for Rails' country_select and state_select plugins}
|
14
14
|
s.email = %q{jim@autonomousmachine.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
"
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
19
|
+
".gitignore",
|
20
|
+
"Gemfile",
|
21
|
+
"MIT-LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"carmen.gemspec",
|
26
|
+
"data/countries/de.yml",
|
27
|
+
"data/countries/en.yml",
|
28
|
+
"data/states/au.yml",
|
29
|
+
"data/states/br.yml",
|
30
|
+
"data/states/ca.yml",
|
31
|
+
"data/states/cu.yml",
|
32
|
+
"data/states/de.yml",
|
33
|
+
"data/states/dk.yml",
|
34
|
+
"data/states/es.yml",
|
35
|
+
"data/states/hr.yml",
|
36
|
+
"data/states/in.yml",
|
37
|
+
"data/states/it.yml",
|
38
|
+
"data/states/mx.yml",
|
39
|
+
"data/states/no.yml",
|
40
|
+
"data/states/nz.yml",
|
41
|
+
"data/states/ua.yml",
|
42
|
+
"data/states/us.yml",
|
43
|
+
"lib/carmen.rb",
|
44
|
+
"lib/carmen/action_view_helpers.rb",
|
45
|
+
"lib/carmen/railtie.rb",
|
46
|
+
"test/carmen_test.rb",
|
47
|
+
"test/carmen_view_helper_test.rb",
|
48
|
+
"test/test_helper.rb"
|
47
49
|
]
|
48
50
|
s.homepage = %q{http://github.com/jim/carmen}
|
51
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
49
52
|
s.require_paths = ["lib"]
|
50
53
|
s.rubygems_version = %q{1.3.7}
|
51
54
|
s.summary = %q{A collection of geographic country and state names for Ruby}
|
52
55
|
s.test_files = [
|
53
56
|
"test/carmen_test.rb",
|
54
|
-
|
55
|
-
|
57
|
+
"test/carmen_view_helper_test.rb",
|
58
|
+
"test/test_helper.rb"
|
56
59
|
]
|
57
60
|
|
58
61
|
if s.respond_to? :specification_version then
|
@@ -60,15 +63,18 @@ Gem::Specification.new do |s|
|
|
60
63
|
s.specification_version = 3
|
61
64
|
|
62
65
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
66
|
+
s.add_development_dependency(%q<jeweler>, ["= 1.4"])
|
63
67
|
s.add_development_dependency(%q<mocha>, [">= 0"])
|
64
68
|
s.add_development_dependency(%q<rails>, [">= 0"])
|
65
69
|
s.add_development_dependency(%q<hanna>, [">= 0"])
|
66
70
|
else
|
71
|
+
s.add_dependency(%q<jeweler>, ["= 1.4"])
|
67
72
|
s.add_dependency(%q<mocha>, [">= 0"])
|
68
73
|
s.add_dependency(%q<rails>, [">= 0"])
|
69
74
|
s.add_dependency(%q<hanna>, [">= 0"])
|
70
75
|
end
|
71
76
|
else
|
77
|
+
s.add_dependency(%q<jeweler>, ["= 1.4"])
|
72
78
|
s.add_dependency(%q<mocha>, [">= 0"])
|
73
79
|
s.add_dependency(%q<rails>, [">= 0"])
|
74
80
|
s.add_dependency(%q<hanna>, [">= 0"])
|
data/data/states/in.yml
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# from http://en.wikipedia.org/wiki/ISO_3166-2:IN
|
2
|
+
---
|
3
|
+
- - Andhra Pradesh
|
4
|
+
- AP
|
5
|
+
- - Arunachal Pradesh
|
6
|
+
- AR
|
7
|
+
- - Assam
|
8
|
+
- AS
|
9
|
+
- - Bihar
|
10
|
+
- BR
|
11
|
+
- - Chhattisgarh
|
12
|
+
- CT
|
13
|
+
- - Goa
|
14
|
+
- GA
|
15
|
+
- - Haryana
|
16
|
+
- HR
|
17
|
+
- - Himachal Pradesh
|
18
|
+
- HP
|
19
|
+
- - Jammu and Kashmir
|
20
|
+
- JK
|
21
|
+
- - Jharkhand
|
22
|
+
- JH
|
23
|
+
- - Karnataka
|
24
|
+
- KA
|
25
|
+
- - Kerala
|
26
|
+
- KL
|
27
|
+
- - Madhya Pradesh
|
28
|
+
- MP
|
29
|
+
- - Maharashtra
|
30
|
+
- MH
|
31
|
+
- - Manipur
|
32
|
+
- MN
|
33
|
+
- - Meghalaya
|
34
|
+
- ML
|
35
|
+
- - Mizoram
|
36
|
+
- MZ
|
37
|
+
- - Nagaland
|
38
|
+
- NL
|
39
|
+
- - Orissa
|
40
|
+
- OR
|
41
|
+
- - Punjab
|
42
|
+
- PB
|
43
|
+
- - Rajasthan
|
44
|
+
- RJ
|
45
|
+
- - Sikkim
|
46
|
+
- SK
|
47
|
+
- - Tamil Nadu
|
48
|
+
- TN
|
49
|
+
- - Tripura
|
50
|
+
- TR
|
51
|
+
- - Uttarakhand
|
52
|
+
- UL
|
53
|
+
- - Uttar Pradesh
|
54
|
+
- UP
|
55
|
+
- - West Bengal
|
56
|
+
- WB
|
57
|
+
- - Andaman and Nicobar Islands
|
58
|
+
- AN
|
59
|
+
- - Chandigarh
|
60
|
+
- CH
|
61
|
+
- - Dadra and Nagar Haveli
|
62
|
+
- DN
|
63
|
+
- - Daman and Diu
|
64
|
+
- DD
|
65
|
+
- - Delhi
|
66
|
+
- DL
|
67
|
+
- - Lakshadweep
|
68
|
+
- LD
|
69
|
+
- - Puducherry
|
70
|
+
- PY
|
71
|
+
|
data/lib/carmen.rb
CHANGED
@@ -6,8 +6,12 @@ rescue LoadError
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# Fix to autoload in Rails 3
|
9
|
-
if defined?(Rails)
|
10
|
-
|
9
|
+
if defined?(Rails)
|
10
|
+
if Rails::VERSION::MAJOR > 2
|
11
|
+
require 'carmen/railtie'
|
12
|
+
else
|
13
|
+
require 'carmen/action_view_helpers'
|
14
|
+
end
|
11
15
|
end
|
12
16
|
|
13
17
|
module Carmen
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carmen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 7
|
10
|
+
version: 0.2.7
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jim Benton
|
@@ -15,13 +15,28 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-03-11 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: jeweler
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - "="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 7
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 4
|
33
|
+
version: "1.4"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: mocha
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
25
40
|
none: false
|
26
41
|
requirements:
|
27
42
|
- - ">="
|
@@ -31,11 +46,11 @@ dependencies:
|
|
31
46
|
- 0
|
32
47
|
version: "0"
|
33
48
|
type: :development
|
34
|
-
version_requirements: *
|
49
|
+
version_requirements: *id002
|
35
50
|
- !ruby/object:Gem::Dependency
|
36
51
|
name: rails
|
37
52
|
prerelease: false
|
38
|
-
requirement: &
|
53
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
54
|
none: false
|
40
55
|
requirements:
|
41
56
|
- - ">="
|
@@ -45,11 +60,11 @@ dependencies:
|
|
45
60
|
- 0
|
46
61
|
version: "0"
|
47
62
|
type: :development
|
48
|
-
version_requirements: *
|
63
|
+
version_requirements: *id003
|
49
64
|
- !ruby/object:Gem::Dependency
|
50
65
|
name: hanna
|
51
66
|
prerelease: false
|
52
|
-
requirement: &
|
67
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
68
|
none: false
|
54
69
|
requirements:
|
55
70
|
- - ">="
|
@@ -59,7 +74,7 @@ dependencies:
|
|
59
74
|
- 0
|
60
75
|
version: "0"
|
61
76
|
type: :development
|
62
|
-
version_requirements: *
|
77
|
+
version_requirements: *id004
|
63
78
|
description: A collection of geographic country and state names for Ruby. Also includes replacements for Rails' country_select and state_select plugins
|
64
79
|
email: jim@autonomousmachine.com
|
65
80
|
executables: []
|
@@ -69,6 +84,8 @@ extensions: []
|
|
69
84
|
extra_rdoc_files:
|
70
85
|
- README.rdoc
|
71
86
|
files:
|
87
|
+
- .gitignore
|
88
|
+
- Gemfile
|
72
89
|
- MIT-LICENSE
|
73
90
|
- README.rdoc
|
74
91
|
- Rakefile
|
@@ -84,6 +101,7 @@ files:
|
|
84
101
|
- data/states/dk.yml
|
85
102
|
- data/states/es.yml
|
86
103
|
- data/states/hr.yml
|
104
|
+
- data/states/in.yml
|
87
105
|
- data/states/it.yml
|
88
106
|
- data/states/mx.yml
|
89
107
|
- data/states/no.yml
|
@@ -93,7 +111,6 @@ files:
|
|
93
111
|
- lib/carmen.rb
|
94
112
|
- lib/carmen/action_view_helpers.rb
|
95
113
|
- lib/carmen/railtie.rb
|
96
|
-
- rails/init.rb
|
97
114
|
- test/carmen_test.rb
|
98
115
|
- test/carmen_view_helper_test.rb
|
99
116
|
- test/test_helper.rb
|
@@ -102,8 +119,8 @@ homepage: http://github.com/jim/carmen
|
|
102
119
|
licenses: []
|
103
120
|
|
104
121
|
post_install_message:
|
105
|
-
rdoc_options:
|
106
|
-
|
122
|
+
rdoc_options:
|
123
|
+
- --charset=UTF-8
|
107
124
|
require_paths:
|
108
125
|
- lib
|
109
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
data/rails/init.rb
DELETED