Almost all software require other software in order to run. We call those other software 'dependencies'. Reliably checking for dependencies can be difficult. Helping the user in case a dependency is not installed (or doesn't seem to be installed) is more difficult still.
The Depcheck framework seeks to make all this easier. It allows the programmer to write "specs" which contain dependency checking code in a structured way. The programmer defines a dependency's basic information (name, website, etc), defines installation instructions (which may be customized per platform) and defines code for checking whether the dependency actually exists. The Depcheck framework:
* Provides helpers for checking for the existance of commands, libraries, headers, etc. * Registers all dependency specs in a way that can be easily accessed structurally. * Allows user-friendly display of dependency checking progress and user help instructions.
Most dependency checking code (e.g. autoconf) is very straightforward: they just check for the existance of a command, library, header, etc and either report "found" or "not found". In our experience the world is unfortunately not that simple. Users can have multiple versions of a dependency installed, where some dependencies are suitable while others are not. Therefore specs should print as many details about the dependency as possible (location, version, etc) so that the user can override any decisions if necessary.
# File lib/phusion_passenger/platform_info/depcheck.rb, line 50 def self.define(identifier, &block) @@database[identifier.to_s] = block end
# File lib/phusion_passenger/platform_info/depcheck.rb, line 54 def self.find(identifier) # We lazy-initialize everything in order to save resources. This also # allows blocks to perform relatively expensive checks without hindering # startup time. identifier = identifier.to_s result = @@database[identifier] if result.is_a?(Proc) result = Dependency.new(&result) @@database[identifier] = result end result end
# File lib/phusion_passenger/platform_info/depcheck.rb, line 41 def self.load(partial_filename) if !@@loaded[partial_filename] filename = "#{THIS_DIR}/#{partial_filename}.rb" content = File.read(filename) instance_eval(content, filename) @@loaded[partial_filename] = true end end
Generated with the Darkfish Rdoc Generator 2.