bddgenx 0.1.26 → 0.1.29

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: 3f5d88f89154eb31e1556cf63bf26786a1c5d0db825e3a3d6a7e7b09ce053392
4
- data.tar.gz: 8ae7790840345d95d020e63a92cfc3f13e890c7c62d230483f283cb7d0807b10
3
+ metadata.gz: 119bc4e3aa9e3a0022d0e1abd2e7be255a854003e4eaf12f05d59b06611d4ca3
4
+ data.tar.gz: 8d7c69b6884718ddd67ea4af3addfbe99514d3767de9de8c544a24178468dad3
5
5
  SHA512:
6
- metadata.gz: 689a8a8ea39be89e3ed41951421a78ae713dbe3af31f46d9d40871e70c11b383eb3d8cca3de554dc5af80ebc46f1e4a6b29040f2fadf639be29bd121e9a39bc7
7
- data.tar.gz: 5e122e5ba59b8b11b4b17f21451ab3657748735dbb8c7a0fa11c8d1cd2a42f75c3268591ebad5f3d05f9ff791fec488fb21fa0af70ba6560f276a75d282d77be
6
+ metadata.gz: ac392e79d2de7909eb419ade1a2d1a6b9a9466c45daa88353140acb584ef0f266e92356d3b15e03970a73f9c38d9405bb803330892af8ede23812d69460911cc
7
+ data.tar.gz: b0eaad5600fbb00bb83138e9276cce17d202327b72e527f733a670c44698202af1435caaeda3b21eeba9181453912f6c031face99aa8f0047c16fdfbf8fae77f
data/README.md CHANGED
@@ -6,37 +6,31 @@ Este projeto gera arquivos `.feature` (Gherkin) e `steps.rb` automaticamente a p
6
6
 
7
7
  ## 📂 Estrutura do Projeto
8
8
  ```txt
9
- bddgenx/ # raiz do repositório
10
- ├── bin/ # executáveis CLI
11
- │ └── bddgenx # script que chama Bddgenx::Runner.executar
12
- ├── lib/ # código-fonte da gem
13
- ├── bddgenx/ # namespace principal
14
- │ │ ├── parser.rb
15
- ├── validator.rb
16
- ├── generator.rb
17
- │ ├── steps_generator.rb
18
- │ │ ├── tracer.rb
19
- ├── backup.rb
20
- │ │ ├── pdf_exporter.rb
21
- │ │ └── utils/ # helpers e módulos auxiliares
22
- │ │ └── verificador.rb
23
- └── bddgenx.rb # entrypoint: require_relative de tudo
24
- ├── features/ # specs Cucumber para testar a gem
25
- └── support/ # support files para os testes
26
- ├── spec/ or test/ # unit tests (RSpec, Minitest)
27
- ├── input/ # exemplos de .txt de usuários
28
- ├── output/ # artefatos gerados (rastreabilidade.csv, etc.)
29
- ├── pdf/ # PDFs gerados
30
- ├── backup/ # backups automáticos
31
- ├── doc/ # documentação (markdown)
32
- ├── configuracao-padra.md
33
- └── configuracao-rake.md
34
- ├── bddgenx.gemspec # gemspec
35
- ├── Gemfile # dependências de desenvolvimento
36
- ├── Rakefile # tarefas: build, test, release, clean…
37
- ├── .gitignore
38
- └── README.md # descrição, instalação, exemplos de uso
39
-
9
+ bddgenx/
10
+ ├── bin/bddgenx # CLI executável
11
+ ├── input/ # .txt de histórias de usuário
12
+ ├── features/ # .feature geradas
13
+ ├── features/<nome>/steps/ # step definitions por feature (se existir)
14
+ ├── reports/ # todos os artefatos de saída
15
+ │ ├── backup/ # versões antigas de .feature
16
+ │ ├── output/ # rastreabilidade.csv
17
+ └── pdf/ # relatórios camelCase
18
+ ├── lib/
19
+ │ ├── bddgenx/
20
+ │ │ ├── parser.rb
21
+ │ │ ├── validator.rb
22
+ │ │ ├── generator.rb
23
+ │ ├── steps_generator.rb
24
+ │ │ ├── tracer.rb
25
+ │ ├── backup.rb
26
+ │ │ └── pdf_exporter.rb
27
+ │ └── bddgenx.rb # Runner que orquestra tudo
28
+ ├── Gemfile
29
+ ├── bddgenx.gemspec
30
+ ├── Rakefile
31
+ ├── VERSION
32
+ ├── bump_version.sh
33
+ └── README.md
40
34
  ```
