Merge branch 'develop' of 10.0.47.245:/home/trustie2 into develop

This commit is contained in:
Wen 2014-04-15 14:48:51 +08:00
commit 399d7b559a
2 changed files with 29 additions and 4 deletions

View File

@ -7,7 +7,8 @@ class TestController < ApplicationController
bid.homeworks.each do |homeattach| bid.homeworks.each do |homeattach|
homeattach.attachments.each do |attach| homeattach.attachments.each do |attach|
homeworks_attach_path << attach.disk_filename length = attach.storage_path.length
homeworks_attach_path << attach.diskfile.to_s.slice((length+1)..-1)
end end
end end
@paths = homeworks_attach_path @paths = homeworks_attach_path
@ -24,13 +25,13 @@ class TestController < ApplicationController
def ziping files_path def ziping files_path
folder = "#{Rails.root}/files" folder = "#{Rails.root}/files"
input_filename = files_path input_filename = files_path
zipfile_name = "#{Rails.root}/tmp/archive_#{Time.now.to_i}.zip" zipfile_name = "#{Rails.root}/tmp/archiveZip/archive_#{Time.now.to_i}.zip"
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
input_filename.each do |filename| input_filename.each do |filename|
zipfile.add(filename, folder + '/' + filename) zipfile.add(filename.split('/').last, folder + '/' + filename)
end end
zipfile.get_ouput_stream("ReadMe"){ |os| zipfile.get_output_stream("ReadMe"){ |os|
os.write "Homeworks" os.write "Homeworks"
} }
end end

24
lib/tasks/rubyzip.rake Normal file
View File

@ -0,0 +1,24 @@
desc "nyan ruby zip operation"
task :zip do
puts "will building zip tmp files sweeper."
end
namespace :zip do
desc "ruby zip sweeper"
task :rubyzip_clean do
puts "ruby zip sweeping..."
end
end
desc "create tmp file, to test"
file 'tmp/test.yml' do
require 'yaml'
var = {
:name => "name",
:age => "age",
:agent => "agent"
}
File.open('tmp/test.yml', 'w') do |f|
f.write YAML.dump({'conf' => var })
end
end