Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from phonk64/master

Include Rake tasks when bundled into an application
  • Loading branch information...
commit 90e1d03f964bc782423c6c8317fe1df822a1c545 2 parents fb580a1 + c1abe44
@gentooboontoo gentooboontoo authored
View
3  lib/localized_country_select.rb
@@ -1,3 +1,6 @@
+require 'rake'
+load 'tasks/localized_country_select_tasks.rake'
+
# = LocalizedCountrySelect
#
# View helper for displaying select list with countries:
View
9 lib/tasks/localized_country_select_tasks.rake
@@ -52,7 +52,7 @@ namespace :import do
doc.search("//tr").each do |row|
if row.search("td[@class='n']") &&
row.search("td[@class='n']").inner_html =~ /^namesterritory$/ &&
- row.search("td[@class='g']").inner_html =~ /^[A-Z]{2}/
+ row.search("td[@class='g']").inner_html =~ /^[A-Z]{2}$/
code = row.search("td[@class='g']").inner_text
code = code[-code.size, 2]
name = row.search("td[@class='v']").inner_text
@@ -63,7 +63,8 @@ namespace :import do
# ----- Prepare the output format ------------------------------------------
- output =<<HEAD
+ output = "#encoding: UTF-8\n"
+ output <<<<HEAD
{ :#{locale} => {
:countries => {
@@ -81,10 +82,10 @@ TAIL
# ----- Write the parsed values into file ---------------------------------
puts "\n... writing the output"
- filename = File.join(File.dirname(__FILE__), '..', '..', 'locale', "#{locale}.rb")
+ filename = File.join(Rails.root, 'config', 'locales', "localized_country_select.#{locale}.rb")
filename += '.NEW' if File.exists?(filename) # Append 'NEW' if file exists
File.open(filename, 'w+') { |f| f << output }
- puts "\n---\nWritten values for the '#{locale}' into file: #{filename}\n"
+ puts "\n---\nWritten values for the locale '#{locale}' into file: #{filename}\n"
# ------------------------------------------------------------------------------
end
Please sign in to comment.
Something went wrong with that request. Please try again.