41
35
  ## ▶️ Como Executar
42
36
 
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.29
@@ -6,10 +6,11 @@ module Bddgenx
6
6
  def self.salvar_versao_antiga(caminho)
7
7
  return unless File.exist?(caminho)
8
8
 
9
- FileUtils.mkdir_p("backup")
9
+ pasta = 'reports/backup'
10
+ FileUtils.mkdir_p(pasta)
10
11
  base = File.basename(caminho, ".feature")
11
12
  timestamp = Time.now.strftime("%Y%m%d_%H%M%S")
12
- destino = "backup/#{base}_#{timestamp}.feature"
13
+ destino = "reports/backup/#{base}_#{timestamp}.feature"
13
14
 
14
15
  FileUtils.cp(caminho, destino)
15
16
  puts "📦 Backup criado: #{destino}"
@@ -23,7 +23,12 @@ module Bddgenx
23
23
  regra: idioma == 'en' ? 'Rule' : 'Regra'
24
24
  }
25
25
 
26
- nome_base = historia[:quero].gsub(/[^a-z0-9]/i, '_').downcase
26
+ frase_quero = historia[:quero].sub(/^\s*quero\s*/i, '')
27
+ partes = frase_quero.split(/\s+/)[0,3] # pega só as 3 primeiras palavras
28
+ slug = partes.join('_')
29
+ .gsub(/[^a-z0-9_]/i, '') # remove caracteres especiais
30
+ .downcase
31
+ nome_base = slug
27
32
  caminho = "features/#{nome_base}.feature"
28
33
 
29
34
  conteudo = <<~GHERKIN
@@ -11,55 +11,61 @@ module Bddgenx
11
11
  .map(&:strip)
12
12
  .reject(&:empty?)
13
13
 
14
- # idioma
14
+ # Detecta idioma (padrão pt, usa en se encontrar '# lang: en')
15
15
  idioma = linhas.first.downcase.include?('# lang: en') ? 'en' : 'pt'
16
16
  linhas.shift if linhas.first.downcase.start_with?('# lang:')
17
17
 
18
- # cabeçalho Gherkin: Como / Quero / Para
19
- until linhas.empty?
20
- linha = linhas.shift
21
- break if linha =~ /^(Como |As a )/
18
+ # Cabeçalho Gherkin (case-insensitive): Como, Eu Como ou As a
19
+ como = nil
20
+ linhas.each_with_index do |l, i|
21
+ if l =~ /^\s*(?:como|eu como|as a)\b/i || l =~ /^\s*(?:COMO|EU COMO|AS A)\b/i
22
+ como = l
23
+ linhas = linhas[(i+1)..]
24
+ break
25
+ end
26
+ end
27
+
28
+ # 'Quero' ou 'Eu Quero'
29
+ quero = nil
30
+ linhas.each_with_index do |l, i|
31
+ if l =~ /^\s*(?:quero|eu quero|quero que)\b/i || l =~ /^\s*(?:QUERO|EU QUERO|QUERO QUE)\b/i
32
+ quero = l
33
+ linhas = linhas[(i+1)..]
34
+ break
35
+ end
22
36
  end
23
- como = linha
24
- quero = linhas.shift
25
- para = linhas.shift
26
37
 
27
- historia = {
28
- como: como,
29
- quero: quero,
30
- para: para,
31
- idioma: idioma,
32
- grupos: [] # cada bloco ([TIPO]@tag) será um grupo
33
- }
38
+ # 'Para', 'Para Eu' ou 'Para Que'
39
+ para = nil
40
+ linhas.each_with_index do |l, i|
41
+ if l =~ /^\s*(?:para|para eu|para que)\b/i || l =~ /^\s*(?:PRA|PARA EU|PARA QUE)\b/i
42
+ para = l
43
+ linhas = linhas[(i+1)..]
44
+ break
45
+ end
46
+ end
34
47
 
48
+ historia = { como: como, quero: quero, para: para, idioma: idioma, grupos: [] }
35
49
  exemplos_mode = false
36
- tipo_atual = nil
37
- tag_atual = nil
38
50
 
39
51
  linhas.each do |linha|
40
- # início de bloco EXAMPLES: modo exemplos para último grupo
41
- if linha =~ /^\[EXAMPLES\](?:@(\w+))?$/
52
+ # Início de bloco de exemplos
53
+ if linha =~ /^\[EXAMPLES\](?:@(\w+))?$/i
42
54
  exemplos_mode = true
43
- raise "Formato inválido: EXAMPLES sem bloco anterior" if historia[:grupos].empty?
44
55
  historia[:grupos].last[:exemplos] = []
