Sha256: 14abd0da4ba944c5add2bffe3b6f2de89d396f7ca0424f8aad9569d0d4a48f4f

Contents?: true

Size: 774 Bytes

Versions: 5

Compression:

Stored size: 774 Bytes

Contents

module YARD
  module Server
    module Commands
      # Displays a README or extra file.
      # 
      # @todo Implement better support for detecting binary (image) filetypes
      class DisplayFileCommand < LibraryCommand
        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
            options.update(:object => Registry.root, :type => :layout, :file => filename)
            render
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
yard-0.6.8 lib/yard/server/commands/display_file_command.rb
yard-0.6.7 lib/yard/server/commands/display_file_command.rb
yard-0.6.6 lib/yard/server/commands/display_file_command.rb
yard-0.6.5 lib/yard/server/commands/display_file_command.rb
yard-0.6.4 lib/yard/server/commands/display_file_command.rb