Class: YARD::Server::Commands::LibraryCommand Abstract

Inherits:
Base
  • Object
show all
Defined in:
lib/yard/server/commands/library_command.rb

Overview

This class is abstract.

This is the base command for all commands that deal directly with libraries. Some commands do not, but most (like DisplayObjectCommand) do. If your command deals with libraries directly, subclass this class instead. See Base for notes on how to subclass a command.

Since:

Direct Known Subclasses

DisplayFileCommand, DisplayObjectCommand, ListCommand, SearchCommand

Basic Command and Adapter Options (collapse)

Attributes Set Per Request (collapse)

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (LibraryCommand) initialize(opts = {})

Returns a new instance of LibraryCommand

Since:

  • 0.6.0



51
52
53
54
# File 'lib/yard/server/commands/library_command.rb', line 51

def initialize(opts = {})
  super
  self.serializer = DocServerSerializer.new
end

Instance Attribute Details

- (Adapter) adapter Originally defined in class Base

Returns the server adapter

Returns:

Since:

  • 0.6.0

- (String) body Originally defined in class Base

Returns the response body. Defaults to empty string.

Returns:

  • (String)

    the response body. Defaults to empty string.

Since:

  • 0.6.0

- (Boolean) caching Originally defined in class Base

Returns whether to cache

Returns:

  • (Boolean)

    whether to cache

Since:

  • 0.6.0

- (Hash) command_options Originally defined in class Base

Returns the options passed to the command's constructor

Returns:

  • (Hash)

    the options passed to the command's constructor

Since:

  • 0.6.0

- (Hash{String => String}) headers Originally defined in class Base

Returns response headers

Returns:

Since:

  • 0.6.0

- (Boolean) incremental

Returns whether to reparse data

Returns:

  • (Boolean)

    whether to reparse data

Since:

  • 0.6.0



45
46
47
# File 'lib/yard/server/commands/library_command.rb', line 45

def incremental
  @incremental
end

- (LibraryVersion) library

Returns the object containing library information

Returns:

Since:

  • 0.6.0



33
34
35
# File 'lib/yard/server/commands/library_command.rb', line 33

def library
  @library
end

- (LibraryOptions) options

Returns default options for the library

Returns:

Since:

  • 0.6.0



36
37
38
# File 'lib/yard/server/commands/library_command.rb', line 36

def options
  @options
end

- (String) path Originally defined in class Base

Returns the path after the command base URI

Returns:

  • (String)

    the path after the command base URI

Since:

  • 0.6.0

- (Request) request Originally defined in class Base

Returns request object

Returns:

  • (Request)

    request object

Since:

  • 0.6.0

- (Serializers::Base) serializer

Returns the serializer used to perform file linking

Returns:

Since:

  • 0.6.0



39
40
41
# File 'lib/yard/server/commands/library_command.rb', line 39

def serializer
  @serializer
end

- (Boolean) single_library

Returns whether router should route for multiple libraries

Returns:

  • (Boolean)

    whether router should route for multiple libraries

Since:

  • 0.6.0



42
43
44
# File 'lib/yard/server/commands/library_command.rb', line 42

def single_library
  @single_library
end

- (Numeric) status Originally defined in class Base

Returns status code. Defaults to 200 per request

Returns:

  • (Numeric)

    status code. Defaults to 200 per request

Since:

  • 0.6.0

Instance Method Details

- (Object) call(request)

Since:

  • 0.6.0



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/yard/server/commands/library_command.rb', line 56

def call(request)
  save_default_template_info
  self.request = request
  self.options = LibraryOptions.new
  self.options.reset_defaults
  self.options.command = self
  setup_library
  self.options.title = "Documentation for #{library.name} " +
    (library.version ? '(' + library.version + ')' : '')
  super
rescue LibraryNotPreparedError
  not_prepared
ensure
  restore_template_info
end