You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pgfqe6ch8/lib/tasks/office.rake

23 lines
733 B

#coding=utf-8
namespace :office do
desc "conver any files to html"
task :conver => :environment do
all_count = Attachment.where(["container_type IN (?)", %w(Project Course)]).count
i = 0
Attachment.where(["container_type IN (?)", %w(Project Course)]).find_each do |a|
i += 1
puts "process [#{i}/#{all_count}] => id #{a.id}"
saved_path = File.join(Rails.root, "files", "convered_office")
unless Dir.exist?(saved_path)
Dir.mkdir(saved_path)
end
convered_file = File.join(saved_path, a.disk_filename + ".pdf")
office = Trustie::Utils::Office.new(a.diskfile)
if office.conver(convered_file)
puts "process ok: #{convered_file} "
end
end
end
end