country_select 1.3.1 → 2.0.0.rc1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85cd9956d8ad64b2416fb3709b58b6cbd0690594
4
- data.tar.gz: 46a5e1a828ccd13f6bb7fcccb481a4abfd23a905
3
+ metadata.gz: 401df54254b9c4583008b5911cccf52b5b3f2e58
4
+ data.tar.gz: 11545a1a878be17f4ecc0702f02d62654119469d
5
5
  SHA512:
6
- metadata.gz: 3f23d5d029d2c64cd52415d184c369d2c9e78224946a886cde30e7905ad08de1370cc02efdbda7dd7ae1284f1dd3bbd38f8c3f9a3ee4965651500ffb57383d55
7
- data.tar.gz: 875ea57ddb1bfd27a1eb7e7571124e9df206ba8e02ca46f6c60b5701110eabdcb3ded1407422d5f5ab5bb1f6943a15eb27c32a391c67ea6c19cd9c82a9ff5487
6
+ metadata.gz: 673e9a647e516829b6aa503463d0af4d37fbbdad31fc94cedd4f98783947373d6eec776ac1521607113d7473dceb58bf22690c0a6f9c7525734557375da3ad23
7
+ data.tar.gz: 7a33b1de4fed4658a9cc9b6e0e13d98f4d9ac4ed094ceb239884369c823a336fbf04dc83eee7f030fee818069e741b5f036914ff19f32a7ba1c10f511facde3e
data/.travis.yml CHANGED
@@ -1,19 +1,24 @@
1
1
  language: ruby
2
2
  script: "bundle exec rake appraisal:integration"
3
3
  rvm:
4
- - 1.8.7
5
- - 1.9.2
6
4
  - 1.9.3
7
5
  - 2.0.0
8
- - 2.1.0
9
- - jruby-18mode
6
+ - 2.1.2
10
7
  - jruby-19mode
11
8
  - jruby-head
12
- - rbx
13
- - ree
9
+ - rbx-2
14
10
  - ruby-head
11
+ gemfile:
12
+ - gemfiles/actionpack3.2.gemfile
13
+ - gemfiles/actionpack4.0.gemfile
14
+ - gemfiles/actionpack4.1.gemfile
15
15
  matrix:
16
+ exclude:
17
+ - rvm: 1.9.3
18
+ gemfile: gemfiles/actionpack4.0.gemfile
19
+ - rvm: 1.9.3
20
+ gemfile: gemfiles/actionpack4.1.gemfile
16
21
  allow_failures:
17
22
  - rvm: ruby-head
18
23
  - rvm: jruby-head
19
- - rvm: rbx
24
+ - rvm: rbx-2
data/Appraisals CHANGED
@@ -1,13 +1,13 @@
1
1
  appraise 'actionpack3.0' do
2
- gem 'actionpack', '~> 3.0.0'
2
+ gem 'actionpack', '~> 3.0.20'
3
3
  end
4
4
 
5
5
  appraise 'actionpack3.1' do
6
- gem 'actionpack', '~> 3.1.0'
6
+ gem 'actionpack', '~> 3.1.12'
7
7
  end
8
8
 
9
9
  appraise 'actionpack3.2' do
10
- gem 'actionpack', '~> 3.2.0'
10
+ gem 'actionpack', '~> 3.2.17'
11
11
  end
12
12
 
13
13
  appraise 'actionpack4.0' do
@@ -15,5 +15,5 @@ appraise 'actionpack4.0' do
15
15
  end
16
16
 
17
17
  appraise 'actionpack4.1' do
18
- gem 'actionpack', '~> 4.1.0.beta1'
18
+ gem 'actionpack', '~> 4.1.0'
19
19
  end
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ == 2.0.0 2014-08-10
2
+
3
+ * Removed support for Ruby < 1.9.3
4
+ * ISO-3166 alpha-2 codes are now on by default, stored in uppercase
5
+ (e.g., US)
6
+ * Localization is always on
7
+ * The `country_select` method will always attempt to localize
8
+ country names based on the value of `I18n.locale` via translations
9
+ stored in the `countries` gem
10
+ * Priority countries should now be set via the `priority_countries` option
11
+ * The original 1.x syntax is still available
12
+ * The list of countries can now be limited with the `only` and
13
+ `except` options
14
+ * Add best-guess support for country names when codes aren't provided
15
+ in options (e.g., priority_countries)
16
+
1
17
  == 1.2.0 2013-07-06
2
18
 
3
19
  * Country names have been synced with UTF-8 encoding to the list of
