Module Boson::Loader

  1. lib/boson/loader.rb

This module is mixed into Library to give it load() functionality. When creating your own Library subclass, you should override load_source_and_set_module You can override other methods in this module as needed.

Module Callbacks

For libraries that have a module i.e. FileLibrary and GemLibrary, the following class methods are invoked in the order below when loading a library:

:config
This method returns a library’s hash of attributes as explained by Library.new. This is useful for distributing libraries with a default configuration. The library attributes specified here are overridden by ones a user has in their config file except for the :commands attribute, which is recursively merged together.
:append_features
In addition to its normal behavior, this method’s return value determines if a library is loaded in the current environment. This is useful for libraries that you want loaded by default but not in some environments i.e. different ruby versions or in irb but not in script/console. Remember to use super when returning true.
:included
In addition to its normal behavior, this method should be used to require external libraries. Although requiring dependencies could be done anywhere in a module, putting dependencies here are encouraged. By not having dependencies hardcoded in a module, it’s possible to analyze and view a library’s commands without having to install and load its dependencies. If creating commands here, note that conflicts with existing commands won’t be detected.
:after_included
This method is called after included() to initialize functionality. This is useful for libraries that are primarily executing ruby code i.e. defining ruby extensions or setting irb features. This method isn’t called when indexing a library.

Public instance methods

load () {|if block_given?| ...}

Loads a library and its dependencies and returns true if library loads correctly.

[show source]
# File lib/boson/loader.rb, line 31
    def load
      @gems ||= []
      load_source_and_set_module
      module_callbacks if @module
      yield if block_given?
      (@module || @class_commands) ? detect_additions { load_module_commands } : @namespace = false
      set_library_commands
      @indexed_namespace = (@namespace == false) ? nil : @namespace if @index
      loaded_correctly? && (@loaded = true)
    end
load_source_and_set_module ()

Load the source and set instance variables necessary to make a library valid i.e. @module.

[show source]
# File lib/boson/loader.rb, line 43
    def load_source_and_set_module; end
loaded_correctly? ()

Boolean which indicates if library loaded correctly.

[show source]
# File lib/boson/loader.rb, line 46
    def loaded_correctly?
      !!@module
    end