Sha256: b4c415a1770577e6db5922f9a47f3fcdf9b3df21fc70896c7abf47979cbb4c48

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

module YARD
  module Server
    class FinishRequest < RuntimeError; end
    class NotFoundError < RuntimeError; end

    class Adapter
      # @return [String] the location where static files are located, if any
      attr_accessor :document_root
      
      attr_accessor :libraries
      
      attr_accessor :options
      
      attr_accessor :server_options
      
      attr_accessor :router

      def self.setup
        Templates::Template.extra_includes |= [YARD::Server::DocServerHelper]
        Templates::Engine.template_paths |= [File.dirname(__FILE__) + '/templates']
      end

      def self.shutdown
        Templates::Template.extra_includes -= [YARD::Server::DocServerHelper]
        Templates::Engine.template_paths -= [File.dirname(__FILE__) + '/templates']
      end
      
      def initialize(libs, opts = {}, server_opts = {})
        self.class.setup
        self.libraries = libs
        self.options = opts
        self.server_options = server_opts
        self.document_root = server_options[:DocumentRoot]
        self.router = (options[:router] || Router).new(self)
        options[:adapter] = self
        log.debug "Serving libraries using #{self.class}: #{libraries.keys.join(', ')}"
        log.debug "Caching on" if options[:caching]
        log.debug "Document root: #{document_root}" if document_root
      end
      
      def add_library(library)
        libraries[library.name] ||= []
        libraries[library.name] |= [library]
      end
      
      def start
        raise NotImplementedError
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
yard-0.6.3 lib/yard/server/adapter.rb
yard-0.6.2 lib/yard/server/adapter.rb
yard-0.6.1 lib/yard/server/adapter.rb
yard-0.6.0 lib/yard/server/adapter.rb