Module: Powerpoint

Defined in:
lib/powerpoint.rb,
lib/powerpoint/util.rb,
lib/powerpoint/version.rb,
lib/powerpoint/compression.rb,
lib/powerpoint/slide/intro.rb,
lib/powerpoint/presentation.rb,
lib/powerpoint/slide/textual.rb,
lib/powerpoint/slide/pictorial.rb,
lib/powerpoint/slide/text_picture_split.rb,
lib/powerpoint/slide/picture_description.rb

Defined Under Namespace

Modules: Slide, Util Classes: Presentation

Constant Summary collapse

ROOT_PATH =
File.expand_path("../..", __FILE__)
TEMPLATE_PATH =
"#{ROOT_PATH}/template/"
VIEW_PATH =
"#{ROOT_PATH}/lib/powerpoint/views/"
VERSION =
"1.8"

Class Method Summary collapse

Class Method Details

.compress_pptx(in_path, out_path) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/powerpoint/compression.rb', line 12

def self.compress_pptx(in_path, out_path)
  Zip::File.open(out_path, Zip::File::CREATE) do |zip_file|
    Dir.glob("#{in_path}/**/*", ::File::FNM_DOTMATCH).each do |path|
      zip_path = path.gsub("#{in_path}/","")
      next if zip_path == "." || zip_path == ".." || zip_path.match(/DS_Store/)
      begin
        zip_file.add(zip_path, path)
      rescue Zip::ZipEntryExistsError
        raise "#{out_path} already exists!"
      end
    end
  end
end

.decompress_pptx(in_path, out_path) ⇒ Object



2
3
4
5
6
7
8
9
10
# File 'lib/powerpoint/compression.rb', line 2

def self.decompress_pptx(in_path, out_path)
  Zip::File.open(in_path) do |zip_file|
    zip_file.each do |f|
      f_path = File.join(out_path, f.name)
      FileUtils.mkdir_p(File.dirname(f_path))
      zip_file.extract(f, f_path) unless File.exist?(f_path)
    end
  end
end