lennarb 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0fafe6e0a4a4fcb12d0cb7d75187b89c5ff2a8f4847bdab4db666d670fd1d40e
4
- data.tar.gz: 43739df71271e6410f691b19d0e31c64ea5e883ae79150a3d0055d17a200fe8a
3
+ metadata.gz: cd39c745c65bf722a7075f57bbd36a2a603b659ddecb23bac33b7733c0b912e2
4
+ data.tar.gz: 723a60bc0e9cf0ed60c3f548e8e9004310a29c3c36c63b6ab55308ca99c83da3
5
5
  SHA512:
6
- metadata.gz: 8015dceb914f8bf52ee77eff7faf3adca26cdb020a3acba0ce3cc58ecd7eec338e84afe87fcd691867e087a646875b06a9f278c220b25f4f627bc87ff7288306
7
- data.tar.gz: c9a7b74731ac3fe4e607396647931656628e1df03968069891d65189b0f387df44d89054191a34a41bdaf7a3381ad6c2486f91fba13dfd4b5a3b04a79f299af7
6
+ metadata.gz: 901cfe54fe27ea6addd4b48690f3cd12b73a9f85e05066f9382f6467e65e537760509958bfb4ffd23cc2ab523168428dd3c2b50027c523b8cfb15b3c1af1b4a0
7
+ data.tar.gz: c877fb10d4a3f918016390b43fcc54ed3b70fb8c38577b23a4c34b1820f3c2d898c685f738de1f6c7ff6e2c25066b2fb95e8020ef7a00c22a02f0c5f847fa76b
@@ -0,0 +1,8 @@
1
+ # Released under the MIT License.
2
+ # Copyright, 2023, by Aristóteles Coutinho.
3
+
4
+ # [Choice] Ruby version: 3, 3.0, 2, 2.7, 2.6
5
+ ARG VARIANT="3"
6
+ FROM mcr.microsoft.com/devcontainers/ruby:${VARIANT}
7
+
8
+ RUN apt-get update
@@ -0,0 +1,20 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2
+ // README at: https://github.com/devcontainers/templates/tree/main/src/ruby
3
+ {
4
+ "name": "Lennarb project development",
5
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
6
+ // "image": "mcr.microsoft.com/devcontainers/ruby:1-3.2-bullseye"
7
+ "build": {
8
+ "dockerfile": "Dockerfile"
9
+ }
10
+ // Features to add to the dev container. More info: https://containers.dev/features.
11
+ // "features": {},
12
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
13
+ // "forwardPorts": [],
14
+ // Use 'postCreateCommand' to run commands after the container is created.
15
+ // "postCreateCommand": "ruby --version",
16
+ // Configure tool-specific properties.
17
+ // "customizations": {},
18
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
19
+ // "remoteUser": "root"
20
+ }
data/.editorconfig ADDED
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+
7
+ [*.{yml,yaml}]
8
+ indent_style = space
9
+ indent_size = 2
@@ -0,0 +1,58 @@
1
+ name: Coverage
2
+
3
+ on: [push, pull_request]
4
+
5
+ permissions:
6
+ contents: read
7
+
8
+ env:
9
+ CONSOLE_OUTPUT: XTerm
10
+ COVERAGE: PartialSummary
11
+ BUNDLE_WITH: maintenance
12
+
13
+ jobs:
14
+ test:
15
+ name: ${{matrix.ruby}} on ${{matrix.os}}
16
+ runs-on: ${{matrix.os}}-latest
17
+
18
+ strategy:
19
+ matrix:
20
+ os:
21
+ - ubuntu
22
+ - macos
23
+
24
+ ruby:
25
+ - '3.4'
26
+
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+ - uses: ruby/setup-ruby@v1
30
+ with:
31
+ ruby-version: ${{matrix.ruby}}
32
+ bundler-cache: true
33
+
34
+ - name: Run tests
35
+ timeout-minutes: 5
36
+ run: bundle exec rake
37
+
38
+ - uses: actions/upload-artifact@v4
39
+ with:
40
+ name: coverage-${{matrix.os}}-${{matrix.ruby}}
41
+ path: .covered.db
42
+
43
+ validate:
44
+ needs: test
45
+ runs-on: ubuntu-latest
46
+
47
+ steps:
48
+ - uses: actions/checkout@v4
49
+ - uses: ruby/setup-ruby@v1
50
+ with:
51
+ ruby-version: '3.4'
52
+ bundler-cache: true
53
+
54
+ - uses: actions/download-artifact@v4
55
+
56
+ - name: Validate coverage
57
+ timeout-minutes: 5
58
+ run: bundle exec bake covered:validate --paths */.covered.db \;
@@ -0,0 +1,47 @@
1
+ name: Documentation
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+ pages: write
13
+ id-token: write
14
+
15
+ concurrency:
16
+ group: 'pages'
17
+ cancel-in-progress: true
18
+
19
+ env:
20
+ CONSOLE_OUTPUT: XTerm
21
+ BUNDLE_WITH: maintenance
22
+
23
+ jobs:
24
+ generate:
25
+ runs-on: ubuntu-latest
26
+
27
+ steps:
28
+ - uses: actions/checkout@v4
29
+
30
+ - uses: ruby/setup-ruby@v1
31
+ with:
32
+ ruby-version: '3.4'
33
+ bundler-cache: true
34
+
35
+ - name: Installing packages
36
+ run: sudo apt-get install wget
37
+
38
+ - name: Prepare GitHub Pages
39
+ run: bundle exec bake github:pages:prepare --directory docs
40
+
41
+ - name: Generate documentation
42
+ timeout-minutes: 5
43
+ run: bundle exec bake utopia:project:static --force no
44
+
45
+ - name: Deploy GitHub Pages
46
+ run: bundle exec bake github:pages:commit --directory docs
47
+
@@ -0,0 +1,27 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ pull_request:
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+ name: Ruby ${{ matrix.ruby }}
14
+ strategy:
15
+ matrix:
16
+ ruby:
17
+ - '3.4'
18
+
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - name: Set up Ruby
22
+ uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - name: Run the default task
27
+ run: bundle exec rake test
@@ -0,0 +1,50 @@
1
+ name: Test
2
+
3
+ on: [push, pull_request]
4
+
5
+ permissions:
6
+ contents: read
7
+
8
+ env:
9
+ CONSOLE_OUTPUT: XTerm
10
+
11
+ jobs:
12
+ test:
13
+ name: ${{matrix.ruby}} on ${{matrix.os}}
14
+ runs-on: ${{matrix.os}}-latest
15
+ continue-on-error: ${{matrix.experimental}}
16
+
17
+ strategy:
18
+ matrix:
19
+ os:
20
+ - ubuntu
21
+ - macos
22
+
23
+ ruby:
24
+ - '3.4'
25
+
26
+ experimental: [false]
27
+
28
+ include:
29
+ - os: ubuntu
30
+ ruby: truffleruby
31
+ experimental: true
32
+ - os: ubuntu
33
+ ruby: jruby
34
+ experimental: true
35
+ - os: ubuntu
36
+ ruby: head
37
+ experimental: true
38
+
39
+ steps:
40
+ - uses: actions/checkout@v4
41
+ - uses: ruby/setup-ruby@v1
42
+ with:
43
+ ruby-version: ${{matrix.ruby}}
44
+ bundler-cache: true
45
+
46
+ - name: Run tests
47
+ timeout-minutes: 10
48
+ run: bundle exec rake test
49
+ - name: Run linter
50
+ run: bundle exec rake standard
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /pkg/
3
+ /gems.locked
4
+ /.covered.db
5
+ /external
6
+ /docs
7
+ .DS_Store
8
+ *.gem
9
+ *.rbc
10
+ .git
11
+ .ruby-lsp
12
+ coverage/
data/.standard.yml ADDED
@@ -0,0 +1,23 @@
1
+ ruby_version: 3.4.1
2
+
3
+ ignore:
4
+ - 'bin/**/*'
5
+ - 'vendor/**/*'
6
+ - 'db/schema.rb'
7
+
8
+ plugins:
9
+ - standard-custom
10
+ - standard-performance
11
+
12
+ standard_custom:
13
+ rules:
14
+ lambda_call_style:
15
+ enabled: false
16
+ style: "call"
17
+
18
+ lambda_syntax:
19
+ enabled: false
20
+ style: "line_count_dependent"
21
+
22
+ copyright_notice:
23
+ enabled: false
data/.tool-versions ADDED
@@ -0,0 +1 @@
1
+ ruby 3.4.1
data/LICENCE ADDED
@@ -0,0 +1,24 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023, Aristóteles Coutinho costa
4
+
5
+ Permission is hereby granted, free of charge, to any person
6
+ obtaining a copy of this software and associated documentation
7
+ files (the "Software"), to deal in the Software without
8
+ restriction, including without limitation the rights to use,
9
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the
11
+ Software is furnished to do so, subject to the following
12
+ conditions:
13
+
14
+ The above copyright notice and this permission notice shall be
15
+ included in all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24
+ OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+ require "standard/rake"
3
+ require "rake/testtask"
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << "test"
7
+ t.libs << "lib"
8
+ t.test_files = FileList["test/**/*_test.rb"]
9
+ t.verbose = true
10
+ end
11
+
12
+ task default: :test
Binary file
data/benchmark/rps.png ADDED
Binary file
Binary file
data/bin/console ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/lennarb"
4
+ # You can add fixtures and/or initialization code here to make experimenting
5
+ # with your gem easier. You can also use a different console, if you like.
6
+
7
+ require "irb"
8
+ IRB.start(__FILE__)
data/bin/release ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'lennarb/version'
4
+ require 'colorize'
5
+
6
+ puts 'Generating gem version...'.green
7
+ system('bundle exec gem build lennarb.gemspec')
8
+ puts 'Gem version generated successfully'.green
9
+
10
+ puts 'Installing gem version...'.green
11
+
12
+ version = Lennarb::VERSION
13
+ system("gem install ./lennarb-#{version}.gem")
14
+ puts 'Lenna installed successfully'.green
15
+
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/changelog.md CHANGED
@@ -7,6 +7,77 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.4.1] - 2025-02-23
11
+
12
+ ### Added
13
+
14
+ - Add support to mount routes. Now, you can centralize the routes in a single file and mount them in the main application. Ex.
15
+
16
+ ```rb
17
+ class PostsController
18
+ extend Lennarb::Routes::Mixin
19
+
20
+ get '/posts' do |req, res|
21
+ res.html('Posts')
22
+ end
23
+ end
24
+
25
+ SampleApp = Lennarb.new do |router|
26
+ mount PostsController
27
+ end
28
+ ```
29
+
30
+ The `mount` method will add the routes from the `PostsController` class to the main application. You can use the `mount` method with multiple classes, ex. `mount PostsController, CommentsController`.
31
+
32
+ - Add `Lennarb::Environment` module to manage the environment variables in the project. Now, the `Lennarb` class is the main class of the project.
33
+ - Add `Lennarb::Config` module to manage the configuration in the project. Now, the `Lennarb` class is the main class of the project.
34
+ - Add `Lennarb::App` class.
35
+ - Lint the code with `standard` gem on the CI/CD pipeline.
36
+
37
+ ### Changed
38
+
39
+ - Convert the `Lennarb` class to a module. Now, the `App` class is the main class of the project.
40
+ - Move the request process to `Lennarb::RequestHandler` class.
41
+ - Improve the method `merge!` from `Lennarb::RouterNode` to prevent the duplication of the routes.
42
+
43
+ ### Fixed
44
+
45
+ - Software design issues.
46
+
47
+ ## [1.4.0] - 2025-02-09
48
+
49
+ ### Changed
50
+
51
+ - The `freeze!` method was removed from the `Lennarb` class. Use `initializer!` to build and freeze the application.
52
+
53
+ ```rb
54
+ # app.rb
55
+
56
+ require 'lennarb'
57
+
58
+ MyApp = Lennarb.new do |router|
59
+ router.get '/hello' do |req, res|
60
+ res.html('Hello World')
61
+ end
62
+ end
63
+
64
+ MyApp.initializer!
65
+
66
+ run MyApp
67
+ ```
68
+
69
+ ### Remove
70
+
71
+ - Removes bake scripts from the project. Use `rack'` to run tasks.
72
+ - Removes `plugin` module and basic plugins from the project. Now, the `Lennarb` class is the main class of the project.
73
+ - Removes unnecessary tests.
74
+ - Removes `.rubocop.yml` file from the project. Now, the project uses the default configuration of the `standard` gem.
75
+
76
+ ### Added
77
+
78
+ - Add `simplecov` gem to generate the test coverage report.
79
+ - Add `m` gem to run the tests.
80
+
10
81
  ## [1.3.0] - 2024-11-21
