aptible/aptible-api-ruby — pull request #13 by fancyremarker (2014-05-13 22:40:57+00:00)
Title: Require aptible/auth within gem and dependencies

I hate myself and the world for this, but I'm pretty confident it's the only robust solution to aptible/aptible-cli#7).

RubyGems [overrides](https://github.com/rubygems/rubygems/blob/master/lib/rubygems/core_ext/kernel_require.rb#L38-L144) Ruby's own `require` method to find suitable files among available gems.

There are two states for gems during the `require` search: "activated" and "unresolved." As soon as a version is selected for a gem, it becomes activated. Once a gem is "activated", any `require` statements within that gem and its dependencies are then evaluated by scanning all files within all versions of the unresolved gems for possible conflicts.

So, if there are 2 or more versions of `aptible-api` and 2 or more versions of `aptible-auth` installed on a system, all the dependencies shared between them (i.e., all the dependencies of `aptible-resource`) will trigger a full scan for conflicts.

The only way to avoid this behavior is to `require 'aptible-auth'` immedately after `aptible-api`, but before any of `aptible-auth`'s other dependencies have been loaded. This necessarily implies requiring `aptible-auth` within `aptible-api`.