From c7f69961695552c12f02bb8def07535530d59882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arist=C3=B3teles=20Coutinho?= Date: Sat, 25 Nov 2023 19:36:59 -0300 Subject: [PATCH 1/4] test(request): add test for assigning params --- test/lib/lenna/router/test_request.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/lib/lenna/router/test_request.rb b/test/lib/lenna/router/test_request.rb index 83eb854..531b62c 100644 --- a/test/lib/lenna/router/test_request.rb +++ b/test/lib/lenna/router/test_request.rb @@ -5,6 +5,15 @@ module Lenna class Router class TestRequest < Minitest::Test + def test_assing_params + env = ::Rack::MockRequest.env_for('/', method: 'POST') + request = Request.new(env) + + request.assign_params({ 'foo' => 'bar' }) + + assert_equal({ 'foo' => 'bar' }, request.params) + end + def test_with_query_string env = ::Rack::MockRequest.env_for('/?foo=bar') From 922226b6f6cd88939e17fe65b8f332e24365d183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arist=C3=B3teles=20Coutinho?= Date: Sat, 25 Nov 2023 19:38:24 -0300 Subject: [PATCH 2/4] feat(rrequest): add assign_params to Request class --- lib/lenna/router/request.rb | 10 ++++++++++ lib/lennarb/version.rb | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/lenna/router/request.rb b/lib/lenna/router/request.rb index b34a03f..d1cd552 100644 --- a/lib/lenna/router/request.rb +++ b/lib/lenna/router/request.rb @@ -8,6 +8,16 @@ class Router # @attr body [Hash] the request body # @attr params [Hash] the request params class Request < ::Rack::Request + + # This method is used to set the request params. + # + # @param params [Hash] the request params + # + # @return [Hash] the request params + # + # @api public + def assign_params(params) = @params = params + # This method is used to parse the body params. # # @return [Hash] the request params diff --git a/lib/lennarb/version.rb b/lib/lennarb/version.rb index ce700ff..cab8303 100644 --- a/lib/lennarb/version.rb +++ b/lib/lennarb/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Lennarb - VERSION = '0.1.4' + VERSION = '0.1.5' public_constant :VERSION end From f1f5ebc216148fa79c109857704cdd3be352238d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arist=C3=B3teles=20Coutinho?= Date: Sat, 25 Nov 2023 19:39:16 -0300 Subject: [PATCH 3/4] documentation: UPDATE changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3fc04b..8ccbc86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.1.5] - 2023-25-11 + +### Added + +- Add `assign_params` method to Request class + ## [0.1.4] - 2023-25-11 ### Fixed From 04d5600f74cd39827a44ba220e1326231bd1fd97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arist=C3=B3teles=20Coutinho?= Date: Sat, 25 Nov 2023 19:41:37 -0300 Subject: [PATCH 4/4] chore: Update gem version --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e8268c7..749c6d1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - lennarb (0.1.4) + lennarb (0.1.5) colorize (~> 1.1) puma (~> 6.4) rack (~> 3.0, >= 3.0.8)