puppetlabs/cfacter — pull request #90 by peterhuene (2014-08-13 04:06:43+00:00)
Title: (CFACT-44) Bind to loaded Ruby (if present) instead of searching.

Currently we always search the file system for a Ruby library.
While we do check to see if the library found has already loaded,
if libfacter finds a different library than the already loaded Ruby
library, a separate VM will be created that will be isolated from
the original VM. This would prevent facts from populating correctly.

POSIX libdl (and Windows through a different mechanism) has a way
for us to bind to the loaded Ruby without having to search the file
system. Specifically, dlsym will search for symbols exported by
the initially loaded objects and any objects that were loaded as
global. Ruby thankfully links against libruby such that we can
discover libruby's exports this way. When libfacter is running
under Ruby, we should now reliably function under the same Ruby VM.