45
56
  next
46
57
  end
47
58
 
48
- # início de um novo bloco (exceto EXAMPLES)
49
- if linha =~ /^\[(#{TIPOS_BLOCOS.join('|')})\](?:@(\w+))?$/
59
+ # Início de bloco de tipo (SUCCESS, FAILURE etc.)
60
+ if linha =~ /^\[(#{TIPOS_BLOCOS.join('|')})\](?:@(\w+))?$/i
50
61
  exemplos_mode = false
51
- tipo_atual = $1
52
- tag_atual = $2
53
- historia[:grupos] << {
54
- tipo: tipo_atual,
55
- tag: tag_atual,
56
- passos: [],
57
- exemplos: []
58
- }
62
+ tipo = $1.upcase
63
+ tag = $2
64
+ historia[:grupos] << { tipo: tipo, tag: tag, passos: [], exemplos: [] }
59
65
  next
60
66
  end
61
67
 
62
- # atribuir linhas ao bloco atual
68
+ # Atribui linhas ao último grupo existente
63
69
  next if historia[:grupos].empty?
64
70
  atual = historia[:grupos].last
65
71
 
@@ -4,12 +4,12 @@ require 'fileutils'
4
4
  module Bddgenx
5
5
  class PDFExporter
6
6
  def self.exportar_todos
7
- FileUtils.mkdir_p('pdf')
7
+ FileUtils.mkdir_p('reports/pdf')
8
8
 
9
9
  Dir.glob('features/*.feature').each do |feature_file|
10
10
  base = File.basename(feature_file, '.feature')
11
11
  nome_pdf = camel_case(base)
12
- destino = "pdf/#{nome_pdf}.pdf"
12
+ destino = "reports/pdf/#{nome_pdf}.pdf"
13
13
 
14
14
  if File.exist?(destino)
15
15
  puts "⚠️ PDF já existe: #{destino}"
@@ -4,8 +4,8 @@ require 'fileutils'
4
4
  module Bddgenx
5
5
  class Tracer
6
6
  def self.adicionar_entrada(historia, nome_arquivo_feature)
7
- FileUtils.mkdir_p('output')
8
- arquivo_csv = 'output/rastreabilidade.csv'
7
+ FileUtils.mkdir_p('reports/output')
8
+ arquivo_csv = 'reports/output/rastreabilidade.csv'
9
9
 
10
10
  cabecalho = ['Funcionalidade', 'Tipo', 'Tag', 'Cenário', 'Passo', 'Origem']
11
11
 
@@ -1,3 +1,11 @@
1
1
  module Bddgenx
2
- VERSION = "0.1.26"
2
+ # Sobe 3 níveis: lib/bddgenx/version.rb → bddgenx → lib → [raiz do projeto]
3
+ VERSION_FILE = File.expand_path("../../../VERSION", __FILE__)
4
+
5
+ VERSION = if File.exist?(VERSION_FILE)
6
+ File.read(VERSION_FILE).strip
7
+ else
8
+ warn "WARNING: VERSION file not found, defaulting to 0.0.0"
9
+ "0.0.0"
10
+ end
3
11
  end
data/lib/bddgenx.rb CHANGED
@@ -34,11 +34,13 @@ arquivos.each do |arquivo_path|
34
34
  cont_features += 1 if Bddgenx::Generator.salvar_feature(nome_feature, conteudo_feature)
35
35
  cont_steps += 1 if Bddgenx::StepsGenerator.gerar_passos(historia, nome_feature)
36
36
 
37
+ # cria pasta reports raiz
38
+ FileUtils.mkdir_p('reports')
37
39
  Bddgenx::Tracer.adicionar_entrada(historia, nome_feature)
38
40
  Bddgenx::PDFExporter.exportar_todos
39
41
  end
40
42
  puts "\n✅ Processamento finalizado. Arquivos gerados em: features/, steps/, output/"
41
- puts "🔄 Versões antigas salvas em: backup/"
43
+ puts "🔄 Versões antigas salvas em: reports/backup/"
42
44
 
43
45
  puts "\n✅ Processamento finalizado:"
44
46
  puts "- Arquivos processados: #{cont_total}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bddgenx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.26
4
+ version: 0.1.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Nascimento
@@ -35,6 +35,7 @@ extra_rdoc_files: []
35
35
  files:
36
36
  - README.md
37
37
  - Rakefile
38
+ - VERSION
38
39
  - bin/bddgenx
39
40
  - lib/bddgenx.rb
40
41
  - lib/bddgenx/assets/fonts/DejaVuSansMono-Bold.ttf