Module | Listen::DependencyManager |
In: |
lib/listen/dependency_manager.rb
|
The dependency-manager offers a simple DSL which allows classes to declare their gem dependencies and load them when needed. It raises a user-friendly exception when the dependencies can‘t be loaded which has the install command in the message.
GEM_LOAD_MESSAGE | = | <<-EOS.gsub(/^ {6}/, '') Missing dependency '%s' (version '%s')! EOS .gsub(/^ {6}/, '') |
GEM_INSTALL_COMMAND | = | <<-EOS.gsub(/^ {6}/, '') Please run the following to satisfy the dependency: gem install --version '%s' %s EOS .gsub(/^ {6}/, '') |
BUNDLER_DECLARE_GEM | = | <<-EOS.gsub(/^ {6}/, '') Please add the following to your Gemfile to satisfy the dependency: gem '%s', '%s' EOS .gsub(/^ {6}/, '') |
Dependency | = | Struct.new(:name, :version) |
Adds a loaded dependency to a list so that it doesn‘t have to be loaded again by another classes.
@param [Dependency] dependency
Returns whether the dependency is alread loaded or not.
@param [Dependency] dependency @return [Boolean]
Initializes the extended class.
@param [Class] the class for which some dependencies must be managed
Registers a new dependency.
@param [String] name the name of the gem @param [String] version the version of the gem
Loads the registered dependencies.
@raise DependencyManager::Error if the dependency can‘t be loaded.