class Bundler::LazySpecification

def __materialize__

def __materialize__
  @specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
    source.gemspec.tap {|s| s.source = source }
  else
    search_object = if source.is_a?(Source::Path)
      Dependency.new(name, version)
    else
      ruby_platform_materializes_to_ruby_platform? ? self : Dependency.new(name, version)
    end
    platform_object = ruby_platform_materializes_to_ruby_platform? ? Gem::Platform.new(platform) : Gem::Platform.local
    candidates = source.specs.search(search_object)
    same_platform_candidates = candidates.select do |spec|
      MatchPlatform.platforms_match?(spec.platform, platform_object)
    end
    installable_candidates = same_platform_candidates.select do |spec|
      spec.is_a?(StubSpecification) ||
        (spec.required_ruby_version.satisfied_by?(Gem.ruby_version) &&
          spec.required_rubygems_version.satisfied_by?(Gem.rubygems_version))
    end
    search = installable_candidates.last || same_platform_candidates.last
    search.dependencies = dependencies if search && (search.is_a?(RemoteSpecification) || search.is_a?(EndpointSpecification))
    search
  end
end