file-convert Gem Version Build Status tolingo

Code Climate Test Coverage Dependency Status

Use google-api-ruby-client and Google Drive to convert files from one mime-type to another. For available formats see Google Drive API Export Formats.

Installation

Simply add it to your Gemfile:

gem 'file-convert'

Config

FileConvert exposes .configure which accepts a block and passes the config hash. Example:

FileConvert.configure do |config|
  config['google_service_account'] = {
    'email' => '<strange-hash>@developer.gserviceaccount.com',
    'pkcs12_file_path' => 'config/file_convert_key.p12'
  }
end

Examples

# converts `path_to_some_file` from <txt> to <pdf>
conversion = FileConvert.convert('path_to_some_file.txt', 'text/plain', 'application/pdf')
# converted body is accessible via `#body`
conversion.body
# .. or define a path to save the converted document to
conversion.save('path_to_new_file.pdf')

Specs

  • $ bundle exec rake for rspec and rubocop.
  • $ bundle exec rake build to also run the integration tests located at spec/integration/**/*_integration.rb. Note that you need to configure valid Google API credentials (i.e. set ENV['email'] and ENV['pkcspath']) for these tests to work, since we want to actually test the integration with the Google API here. (Do not worry, TravisCI will run these tests as well.)

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using the ways described above.

Next Steps

  • Enable OCR if necessary when uploading files
  • Add CLI
  • Add different adapter than Google?

License

file-convert is Copyright © 2014 Roman Ernst and tolingo GmbH and may be redistributed under the terms specified in the LICENSE file.