Class: PowerPointer::PresentationPackage
- Inherits:
-
Object
- Object
- PowerPointer::PresentationPackage
- Defined in:
- lib/powerpointer/presentation_package.rb
Instance Method Summary collapse
- #add(file) ⇒ Object
- #add_content_type(ct) ⇒ Object
- #export_xml(output) ⇒ Object
- #get_presentation ⇒ Object
- #get_relationships ⇒ Object
-
#initialize ⇒ PresentationPackage
constructor
A new instance of PresentationPackage.
- #verbose ⇒ Object
- #verbose=(verbose) ⇒ Object
Constructor Details
#initialize ⇒ PresentationPackage
Returns a new instance of PresentationPackage.
6 7 8 9 10 11 12 13 14 |
# File 'lib/powerpointer/presentation_package.rb', line 6 def initialize @presentation = Presentation.new @contentTypes = ContentTypes.new @relationships = Relationships.new("") @exportFiles = [] @verbose = false end |
Instance Method Details
#add(file) ⇒ Object
96 97 98 |
# File 'lib/powerpointer/presentation_package.rb', line 96 def add file @exportFiles << file end |
#add_content_type(ct) ⇒ Object
76 77 78 |
# File 'lib/powerpointer/presentation_package.rb', line 76 def add_content_type(ct) @contentTypes.add_content_type ct end |
#export_xml(output) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/powerpointer/presentation_package.rb', line 16 def export_xml output rootFolder = "" vputs "" vputs "Preparing..." vputs "" # 1. Prepare presentation (Adds relationships and content types) @presentation.export_xml(rootFolder, self) # 2. Prepare relationships (Adds content types) @relationships.export_xml(rootFolder, self) # 3. Prepare content types @contentTypes.export_xml(rootFolder, self) # Create tmp directory Dir.mktmpdir do |tmp_folder| vputs "Created temporary directory: #{tmp_folder}" # Do the export @exportFiles.each do |file| vputs "Exporting #{file.get_full_path}" # Create the path if it doesn't exist path = "#{tmp_folder}/#{file.get_path}" FileUtils::mkdir_p path # Write the file File.open("#{path}/#{file.get_filename}", "w") do |f| f << file.get_content end end vputs "" vputs "Export complete." vputs "" vputs "Zipping..." vputs "" # Delete zip file if it exists if File::exists? output File::delete output end # Init zip file Zip::File.open(output, Zip::File::CREATE) do |zip| # Add each file to zip @exportFiles.each do |file| zip.add(file.get_full_path, File.join(tmp_folder, file.get_full_path)) end end vputs "Zipping complete." vputs "" # tmp directory is erased end end |
#get_presentation ⇒ Object
92 93 94 |
# File 'lib/powerpointer/presentation_package.rb', line 92 def get_presentation @presentation end |
#get_relationships ⇒ Object
88 89 90 |
# File 'lib/powerpointer/presentation_package.rb', line 88 def get_relationships @relationships end |
#verbose ⇒ Object
84 85 86 |
# File 'lib/powerpointer/presentation_package.rb', line 84 def verbose @verbose end |
#verbose=(verbose) ⇒ Object
80 81 82 |
# File 'lib/powerpointer/presentation_package.rb', line 80 def verbose=(verbose) @verbose = verbose end |