feature_pack 0.10.0 → 0.10.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 +4 -4
- data/README.md +62 -0
- data/lib/generators/feature_pack/add_feature/add_feature_generator.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c48de284c1d9224798b073645f3a80e923d4e72445272641f644e8ed15bb6bf
|
4
|
+
data.tar.gz: 9c8c489303a5f0a878c756abbc6abb03b8c6073e3cb8a1beda43eeaba0705365
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76ac5cdd3bcb0a241cbc40cd12ad11edbf94e267142e5d2a0e30e26a4b71462c9ae2cc58f0244034ec8d862d7ae8a67f70047273540eab4592e195e6085ca7fe
|
7
|
+
data.tar.gz: f021bce17beadad88f4501768d2021e65e2393db17cd625053ad51e0cfff334555041d055c867517317f52cf79f78b647fe1fa38620f0427c112f8184094e6c1
|
data/README.md
CHANGED
@@ -247,6 +247,68 @@ Access aliased constants:
|
|
247
247
|
@feature.service # => FeaturePack::HumanResources::Employees::EmployeeService
|
248
248
|
```
|
249
249
|
|
250
|
+
## Hooks
|
251
|
+
|
252
|
+
### after_initialize Hook
|
253
|
+
|
254
|
+
O FeaturePack suporta hooks `after_initialize` que permitem executar código customizado após o carregamento de grupos e features.
|
255
|
+
|
256
|
+
#### Como Funciona
|
257
|
+
|
258
|
+
Durante o processo de setup do FeaturePack, após todos os grupos e features serem descobertos e configurados, o sistema procura e executa arquivos `__after_initialize.rb` específicos.
|
259
|
+
|
260
|
+
#### Localização dos Arquivos
|
261
|
+
|
262
|
+
- **Para grupos**: `app/feature_packs/[nome_do_grupo]/_group_space/__after_initialize.rb`
|
263
|
+
- **Para features**: `app/feature_packs/[nome_do_grupo]/[nome_da_feature]/__after_initialize.rb`
|
264
|
+
|
265
|
+
#### Contexto de Execução
|
266
|
+
|
267
|
+
Os arquivos `__after_initialize.rb` são executados no contexto do objeto group ou feature, permitindo acesso direto a todas as suas propriedades através de `self`.
|
268
|
+
|
269
|
+
#### Exemplos de Uso
|
270
|
+
|
271
|
+
**Hook para grupo:**
|
272
|
+
```ruby
|
273
|
+
# app/feature_packs/group_241209_human_resources/_group_space/__after_initialize.rb
|
274
|
+
|
275
|
+
# Registrar o grupo em um sistema de auditoria
|
276
|
+
Rails.logger.info "Grupo #{name} carregado com #{features.size} features"
|
277
|
+
|
278
|
+
# Configurar permissões globais do grupo
|
279
|
+
features.each do |feature|
|
280
|
+
Rails.logger.info " - Feature #{feature.name} disponível em #{feature.manifest[:url]}"
|
281
|
+
end
|
282
|
+
|
283
|
+
# Carregar configurações específicas do grupo
|
284
|
+
config_file = File.join(absolute_path, '_group_space', 'config.yml')
|
285
|
+
if File.exist?(config_file)
|
286
|
+
@config = YAML.load_file(config_file)
|
287
|
+
end
|
288
|
+
```
|
289
|
+
|
290
|
+
**Hook para feature:**
|
291
|
+
```ruby
|
292
|
+
# app/feature_packs/group_241209_human_resources/feature_241209_employees/__after_initialize.rb
|
293
|
+
|
294
|
+
# Registrar rotas dinâmicas
|
295
|
+
Rails.logger.info "Feature #{name} inicializada no grupo #{group.name}"
|
296
|
+
|
297
|
+
# Verificar dependências
|
298
|
+
required_gems = %w[devise cancancan]
|
299
|
+
required_gems.each do |gem_name|
|
300
|
+
unless Gem.loaded_specs.key?(gem_name)
|
301
|
+
Rails.logger.warn "Feature #{name} requer a gem #{gem_name}"
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
# Registrar a feature em um sistema de métricas
|
306
|
+
StatsD.increment("features.#{group.name}.#{name}.loaded") if defined?(StatsD)
|
307
|
+
|
308
|
+
# Configurar cache específico da feature
|
309
|
+
Rails.cache.write("feature:#{group.name}:#{name}:loaded_at", Time.current)
|
310
|
+
```
|
311
|
+
|
250
312
|
## Best Practices
|
251
313
|
|
252
314
|
1. **Group Organization**: Group related features that share common functionality
|
@@ -36,8 +36,8 @@ module FeaturePack
|
|
36
36
|
def parse_names
|
37
37
|
@group_name, @feature_name = name.split('/')
|
38
38
|
|
39
|
-
unless @group_name.match?(/^[a-
|
40
|
-
raise Thor::Error, "Group and feature names must be in snake_case format"
|
39
|
+
unless @group_name.match?(/^[a-z][a-z0-9_]*$/) && @feature_name.match?(/^[a-z][a-z0-9_]*$/)
|
40
|
+
raise Thor::Error, "Group and feature names must be in snake_case format (lowercase letters, numbers, and underscores, starting with a letter)"
|
41
41
|
end
|
42
42
|
|
43
43
|
@group_class_name = @group_name.camelcase
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feature_pack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gedean Dias
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-10-06 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activesupport
|
@@ -88,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
requirements: []
|
91
|
-
rubygems_version: 3.7.
|
91
|
+
rubygems_version: 3.7.2
|
92
92
|
specification_version: 4
|
93
93
|
summary: A different approach to organizing Rails app features.
|
94
94
|
test_files: []
|