11
82
 
12
83
  ### Added
@@ -78,9 +149,9 @@ That permits to create a new application with the `Lennarb::ApplicationBase` cla
78
149
  require 'lennarb'
79
150
 
80
151
  class MyApp < Lennarb::ApplicationBase
81
- get '/hello' do |req, res|
82
- res.html('Hello World')
83
- end
152
+ get '/hello' do |req, res|
153
+ res.html('Hello World')
154
+ end
84
155
  end
85
156
  ```
86
157
 
@@ -88,7 +159,6 @@ end
88
159
 
89
160
  - Remove `Lennarb::Application` module from the project. Now, the `Lennarb` class is the main class of the project.
90
161
 
91
-
92
162
  ## [0.4.0] - 2024-07-02
93
163
 
94
164
  ### Added
@@ -105,9 +175,9 @@ require 'lennarb'
105
175
  class MyApp
106
176
  include Lennarb::ApplicationBase
107
177
 
108
- get '/hello' do |req, res|
109
- res.html('Hello World')
110
- end
178
+ get '/hello' do |req, res|
179
+ res.html('Hello World')
180
+ end
111
181
  end
112
182
  ```
113
183
 
@@ -144,6 +214,7 @@ end
144
214
  - Add `console` gem to print the logs in the console.
145
215
 
