123456789_123456789_123456789_123456789_123456789_

Class: YARD::Server::Commands::DisplayFileCommand

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: YARD::Server::Commands::LibraryCommand
Defined in: lib/yard/server/commands/display_file_command.rb

Overview

TODO:

Implement better support for detecting binary (image) filetypes

Displays a README or extra file.

Since:

  • 0.6.0

Class Method Summary

LibraryCommand - Inherited

Base - Inherited

.new

Creates a new command object, setting attributes named by keys in the options hash.

Instance Attribute Summary

Instance Method Summary

LibraryCommand - Inherited

#call, #call_with_fork, #call_without_fork,
#fulldoc_template

Hack to load a custom fulldoc template object that does not do any rendering/generation.

#load_yardoc, #not_prepared, #restore_template_info, #save_default_template_info, #setup_library, #setup_yardopts

Base - Inherited

#call

The main method called by a router with a request object.

#run

Subclass this method to implement a custom command.

#add_cache_control

Add a conservative cache control policy to reduce load on requests served with "?1234567890" style timestamp query strings.

Constructor Details

This class inherits a constructor from YARD::Server::Commands::LibraryCommand

Instance Attribute Details

#index (rw)

Since:

  • 0.6.0

[ GitHub ]

  
# File 'lib/yard/server/commands/display_file_command.rb', line 9

attr_accessor :index

Instance Method Details

#run

Raises:

Since:

  • 0.6.0

[ GitHub ]

  
# File 'lib/yard/server/commands/display_file_command.rb', line 11

def run
  filename = File.cleanpath(File.join(library.source_path, path))
  raise NotFoundError unless File.file?(filename)
  if filename =~ /\.(jpe?g|gif|png|bmp|svg)$/i
    headers['Content-Type'] = StaticFileCommand::DefaultMimeTypes[$1.downcase] || 'text/html'
    render File.read_binary(filename)
  else
    file = CodeObjects::ExtraFileObject.new(filename)
    options.update :object => Registry.root,
                   :type => :layout,
                   :file => file,
                   :index => index ? true : false
    render
  end
end