When files are not available, the require
family will throw a [LoadError](<http://www.rubydoc.info/stdlib/core/LoadError>)
. This is an example which illustrates loading optional modules only if they exist.
module TidBits
@@unavailableModules = []
[
{ name: 'CoreExtend', file: 'core_extend/lib/core_extend' } \\
, { name: 'Fs' , file: 'fs/lib/fs' } \\
, { name: 'Options' , file: 'options/lib/options' } \\
, { name: 'Susu' , file: 'susu/lib/susu' } \\
].each do |lib|
begin
require_relative lib[ :file ]
rescue LoadError
@@unavailableModules.push lib
end
end
end # module TidBits