lennarb 1.4.0 → 1.5.0
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 +4 -4
- data/.github/workflows/coverage.yaml +11 -33
- data/.github/workflows/documentation.yaml +32 -13
- data/.github/workflows/test.yaml +2 -1
- data/.gitignore +9 -0
- data/.yardopts +8 -0
- data/CODE_OF_CONDUCT.md +118 -0
- data/CONTRIBUTING.md +155 -0
- data/README.pt-BR.md +147 -0
- data/Rakefile +35 -2
- data/changelog.md +76 -0
- data/gems.rb +3 -22
- data/guides/getting-started/readme.md +48 -30
- data/guides/mounting-applications/readme.md +38 -0
- data/guides/response/readme.md +6 -6
- data/lennarb.gemspec +5 -2
- data/lib/lennarb/app.rb +253 -0
- data/lib/lennarb/base.rb +314 -0
- data/lib/lennarb/config.rb +52 -0
- data/lib/lennarb/constants.rb +12 -0
- data/lib/lennarb/environment.rb +80 -0
- data/lib/lennarb/errors.rb +17 -0
- data/lib/lennarb/helpers.rb +40 -0
- data/lib/lennarb/hooks.rb +71 -0
- data/lib/lennarb/logger.rb +100 -0
- data/lib/lennarb/middleware/request_logger.rb +117 -0
- data/lib/lennarb/middleware_stack.rb +56 -0
- data/lib/lennarb/parameter_filter.rb +76 -0
- data/lib/lennarb/request.rb +211 -33
- data/lib/lennarb/request_handler.rb +61 -0
- data/lib/lennarb/response.rb +34 -28
- data/lib/lennarb/route_node.rb +58 -4
- data/lib/lennarb/routes.rb +67 -0
- data/lib/lennarb/version.rb +2 -4
- data/lib/lennarb.rb +35 -67
- data/logo/lennarb.svg +11 -0
- data/readme.md +183 -34
- metadata +67 -7
- data/lib/lennarb/constansts.rb +0 -1
- data/logo/lennarb.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b091cfa5731b3dc0b46ecfa6712b9e3ceeae0eedcce9bc97133683162e12ce28
|
4
|
+
data.tar.gz: 49a8957ed5b951e9e9b7d728fb72c9675e1c6d5eb22a897f2d305e106f02dd98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f494fd50eefbe648c73be463054f14995af8d771d593571ca3908aaa8341502433e925d6df74e99c8427a1cad5473a28495d10e45fe4e54e18a10efd1b22edd9
|
7
|
+
data.tar.gz: 4e858da099b1bdb88ad3593aa8354da285a4e33b4c59545dfb394ea84c6623f4d163c5500143fb86accb76356a1c35b67e9972d0a2667fd925dd79b6852e963c
|
@@ -7,52 +7,30 @@ permissions:
|
|
7
7
|
|
8
8
|
env:
|
9
9
|
CONSOLE_OUTPUT: XTerm
|
10
|
-
COVERAGE: PartialSummary
|
11
10
|
BUNDLE_WITH: maintenance
|
12
11
|
|
13
12
|
jobs:
|
14
13
|
test:
|
15
|
-
name:
|
16
|
-
runs-on:
|
17
|
-
|
18
|
-
strategy:
|
19
|
-
matrix:
|
20
|
-
os:
|
21
|
-
- ubuntu
|
22
|
-
- macos
|
23
|
-
|
24
|
-
ruby:
|
25
|
-
- '3.4'
|
14
|
+
name: Coverage Check
|
15
|
+
runs-on: ubuntu-latest
|
26
16
|
|
27
17
|
steps:
|
28
18
|
- uses: actions/checkout@v4
|
29
19
|
- uses: ruby/setup-ruby@v1
|
30
20
|
with:
|
31
|
-
ruby-version:
|
21
|
+
ruby-version: '3.4'
|
32
22
|
bundler-cache: true
|
33
23
|
|
34
24
|
- name: Run tests
|
35
25
|
timeout-minutes: 5
|
36
|
-
run: bundle exec rake
|
26
|
+
run: bundle exec rake test
|
37
27
|
|
38
|
-
-
|
39
|
-
|
40
|
-
|
41
|
-
path: .covered.db
|
42
|
-
|
43
|
-
validate:
|
44
|
-
needs: test
|
45
|
-
runs-on: ubuntu-latest
|
28
|
+
- name: Check coverage threshold
|
29
|
+
timeout-minutes: 1
|
30
|
+
run: bundle exec rake coverage:check
|
46
31
|
|
47
|
-
|
48
|
-
|
49
|
-
- uses: ruby/setup-ruby@v1
|
32
|
+
- name: Upload coverage reports
|
33
|
+
uses: actions/upload-artifact@v4
|
50
34
|
with:
|
51
|
-
|
52
|
-
|
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 \;
|
35
|
+
name: coverage-report
|
36
|
+
path: coverage
|
@@ -4,11 +4,16 @@ on:
|
|
4
4
|
push:
|
5
5
|
branches:
|
6
6
|
- main
|
7
|
-
|
8
|
-
|
7
|
+
paths:
|
8
|
+
- 'lib/**'
|
9
|
+
- '*.md'
|
10
|
+
- 'logo/**'
|
11
|
+
- '.yardopts'
|
12
|
+
- '.github/workflows/documentation.yaml'
|
13
|
+
workflow_dispatch:
|
9
14
|
|
10
15
|
permissions:
|
11
|
-
contents:
|
16
|
+
contents: write
|
12
17
|
pages: write
|
13
18
|
id-token: write
|
14
19
|
|
@@ -25,23 +30,37 @@ jobs:
|
|
25
30
|
runs-on: ubuntu-latest
|
26
31
|
|
27
32
|
steps:
|
28
|
-
-
|
33
|
+
- name: Checkout code
|
34
|
+
uses: actions/checkout@v4
|
35
|
+
with:
|
36
|
+
fetch-depth: 0
|
29
37
|
|
30
|
-
-
|
38
|
+
- name: Set up Ruby
|
39
|
+
uses: ruby/setup-ruby@v1
|
31
40
|
with:
|
32
41
|
ruby-version: '3.4'
|
33
42
|
bundler-cache: true
|
34
43
|
|
35
|
-
- name:
|
36
|
-
run:
|
37
|
-
|
38
|
-
- name: Prepare GitHub Pages
|
39
|
-
run: bundle exec bake github:pages:prepare --directory docs
|
44
|
+
- name: Install dependencies
|
45
|
+
run: bundle install
|
40
46
|
|
41
47
|
- name: Generate documentation
|
42
48
|
timeout-minutes: 5
|
43
|
-
run:
|
49
|
+
run: |
|
50
|
+
bundle exec yard doc
|
51
|
+
echo "Documentation generated successfully"
|
44
52
|
|
45
|
-
|
46
|
-
|
53
|
+
if [ -f "doc/logo/lennarb.svg" ]; then
|
54
|
+
echo "Logo file successfully included in documentation"
|
55
|
+
else
|
56
|
+
echo "Warning: Logo file not found in generated documentation"
|
57
|
+
exit 1
|
58
|
+
fi
|
47
59
|
|
60
|
+
- name: Deploy to GitHub Pages
|
61
|
+
uses: JamesIves/github-pages-deploy-action@v4
|
62
|
+
with:
|
63
|
+
folder: doc
|
64
|
+
branch: gh-pages
|
65
|
+
clean: true
|
66
|
+
commit-message: "docs: update documentation [skip ci]"
|
data/.github/workflows/test.yaml
CHANGED
data/.gitignore
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
2
5
|
/pkg/
|
3
6
|
/gems.locked
|
4
7
|
/.covered.db
|
5
8
|
/external
|
6
9
|
/docs
|
10
|
+
/.ruby-lsp
|
11
|
+
doc/
|
7
12
|
.DS_Store
|
8
13
|
*.gem
|
9
14
|
*.rbc
|
10
15
|
.git
|
11
16
|
.ruby-lsp
|
12
17
|
coverage/
|
18
|
+
tmp/
|
19
|
+
!tmp/.keep
|
20
|
+
.yardo/
|
21
|
+
minitestfailures
|
data/.yardopts
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
14
|
+
|
15
|
+
## Our Standards
|
16
|
+
|
17
|
+
Examples of behavior that contributes to a positive environment include:
|
18
|
+
|
19
|
+
* Demonstrating empathy and kindness toward other people
|
20
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
21
|
+
* Giving and gracefully accepting constructive feedback
|
22
|
+
* Accepting responsibility and apologizing to those affected by our mistakes
|
23
|
+
* Focusing on what is best for the community
|
24
|
+
|
25
|
+
Examples of unacceptable behavior include:
|
26
|
+
|
27
|
+
* The use of sexualized language or imagery, and sexual attention or advances
|
28
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
29
|
+
* Public or private harassment
|
30
|
+
* Publishing others' private information without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Enforcement Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying and enforcing standards of
|
37
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
38
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
39
|
+
or harmful.
|
40
|
+
|
41
|
+
## Scope
|
42
|
+
|
43
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
44
|
+
an individual is officially representing the community in public spaces.
|
45
|
+
|
46
|
+
## Enforcement
|
47
|
+
|
48
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
49
|
+
reported to the project team. All complaints will be reviewed and investigated
|
50
|
+
promptly and fairly.
|
51
|
+
|
52
|
+
## Attribution
|
53
|
+
|
54
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
|
55
|
+
version 2.0, available at
|
56
|
+
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
|
57
|
+
|
58
|
+
---
|
59
|
+
|
60
|
+
# Código de Conduta
|
61
|
+
|
62
|
+
## Nossa Promessa
|
63
|
+
|
64
|
+
Nós, como membros, contribuidores e líderes, comprometemo-nos a fazer a
|
65
|
+
participação em nossa comunidade uma experiência livre de assédio para todos,
|
66
|
+
independentemente de idade, corpo, deficiência visível ou invisível, etnia,
|
67
|
+
características sexuais, identidade de gênero e expressão,
|
68
|
+
nível de experiência, educação, situação socioeconômica, nacionalidade,
|
69
|
+
aparência pessoal, raça, religião ou identidade e orientação sexual.
|
70
|
+
|
71
|
+
Comprometemo-nos a agir e interagir de maneiras que contribuam para uma
|
72
|
+
comunidade aberta, acolhedora, diversificada, inclusiva e saudável.
|
73
|
+
|
74
|
+
## Nossos Padrões
|
75
|
+
|
76
|
+
Exemplos de comportamento que contribuem para um ambiente positivo:
|
77
|
+
|
78
|
+
* Demonstrar empatia e bondade com outras pessoas
|
79
|
+
* Respeitar opiniões, pontos de vista e experiências divergentes
|
80
|
+
* Dar e receber feedback construtivo de forma graciosa
|
81
|
+
* Assumir responsabilidade e pedir desculpas aos afetados por nossos erros
|
82
|
+
* Focar no que é melhor para a comunidade
|
83
|
+
|
84
|
+
Exemplos de comportamento inaceitável:
|
85
|
+
|
86
|
+
* Uso de linguagem ou imagens sexualizadas e atenção ou avanços sexuais
|
87
|
+
* Comentários insultuosos/depreciativos e ataques pessoais ou políticos
|
88
|
+
* Assédio público ou privado
|
89
|
+
* Publicar informações privadas de outros sem permissão explícita
|
90
|
+
* Outras condutas que possam ser razoavelmente consideradas inadequadas em um
|
91
|
+
ambiente profissional
|
92
|
+
|
93
|
+
## Responsabilidades de Aplicação
|
94
|
+
|
95
|
+
Os mantenedores do projeto são responsáveis por esclarecer e aplicar
|
96
|
+
nossos padrões de comportamento aceitável e tomarão ações corretivas
|
97
|
+
apropriadas e justas em resposta a qualquer comportamento que considerem
|
98
|
+
inapropriado, ameaçador, ofensivo ou prejudicial.
|
99
|
+
|
100
|
+
## Escopo
|
101
|
+
|
102
|
+
Este Código de Conduta se aplica em todos os espaços comunitários e também
|
103
|
+
quando um indivíduo está representando oficialmente a comunidade em espaços
|
104
|
+
públicos.
|
105
|
+
|
106
|
+
## Aplicação
|
107
|
+
|
108
|
+
Instâncias de comportamento abusivo, assediador ou de outra forma
|
109
|
+
inaceitável podem ser reportadas à equipe do projeto. Todas as reclamações
|
110
|
+
serão analisadas e investigadas prontamente e de forma justa.
|
111
|
+
|
112
|
+
## Atribuição
|
113
|
+
|
114
|
+
Este Código de Conduta é adaptado do
|
115
|
+
[Contributor Covenant](https://www.contributor-covenant.org),
|
116
|
+
versão 2.0, disponível em
|
117
|
+
<https://www.contributor-covenant.org/version/2/0/code_of_conduct.html>.
|
118
|
+
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
# Contributing to Lennarb
|
2
|
+
|
3
|
+
We love your input! We want to make contributing to Lennarb as easy and
|
4
|
+
transparent as possible, whether it's:
|
5
|
+
|
6
|
+
- Reporting a bug
|
7
|
+
- Discussing the current state of the code
|
8
|
+
- Submitting a fix
|
9
|
+
- Proposing new features
|
10
|
+
- Becoming a maintainer
|
11
|
+
|
12
|
+
## Development Process
|
13
|
+
|
14
|
+
We use GitHub to host code, to track issues and feature requests, as well as accept pull requests.
|
15
|
+
|
16
|
+
### Pull Requests
|
17
|
+
|
18
|
+
1. Fork the repository
|
19
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
20
|
+
3. Commit your changes (`git commit -am 'Add amazing feature'`)
|
21
|
+
4. Push to the branch (`git push origin feature/amazing-feature`)
|
22
|
+
5. Open a Pull Request
|
23
|
+
|
24
|
+
### Pull Request Process
|
25
|
+
|
26
|
+
1. Ensure any install or build dependencies are removed before the end of
|
27
|
+
the layer when doing a build.
|
28
|
+
2. Update the `README.md` with details of changes to the interface, this
|
29
|
+
includes new environment variables, exposed ports, useful file locations,
|
30
|
+
and container parameters.
|
31
|
+
3. Increase the version numbers in any examples files and the `README.md`
|
32
|
+
to the new version that this Pull Request would represent. The versioning
|
33
|
+
scheme we use is [SemVer](http://semver.org/).
|
34
|
+
4. You may merge the Pull Request once you have the sign-off of at least one
|
35
|
+
other developer, or if you do not have permission to do that, you may request
|
36
|
+
the reviewer to merge it for you.
|
37
|
+
|
38
|
+
## Reporting Bugs
|
39
|
+
|
40
|
+
We use GitHub issues to track public bugs. Report a bug by opening a new issue;
|
41
|
+
it's that easy!
|
42
|
+
|
43
|
+
### Bug Report Template
|
44
|
+
|
45
|
+
**Title**: Short description of the bug
|
46
|
+
|
47
|
+
**Description**:
|
48
|
+
|
49
|
+
- **Current Behavior**: A clear and concise description of what the bug is.
|
50
|
+
- **Expected Behavior**: A clear and concise description of what you
|
51
|
+
expected to happen.
|
52
|
+
- **Steps To Reproduce**: Steps to reproduce the behavior:
|
53
|
+
1. Go to '...'
|
54
|
+
2. Click on '....'
|
55
|
+
3. Scroll down to '....'
|
56
|
+
4. See error
|
57
|
+
- **Environment**:
|
58
|
+
- Ruby version:
|
59
|
+
- OS:
|
60
|
+
- Lennarb version:
|
61
|
+
- **Additional Context**: Add any other context about the problem here.
|
62
|
+
|
63
|
+
## Code Style
|
64
|
+
|
65
|
+
Maintain the code style used throughout the project:
|
66
|
+
|
67
|
+
- Follow Ruby style guidelines
|
68
|
+
- Use meaningful variable and function names
|
69
|
+
- Comment your code when necessary
|
70
|
+
- Keep your code clean and maintainable
|
71
|
+
|
72
|
+
## License
|
73
|
+
|
74
|
+
By contributing, you agree that your contributions will be licensed under
|
75
|
+
the project's MIT License.
|
76
|
+
|
77
|
+
---
|
78
|
+
|
79
|
+
## Contribuindo para o Lennarb - Português
|
80
|
+
|
81
|
+
Adoramos seu input! Queremos tornar a contribuição para o Lennarb o
|
82
|
+
mais fácil e transparente possível, seja:
|
83
|
+
|
84
|
+
- Reportando um bug
|
85
|
+
- Discutindo o estado atual do código
|
86
|
+
- Enviando uma correção
|
87
|
+
- Propondo novos recursos
|
88
|
+
- Tornando-se um mantenedor
|
89
|
+
|
90
|
+
## Processo de Desenvolvimento
|
91
|
+
|
92
|
+
Usamos o GitHub para hospedar código, rastrear problemas e solicitações de
|
93
|
+
recursos, bem como aceitar pull requests.
|
94
|
+
|
95
|
+
### Solicitações de Pull Request
|
96
|
+
|
97
|
+
1. Faça um fork do repositório
|
98
|
+
2. Crie sua branch de recurso (`git checkout -b feature/recurso-incrivel`)
|
99
|
+
3. Faça commit de suas alterações (`git commit -am 'Adicionar recurso incrível'`)
|
100
|
+
4. Envie para a branch (`git push origin feature/recurso-incrivel`)
|
101
|
+
5. Abra um Pull Request
|
102
|
+
|
103
|
+
### Processo de Pull Request
|
104
|
+
|
105
|
+
1. Certifique-se de que todas as dependências de instalação ou compilação
|
106
|
+
sejam removidas antes do fim da camada ao fazer uma compilação.
|
107
|
+
2. Atualize o README.md com detalhes das alterações na interface, incluindo
|
108
|
+
novas variáveis de ambiente, portas expostas, localizações úteis de arquivos
|
109
|
+
e parâmetros de contêiner.
|
110
|
+
3. Aumente os números de versão em quaisquer arquivos de exemplos e o
|
111
|
+
`README.md` para a nova versão que este Pull Request representaria. O esquema
|
112
|
+
de versionamento que usamos é [SemVer](http://semver.org/).
|
113
|
+
4. Você pode mesclar o Pull Request depois de ter a aprovação de pelo menos um
|
114
|
+
outro desenvolvedor, ou se não tiver permissão para isso, poderá solicitar ao
|
115
|
+
revisor que o mescle para você.
|
116
|
+
|
117
|
+
## Reportando Bugs
|
118
|
+
|
119
|
+
Usamos issues do GitHub para rastrear bugs públicos. Reporte um bug abrindo
|
120
|
+
uma nova issue; é simples assim!
|
121
|
+
|
122
|
+
### Modelo de Relatório de Bug
|
123
|
+
|
124
|
+
**Título**: Breve descrição do bug
|
125
|
+
|
126
|
+
**Descrição**:
|
127
|
+
|
128
|
+
- **Comportamento Atual**: Uma descrição clara e concisa do bug.
|
129
|
+
- **Comportamento Esperado**: Uma descrição clara e concisa do que você
|
130
|
+
esperava que acontecesse.
|
131
|
+
- **Passos Para Reproduzir**: Passos para reproduzir o comportamento:
|
132
|
+
1. Vá para '...'
|
133
|
+
2. Clique em '....'
|
134
|
+
3. Role para baixo até '....'
|
135
|
+
4. Veja o erro
|
136
|
+
- **Ambiente**:
|
137
|
+
- Versão do Ruby:
|
138
|
+
- Sistema Operacional:
|
139
|
+
- Versão do Lennarb:
|
140
|
+
- **Contexto Adicional**: Adicione qualquer outro contexto sobre o problema aqui.
|
141
|
+
|
142
|
+
## Estilo de Código
|
143
|
+
|
144
|
+
Mantenha o estilo de código usado em todo o projeto:
|
145
|
+
|
146
|
+
- Siga as diretrizes de estilo Ruby
|
147
|
+
- Use nomes significativos para variáveis e funções
|
148
|
+
- Comente seu código quando necessário
|
149
|
+
- Mantenha seu código limpo e de fácil manutenção
|
150
|
+
|
151
|
+
## Licença
|
152
|
+
|
153
|
+
Ao contribuir, você concorda que suas contribuições serão licenciadas sob a
|
154
|
+
Licença MIT do projeto.
|
155
|
+
|
data/README.pt-BR.md
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<picture>
|
3
|
+
<img alt="Lennarb" src="logo/lennarb.svg" width="250">
|
4
|
+
</picture>
|
5
|
+
|
6
|
+
---
|
7
|
+
|
8
|
+
Um framework web leve, rápido e modular para Ruby baseado em Rack. **Lennarb** suporta Ruby (MRI) 3.4+
|
9
|
+
|
10
|
+
[](https://github.com/aristotelesbr/lennarb/actions/workflows/test.yaml)
|
11
|
+
[](https://rubygems.org/gems/lennarb)
|
12
|
+
[](https://rubygems.org/gems/lennarb)
|
13
|
+
[](https://tldrlegal.com/license/mit-license)
|
14
|
+
|
15
|
+
</div>
|
16
|
+
|
17
|
+
## Índice
|
18
|
+
|
19
|
+
- [Características](#características)
|
20
|
+
- [Instalação](#instalação)
|
21
|
+
- [Início Rápido](#início-rápido)
|
22
|
+
- [Performance](#performance)
|
23
|
+
- [Documentação](#documentação)
|
24
|
+
- [Contribuindo](#contribuindo)
|
25
|
+
- [Licença](#licença)
|
26
|
+
|
27
|
+
## Características
|
28
|
+
|
29
|
+
- Arquitetura leve e modular
|
30
|
+
- Sistema de roteamento de alta performance
|
31
|
+
- API simples e intuitiva
|
32
|
+
- Suporte para middleware
|
33
|
+
- Opções de configuração flexíveis
|
34
|
+
- Duas opções de implementação:
|
35
|
+
- `Lennarb::App`: Abordagem minimalista para controle completo
|
36
|
+
- `Lennarb::Application`: Versão estendida com componentes comuns
|
37
|
+
|
38
|
+
## Opções de Implementação
|
39
|
+
|
40
|
+
Lennarb oferece duas abordagens de implementação para atender diferentes necessidades:
|
41
|
+
|
42
|
+
- **Lennarb::App**: Abordagem minimalista para controle completo
|
43
|
+
- **Lennarb::Application**: Versão estendida com componentes comuns
|
44
|
+
|
45
|
+
Consulte a [documentação](https://aristotelesbr.github.io/lennarb/guides/getting-started/index) para detalhes sobre cada implementação.
|
46
|
+
|
47
|
+
## Instalação
|
48
|
+
|
49
|
+
Adicione esta linha ao Gemfile da sua aplicação:
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
gem 'lennarb'
|
53
|
+
```
|
54
|
+
|
55
|
+
Ou instale diretamente:
|
56
|
+
|
57
|
+
```bash
|
58
|
+
gem install lennarb
|
59
|
+
```
|
60
|
+
|
61
|
+
## Guia Rápido
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
require "lennarb"
|
65
|
+
|
66
|
+
app = Lennarb::App.new do
|
67
|
+
configure do
|
68
|
+
mandary :database_url, string
|
69
|
+
optional :port, integer, 9292
|
70
|
+
optional :env, string, "development"
|
71
|
+
end
|
72
|
+
|
73
|
+
routes do
|
74
|
+
get("/") do |req, res|
|
75
|
+
res.html("<h1>Bem-vindo ao Lennarb!</h1>")
|
76
|
+
end
|
77
|
+
|
78
|
+
get("/hello/:name") do |req, res|
|
79
|
+
name = req.params[:name]
|
80
|
+
res.html("Olá, #{name}!")
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
app.initialize!
|
86
|
+
run app # Em config.ru
|
87
|
+
```
|
88
|
+
|
89
|
+
Inicie com: `rackup`
|
90
|
+
|
91
|
+
## Performance
|
92
|
+
|
93
|
+
Lennarb é projetado para alta performance:
|
94
|
+
|
95
|
+

|
96
|
+
|
97
|
+
| Posição | Aplicação | 10 RPS | 100 RPS | 1.000 RPS | 10.000 RPS |
|
98
|
+
| ------- | ---------- | ---------- | ---------- | --------- | ---------- |
|
99
|
+
| 1 | Lenna | 126.252,36 | 108.086,55 | 87.111,91 | 68.460,64 |
|
100
|
+
| 2 | Roda | 123.360,37 | 88.380,56 | 66.990,77 | 48.108,29 |
|
101
|
+
| 3 | Syro | 114.105,38 | 80.909,39 | 61.415,86 | 46.639,81 |
|
102
|
+
| 4 | Hanami-API | 68.089,18 | 52.851,88 | 40.801,78 | 27.996,00 |
|
103
|
+
|
104
|
+
Veja todos os [gráficos de benchmark](https://github.com/aristotelesbr/lennarb/blob/main/benchmark)
|
105
|
+
|
106
|
+
## Documentação
|
107
|
+
|
108
|
+
- [Primeiros Passos](https://aristotelesbr.github.io/lennarb/guides/getting-started/index) - Configuração e primeiros passos
|
109
|
+
- [Performance](https://aristotelesbr.github.io/lennarb/guides/performance/index.html) - Benchmarks e otimização
|
110
|
+
- [Response](https://aristotelesbr.github.io/lennarb/guides/response/index.html) - Tratamento de respostas
|
111
|
+
- [Request](https://aristotelesbr.github.io/lennarb/guides/request/index.html) - Tratamento de requisições
|
112
|
+
|
113
|
+
## Funcionalidades Principais
|
114
|
+
|
115
|
+
```ruby
|
116
|
+
# Diferentes tipos de resposta
|
117
|
+
res.html("<h1>Olá Mundo</h1>")
|
118
|
+
res.json("{\"mensagem\": \"Olá Mundo\"}")
|
119
|
+
res.text("Resposta em texto simples")
|
120
|
+
|
121
|
+
# Parâmetros de rota
|
122
|
+
get("/usuarios/:id") do |req, res|
|
123
|
+
user_id = req.params[:id]
|
124
|
+
res.json("{\"id\": #{user_id}}")
|
125
|
+
end
|
126
|
+
|
127
|
+
# Redirecionamentos
|
128
|
+
res.redirect("/nova-localizacao")
|
129
|
+
```
|
130
|
+
|
131
|
+
Para mais exemplos e documentação completa, consulte:
|
132
|
+
[Documentação Completa do Lennarb](https://aristotelesbr.github.io/lennarb/guides/getting-started/index)
|
133
|
+
|
134
|
+
## Contribuindo
|
135
|
+
|
136
|
+
1. Faça um fork do repositório
|
137
|
+
2. Crie sua branch de feature (`git checkout -b feature/recurso-incrivel`)
|
138
|
+
3. Commit suas alterações (`git commit -am 'Adiciona recurso incrível'`)
|
139
|
+
4. Push para a branch (`git push origin feature/recurso-incrivel`)
|
140
|
+
5. Abra um Pull Request
|
141
|
+
|
142
|
+
Este projeto utiliza o [Developer Certificate of Origin](https://developercertificate.org/) e é regido pelo [Contributor Covenant](https://www.contributor-covenant.org/).
|
143
|
+
|
144
|
+
## Licença
|
145
|
+
|
146
|
+
Licença MIT - veja o arquivo [LICENSE](LICENSE) para detalhes.
|
147
|
+
|
data/Rakefile
CHANGED
@@ -1,10 +1,43 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require "standard/rake"
|
2
3
|
require "rake/testtask"
|
3
4
|
|
4
|
-
Rake::TestTask.new
|
5
|
+
Rake::TestTask.new do |t|
|
5
6
|
t.libs << "test"
|
6
7
|
t.libs << "lib"
|
7
8
|
t.test_files = FileList["test/**/*_test.rb"]
|
9
|
+
t.verbose = false
|
8
10
|
end
|
9
11
|
|
10
|
-
|
12
|
+
namespace :coverage do
|
13
|
+
desc "Validate code coverage meets minimum threshold (85%)"
|
14
|
+
task :check do
|
15
|
+
require "json"
|
16
|
+
|
17
|
+
puts "Validating code coverage..."
|
18
|
+
|
19
|
+
coverage_dir = "coverage"
|
20
|
+
coverage_json = File.join(coverage_dir, "coverage.json")
|
21
|
+
|
22
|
+
unless File.exist?(coverage_json)
|
23
|
+
puts "Error: Coverage JSON data not found at #{coverage_json}."
|
24
|
+
puts "Run tests with SimpleCov enabled first."
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
|
28
|
+
data = JSON.parse(File.read(coverage_json))
|
29
|
+
percent = data["metrics"]["covered_percent"].to_f.round(2)
|
30
|
+
|
31
|
+
puts "Coverage: #{percent}%"
|
32
|
+
|
33
|
+
threshold = 85
|
34
|
+
if percent < threshold
|
35
|
+
puts "Coverage is below the required #{threshold}% threshold!"
|
36
|
+
exit 1
|
37
|
+
else
|
38
|
+
puts "Coverage meets the required threshold. Good job!"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
task default: :test
|