Module: CarrierWave::UNOConv

Extended by:
ActiveSupport::Concern
Defined in:
lib/carrierwave-unoconv/unoconv.rb,
lib/carrierwave-unoconv/version.rb

Defined Under Namespace

Modules: ClassMethods

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#uno_convert(format) ⇒ Object

Raises:

  • (CarrierWave::ProcessingError)


10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/carrierwave-unoconv/unoconv.rb', line 10

def uno_convert format
  directory = File.dirname( current_path )
  tmpfile   = File.join( directory, "tmpfile" )
  
  File.rename( current_path, tmpfile )
    
  raise CarrierWave::ProcessingError, "UNOconv failed." unless system "unoconv -f #{format} '#{tmpfile}'"
  
  File.rename( File.join(directory, "tmpfile.#{format}"), current_path )
  
  File.delete( tmpfile )
end