ruby-win32/lib/ruby/gems/1.8/gems/gem_plugin-0.2.3/lib/gem_plugin.rb
def load(needs = {})
      sdir = File.join(Gem.dir, "specifications")
      gems = Gem::SourceIndex.from_installed_gems(sdir)
      needs = needs.merge({"gem_plugin" => INCLUDE})
      
      gems.each do |path, gem|
        # don't load gems more than once
        next if @gems.has_key? gem.name        
        check = needs.dup

        # rolls through the depends and inverts anything it finds
        gem.dependencies.each do |dep|
          # this will fail if a gem is depended more than once
          if check.has_key? dep.name
            check[dep.name] = !check[dep.name]
          end
        end
        
        # now since excluded gems start as true, inverting them
        # makes them false so we'll skip this gem if any excludes are found
        if (check.select {|name,test| !test}).length == 0
          # looks like no needs were set to false, so it's good
          
          # Previously was set wrong, we already have the correct gem path!
          #gem_dir = File.join(Gem.dir, "gems", "#{gem.name}-#{gem.version}")
          gem_dir = File.join(Gem.dir, "gems", path)
          
          require File.join(gem_dir, "lib", gem.name, "init.rb")
          @gems[gem.name] = gem_dir
        end
      end

      return nil
    end
# Responsible for going through the list of available gems and loading 
# any plugins requested.  It keeps track of what it's loaded already
# and won't load them again.
#
# It accepts one parameter which is a hash of gem depends that should include
# or exclude a gem from being loaded.  A gem must depend on gem_plugin to be
# considered, but then each system has to add it's own INCLUDE to make sure
# that only plugins related to it are loaded.
#
# An example again comes from Mongrel.  In order to load all Mongrel plugins:
#
#  GemPlugin::Manager.instance.load "mongrel" => GemPlugin::INCLUDE
#
# Which will load all plugins that depend on mongrel AND gem_plugin.  Now, one
# extra thing we do is we delay loading Rails Mongrel plugins until after rails
# is configured.  Do do this the mongrel_rails script has:
#
# GemPlugin::Manager.instance.load "mongrel" => GemPlugin::INCLUDE, "rails" => GemPlugin::EXCLUDE
# The only thing to remember is that this is saying "include a plugin if it
# depends on gem_plugin, mongrel, but NOT rails".  If a plugin also depends on other
# stuff then it's loaded just fine.  Only gem_plugin, mongrel, and rails are
# ever used to determine if it should be included.
#
# NOTE: Currently RubyGems will run autorequire on gems that get required AND
# on their dependencies.  This really messes with people running edge rails
# since activerecord or other stuff gets loaded for just touching a gem plugin.
# To prevent this load requires the full path to the "init.rb" file, which
# avoids the RubyGems autorequire magic.
Responsible for going through the list of available gems and loading
any plugins requested.  It keeps track of what it's loaded already
and won't load them again.

It accepts one parameter which is a hash of gem depends that should include
or exclude a gem from being loaded.  A gem must depend on gem_plugin to be
considered, but then each system has to add it's own INCLUDE to make sure
that only plugins related to it are loaded.

An example again comes from Mongrel.  In order to load all Mongrel plugins.



Which will load all plugins that depend on mongrel AND gem_plugin.  Now, one
extra thing we do is we delay loading Rails Mongrel plugins until after rails
is configured.  Do do this the mongrel_rails script has.



Currently RubyGems will run autorequire on gems that get required AND
on their dependencies.  This really messes with people running edge rails
since activerecord or other stuff gets loaded for just touching a gem plugin.
To prevent this load requires the full path to the "init.rb" file, which
avoids the RubyGems autorequire magic.
Responsible for going through the list of available gems and loading any plugins requested . It keeps track of what it ' s loaded already and won ' t load them again . It accepts one parameter which is a hash of gem depends that should include or exclude a gem from being loaded . A gem must depend on gem_plugin to be considered but then each system has to add it ' s own INCLUDE to make sure that only plugins related to it are loaded . An example again comes from Mongrel . In order to load all Mongrel plugins . Which will load all plugins that depend on mongrel AND gem_plugin . Now one extra thing we do is we delay loading Rails Mongrel plugins until after rails is configured . Do do this the mongrel_rails script has . Currently RubyGems will run autorequire on gems that get required AND on their dependencies . This really messes with people running edge rails since activerecord or other stuff gets loaded for just touching a gem plugin . To prevent this load requires the full path to the " init . rb " file which avoids the RubyGems autorequire magic .
def load(needs = {})
      sdir = File.join(Gem.dir, "specifications")
      gems = Gem::SourceIndex.from_installed_gems(sdir)
      needs = needs.merge({"gem_plugin" => INCLUDE})
      gems.each do |path, gem|
        next if @gems.has_key? gem.name        
        check = needs.dup
        gem.dependencies.each do |dep|
          if check.has_key? dep.name
            check[dep.name] = !check[dep.name]
          end
        end
        if (check.select {|name,test| !test}).length == 0
          gem_dir = File.join(Gem.dir, "gems", path)
          require File.join(gem_dir, "lib", gem.name, "init.rb")
          @gems[gem.name] = gem_dir
        end
      end
      return nil
    end
def load ( needs = { } ) sdir = File . join ( Gem . dir , "specifications" ) gems = Gem :: SourceIndex . from_installed_gems ( sdir ) needs = needs . merge ( { "gem_plugin" => INCLUDE } ) gems . each do | path , gem | next if @gems . has_key? gem . name check = needs . dup gem . dependencies . each do | dep | if check . has_key? dep . name check [ dep . name ] = ! check [ dep . name ] end end if ( check . select { | name , test | ! test } ) . length == 0 gem_dir = File . join ( Gem . dir , "gems" , path ) require File . join ( gem_dir , "lib" , gem . name , "init.rb" ) @gems [ gem . name ] = gem_dir end end return nil end
Responsible for going through the list of available gems and loading
any plugins requested.
Responsible for going through the list of available gems and loading any plugins requested .
# don't load gems more than once # rolls through the depends and inverts anything it finds # this will fail if a gem is depended more than once # now since excluded gems start as true, inverting them # makes them false so we'll skip this gem if any excludes are found # looks like no needs were set to false, so it's good # Previously was set wrong, we already have the correct gem path! #gem_dir = File.join(Gem.dir, "gems", "#{gem.name}-#{gem.version}")
needs