bddgenx 0.1.26 → 0.1.27

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: 8f4d4a0d722941eb7d15b474586da0bc25a2aae85b0542ed74841c13b2a545d3
4
+ data.tar.gz: d4e0b1bf37384a517d97ee71b2ad3d6d8ba87e4cbc9a1c2b456be181e68e4f87
5
5
  SHA512:
6
- metadata.gz: 689a8a8ea39be89e3ed41951421a78ae713dbe3af31f46d9d40871e70c11b383eb3d8cca3de554dc5af80ebc46f1e4a6b29040f2fadf639be29bd121e9a39bc7
7
- data.tar.gz: 5e122e5ba59b8b11b4b17f21451ab3657748735dbb8c7a0fa11c8d1cd2a42f75c3268591ebad5f3d05f9ff791fec488fb21fa0af70ba6560f276a75d282d77be
6
+ metadata.gz: 67ece000b01a4d5abe5fda121ebe5486ed3eb8866e102fee704793df7d1c93e369e2c8b92f803df3b43cde3c4d6b25e78efeda48ec6de943734123b01bdb872b
7
+ data.tar.gz: 11180ba8fed1854d60ad6250376949807332ff04f4432d5e24b5b1b3af89d0d119036c4c38585d1826548c02f099ab4779129030537790e2837d9829766f6cb9
@@ -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,3 @@
1
1
  module Bddgenx
2
- VERSION = "0.1.26"
2
+ VERSION = "0.1.27"
3
3
  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.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Nascimento