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

Instance Attribute Summary

Attributes inherited from Library

#dependencies

Attributes included from Library::NamespaceLoader

#indexed_namespace, #object_namespace

Attributes included from Library::Namespacer

#namespace

Attributes included from Library::Libraries

#gems

Attributes included from Library::Alias

#class_commands, #no_alias_creation

Attributes included from Library::Save

#repo_dir

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Library::NamespaceLoader

#actual_load_commands, #clean_library_commands, #handle_method_conflict_error, #method_conflicts, #set_library_commands

Methods included from Library::Namespacer

#namespace_object

Methods included from Library::LibrariesLoader

#after_include, #before_load_commands, #detect_additions, #module_callbacks

Methods included from Library::Libraries

#local?

Methods included from Library::AliasLoader

#before_load_commands, #load_commands?

Methods included from Library::Save

#before_initialize, #config, #marshal_dump, #marshal_load, #set_repo

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