Skip to content

Instantly share code, notes, and snippets.

@lukeledet
Forked from betawaffle/config.ru
Created May 17, 2012 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukeledet/2719933 to your computer and use it in GitHub Desktop.
Save lukeledet/2719933 to your computer and use it in GitHub Desktop.
Rack-based Local YARD Server
require 'rubygems'
require 'yard'
libs = Hash.new {|hash,key| hash[key] = [] }
base = ENV['GEM_PATH'].split(':')[1][%r{^.+(?=/.+@global$)}] rescue nil
if base
Gem.paths = {
'GEM_PATH' => Dir["#{base}/ruby-*"].join(':'),
'GEM_HOME' => ENV['GEM_HOME']
}
Gem.source_index.find_name('').each do |spec|
libs[spec.name] << YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem)
end
end
run YARD::Server::RackAdapter.new(libs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment