Class: YARD::Server::Commands::StaticFileCommand
- Includes:
- WEBrick::HTTPUtils
- Defined in:
- lib/yard/server/commands/static_file_command.rb
Overview
Constant Summary collapse
- STATIC_PATHS =
[ File.join(YARD::TEMPLATE_ROOT, 'default', 'fulldoc', 'html'), File.join(File.dirname(__FILE__), '..', 'templates', 'default', 'fulldoc', 'html') ]
Instance Attribute Summary
Attributes inherited from Base
#adapter, #body, #caching, #command_options, #headers, #path, #request, #status
Instance Method Summary collapse
Methods inherited from Base
#cache, #call, #initialize, #not_found, #redirect, #render
Constructor Details
This class inherits a constructor from YARD::Server::Commands::Base
Instance Method Details
#run ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/yard/server/commands/static_file_command.rb', line 16 def run path = File.cleanpath(request.path).gsub(%r{^(../)+}, '') ([adapter.document_root] + STATIC_PATHS).compact.each do |path_prefix| file = File.join(path_prefix, path) if File.exist?(file) ext = "." + (request.path[/\.(\w+)$/, 1] || "html") headers['Content-Type'] = mime_type(ext, DefaultMimeTypes) self.body = File.read(file) return end end favicon? self.status = 404 end |