123456789_123456789_123456789_123456789_123456789_

Class: YARD::Server::RackAdapter

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Adapter
Instance Chain:
Inherits: YARD::Server::Adapter
Defined in: lib/yard/server/rack_adapter.rb

Overview

A server adapter to respond to requests using the Rack server infrastructure.

Since:

  • 0.6.0

Constant Summary

HTTPUtils - Included

DefaultMimeTypes, ESCAPED, NONASCII, UNESCAPED, UNESCAPED_FORM, UNESCAPED_PCHAR

Class Method Summary

Adapter - Inherited

.new

Creates a new adapter object.

.setup

Performs any global initialization for the adapter.

.shutdown

Performs any global shutdown procedures for the adapter.

Instance Attribute Summary

Instance Method Summary

HTTPUtils - Included

#_escape, #_make_regex, #_make_regex!, #_unescape,
#dequote

Removes quotes and escapes from str.

#escape

Escapes HTTP reserved and unwise characters in str

#escape8bit

Escapes 8 bit characters in str

#escape_form

Escapes form reserved characters in str

#escape_path

Escapes path str

#load_mime_types

Loads Apache-compatible mime.types in file.

#mime_type

Returns the mime type of filename from the list in mime_tab.

#normalize_path

Normalizes a request path.

#parse_form_data

Parses form data in io with the given boundary.

#parse_header

Parses an HTTP header raw into a hash of header fields with an ::Array of values.

#parse_query

Parses the query component of a URI in str.

#parse_qvalues

Parses q values in value as used in Accept headers.

#parse_range_header

Parses a Range header value ranges_specifier.

#quote

Quotes and escapes quotes in str.

#split_header_value

Splits a header value str according to HTTP specification.

#unescape

Unescapes HTTP reserved and unwise characters in str

#unescape_form

Unescapes form reserved characters in str

Adapter - Inherited

#add_library

Adds a library to the #libraries mapping for a given library object.

#start

Implement this method to connect your adapter to your server.

Constructor Details

This class inherits a constructor from YARD::Server::Adapter

Instance Method Details

#call(env) ⇒ Array(Numeric,Hash,Array)

Responds to Rack requests and builds a response with the Router.

Returns:

Since:

  • 0.6.0

[ GitHub ]

  
# File 'lib/yard/server/rack_adapter.rb', line 57

def call(env)
  request = Rack::Request.new(env)
  request.path_info = unescape(request.path_info) # unescape things like %3F
  router.call(request)
rescue StandardError => ex
  log.backtrace(ex)
  [500, {'Content-Type' => 'text/plain'},
    [ex.message + "\n" + ex.backtrace.join("\n")]]
end

#startvoid

This method returns an undefined value.

Starts the Rack server. This method will pass control to the server and block.

Since:

  • 0.6.0

[ GitHub ]

  
# File 'lib/yard/server/rack_adapter.rb', line 70

def start
  server = RackServer.new(server_options)
  server.instance_variable_set("@app", self)
  print_start_message(server)
  server.start
end