Class: Boson::GemLibrary

Inherits:
Library show all
Defined in:
lib/boson/libraries/gem_library.rb

Overview

This library loads a gem by the given name. Unlike FileLibrary or ModuleLibrary, this library doesn’t need a module to provide its functionality.

Example:

>> load_library 'httparty', :class_commands=>{'put'=>'HTTParty.put',
   'delete'=>'HTTParty.delete' }
=> true
>> put 'http://someurl.com'

Direct Known Subclasses

RequireLibrary

Constant Summary

Constants inherited from Library

Library::ATTRIBUTES

Instance Attribute Summary

Attributes inherited from Library

#class_commands, #lib_file, #namespace, #new_commands, #new_module, #no_alias_creation, #repo_dir

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Library

#clean_name, #command_object, #command_objects, handles, #initialize, #library_type, #local?, #marshal_dump, #marshal_load, #namespace_object, #set_attributes, #set_command_aliases, #set_config, #set_name, #set_repo

Methods included from Loader

#check_for_method_conflicts, #detect_additions, #include_in_universe, #initialize_library_module, #load, #load_module_commands, #module_callbacks, #set_library_commands

Constructor Details

This class inherits a constructor from Boson::Library

Class Method Details

.is_a_gem?(name) ⇒ Boolean

:stopdoc:

Returns:

  • (Boolean)


12
13
14
15
16
17
# File 'lib/boson/libraries/gem_library.rb', line 12

def self.is_a_gem?(name)
  return false unless defined? Gem
  Gem::VERSION >= '1.8.0' ?
    Gem::Specification.find_all_by_name(name)[0].is_a?(Gem::Specification) :
    Gem.searcher.find(name).is_a?(Gem::Specification)
end

Instance Method Details

#load_source_and_set_moduleObject



25
26
27
# File 'lib/boson/libraries/gem_library.rb', line 25

def load_source_and_set_module
  detect_additions { Util.safe_require @name }
end

#loaded_correctly?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/boson/libraries/gem_library.rb', line 21

def loaded_correctly?
  !@gems.empty? || !@commands.empty? || !!@module
end