country-select-engine 0.1.2 → 0.2.0

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.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +3 -0
  3. data.tar.gz.sig +0 -0
  4. data/.gitignore +1 -1
  5. data/Gemfile +1 -1
  6. data/Gemfile.lock +66 -71
  7. data/Rakefile +14 -9
  8. data/{script → bin}/convert_cldr.rb +0 -0
  9. data/{script → bin}/google.yml +0 -0
  10. data/{script → bin}/google.zh-TW.yml +0 -0
  11. data/{script → bin}/rails +1 -1
  12. data/{script → bin}/timezones.yml +0 -0
  13. data/{script → bin}/translate_timezones.rb +0 -0
  14. data/country-select-engine.gemspec +2 -3
  15. data/lib/country-select-engine.rb +9 -22
  16. data/lib/country-select-engine/version.rb +1 -1
  17. data/test/dummy/README.rdoc +28 -0
  18. data/{spec → test}/dummy/Rakefile +0 -1
  19. data/{spec → test}/dummy/app/assets/javascripts/application.js +3 -5
  20. data/{spec → test}/dummy/app/assets/stylesheets/application.css +1 -1
  21. data/test/dummy/app/controllers/application_controller.rb +5 -0
  22. data/{spec → test}/dummy/app/controllers/dummy_controller.rb +2 -0
  23. data/{spec → test}/dummy/app/helpers/application_helper.rb +0 -0
  24. data/{spec → test}/dummy/app/mailers/.gitkeep +0 -0
  25. data/{spec → test}/dummy/app/models/.gitkeep +0 -0
  26. data/test/dummy/app/models/user.rb +2 -0
  27. data/{spec → test}/dummy/app/views/dummy/index.html.erb +14 -0
  28. data/{spec → test}/dummy/app/views/layouts/application.html.erb +0 -0
  29. data/test/dummy/bin/bundle +3 -0
  30. data/test/dummy/bin/rails +4 -0
  31. data/test/dummy/bin/rake +4 -0
  32. data/{spec → test}/dummy/config.ru +1 -1
  33. data/test/dummy/config/application.rb +23 -0
  34. data/test/dummy/config/boot.rb +5 -0
  35. data/{spec → test}/dummy/config/database.yml +0 -0
  36. data/{spec → test}/dummy/config/environment.rb +2 -2
  37. data/test/dummy/config/environments/development.rb +29 -0
  38. data/test/dummy/config/environments/production.rb +80 -0
  39. data/{spec → test}/dummy/config/environments/test.rb +13 -14
  40. data/{spec → test}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  41. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  42. data/{spec → test}/dummy/config/initializers/inflections.rb +6 -5
  43. data/{spec → test}/dummy/config/initializers/mime_types.rb +0 -0
  44. data/test/dummy/config/initializers/secret_token.rb +12 -0
  45. data/test/dummy/config/initializers/session_store.rb +3 -0
  46. data/{spec → test}/dummy/config/initializers/wrap_parameters.rb +6 -6
  47. data/test/dummy/config/routes.rb +60 -0
  48. data/test/dummy/db/development.sqlite3 +0 -0
  49. data/test/dummy/db/migrate/20130716075309_create_users.rb +12 -0
  50. data/test/dummy/db/schema.rb +25 -0
  51. data/test/dummy/db/test.sqlite3 +0 -0
  52. data/{spec → test}/dummy/lib/assets/.gitkeep +0 -0
  53. data/{spec → test}/dummy/log/.gitkeep +0 -0
  54. data/test/dummy/public/404.html +58 -0
  55. data/test/dummy/public/422.html +58 -0
  56. data/test/dummy/public/500.html +57 -0
  57. data/{spec → test}/dummy/public/favicon.ico +0 -0
  58. data/test/dummy/test/fixtures/users.yml +13 -0
  59. data/test/dummy/test/models/user_test.rb +7 -0
  60. data/{spec → test}/localized_country_select_test.rb +0 -0
  61. data/{spec → test}/spec_helper.rb +0 -0
  62. metadata +139 -132
  63. metadata.gz.sig +0 -0
  64. data/spec/dummy/README.rdoc +0 -261
  65. data/spec/dummy/app/assets/javascripts/dummy.js +0 -2
  66. data/spec/dummy/app/assets/stylesheets/dummy.css +0 -4
  67. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  68. data/spec/dummy/app/helpers/dummy_helper.rb +0 -2
  69. data/spec/dummy/config/application.rb +0 -62
  70. data/spec/dummy/config/boot.rb +0 -10
  71. data/spec/dummy/config/environments/development.rb +0 -37
  72. data/spec/dummy/config/environments/production.rb +0 -67
  73. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  74. data/spec/dummy/config/initializers/session_store.rb +0 -8
  75. data/spec/dummy/config/routes.rb +0 -60
  76. data/spec/dummy/db/development.sqlite3 +0 -0
  77. data/spec/dummy/public/404.html +0 -26
  78. data/spec/dummy/public/422.html +0 -26
  79. data/spec/dummy/public/500.html +0 -25
  80. data/spec/dummy/script/rails +0 -6
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5d9eefe4d98c7206992dc7d72e72d5d68d05b6cb
4
+ data.tar.gz: d5c3e5fb95d3f285d35b68d23c6745a4df322344
5
+ SHA512:
6
+ metadata.gz: 069e38875ec1335daeec5b769e765bdd57d825272566b6a1d9dd69c8a199ded2f8ba27b3304fdfdbacf03855e2cbde4cd4186e298c7fdb02322b9658be79357e
7
+ data.tar.gz: 32ef6e8cfe422a0f3a625de8943d43b4e99a5d3b9645f8dfa7beac3d225c42833281925136647afc4b4e9e60971d2ac496f31a316c6f12a512aa633f7a807b70
@@ -0,0 +1,3 @@
1
+ �-��Y��uVQ�V-���"o|�;q
2
+ ���V�_��+Ʃ�d�VJ�ܥv��WH%����lۮ�rT�f�{!m7���X�=&��G�)pnȧh����;�r�/� +W{o?��u%�ں���]�jԒs�$�ru�~=�@.T�����%ePp]���N��w8�Xa���
3
+ �vD�ZӲ<�@�{��5��0��ݔ3��)-��2�sB$ĭ� �:������d����y������]�p&,���'�\��
data.tar.gz.sig CHANGED
Binary file
data/.gitignore CHANGED
@@ -13,7 +13,7 @@
13
13
  # Ignore all logfiles and tempfiles.
