bddgenx 0.1.9 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7ba8a9b2ab19197483676975007bab1eb09cb82cc2d05c9b60c9c2daf007cb1c
4
- data.tar.gz: 6736a1ea2f7d55c17a6efc38664c63b47795353ace4935fb03e6ff657dabcbcb
3
+ metadata.gz: 412eee7cb6c56d539e31e45baeebccf7db3746d9e6ac440bafbe7cdbf4050c2c
4
+ data.tar.gz: 6c0dba41550f7965567c503987c7a73dc52ead909bc65950b776fc34a2b6d11d
5
5
  SHA512:
6
- metadata.gz: b2479cc4f84348a3f7958ab1c412b83a8c15a0497db4cd12fec8a906460edc3613a974ce22d6dfddd562ede3f47812636ee0fcf7976a02f1671400ced332ad5e
7
- data.tar.gz: 3d404dc33cb750a35b33441ce183566ea97124fae52483458146af442d4c8c0dd442683e39199a665de6e1044071bcf6beea59defd5be3707745f6fc2c8a4a67
6
+ metadata.gz: 64a9b9ed93fccccf3ee74c16e9bcb7da5a3a478b16801306d04ef841b519cf82481a22a4d85de8700e48977ee3348a7999bd344545740b9363917740c40e539c
7
+ data.tar.gz: db405418d2c50e990e3904cb7bc527109ff7e8f3647dcf3cd758ff240f43d0c5dbdbc36abbd17929bb893a375a42a6eb6dda67b2d08709ca000d93105d727f23
@@ -1,52 +1,53 @@
1
- module Parser
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
- 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
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
- if %w[REGRA RULE].include?(tipo_atual)
44
- historia[:regras] << linha
45
- else
46
- historia[:blocos][tipo_atual] << linha if tipo_atual
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
- historia
50
+ historia
51
+ end
51
52
  end
52
53
  end
@@ -1,3 +1,3 @@
1
1
  module Bddgenx
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
data/lib/bddgenx.rb CHANGED
@@ -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
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.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Nascimento