Sha256: d6d116590de1c2274f0c59c8e1f810bcf9eb5d8d86e74f7900d33ed2e3d6e9fc
Contents?: true
Size: 1.47 KB
Versions: 2
Compression:
Stored size: 1.47 KB
Contents
module ImportFile def self.included(base) base.extend ClassMethods end module ClassMethods def enju_import_file_model include InstanceMethods end def expire self.stucked.find_each do |file| file.destroy end end end module InstanceMethods def import_start case edit_mode when 'create' import when 'update' modify when 'destroy' remove else import end end def convert_encoding(line) if defined?(CharlockHolmes::EncodingDetector) begin case user_encoding when 'auto_detect' encoding = CharlockHolmes::EncodingDetector.detect(line)[:encoding] when nil encoding = CharlockHolmes::EncodingDetector.detect(line)[:encoding] else encoding = user_encoding end string = line.encode('UTF-8', user_encoding, universal_newline: true) rescue StandardError string = nkf_encode(line) end else string = nkf_encode(line) end end private def nkf_encode(line) case user_encoding when 'auto_detect' output_encoding = '-w' when 'UTF-8' output_encoding = '' when 'Shift_JIS' output_encoding = '-Sw' when 'EUC-JP' output_encoding = '-Ew' else output_encoding = '-w' end string = NKF.nkf("#{output_encoding} -Lu", line) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
enju_leaf-1.1.0.rc12 | lib/enju_leaf/import_file.rb |
enju_leaf-1.1.0.rc11 | lib/enju_leaf/import_file.rb |