From d97e4c8a3d61bc0d56e00cdd64b4e01d04006012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arist=C3=B3teles=20Coutinho?= Date: Fri, 19 Jan 2024 10:19:38 -0300 Subject: [PATCH] docs: fix @returns directive --- lib/lennarb.rb | 14 +++++++------- lib/lennarb/request.rb | 6 +++--- lib/lennarb/response.rb | 24 ++++++++++++------------ lib/lennarb/route_node.rb | 2 +- lib/lennarb/version.rb | 2 +- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/lennarb.rb b/lib/lennarb.rb index 45c4cc2..85de9a9 100644 --- a/lib/lennarb.rb +++ b/lib/lennarb.rb @@ -23,7 +23,7 @@ class Lennarb class LennarbError < StandardError; end # @attribute [r] root - # @return [RouteNode] + # @returns [RouteNode] # attr_reader :root @@ -31,7 +31,7 @@ class LennarbError < StandardError; end # # @yield { ... } The application # - # @return [Lennarb] + # @returns [Lennarb] # def initialize @root = RouteNode.new @@ -42,7 +42,7 @@ def initialize # # @parameter [String] path # - # @return [Array] parts. Ex. ['users', ':id'] + # @returns [Array] parts. Ex. ['users', ':id'] # SplitPath = ->(path) { path.split('/').reject(&:empty?) } private_constant :SplitPath @@ -51,16 +51,16 @@ def initialize # # @parameter [Hash] env # - # @return [Array] response + # @returns [Array] response # def call(env) - res = Response.new http_method = env.fetch('REQUEST_METHOD').to_sym parts = SplitPath[env.fetch('PATH_INFO')] block, params = @root.match_route(parts, http_method) return [404, { 'content-type' => 'text/plain' }, ['Not Found']] unless block + res = Response.new req = Request.new(env, params) instance_exec(req, res, &block) @@ -72,7 +72,7 @@ def call(env) # @parameter [String] path # @parameter [Proc] block # - # @return [void] + # @returns [void] # def get(path, &block) = add_route(path, :GET, block) def post(path, &block) = add_route(path, :POST, block) @@ -88,7 +88,7 @@ def delete(path, &block) = add_route(path, :DELETE, block) # @parameter [String] http_method # @parameter [Proc] block # - # @return [void] + # @returns [void] # def add_route(path, http_method, block) parts = SplitPath[path] diff --git a/lib/lennarb/request.rb b/lib/lennarb/request.rb index a6079bd..b1e13f9 100644 --- a/lib/lennarb/request.rb +++ b/lib/lennarb/request.rb @@ -10,7 +10,7 @@ class Request < Rack::Request # @parameter [Hash] env # @parameter [Hash] route_params # - # @return [Request] + # @returns [Request] # def initialize(env, route_params = {}) super(env) @@ -19,7 +19,7 @@ def initialize(env, route_params = {}) # Get the request body # - # @return [String] + # @returns [String] def params @params ||= super.merge(@route_params) end @@ -28,7 +28,7 @@ def params # Get the query string # - # @return [String] + # @returns [String] # def query_params @query_params ||= Rack::Utils.parse_nested_query(query_string) diff --git a/lib/lennarb/response.rb b/lib/lennarb/response.rb index b67a1c2..b9c4a54 100644 --- a/lib/lennarb/response.rb +++ b/lib/lennarb/response.rb @@ -6,22 +6,22 @@ class Lennarb class Response # @!attribute [rw] status - # @return [Integer] + # @returns [Integer] # attr_accessor :status # @!attribute [r] body - # @return [Array] + # @returns [Array] # attr_reader :body # @!attribute [r] headers - # @return [Hash] + # @returns [Hash] # attr_reader :headers # @!attribute [r] length - # @return [Integer] + # @returns [Integer] # attr_reader :length @@ -41,7 +41,7 @@ class Response # Initialize the response object # - # @return [Response] + # @returns [Response] # def initialize @status = 404 @@ -54,7 +54,7 @@ def initialize # # @parameter [String] key # - # @return [String] value + # @returns [String] value # def [](key) @headers[key] @@ -65,7 +65,7 @@ def [](key) # @parameter [String] key # @parameter [String] value # - # @return [String] value + # @returns [String] value # def []=(key, value) @headers[key] = value @@ -75,7 +75,7 @@ def []=(key, value) # # @parameter [String] str # - # @return [String] str + # @returns [String] str # def write(str) str = str.to_s @@ -88,7 +88,7 @@ def write(str) # # @parameter [String] str # - # @return [String] str + # @returns [String] str # def text(str) @headers[CONTENT_TYPE] = ContentType[:TEXT] @@ -99,7 +99,7 @@ def text(str) # # @parameter [String] str # - # @return [String] str + # @returns [String] str # def html(str) @headers[CONTENT_TYPE] = ContentType[:HTML] @@ -110,7 +110,7 @@ def html(str) # # @parameter [String] str # - # @return [String] str + # @returns [String] str # def json(str) @headers[CONTENT_TYPE] = ContentType[:JSON] @@ -129,7 +129,7 @@ def redirect(path, status = 302) # Finish the response # - # @return [Array] response + # @returns [Array] response # def finish [@status, @headers, @body] diff --git a/lib/lennarb/route_node.rb b/lib/lennarb/route_node.rb index d498ac5..84ec919 100644 --- a/lib/lennarb/route_node.rb +++ b/lib/lennarb/route_node.rb @@ -12,7 +12,7 @@ class RouteNode # @return [RouteNode] # def initialize - @children = {} + @children = {} @blocks = {} @param_key = nil end diff --git a/lib/lennarb/version.rb b/lib/lennarb/version.rb index f27a1c1..e634cdb 100644 --- a/lib/lennarb/version.rb +++ b/lib/lennarb/version.rb @@ -4,7 +4,7 @@ # Copyright, 2023-2024, by Aristóteles Coutinho. class Lennarb - VERSION = '0.2.0' + VERSION = '0.3.0' public_constant :VERSION end