146
216
  - Add CLI module to:
217
+
147
218
  - Create a new project with `lennarb new` command.
148
219
  - Run the server with `lennarb server` command.
149
220
 
data/exe/lenna CHANGED
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
2
 
4
3
  # Released under the MIT License.
5
- # Copyright, 2023, by Aristóteles Coutinho.
4
+ # Copyright, 2023-2025, by Aristóteles Coutinho.
6
5
 
7
6
  # Require the main file
8
7
  #
9
8
  # @private `Since v0.1`
10
9
  #
11
- require 'lennarb'
10
+ require "lennarb"
12
11
 
13
12
  # Show the version
14
13
  #
data/gems.rb ADDED
@@ -0,0 +1,29 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in lennarb.gemspec
4
+ gemspec
5
+
6
+ group :maintenance, optional: true do
7
+ # [https://rubygems.org/gems/bake]
8
+ # Bake is a Ruby library that helps you to create a new project.
9
+ gem "bake"
10
+ # [https://rubygems.org/gems/covered]
11
+ # Covered is a Ruby library that helps you to test your project.
12
+ gem "covered"
13
+ # [https://rubygems.org/gems/bake-gem]
14
+ # Bake Gem is a Bake extension that helps you to create a new Ruby
15
+ # gem.
16
+ gem "bake-gem"
17
+ # [https://rubygems.org/gems/bake-modernize]
18
+ # Bake Modernize is a Bake extension that helps you to modernize your
19
+ # Ruby code.
20
+ gem "bake-modernize"
21
+ # [https://rubygems.org/gems/bake-github-pages]
22
+ # Bake Github Pages is a Bake extension that helps you to publish your
23
+ # project documentation to Github Pages.
24
+ gem "bake-github-pages"
25
+ # [https://rubygems.org/gems/utpia-project]
26
+ # Utopia Project is a Bake extension that helps you to create a new
27
+ # project.
28
+ gem "utopia-project"
29
+ end