14
14
  /log/*.log
15
15
  /tmp
16
- /spec/dummy/tmp
16
+ /test/dummy/tmp
17
17
  /public/assets/
18
18
  /config/secret_settings.yml
19
19
 
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Declare your gem's dependencies in country-select-engine.gemspec.
4
4
  # Bundler will treat runtime dependencies like base dependencies, and
@@ -1,92 +1,87 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- country-select-engine (0.1.1)
5
- rails (~> 3.2.3)
4
+ country-select-engine (0.1.3)
5
+ rails (>= 4.0.0)
6
6
 
7
7
  GEM
8
- remote: http://rubygems.org/
8
+ remote: https://rubygems.org/
9
9
  specs:
10
- actionmailer (3.2.5)
11
- actionpack (= 3.2.5)
12
- mail (~> 2.4.4)
13
- actionpack (3.2.5)
14
- activemodel (= 3.2.5)
15
- activesupport (= 3.2.5)
16
- builder (~> 3.0.0)
10
+ actionmailer (4.0.0)
11
+ actionpack (= 4.0.0)
12
+ mail (~> 2.5.3)
13
+ actionpack (4.0.0)
14
+ activesupport (= 4.0.0)
15
+ builder (~> 3.1.0)
17
16
  erubis (~> 2.7.0)
18
- journey (~> 1.0.1)
19
- rack (~> 1.4.0)
20
- rack-cache (~> 1.2)
21
- rack-test (~> 0.6.1)
22
- sprockets (~> 2.1.3)
23
- activemodel (3.2.5)
24
- activesupport (= 3.2.5)
25
- builder (~> 3.0.0)
26
- activerecord (3.2.5)
27
- activemodel (= 3.2.5)
28
- activesupport (= 3.2.5)
29
- arel (~> 3.0.2)
30
- tzinfo (~> 0.3.29)
31
- activeresource (3.2.5)
32
- activemodel (= 3.2.5)
33
- activesupport (= 3.2.5)
34
- activesupport (3.2.5)
35
- i18n (~> 0.6)
36
- multi_json (~> 1.0)
37
- arel (3.0.2)
38
- builder (3.0.0)
17
+ rack (~> 1.5.2)
18
+ rack-test (~> 0.6.2)
19
+ activemodel (4.0.0)
20
+ activesupport (= 4.0.0)
21
+ builder (~> 3.1.0)
22
+ activerecord (4.0.0)
23
+ activemodel (= 4.0.0)
24
+ activerecord-deprecated_finders (~> 1.0.2)
25
+ activesupport (= 4.0.0)
26
+ arel (~> 4.0.0)
27
+ activerecord-deprecated_finders (1.0.3)
28
+ activesupport (4.0.0)
29
+ i18n (~> 0.6, >= 0.6.4)
30
+ minitest (~> 4.2)
31
+ multi_json (~> 1.3)
32
+ thread_safe (~> 0.1)
33
+ tzinfo (~> 0.3.37)
34
+ arel (4.0.0)
35
+ atomic (1.1.10)
36
+ builder (3.1.4)
39
37
  erubis (2.7.0)
40
- hike (1.2.1)
41
- i18n (0.6.0)
42
- journey (1.0.3)
43
- jquery-rails (2.0.2)
44
- railties (>= 3.2.0, < 5.0)
45
- thor (~> 0.14)
46
- json (1.7.3)
47
- mail (2.4.4)
48
- i18n (>= 0.4.0)
38
+ hike (1.2.3)
39
+ i18n (0.6.4)
40
+ jquery-rails (3.0.4)
41
+ railties (>= 3.0, < 5.0)
42
+ thor (>= 0.14, < 2.0)
43
+ mail (2.5.4)
49
44
  mime-types (~> 1.16)
50
45
  treetop (~> 1.4.8)
51
- mime-types (1.19)
52
- multi_json (1.3.6)
46
+ mime-types (1.23)
47
+ minitest (4.7.5)
48
+ multi_json (1.7.7)
53
49
  polyglot (0.3.3)
54
- rack (1.4.1)
55
- rack-cache (1.2)
56
- rack (>= 0.4)
57
- rack-ssl (1.3.2)
58
- rack
59
- rack-test (0.6.1)
50
+ rack (1.5.2)
51
+ rack-test (0.6.2)
60
52
  rack (>= 1.0)
61
- rails (3.2.5)
62
- actionmailer (= 3.2.5)
63
- actionpack (= 3.2.5)
64
- activerecord (= 3.2.5)
65
- activeresource (= 3.2.5)
66
- activesupport (= 3.2.5)
67
- bundler (~> 1.0)
68
- railties (= 3.2.5)
69
- railties (3.2.5)
70
- actionpack (= 3.2.5)
71
- activesupport (= 3.2.5)
72
- rack-ssl (~> 1.3.2)
53
+ rails (4.0.0)
54
+ actionmailer (= 4.0.0)
55
+ actionpack (= 4.0.0)
56
+ activerecord (= 4.0.0)
57
+ activesupport (= 4.0.0)
58
+ bundler (>= 1.3.0, < 2.0)
59
+ railties (= 4.0.0)
60
+ sprockets-rails (~> 2.0.0)
61
+ railties (4.0.0)
62
+ actionpack (= 4.0.0)
63
+ activesupport (= 4.0.0)
73
64
  rake (>= 0.8.7)
74
- rdoc (~> 3.4)
75
- thor (>= 0.14.6, < 2.0)
76
- rake (10.0.3)
77
- rdoc (3.12)
78
- json (~> 1.4)
79
- sprockets (2.1.3)
65
+ thor (>= 0.18.1, < 2.0)
66
+ rake (10.1.0)
67
+ sprockets (2.10.0)
80
68
  hike (~> 1.2)
69
+ multi_json (~> 1.0)
81
70
  rack (~> 1.0)
82
71
  tilt (~> 1.1, != 1.3.0)
83
- sqlite3 (1.3.6)
84
- thor (0.15.2)
85
- tilt (1.3.3)
86
- treetop (1.4.12)
72
+ sprockets-rails (2.0.0)
73
+ actionpack (>= 3.0)
74
+ activesupport (>= 3.0)
75
+ sprockets (~> 2.8)
76
+ sqlite3 (1.3.7)
77
+ thor (0.18.1)
78
+ thread_safe (0.1.0)
79
+ atomic
80
+ tilt (1.4.1)
81
+ treetop (1.4.14)
87
82
  polyglot
88
83
  polyglot (>= 0.3.1)
89
- tzinfo (0.3.35)
84
+ tzinfo (0.3.37)
90
85
 
91
86
  PLATFORMS
92
87
  ruby
data/Rakefile CHANGED
@@ -1,16 +1,10 @@
1
- #!/usr/bin/env rake
2
1
  begin
3
2
  require 'bundler/setup'
4
3
  rescue LoadError
5
4
  puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
5
  end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
6
+
7
+ require 'rdoc/task'
14
8
 
15
9
  RDoc::Task.new(:rdoc) do |rdoc|
16
10
  rdoc.rdoc_dir = 'rdoc'
@@ -20,10 +14,21 @@ RDoc::Task.new(:rdoc) do |rdoc|
20
14
  rdoc.rdoc_files.include('lib/**/*.rb')
