AWS Developer Tools Blog

Flexible Gem Dependencies

Version 1 of the AWS SDK for Ruby (aws-sdk gem) depends on Nokogiri and JSON. While these are robust and performant libraries, there are multiple reasons why a developer may not want to be locked into these dependencies:

  • I might want to use pure Ruby solutions that do not require native extensions for maximum portability.
  • I might want to use Oj/Ox for performance reasons
  • I might require more flexibility in choosing the version of dependent gem.

MultiJSON and MultiXML

In version 2 of the Ruby SDK (aws-sdk-core gem), we depend on the multi_json and multi_xml gems. By default these gems use the fastest available XML and JSON libraries available. If you have not explicitly installed any libraries, then those available in the Ruby standard library will be used. These are REXML and JSON.

I very much enjoy Oj and Ox. They are fast XML and JSON parsers/serializers. They are written in c, but have no external dependencies. You can enable these libraries by adding them to your Gemfile as follows:

gem 'oj'
gem 'ox'

MultiJSON and MultiXML will choose these by default. The same approach works with Nokogiri. Just add gem 'nokogiri' to your Bundler Gemfile and you are set.

We are working hard to ensure the SDK depends on as few gems as possible and to ensure it works on as many platforms as possible. If you have any feedback or suggestions on the version 2 Ruby SDK, please let us know!