Class: YARD::Server::RackAdapter

Inherits:
Adapter
  • Object
show all
Includes:
HTTPUtils
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

Constants included from HTTPUtils

HTTPUtils::DefaultMimeTypes, HTTPUtils::ESCAPED, HTTPUtils::NONASCII, HTTPUtils::UNESCAPED, HTTPUtils::UNESCAPED_FORM, HTTPUtils::UNESCAPED_PCHAR

Instance Attribute Summary

Attributes inherited from Adapter

#document_root, #libraries, #options, #router, #server_options

Instance Method Summary collapse

Methods included from HTTPUtils

_escape, _make_regex, _make_regex!, _unescape, dequote, escape, escape8bit, escape_form, escape_path, load_mime_types, mime_type, normalize_path, parse_form_data, parse_header, parse_query, parse_qvalues, parse_range_header, quote, split_header_value, unescape, unescape_form

Methods inherited from Adapter

#add_library, #initialize, setup, shutdown

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 YARD::Server::Router.

Returns:

Since:

  • 0.6.0



68
69
70
71
72
73
74
75
76
# File 'lib/yard/server/rack_adapter.rb', line 68

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



81
82
83
84
85
86
# File 'lib/yard/server/rack_adapter.rb', line 81

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