Method: Documentalist::OpenOffice.convert
- Defined in:
- lib/backends/open_office.rb
.convert(origin, options) ⇒ Object
Converts documents
15 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 |
# File 'lib/backends/open_office.rb', line 15 def self.convert(origin, ) Documentalist.logger.debug("Going to convert #{origin} to #{[:to]}") # See how to make OpenOffice startup as smooth as possible and not on first conversion # OO auto-start option if in Rails app ? Server.ensure_available # TODO : manage multi OO instances : http://code.google.com/p/jodconverter/wiki/GettingStarted Documentalist.timeout(Documentalist.config[:open_office][:max_conversion_time], :attempts => Documentalist.config[:open_office][:max_conversion_attempts]) do if Documentalist.config[:open_office][:bridge] == 'JOD' command = "#{Documentalist.config[:java][:path]} -jar #{File.join(File.dirname(__FILE__), %w{open_office bridges jodconverter-2.2.2 lib jodconverter-cli-2.2.2.jar})} #{origin} #{[:to]}" elsif Documentalist.config[:open_office][:bridge] == 'PYOD' command = "#{Documentalist.config[:python][:path]} #{File.join(File.dirname(__FILE__), %w{open_office bridges pyodconverter.py})} #{origin} #{[:to]}" end if Documentalist.config[:log_file] and !Documentalist.config[:log_file].empty? command += " >> #{Documentalist.config[:log_file]} 2>&1" end Documentalist.logger.debug("Going to run #{Documentalist.config[:open_office][:bridge]} bridge with command -- #{command}") system(command) self.convert_txt_to_utf8([:to]) if [:to_format] == :txt [:to] end end |