Class: YARD::Handlers::Sinatra::Legacy::RouteHandler

Inherits:
Ruby::Legacy::Base
  • Object
show all
Includes:
AbstractRouteHandler
Defined in:
lib/yard/sinatra.rb

Constant Summary collapse

VERBS =
%w[get head post put delete not_found]

Instance Method Summary collapse

Methods included from AbstractRouteHandler

error_handlers, #process, #register_error_handler, #register_route, routes

Instance Method Details

#http_pathObject



139
140
141
142
143
144
145
# File 'lib/yard/sinatra.rb', line 139

def http_path
  path = statement.tokens.detect do |t|
    t.is_a?(YARD::Parser::Ruby::Legacy::RubyToken::TkSTRING)
  end

  path.text
end

#http_verbObject



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/yard/sinatra.rb', line 123

def http_verb
  method_call_string = ''
  space  = YARD::Parser::Ruby::Legacy::RubyToken::TkSPACE
  lparen = YARD::Parser::Ruby::Legacy::RubyToken::TkLPAREN

  for token in statement.tokens
    if token.is_a?(space) || token.is_a?(lparen)
      break
    else
      method_call_string << token.text
    end
  end

  VERBS.detect{|v| method_call_string.include?(v)}.upcase
end