21
15
  end
22
16
 
23
- APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
24
18
  load 'rails/tasks/engine.rake'
25
19
 
26
20
 
27
21
 
28
22
  Bundler::GemHelper.install_tasks
29
23
 
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
3
 
4
4
  ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
5
  ENGINE_PATH = File.expand_path('../../lib/country-select-engine/engine', __FILE__)
File without changes
File without changes
@@ -12,6 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.homepage = "https://github.com/yjchen/country-select-engine"
13
13
  s.summary = "Rails engine for localized_country_select."
14
14
  s.description = "Provide a list of localized countries, currencies and time zones"
15
+ s.license = 'MIT'
15
16
 
16
17
  s.files = `git ls-files`.split("\n")
17
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
@@ -20,9 +21,7 @@ Gem::Specification.new do |s|
20
21
  s.signing_key = File.join(Dir.home,'/.gem/trust/gem-private_key.pem')
21
22
  s.cert_chain = ['gem-public_cert.pem']
22
23
 
23
- s.add_dependency "rails", "~> 3.2.3"
24
- # s.add_dependency "hpricot"
25
- # s.add_dependency "jquery-rails"
24
+ s.add_dependency "rails", ">= 4.0.0"
26
25
 
27
26
  s.add_development_dependency "sqlite3"
