diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb index bd591896d..79b2b5641 100644 --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -7,7 +7,8 @@ class TestController < ApplicationController bid.homeworks.each do |homeattach| 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 @paths = homeworks_attach_path @@ -28,9 +29,9 @@ class TestController < ApplicationController Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| input_filename.each do |filename| - zipfile.add(filename, folder + '/' + filename) + zipfile.add(filename.split('/').last, folder + '/' + filename) end - zipfile.get_ouput_stream("ReadMe"){ |os| + zipfile.get_output_stream("ReadMe"){ |os| os.write "Homeworks" } end diff --git a/lib/tasks/rubyzip.rake b/lib/tasks/rubyzip.rake new file mode 100644 index 000000000..b57d5ed55 --- /dev/null +++ b/lib/tasks/rubyzip.rake @@ -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 \ No newline at end of file