class Bundler::Source::Path

def load_spec_files

def load_spec_files
  index = Index.new
  if File.directory?(expanded_path)
    # We sort depth-first since `<<` will override the earlier-found specs
    Gem::Util.glob_files_in_dir(@glob, expanded_path).sort_by {|p| -p.split(File::SEPARATOR).size }.each do |file|
      next unless spec = load_gemspec(file)
      spec.source = self
      # Validation causes extension_dir to be calculated, which depends
      # on #source, so we validate here instead of load_gemspec
      validate_spec(spec)
      index << spec
    end
    if index.empty? && @name && @version
      index << Gem::Specification.new do |s|
        s.name     = @name
        s.source   = self
        s.version  = Gem::Version.new(@version)
        s.platform = Gem::Platform::RUBY
        s.summary  = "Fake gemspec for #{@name}"
        s.relative_loaded_from = "#{@name}.gemspec"
        s.authors = ["no one"]
        if expanded_path.join("bin").exist?
          executables = expanded_path.join("bin").children
          executables.reject! {|p| File.directory?(p) }
          s.executables = executables.map {|c| c.basename.to_s }
        end
      end
    end
  else
    message = String.new("The path `#{expanded_path}` ")
    message << if File.exist?(expanded_path)
      "is not a directory."
    else
      "does not exist."
    end
    raise PathError, message
  end
  index
end