28
27
  end
@@ -105,8 +105,14 @@ module ActionView
105
105
  categories.each do |category|
106
106
  class_eval %Q{
107
107
  def localized_#{category.singularize}_select(object, method, priority_countries = nil, options = {}, html_options = {})
108
- InstanceTag.new(object, method, self, options.delete(:object)).
109
- to_localized_#{category.singularize}_select_tag(priority_countries, options, html_options)
108
+ choices = CountrySelectEngine.localized_#{category}_array
109
+ if priority_countries
110
+ priority = CountrySelectEngine::priority_#{category}_array(priority_countries)
111
+ priority << ['--------', nil]
112
+ choices = priority + choices
113
+ end
114
+
115
+ Tags::Select.new(object, method, self, choices, options, html_options).render
110
116
  end
111
117
  }
112
118
  end
@@ -146,31 +152,12 @@ module ActionView
146
152
 
147
153
  end
148
154
 
149
- class InstanceTag
150
- categories = ['currencies', 'countries', 'languages', 'timezones']
151
- categories.each do |category|
152
- class_eval %Q{
153
- def to_localized_#{category.singularize}_select_tag(priority_countries, options, html_options)
154
- html_options = html_options.stringify_keys
155
- add_default_name_and_id(html_options)
156
- value = options.has_key?(:selected) ? options[:selected] : value(object)
157
- content_tag("select",
158
- add_options(
159
- localized_#{category.singularize}_options_for_select(value, priority_countries, options).html_safe,
160
- options, value
161
- ), html_options
162
- )
163
- end
164
- }
165
- end
166
- end
167
-
168
155
  class FormBuilder
