bddgenx 0.1.7 → 0.1.10
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/parser.rb +43 -42
- data/lib/bddgenx/version.rb +1 -1
- data/lib/bddgenx.rb +3 -3
- 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: 412eee7cb6c56d539e31e45baeebccf7db3746d9e6ac440bafbe7cdbf4050c2c
|
4
|
+
data.tar.gz: 6c0dba41550f7965567c503987c7a73dc52ead909bc65950b776fc34a2b6d11d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64a9b9ed93fccccf3ee74c16e9bcb7da5a3a478b16801306d04ef841b519cf82481a22a4d85de8700e48977ee3348a7999bd344545740b9363917740c40e539c
|
7
|
+
data.tar.gz: db405418d2c50e990e3904cb7bc527109ff7e8f3647dcf3cd758ff240f43d0c5dbdbc36abbd17929bb893a375a42a6eb6dda67b2d08709ca000d93105d727f23
|
data/lib/bddgenx/parser.rb
CHANGED
@@ -1,52 +1,53 @@
|
|
1
|
-
module
|
1
|
+
module Bddgenx
|
2
2
|
TIPOS_BLOCOS = %w[
|
3
3
|
CONTEXT SUCCESS FAILURE ERROR EXCEPTION
|
4
4
|
VALIDATION PERMISSION EDGE_CASE PERFORMANCE
|
5
5
|
EXAMPLES REGRA RULE
|
6
6
|
].freeze
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
como = linha
|
22
|
-
quero = linhas.shift
|
23
|
-
para = linhas.shift
|
24
|
-
|
25
|
-
historia = {
|
26
|
-
como: como,
|
27
|
-
quero: quero,
|
28
|
-
para: para,
|
29
|
-
blocos: Hash.new { |h, k| h[k] = [] },
|
30
|
-
regras: [],
|
31
|
-
arquivo_origem: caminho_arquivo,
|
32
|
-
idioma: idioma
|
33
|
-
}
|
34
|
-
|
35
|
-
tipo_atual = nil
|
36
|
-
|
37
|
-
linhas.each do |linha|
|
38
|
-
if linha.match?(/^\[(#{TIPOS_BLOCOS.join('|')})\]$/)
|
39
|
-
tipo_atual = linha.gsub(/[\[\]]/, '')
|
40
|
-
next
|
7
|
+
class Parser
|
8
|
+
def self.ler_historia(caminho_arquivo)
|
9
|
+
linhas = File.readlines(caminho_arquivo, encoding: 'utf-8').map(&:strip).reject(&:empty?)
|
10
|
+
|
11
|
+
# Detecta idioma
|
12
|
+
idioma = linhas.first.downcase.include?('# lang: en') ? 'en' : 'pt'
|
13
|
+
linhas.shift if linhas.first.downcase.start_with?('#')
|
14
|
+
|
15
|
+
# Ignora linhas que sejam blocos ou comentários até encontrar Como/Quero/Para
|
16
|
+
cabecalho = []
|
17
|
+
until linhas.empty?
|
18
|
+
linha = linhas.shift
|
19
|
+
break if linha.start_with?("Como", "As") # início da história em pt ou en
|
41
20
|
end
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
21
|
+
como = linha
|
22
|
+
quero = linhas.shift
|
23
|
+
para = linhas.shift
|
24
|
+
|
25
|
+
historia = {
|
26
|
+
como: como,
|
27
|
+
quero: quero,
|
28
|
+
para: para,
|
29
|
+
blocos: Hash.new { |h, k| h[k] = [] },
|
30
|
+
regras: [],
|
31
|
+
arquivo_origem: caminho_arquivo,
|
32
|
+
idioma: idioma
|
33
|
+
}
|
34
|
+
|
35
|
+
tipo_atual = nil
|
36
|
+
|
37
|
+
linhas.each do |linha|
|
38
|
+
if linha.match?(/^\[(#{TIPOS_BLOCOS.join('|')})\]$/)
|
39
|
+
tipo_atual = linha.gsub(/[\[\]]/, '')
|
40
|
+
next
|
41
|
+
end
|
42
|
+
|
43
|
+
if %w[REGRA RULE].include?(tipo_atual)
|
44
|
+
historia[:regras] << linha
|
45
|
+
else
|
46
|
+
historia[:blocos][tipo_atual] << linha if tipo_atual
|
47
|
+
end
|
47
48
|
end
|
48
|
-
end
|
49
49
|
|
50
|
-
|
50
|
+
historia
|
51
|
+
end
|
51
52
|
end
|
52
53
|
end
|
data/lib/bddgenx/version.rb
CHANGED
data/lib/bddgenx.rb
CHANGED
@@ -5,8 +5,8 @@ require_relative 'bddgenx/steps_generator'
|
|
5
5
|
require_relative 'bddgenx/tracer'
|
6
6
|
require_relative 'bddgenx/backup'
|
7
7
|
require_relative 'bddgenx/cli'
|
8
|
-
require_relative 'bddgenx/pdf_exporter'
|
9
|
-
require_relative 'bddgenx/utils/verificador'
|
8
|
+
require_relative 'bddgenx/pdf_exporter'
|
9
|
+
require_relative 'bddgenx/utils/verificador'
|
10
10
|
|
11
11
|
|
12
12
|
cont_total = 0
|
@@ -20,7 +20,7 @@ arquivos = CLI.selecionar_arquivos_txt('input')
|
|
20
20
|
arquivos.each do |arquivo_path|
|
21
21
|
puts "\n🔍 Processando: #{arquivo_path}"
|
22
22
|
|
23
|
-
historia = Parser.ler_historia(arquivo_path)
|
23
|
+
historia = Bddgenx::Parser.ler_historia(arquivo_path)
|
24
24
|
|
25
25
|
unless Validator.validar(historia)
|
26
26
|
cont_ignorados += 1
|