Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
82 lines (56 sloc) 2.28 KB



Query the availability of required and optional libraries and gems with a nice interface.


  • A nice API


gem install available


A simple example

source = do
  requires :nokogiri, :haml
  optional :textile
source.satisfied?       # => true/false - whether all required dependencies could be loaded
source.has.nokogiri?    # => true/false
source.has?(:nokogiri)  # => same as above
source.need.nokogiri!   # either returns true, or raises a LoadError
source.missing          # => [#<Available::Dependency…>, …] - an array of missing dependencies
source.error(:nokogiri) # => nil/LoadError - the exception that occurred while loading nokogiri
source.errors           # => [#<LoadError…>, …] an array of all errors that occurred while trying to require dependencies

A more complex example

source = do
  requires rack_ssl: 'rack/ssl' # require differs from name
  requires sqlite: gem('sqlite3-ruby', 'sqlite') # explicitely a gem, giving its name and the proper require
  requires markdown: any_of(:maruku, :rdiscount, :bluecloth)
source.which(:markdown)       # => an Available::Depencency
source.which(:markdown).name  # => either :maruku, :rdiscount or :bluecloth

Of course you can combine those requires

source = do
  requires :nokogiri,
           rack_ssl: 'rack/ssl',
           sqlite:   gem('sqlite3-ruby', 'sqlite'),
           markdown: any_of(:maruku, :rdiscount, :bluecloth)

  optional :textile


Running the Tests

You can run the tests using ruby test/runner.rb (I prefer ruby -rturn test/runner.rb, but that's your call). Using test/runner is not a requirement. but it makes things easier.


You can use this code under the {file:LICENSE.txt BSD-2-Clause License}, free of charge. If you need a different license, please ask the author.

Jump to Line
Something went wrong with that request. Please try again.