data/Gemfile CHANGED
@@ -3,11 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in country_select.gemspec
4
4
  gemspec
5
5
 
6
- # Duplicating this in Gemfile until thoughtbot pushes latest version
7
- # that supports Bundler `platform` directive for rbx support in travis-ci
8
- # Once appraisal 1.0.0 is released, this line can be removed
9
- gem 'appraisal', :github => 'thoughtbot/appraisal', :ref => '6d599f'
10
-
11
6
  platforms :rbx do
12
7
  gem 'racc'
13
8
  gem 'rubysl', '~> 2.0'
data/README.md CHANGED
@@ -4,16 +4,14 @@
4
4
  Provides a simple helper to get an HTML select list of countries using the
5
5
  [ISO 3166-1 standard](https://en.wikipedia.org/wiki/ISO_3166-1).
6
6
 
7
- It is also configurable to use countries'
8
- [ISO 3166-1 alpha-2 codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)
9
- as values and
10
- [ISO 3166-1 names](https://en.wikipedia.org/wiki/ISO_3166-1)
11
- as display strings.
12
-
13
7
  While the ISO 3166 standard is a relatively neutral source of country
14
8
  names, it may still offend some users. Developers are strongly advised
15
9
  to evaluate the suitability of this list given their user base.
16
10
 
11
+ ## UPGRADING
12
+
13
+ [**An important message about upgrading from 1.x**](UPGRADING.md)
14
+
17
15
  ## Installation
18
16
 
19
17
  Install as a gem using
@@ -24,7 +22,7 @@ gem install country_select
24
22
  Or put the following in your Gemfile
25
23
 
26
24
  ```ruby
27
- gem 'country_select'
25
+ gem 'country_select', github: 'stefanpenner/country_select'
28
26
  ```
29
27
 
30
28
  ## Usage
@@ -38,48 +36,60 @@ country_select("user", "country")
38
36
  Supplying priority countries to be placed at the top of the list:
39
37
 
40
38
  ```ruby
41
- country_select("user", "country", [ "Great Britain", "France", "Germany" ])
39
+ country_select("user", "country", priority_countries: ["GB", "FR", "DE"])
42
40
  ```
43
41
 
44
- ### Using Country Name Localization
45
- Country names are automatically localized based on the value of
46
- `I18n.locale` thanks to the wonderful
47
- [countries gem](https://github.com/hexorx/countries/).
48
-
49
- Current translations include:
50
- en, it, de, fr, es, ja, nl, but may not be complete. In the event a translation is
51
- not available, it will revert to the globally assigned locale (by default, "en").
42
+ Supplying only certain countries:
52
43
 
53
- The locale can be overridden locally:
54
44
  ```ruby
55
- country_select(:country_name, ['US'], {:iso_codes => true, :locale => 'es'})
45
+ country_select("user", "country", only: ["GB", "FR", "DE"])
56
46
  ```
57
47
 
58
- ### Using ISO 3166-1 alpha-2 codes as values
59
- You can have the `option` tags use ISO 3166-1 alpha-2 codes as values
60
- and the country names as display strings. For example, the United States
61
- would appear as `<option value="US">United States</option>`
62
-
63
- If you're starting a new project, this is the recommended way to store
64
- your country data since it will be more resistant to country names
65
- changing.
48
+ Discarding certain countries:
66
49
 
67
50
  ```ruby
68
- country_select("user", "country_code", nil, iso_codes: true)
51
+ country_select("user", "country", except: ["GB", "FR", "DE"])
69
52
  ```
70
53
 
54
+ Supplying additional html options:
55
+
71
56
  ```ruby
72
- country_select("user", "country_code", [ "GB", "FR", "DE" ], iso_codes: true)
57
+ country_select("user", "country", { priority_countries: ["GB", "FR"] }, { selected: "GB", class: 'form-control' })
73
58
  ```
74
59
 
75
- #### Global configuration to always use ISO codes
76
- Add the following configuration to an initializer.
60
+ ### ISO 3166-1 alpha-2 codes
61
+ The `option` tags use ISO 3166-1 alpha-2 codes as values and the country
62
+ names as display strings. For example, the United States would appear as
63
+ `<option value="US">United States of America</option>`
64
+
65
+ Country names are automatically localized based on the value of
66
+ `I18n.locale` thanks to the wonderful
67
+ [countries gem](https://github.com/hexorx/countries/).
68
+
69
+ Current translations include:
70
+
71
+ * en
72
+ * de
73
+ * es
74
+ * fr
75
+ * it
76
+ * ja
77
+ * nl
78
+
79
+ In the event a translation is not available, it will revert to the
80
+ globally assigned locale (by default, "en").
81
+
82
+ This is the only way to use `country_select` as of version `2.0`. It
83
+ is the recommended way to store your country data since it will be
84
+ resistant to country names changing.
85
+
86
+ The locale can be overridden locally:
77
87
 
78
88
  ```ruby
79
- ::CountrySelect.use_iso_codes = true
89
+ country_select("user", "country_code", locale: 'es')
80
90
  ```
81
91
 
82
- #### Getting the Country from ISO codes
92
+ #### Getting the Country Name from the countries gem
83
93
 
84
94
  ```ruby
85
95
  class User < ActiveRecord::Base
@@ -88,27 +98,25 @@ class User < ActiveRecord::Base
88
98
  # This will attempt to translate the country name and use the default
89
99
  # (usually English) name if no translation is available
90
100
  def country_name
91
- country = Country[country_code]
101
+ country = ISO3166::Country[country_code]
92
102
  country.translations[I18n.locale.to_s] || country.name
93
103
  end
94
104
 
95
105
  end
96
106
  ```
107
+
97
108
  ## Example Application
98
109
 
99
- An example Rails application demonstrating the different options is available at [scudco/country_select_test](https://github.com/scudco/country_select_test). The relevant view file lives [here](https://github.com/scudco/country_select_test/blob/master/app/views/welcome/index.html.erb).
110
+ An example Rails application demonstrating the different options is
111
+ available at [scudco/country_select_test](https://github.com/scudco/country_select_test).
112
+ The relevant view files live [here](https://github.com/scudco/country_select_test/tree/master/app/views/welcome).
100
113
 
101
114
  ## Tests
102
115
 
103
116
  ```shell
104
117
  bundle
105
- bundle exec rspec
106
- ```
107
-
108
- ### Running with multiple versions of actionpack
109
-
110
- ```shell
111
118
  bundle exec appraisal
119
+ bundle exec rake appraisal:integration
112
120
  ```
113
121
 
114
122
  Copyright (c) 2008 Michael Koziarski, released under the MIT license
data/Rakefile CHANGED
@@ -7,18 +7,14 @@ require 'appraisal'
7
7
  require 'rspec/core/rake_task'
8
8
  RSpec::Core::RakeTask.new(:spec)
9
9
 
10
- task :default => :spec
10
+ task default: :spec
11
11
 
12
12
  namespace :appraisal do
13
13
  desc "Run the given task for a particular integration's appraisals"
14
14
  task :integration do
15
15
  Appraisal::File.each do |appraisal|
16
- if RUBY_VERSION < '1.9.3' && appraisal.name =~ /actionpack4/
17
- # skip rails 4 for ruby < 1.9.3
18
- else
19
- appraisal.install
20
- Appraisal::Command.from_args(appraisal.gemfile_path).run
21
- end
16
+ appraisal.install
17
+ Appraisal::Command.from_args(appraisal.gemfile_path).run
22
18
  end
23
19
  end
24
20
  end
data/UPGRADING.md ADDED
@@ -0,0 +1,69 @@
1
+ # Upgrading from 1.x
2
+
3
+ `country_select` 2.0 has brought a few small changes, but these changes
4
+ can have a big impact on existing production systems. Please read these
5
+ points carefully and consider whether upgrading to 2.0 is a good idea.
6
+
7
+ Please post any implications we may have missed as a GitHub Issue
8
+ or Pull Request.
9
+
10
+ ## ISO codes are always on
11
+
12
+ If you upgrade to 2.0 and are currently storing countries by the names
13
+ produced by this gem, your setup will break. It is recommended that you
14
+ stick with 1.x until developing a data migration strategy that allows
15
+ you to map your existing country names to country codes.
16
+
17
+ ## i18n country names are always on (when available)
18
+
19
+ Country names will be generated using `I18n.locale` if a translation
20
+ from the countries gem is available.
21
+
22
+ ## Codes are UPCASED
23
+
24
+ The official ISO 3166-1 standard uses UPCASED codes. This is an easy
25
+ data change, but may affect areas of code dependent on lowercase country
26
+ codes.
27
+
28
+ Here's a sample SQL migration that could address a `users` table with
29
+ lowercased country codes stored in the `country_code` column:
30
+
31
+ ```sql
32
+ UPDATE users SET country_code = UPPER(country_code);
33
+ ```
34
+
35
+ ## Priority countries are now in the options hash
36
+
37
+ The priority countries syntax has changed from
38
+
39
+ ```ruby
40
+ country_select(:user, :country_code, ["GB","FR"])
41
+ ```
42
+
43
+ to
44
+
45
+ ```ruby
46
+ country_select(:user, :country_code, priority_countries: ["GB","FR"])
47
+ ```
48
+
49
+ ### A note on 1.x Syntax
50
+
51
+ In order to seamlessly support popular libraries dependent on
52
+ `country_select`, specifically `formatstic` and `simple_form`, 1.x
53
+ priority syntax is still supported, but will probably be removed in the
54
+ next major release (i.e., 3.0). We'll be working with `simple_form` and
55
+ `formtastic` maintainers to transition away from the old 1.x syntax.
56
+
57
+ ## You can choose to only display a chosen set of countries
58
+
59
+ ```ruby
60
+ country_select(:user, :country_code, only: ["LV","SG"])
61
+ ```
62
+
63
+ ```ruby
64
+ country_select(:user, :country_code, except: ["US","GB"])
65
+ ```
66
+
67
+ ## Ruby 1.9+
68
+
69
+ `country_select` will no longer be tested in Ruby `< 1.9`.
@@ -19,16 +19,10 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ['lib']
21
21
 
22
- # specify any dependencies here; for example:
23
22
  s.add_development_dependency 'rspec', '~> 2'
24
- if RUBY_VERSION < '1.9.3'
25
- s.add_development_dependency 'actionpack', '~> 3.2.13'
26
- else
27
- s.add_development_dependency 'actionpack', '~> 3'
28
- end
29
- # Putting this directly in Gemfile until thoughtbot pushes latest version
30
- # that supports Bundler `platform` directive for rbx support in travis-ci
31
- #s.add_development_dependency 'appraisal'
23
+ s.add_development_dependency 'actionpack', '~> 3'
24
+ s.add_development_dependency 'appraisal', '~> 1.0', '>= 1.0.0'
32
25
  s.add_development_dependency 'pry', '~> 0'
33
- s.add_dependency 'countries', '0.9.3'
26
+
27
+ s.add_dependency 'countries', '~> 0.9', '>= 0.9.3'
34
28
  end
@@ -2,8 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", :github=>"thoughtbot/appraisal", :ref=>"6d599f"
6
- gem "actionpack", "~> 3.0.0"
5
+ gem "actionpack", "~> 3.0.20"
7
6
 
8
7
  platforms :rbx do
9
8
  gem "racc"
@@ -11,4 +10,4 @@ platforms :rbx do
11
10
  gem "psych"
12
11
  end
13
12
 
14
- gemspec :path=>".././"
13
+ gemspec :path => "../"
@@ -2,8 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", :github=>"thoughtbot/appraisal", :ref=>"6d599f"
6
- gem "actionpack", "~> 3.1.0"
5
+ gem "actionpack", "~> 3.1.12"
7
6
 
8
7
  platforms :rbx do
9
8
  gem "racc"
@@ -11,4 +10,4 @@ platforms :rbx do
11
10
  gem "psych"
12
11
  end
13
12
 
14
- gemspec :path=>".././"
13
+ gemspec :path => "../"
@@ -2,8 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", :github=>"thoughtbot/appraisal", :ref=>"6d599f"
6
- gem "actionpack", "~> 3.2.0"
5
+ gem "actionpack", "~> 3.2.17"
7
6
 
8
7
  platforms :rbx do
9
8
  gem "racc"
@@ -11,4 +10,4 @@ platforms :rbx do
11
10
  gem "psych"
12
11
  end
13
12
 
14
- gemspec :path=>".././"
13
+ gemspec :path => "../"
@@ -2,7 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", :github=>"thoughtbot/appraisal", :ref=>"6d599f"
6
5
  gem "actionpack", "~> 4.0.0"
7
6
 
8
7
  platforms :rbx do
@@ -11,4 +10,4 @@ platforms :rbx do
11
10
  gem "psych"
12
11
  end
13
12
 
14
- gemspec :path=>".././"
13
+ gemspec :path => "../"
@@ -2,8 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "appraisal", :github=>"thoughtbot/appraisal", :ref=>"6d599f"
6
- gem "actionpack", "~> 4.1.0.beta1"
5
+ gem "actionpack", "~> 4.1.0"
7
6
 
8
7
  platforms :rbx do
9
8
  gem "racc"
@@ -11,4 +10,4 @@ platforms :rbx do
11
10
  gem "psych"
12
11
  end
13
12
 
14
- gemspec :path=>".././"
13
+ gemspec :path => "../"