@@ -18,7 +18,7 | |||||
18 | desc 'Mantis migration script' |
|
18 | desc 'Mantis migration script' | |
19 |
|
19 | |||
20 | require 'active_record' |
|
20 | require 'active_record' | |
21 | require 'iconv' |
|
21 | require 'iconv' if RUBY_VERSION < '1.9' | |
22 | require 'pp' |
|
22 | require 'pp' | |
23 |
|
23 | |||
24 | namespace :redmine do |
|
24 | namespace :redmine do | |
@@ -440,9 +440,7 task :migrate_from_mantis => :environment do | |||||
440 | end |
|
440 | end | |
441 |
|
441 | |||
442 | def self.encoding(charset) |
|
442 | def self.encoding(charset) | |
443 | @ic = Iconv.new('UTF-8', charset) |
|
443 | @charset = charset | |
444 | rescue Iconv::InvalidEncoding |
|
|||
445 | return false |
|
|||
446 | end |
|
444 | end | |
447 |
|
445 | |||
448 | def self.establish_connection(params) |
|
446 | def self.establish_connection(params) | |
@@ -454,9 +452,12 task :migrate_from_mantis => :environment do | |||||
454 | end |
|
452 | end | |
455 |
|
453 | |||
456 | def self.encode(text) |
|
454 | def self.encode(text) | |
|
455 | if RUBY_VERSION < '1.9' | |||
|
456 | @ic ||= Iconv.new('UTF-8', @charset) | |||
457 | @ic.iconv text |
|
457 | @ic.iconv text | |
458 |
|
|
458 | else | |
459 | text |
|
459 | text.to_s.force_encoding(@charset).encode('UTF-8') | |
|
460 | end | |||
460 | end |
|
461 | end | |
461 | end |
|
462 | end | |
462 |
|
463 |
@@ -16,7 +16,7 | |||||
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require 'active_record' |
|
18 | require 'active_record' | |
19 | require 'iconv' |
|
19 | require 'iconv' if RUBY_VERSION < '1.9' | |
20 | require 'pp' |
|
20 | require 'pp' | |
21 |
|
21 | |||
22 | namespace :redmine do |
|
22 | namespace :redmine do | |
@@ -603,10 +603,7 namespace :redmine do | |||||
603 | end |
|
603 | end | |
604 |
|
604 | |||
605 | def self.encoding(charset) |
|
605 | def self.encoding(charset) | |
606 | @ic = Iconv.new('UTF-8', charset) |
|
606 | @charset = charset | |
607 | rescue Iconv::InvalidEncoding |
|
|||
608 | puts "Invalid encoding!" |
|
|||
609 | return false |
|
|||
610 | end |
|
607 | end | |
611 |
|
608 | |||
612 | def self.set_trac_directory(path) |
|
609 | def self.set_trac_directory(path) | |
@@ -713,11 +710,13 namespace :redmine do | |||||
713 | end |
|
710 | end | |
714 | end |
|
711 | end | |
715 |
|
712 | |||
716 | private |
|
|||
717 | def self.encode(text) |
|
713 | def self.encode(text) | |
|
714 | if RUBY_VERSION < '1.9' | |||
|
715 | @ic ||= Iconv.new('UTF-8', @charset) | |||
718 | @ic.iconv text |
|
716 | @ic.iconv text | |
719 |
|
|
717 | else | |
720 | text |
|
718 | text.to_s.force_encoding(@charset).encode('UTF-8') | |
|
719 | end | |||
721 | end |
|
720 | end | |
722 | end |
|
721 | end | |
723 |
|
722 |
General Comments 0
You need to be logged in to leave comments.
Login now