Sha256: 7417560a0b86c880f99517923e3b6e8ddaed4c64377916948a6bd2dc62d14d23

Contents?: true

Size: 895 Bytes

Versions: 11

Compression:

Stored size: 895 Bytes

Contents

module Boson
  # 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'
  class GemLibrary < Library
    #:stopdoc:
    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

    handles {|source| is_a_gem?(source.to_s) }

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

    def load_source_and_set_module
      detect_additions { Util.safe_require @name }
    end
    #:startdoc:
  end
end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
boson-more-0.3.1 lib/boson/libraries/gem_library.rb
boson-more-0.3.0 lib/boson/libraries/gem_library.rb
boson-more-0.2.2 lib/boson/libraries/gem_library.rb
boson-more-0.2.1 lib/boson/libraries/gem_library.rb
boson-more-0.2.0 lib/boson/libraries/gem_library.rb
boson-more-0.1.0 lib/boson/libraries/gem_library.rb
boson-0.4.0 lib/boson/libraries/gem_library.rb
bosonson-0.304.3 lib/boson/libraries/gem_library.rb
bosonson-0.304.2 lib/boson/libraries/gem_library.rb
bosonson-0.304.1 lib/boson/libraries/gem_library.rb
boson-0.3.4 lib/boson/libraries/gem_library.rb