Sha256: 0c21406630aa45bc46e22a7f32be4771d7f73e0cf7ecb97d122bc9161ace12ea

Contents?: true

Size: 593 Bytes

Versions: 4

Compression:

Stored size: 593 Bytes

Contents

require "tnef/version"
require "tnef/executable"

require "tmpdir"
require "fileutils"

module Tnef

  def self.unpack(winmail_io, &block)
    in_tmp_dir do |dir|
      IO.popen("#{Tnef::Executable.path} --number-backups --save-body --body-pref th -K", "wb") do |tnef|
        tnef.write(winmail_io.read)
        tnef.close
      end

      Dir.glob("#{dir}/*").select { |node| File.file?(node) }.sort.each do |file|
        yield(file)
      end
    end
  end

  def self.in_tmp_dir(&block)
    Dir.mktmpdir do |dir|
      FileUtils.cd(dir) do
        yield(dir)
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tnef-1.0.2 lib/tnef.rb
tnef-1.0.1 lib/tnef.rb
tnef-1.0.0 lib/tnef.rb
tnef-0.0.1 lib/tnef.rb