Sha256: e433cdf4007f4a8169265d5ca165187e88de8045dc005984e464c7500299c451

Contents?: true

Size: 1.43 KB

Versions: 60

Compression:

Stored size: 1.43 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

60 entries across 60 versions & 23 rubygems

Version Path
davidtrogers-webrat-0.4.4.2 spec/integration/merb/tasks/merb.thor/common.rb
diabolo-webrat-0.4.4.1 spec/integration/merb/tasks/merb.thor/common.rb
diabolo-webrat-0.4.4.2 spec/integration/merb/tasks/merb.thor/common.rb
diabolo-webrat-0.4.4 spec/integration/merb/tasks/merb.thor/common.rb
diabolo-webrat-0.5.1 spec/integration/merb/tasks/merb.thor/common.rb
dstrelau-webrat-0.5.1 spec/integration/merb/tasks/merb.thor/common.rb
emipair-webrat-0.0.1 spec/integration/merb/tasks/merb.thor/common.rb
hardbap-webrat-0.5.1 spec/integration/merb/tasks/merb.thor/common.rb
hardbap-webrat-0.5.2 spec/integration/merb/tasks/merb.thor/common.rb
raldred-webrat-0.4.4.2 spec/integration/merb/tasks/merb.thor/common.rb
sr-webrat-0.4.4.1 spec/integration/merb/tasks/merb.thor/common.rb
winton-sum-0.1.0 vendor/webrat/spec/integration/merb/tasks/merb.thor/common.rb
winton-sum-0.1.1 vendor/webrat/spec/integration/merb/tasks/merb.thor/common.rb
radiant-1.0.0 ruby-debug/ruby/1.8/gems/webrat-0.7.3/spec/integration/merb/tasks/merb.thor/common.rb
indirect-webrat-0.7.5 spec/integration/merb/tasks/merb.thor/common.rb
indirect-webrat-0.7.4 spec/integration/merb/tasks/merb.thor/common.rb
webrat-0.7.3 spec/integration/merb/tasks/merb.thor/common.rb
jbd-webrat-0.7.2.rails3 spec/integration/merb/tasks/merb.thor/common.rb
webrat-0.7.2 spec/integration/merb/tasks/merb.thor/common.rb
webrat-0.7.2.beta.2 spec/integration/merb/tasks/merb.thor/common.rb