169
156
  categories = ['currencies', 'countries', 'languages', 'timezones']
170
157
  categories.each do |category|
171
158
  class_eval %Q{
172
159
  def localized_#{category.singularize}_select(method, priority_countries = nil, options = {}, html_options = {})
173
- @template.localized_#{category.singularize}_select(@object_name, method, priority_countries, options.merge(:object => @object), html_options)
160
+ @template.localized_#{category.singularize}_select(@object_name, method, priority_countries, objectify_options(options), @default_options.merge(html_options))
174
161
  end
175
162
  }
176
163
  end
@@ -1,3 +1,3 @@
1
1
  module CountrySelectEngine
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -1,4 +1,3 @@
1
- #!/usr/bin/env rake
2
1
  # Add your own tasks in files placed in lib/tasks ending in .rake,
3
2
  # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
3
 
@@ -5,11 +5,9 @@
5
5
  // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
6
  //
7
7
  // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // the compiled file.
8
+ // compiled file.
9
9
  //
10
- // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
- // GO AFTER THE REQUIRES BELOW.
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
12
  //
13
- //= require jquery
14
- //= require jquery_ujs
15
13
  //= require_tree .
@@ -10,4 +10,4 @@
10
10
  *
11
11
  *= require_self
12
12
  *= require_tree .
13
- */
13
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -1,4 +1,6 @@
1
1
  class DummyController < ApplicationController
2
2
  def index
3
+ @selected = User.new
4
+ @selected.country = 'US'
3
5
  end
4
6
  end
File without changes
@@ -0,0 +1,2 @@
1
+ class User < ActiveRecord::Base
2
+ end
@@ -1,3 +1,4 @@
1
+ <div>
1
2
  <p><b>In English</b></p>
2
3
  <p>
3
4
  Translation of US is <%= t('US', :scope => 'countries') %>
@@ -8,6 +9,8 @@ Translation of US is <%= t('US', :scope => 'countries') %>
8
9
  <%= localized_currency_select(:user, :country, [], :include_blank => 'Please choose...') %>
9
10
  <%= localized_timezone_select(:user, :country, [], :include_blank => 'Please choose...') %>
10
11
  </p>
12
+ </div>
13
+ <div>
11
14
  <p><b>In Deutsch (Germany)</b></p>
12
15
  <% I18n.locale = :de %>
13
16
  <p>
@@ -18,6 +21,8 @@ Translation of US is <%= t('US', :scope => 'countries') %>
18
21
  <%= localized_language_select(:user, :country, [], :include_blank => 'Please choose...') %>
19
22
  <%= localized_currency_select(:user, :country, [], :include_blank => 'Please choose...') %>
20
23
  </p>
24
+ </div>
25
+ <div>
21
26
  <p><b>In Traditional Chinese</b></p>
22
27
  <% I18n.locale = :'zh-TW' %>
23
28
  <p>
@@ -29,3 +34,12 @@ Translation of US is <%= t('US', :scope => 'countries') %>
29
34
  <%= localized_currency_select(:user, :country, [], {:include_blank => 'Please choose...', :symbol => :prepend}) %>
30
35
  <%= localized_timezone_select(:user, :country, [], {:include_blank => 'Please choose...', :sort => false, :timezone => :prepend}) %>
31
36
  </p>
37
+ </div>
38
+ <div>
39
+ <% I18n.locale = :en %>
40
+ <%= form_for @selected do |f| %>
41
+ <%= f.localized_country_select(:country, [:TW, :CN]) %>
42
+ <hr/>
43
+ <%= f.select(:country, localized_country_options_for_select(@selected.country).html_safe) %>
44
+ <% end %>
45
+ </div>