Sha256: 358b652bb16ced6386afa8f2892d6dbd2d15857d95f8b3cabaa6ac616d3a4608

Contents?: true

Size: 1.46 KB

Versions: 19

Compression:

Stored size: 1.46 KB

Contents

# This was added via Merb's bundler

require "rubygems"
require "rubygems/source_index"

module Gem
  BUNDLED_SPECS = File.join(Dir.pwd, "gems", "specifications")
  MAIN_INDEX = Gem::SourceIndex.from_gems_in(BUNDLED_SPECS)
  FALLBACK_INDEX = Gem::SourceIndex.from_installed_gems
  
  def self.source_index
    MultiSourceIndex.new
  end
  
  def self.searcher
    MultiPathSearcher.new
  end
  
  class ArbitrarySearcher < GemPathSearcher
    def initialize(source_index)
      @source_index = source_index
      super()
    end
    
    def init_gemspecs
      @source_index.map { |_, spec| spec }.sort { |a,b|
        (a.name <=> b.name).nonzero? || (b.version <=> a.version)
      }
    end
  end

  class MultiPathSearcher
    def initialize
      @main_searcher = ArbitrarySearcher.new(MAIN_INDEX)
      @fallback_searcher = ArbitrarySearcher.new(FALLBACK_INDEX)
    end
    
    def find(path)
      try = @main_searcher.find(path)
      return try if try
      @fallback_searcher.find(path)
    end
    
    def find_all(path)
      try = @main_searcher.find_all(path)
      return try unless try.empty?
      @fallback_searcher.find_all(path)
    end
  end
  
  class MultiSourceIndex
    def search(*args)
      try = MAIN_INDEX.search(*args)
      return try unless try.empty?
      FALLBACK_INDEX.search(*args)
    end
    
    def find_name(*args)
      try = MAIN_INDEX.find_name(*args)
      return try unless try.empty?
      FALLBACK_INDEX.find_name(*args)
    end
  end
end

Version data entries

19 entries across 19 versions & 3 rubygems

Version Path
adva-0.3.2 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.3.1 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.3.0 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.2.4 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.2.3 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.2.2 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.2.1 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.2.0 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.1.4 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.1.3 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.1.2 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.1.1 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.1.0 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
adva-0.0.1 test/webrat/spec/integration/merb/tasks/merb.thor/common.rb
integrity-0.1.9 vendor/webrat/spec/integration/merb/tasks/merb.thor/common.rb
merb-gen-1.0.5 lib/generators/templates/application/common/merb_thor/common.rb
merb-gen-1.0.7 lib/generators/templates/application/common/merb_thor/common.rb
merb-gen-1.0.6 lib/generators/templates/application/common/merb_thor/common.rb
merb-gen-1.0.6.1 lib/generators/templates/application/common/merb_thor/common.rb