README.md in proselytism-0.0.1 vs README.md in proselytism-0.0.2

- old
+ new

@@ -1,47 +1,65 @@ # Proselytism -Document converter, text and image extractor using OpenOffice headless server, pdf_tools and net_pbm +Document converter, text and image extractor using OpenOffice headless server (JOD or PYOD converter), pdf_tools and net_pbm +Handled formats for document conversion : odt, doc, rtf, sxw, docx, txt, html, htm, wps, pdf + ## Note -This gem has been originally written for as a RoR 3.2 engine running on Ruby 1.8.7. -It should be framework agnostic and has been tested on Ubuntu and MacOSX. +This gem has been originally written as a RoR 3.2 engine running on Ruby 1.8.7. -Due to its dependency to system_timer it doesn't work with ruby 1.9.x +It is framework agnostic and has been tested on Ubuntu and MacOSX. ## Installation Install the required external librairies : # aptitude install netpbm # aptitude install xpdf # aptitude install libreoffice - + Add this line to your application's Gemfile: - gem 'proselytism', :git => "git://github.com/itkin/proselytism.git" + gem 'proselytism' +Note : for ruby 1.9 use the branch 1.9 + + gem 'proselytism', :git => "git://github.com/itkin/proselytism.git", :branch => "1.9" + And then execute: $ bundle -Generate the config file or / and an initializer +Configure the gem: - $ rails g proselytism:config - $ rails g proselytism:initializer + - With a YAML config file: -As an engine, Proselytism automatically load and autoconfig with /config/proselytism.yml if it exists -You can override these configurations params with an initializer. This is especially usefull when you want a custom log file - ```ruby -#/config/initializers/proselytism.rb -Proselytism.config do |config| - config.logger = ActiveSupport::BufferedLogger.new(File.join(Rails.root, 'log', 'proselytism.log')) -end + $ rails g proselytism:config ``` + As an engine, Proselytism automatically load /config/proselytism.yml (if the file exists) and set its config params depending on the current rails env. + + - With an initializer (optional for Rails App) : + + You can override the configuration file params by adding a custom initializer to /config/initializers . + By default Proselytism will log in a separate log file, if you want to use the rails logger + +```ruby + #/config/initializers/proselytism.rb + Proselytism.config do |config| + config.logger = Rails.logger + end +``` + + To generate a full config initializer: + +```ruby + $ rails g proselytism:initializer +``` + ## Usage ```ruby Proselytism.convert source_file_path, :to => :pdf do |converted_file_path| @@ -52,35 +70,41 @@ Proselytism.extract_images source_file_path do |image_files_paths| end ``` -Proselytism create its converted files in temporary folders. - - If you pass a block to the method the folders are automatically deleted after the block is yield, so use or copy the file content within the block - - If you don't pass a block, don't forget to safely remove the temp folder +Proselytism creates its converted files in temporary folders. + - If you pass a block to the method above the folders are automatically deleted after the block is yield, so use or copy the file content within the block + - If you don't pass a block, the mentioned folder and its content remains permanently, so don't forget to safely remove it yourself ```ruby pdf_file_path = Proselytism.convert source_file_path, :to => :pdf +#my code FileUtils.remove_entry_secure File.dirname(pdf_file_path) ``` -## Add your own converter +## Add your own converters Add your own converter by extending Proselytism::Converters::Base - - Your converter will be automatically selected and used related to the form and to extensions list + - Your converter will be automatically selected and used related to the params given to the :from and :to methods - Add a perform method which - - define a text command - - call execute - - return the converted file(s) path + - calls the execute method with your custom command + - returns the converted file(s) path(s) +Proselytism::Converters::Base takes care of + - raising error (if the command execution fail) + - logging the command output + ```ruby class MyConverter < Proselytism::Converters::Base + class Error < parent::Base::Error; end + form :ext1, :ext2 to :ext3, :ext4 def perform(origin, options={}) destination = destination_file_path(origin, options) - command = "pdftotext #{origin} #{destination} 2>&1" + command = "mycommand #{origin} #{destination} 2>&1" execute command destination end end ```