Sha256: fdb030fcd8d53e40cf0492ab8a8cbda80b9a496363ec0896d5f7f36d3f948a33
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
require 'wri/server' module WRI class RiService attr :library def initialize(library=nil) @library = library end def info(keyword) if library `ri -d #{library} -f html #{keyword}` else `ri -f html #{keyword}` end end def names @names ||= if library `ri -d #{library} --list-names` else `ri --list-names` end.split(/\s*\n/) end end end library = ARGV[0] service = WRI::RiService.new(library) wri = WRI::Server.new(service) #puts wri.to_html require 'webrick' include WEBrick p wri.directory + "/public" s = HTTPServer.new( :Port => 8888, :DocumentRoot => wri.directory + "/public" ) s.mount_proc("/"){|req, res| res.body = wri.to_html res['Content-Type'] = "text/html" } s.mount_proc("/ri"){|req, res| res.body = wri.lookup(req) res['Content-Type'] = "text/html" } ## mount subdirectories s.mount("/js", HTTPServlet::FileHandler, wri.directory + "/public/js") s.mount("/css", HTTPServlet::FileHandler, wri.directory + "/public/css") s.mount("/img", HTTPServlet::FileHandler, wri.directory + "/public/img") trap("INT"){ s.shutdown } s.start
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wri-0.1.0 | lib/wri/ri_service.rb |