Class: QuestionCompiler::Zipper
- Inherits:
-
Object
- Object
- QuestionCompiler::Zipper
- Defined in:
- lib/question_compiler/zipper.rb
Instance Method Summary collapse
-
#zip_all(dir) ⇒ Object
Zips each question and each context, placing the results into the ‘zip` subfolder.
Instance Method Details
#zip_all(dir) ⇒ Object
Zips each question and each context, placing the results into the ‘zip` subfolder. Creates `zip` if it doesn’t exist.
Pass the path to the root folder. I.e. the folder that contains the subfolders ‘questions` and `contexts`.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/question_compiler/zipper.rb', line 10 def zip_all(dir) FileUtils.mkdir_p File.join(dir, 'zip') # Zip each question. Dir.glob(File.join(dir, 'questions/*/*')).each do |question_path| if File.directory? question_path question_name = File.basename(question_path).sub('/', '-') zip_folder( question_path, File.join(dir, 'zip', question_name + '.qst.zip') ) end end # Zip each context. Dir.glob(File.join(dir, 'contexts/*/*')).each do |context_path| if File.directory? context_path context_name = File.basename(context_path).sub('/', '-') zip_folder( context_path, File.join(dir, 'zip', context_name + '.ctx.zip') ) end end end |