Class: YARD::Server::Commands::DisplayFileCommand
- Inherits:
-
LibraryCommand
- Object
- Base
- LibraryCommand
- YARD::Server::Commands::DisplayFileCommand
- Defined in:
- lib/yard/server/commands/display_file_command.rb
Overview
Instance Attribute Summary
Attributes inherited from LibraryCommand
#incremental, #library, #options, #serializer, #single_library
Attributes inherited from Base
#adapter, #body, #caching, #command_options, #headers, #path, #request, #status
Instance Method Summary collapse
Methods inherited from LibraryCommand
Methods inherited from Base
#cache, #call, #initialize, #not_found, #redirect, #render
Constructor Details
This class inherits a constructor from YARD::Server::Commands::LibraryCommand
Instance Method Details
#run ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/yard/server/commands/display_file_command.rb', line 5 def run ppath = library.source_path filename = File.cleanpath(File.join(library.source_path, path)) raise NotFoundError if !File.file?(filename) if filename =~ /\.(jpe?g|gif|png|bmp)$/i headers['Content-Type'] = StaticFileCommand::DefaultMimeTypes[$1.downcase] || 'text/html' render IO.read(filename) else .update(:object => Registry.root, :type => :layout, :file => filename) render end end |