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 +4 -4
- data/lib/bddgenx/backup.rb +3 -2
- data/lib/bddgenx/generator.rb +6 -1
- data/lib/bddgenx/parser.rb +37 -31
- data/lib/bddgenx/pdf_exporter.rb +2 -2
- data/lib/bddgenx/tracer.rb +2 -2
- data/lib/bddgenx/version.rb +1 -1
- data/lib/bddgenx.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f4d4a0d722941eb7d15b474586da0bc25a2aae85b0542ed74841c13b2a545d3
|
4
|
+
data.tar.gz: d4e0b1bf37384a517d97ee71b2ad3d6d8ba87e4cbc9a1c2b456be181e68e4f87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67ece000b01a4d5abe5fda121ebe5486ed3eb8866e102fee704793df7d1c93e369e2c8b92f803df3b43cde3c4d6b25e78efeda48ec6de943734123b01bdb872b
|
7
|
+
data.tar.gz: 11180ba8fed1854d60ad6250376949807332ff04f4432d5e24b5b1b3af89d0d119036c4c38585d1826548c02f099ab4779129030537790e2837d9829766f6cb9
|
data/lib/bddgenx/backup.rb
CHANGED
@@ -6,10 +6,11 @@ module Bddgenx
|
|
6
6
|
def self.salvar_versao_antiga(caminho)
|
7
7
|
return unless File.exist?(caminho)
|
8
8
|
|
9
|
-
|
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}"
|
data/lib/bddgenx/generator.rb
CHANGED
@@ -23,7 +23,12 @@ module Bddgenx
|
|
23
23
|
regra: idioma == 'en' ? 'Rule' : 'Regra'
|
24
24
|
}
|
25
25
|
|
26
|
-
|
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
|
data/lib/bddgenx/parser.rb
CHANGED
@@ -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
|
-
#
|
19
|
-
|
20
|
-
|
21
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
30
|
-
para
|
31
|
-
|
32
|
-
|
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
|
-
#
|
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
|
-
#
|
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
|
-
|
52
|
-
|
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
|
-
#
|
68
|
+
# Atribui linhas ao último grupo existente
|
63
69
|
next if historia[:grupos].empty?
|
64
70
|
atual = historia[:grupos].last
|
65
71
|
|
data/lib/bddgenx/pdf_exporter.rb
CHANGED
@@ -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}"
|
data/lib/bddgenx/tracer.rb
CHANGED
@@ -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
|
|
data/lib/bddgenx/version.rb
CHANGED
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}"
|