Skip to content

Commit

Permalink
Merge pull request #204 from countries/remove_sort_alphabetical
Browse files Browse the repository at this point in the history
Remove sort_alphabetical dependency
  • Loading branch information
pmor authored Jun 30, 2022
2 parents 7e73c4c + 6a56dc6 commit 5f92857
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 63 deletions.
6 changes: 1 addition & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ PATH
remote: .
specs:
country_select (7.0.0)
countries (~> 5.1)
sort_alphabetical (~> 1.1)
countries (~> 5.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -70,11 +69,8 @@ GEM
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
sixarm_ruby_unaccent (1.2.0)
sort_alphabetical (1.1.0)
unicode_utils (>= 1.2.2)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode_utils (1.4.0)

PLATFORMS
x86_64-darwin-21
Expand Down
3 changes: 1 addition & 2 deletions country_select.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rake', '~> 13'
s.add_development_dependency 'rspec', '~> 3'

s.add_dependency 'countries', '~> 5.1'
s.add_dependency 'sort_alphabetical', '~> 1.1'
s.add_dependency 'countries', '~> 5.0'
end
8 changes: 2 additions & 6 deletions gemfiles/actionpack-5.2.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ PATH
remote: ..
specs:
country_select (7.0.0)
countries (~> 5.1)
sort_alphabetical (~> 1.1)
countries (~> 5.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -50,7 +49,7 @@ GEM
method_source (~> 1.0)
racc (1.6.0)
rack (2.2.3.1)
rack-test (2.0.0)
rack-test (2.0.2)
rack (>= 1.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
Expand Down Expand Up @@ -78,13 +77,10 @@ GEM
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
sixarm_ruby_unaccent (1.2.0)
sort_alphabetical (1.1.0)
unicode_utils (>= 1.2.2)
thor (1.2.1)
thread_safe (0.3.6)
tzinfo (1.2.9)
thread_safe (~> 0.1)
unicode_utils (1.4.0)

PLATFORMS
x86_64-darwin-21
Expand Down
8 changes: 2 additions & 6 deletions gemfiles/actionpack-6.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ PATH
remote: ..
specs:
country_select (7.0.0)
countries (~> 5.1)
sort_alphabetical (~> 1.1)
countries (~> 5.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -51,7 +50,7 @@ GEM
method_source (~> 1.0)
racc (1.6.0)
rack (2.2.3.1)
rack-test (2.0.0)
rack-test (2.0.2)
rack (>= 1.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
Expand Down Expand Up @@ -79,13 +78,10 @@ GEM
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
sixarm_ruby_unaccent (1.2.0)
sort_alphabetical (1.1.0)
unicode_utils (>= 1.2.2)
thor (1.2.1)
thread_safe (0.3.6)
tzinfo (1.2.9)
thread_safe (~> 0.1)
unicode_utils (1.4.0)
zeitwerk (2.6.0)

PLATFORMS
Expand Down
8 changes: 2 additions & 6 deletions gemfiles/actionpack-6.1.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ PATH
remote: ..
specs:
country_select (7.0.0)
countries (~> 5.1)
sort_alphabetical (~> 1.1)
countries (~> 5.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -51,7 +50,7 @@ GEM
method_source (~> 1.0)
racc (1.6.0)
rack (2.2.3.1)
rack-test (2.0.0)
rack-test (2.0.2)
rack (>= 1.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
Expand Down Expand Up @@ -79,12 +78,9 @@ GEM
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
sixarm_ruby_unaccent (1.2.0)
sort_alphabetical (1.1.0)
unicode_utils (>= 1.2.2)
thor (1.2.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode_utils (1.4.0)
zeitwerk (2.6.0)

PLATFORMS
Expand Down
8 changes: 2 additions & 6 deletions gemfiles/actionpack-7.0.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ PATH
remote: ..
specs:
country_select (7.0.0)
countries (~> 5.1)
sort_alphabetical (~> 1.1)
countries (~> 5.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -50,7 +49,7 @@ GEM
method_source (~> 1.0)
racc (1.6.0)
rack (2.2.3.1)
rack-test (2.0.0)
rack-test (2.0.2)
rack (>= 1.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
Expand Down Expand Up @@ -79,12 +78,9 @@ GEM
rspec-support (~> 3.11.0)
rspec-support (3.11.0)
sixarm_ruby_unaccent (1.2.0)
sort_alphabetical (1.1.0)
unicode_utils (>= 1.2.2)
thor (1.2.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
unicode_utils (1.4.0)
zeitwerk (2.6.0)

PLATFORMS
Expand Down
1 change: 0 additions & 1 deletion lib/country_select.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# encoding: utf-8

require 'countries'
require 'sort_alphabetical'

require 'country_select/version'
require 'country_select/defaults'
Expand Down
6 changes: 1 addition & 5 deletions lib/country_select/tag_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ def country_options_for(country_codes, sorted=true)
end

if sorted
if country_list.respond_to?(:sort_alphabetical)
country_list.sort_alphabetical
else
country_list.sort
end
country_list.sort_by { |name, code| [I18n.transliterate(name), name] }
else
country_list
end
Expand Down
9 changes: 0 additions & 9 deletions lib/country_select_without_sort_alphabetical.rb

This file was deleted.

17 changes: 0 additions & 17 deletions spec/country_select_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,23 +281,6 @@ class Walrus
expect(order).to eq(['AF', 'AX', 'AL', 'ZW'])
end

context "without sort_alphabetical" do
before do
Enumerable.send(:alias_method, :_sort_alphabetical, :sort_alphabetical)
Enumerable.send(:remove_method, :sort_alphabetical)
end

after do
Enumerable.send(:alias_method, :sort_alphabetical, :_sort_alphabetical)
end

it 'falls back to regular sort' do
tag = builder.country_select(:country_code, only: ['AX', 'AL', 'AF', 'ZW'])
order = tag.scan(/value="(\w{2})"/).map { |o| o[0] }
expect(order).to eq(['AF', 'AL', 'ZW', 'AX'])
end
end

describe "custom formats" do
it "accepts a custom formatter" do
::CountrySelect::FORMATS[:with_alpha2] = lambda do |country|
Expand Down

0 comments on commit 5f92857

Please sign in to comment.