bddgenx 0.1.20 → 0.1.22.pre.release

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: 919bbf1314c68b9cd828e92b4eb07624bd7de3d4b2fbf5eb767c321422d19014
4
- data.tar.gz: b46ac8838b38115277c61a702b726e71ad5f7eb506db4358e98a76445ce7304b
3
+ metadata.gz: 129bb90ce3ad0b8be09b6f6e2ef45aad79874021440ec3137465f05b1bf04168
4
+ data.tar.gz: b4f9e706e73983e7d182582b1d646fdf8ea74ed79240418cea99ac7db2e054dc
5
5
  SHA512:
6
- metadata.gz: 172de9e09a66b96d69e7e340001b8c04f659aa513ea8fc033fe7b3d78955e841717f8ebaab0aaeed268689d8ac928c3662069bf417d6990a67eb7b15ad0f0219
7
- data.tar.gz: 781b4cfcab32df206a2415d5c92029c54666c7dcad944cda1c9305da748bbd333a5de47010ffca07fa37b998b882c95c45f84195c8dc9f726296e337ba3aa4c8
6
+ metadata.gz: a10d05b891b01b0014878ba3060c3fc172c87868bc726f5d375402d2e8e0170c08f3c3af3cec844a816322ae062f72425c51be21d96596bdcb8b095ea6573dec
7
+ data.tar.gz: 25da2928b1df75b2dbfc514a1a0b04b612c63acb5a3dd3e7f4816bf1e2095ef2d06cf6b65ef05bcd420acce15d1da68253b3cccdae7b8d0c08384f776595fcdd
@@ -1,6 +1,5 @@
1
1
  require 'prawn'
2
2
  require 'fileutils'
3
- require 'unicode_normalize'
4
3
 
5
4
  module Bddgenx
6
5
  class PDFExporter
@@ -8,29 +7,48 @@ module Bddgenx
8
7
  FileUtils.mkdir_p('pdf')
9
8
 
10
9
  Dir.glob('features/*.feature').each do |feature_file|
11
- nome = File.basename(feature_file, '.feature')
12
- destino = "pdf/#{nome}.pdf"
10
+ base = File.basename(feature_file, '.feature')
11
+ nome_pdf = camel_case(base)
12
+ destino = "pdf/#{nome_pdf}.pdf"
13
13
  exportar_arquivo(feature_file, destino)
14
14
  if File.exist?(destino)
15
- puts "⚠️ PDF já existente: #{destino} — pulando geração."
16
- return
15
+ return puts "⚠️ PDF já existente: #{destino} — pulando geração."
17
16
  else
18
17
  puts "📄 PDF gerado: #{destino}"
19
18
  end
20
19
  end
21
20
  end
22
21
 
23
- def self.sanitizar_utf8_para_ascii(texto)
24
- # Decompõe caracteres Unicode em forma compatível (NFKD),
25
- # remove marcas de combinação (acentos) e retorna apenas ASCII
26
- texto
27
- .unicode_normalize(:nfkd) # separa base + acentos
28
- .chars
29
- .reject { |c| c.match?(/\p{Mn}/) } # remove marcas de combinação
30
- .join
31
- .encode('ASCII', undef: :replace, replace: '?')
22
+ # Converte string para camelCase, removendo caracteres especiais
23
+ def self.camel_case(str)
24
+ # Remove tudo que não for letra ou número ou espaço
25
+ str = str.gsub(/[^0-9A-Za-z ]/, '')
26
+ parts = str.split(/ |_/)
27
+ # Primeira palavra minúscula, demais capitalizadas
28
+ ([parts.first&.downcase] + parts[1..].map(&:capitalize)).join
32
29
  end
33
30
 
31
+ def self.sanitizar_utf8_para_ascii(texto)
32
+ if texto.respond_to?(:unicode_normalize)
33
+ # Decompõe em base + acentos, remove acentos, e garante ASCII
34
+ texto
35
+ .unicode_normalize(:nfkd) # separa letra + marca
36
+ .chars
37
+ .reject { |c| c.match?(/\p{Mn}/) } # descarta marcas de acento
38
+ .join
39
+ .encode('ASCII', undef: :replace, replace: '?')
40
+ else
41
+ # Fallback simples se por algum motivo unicode_normalize não existir
42
+ texto
43
+ .gsub(/[áàâãä]/i, 'a')
44
+ .gsub(/[éèêë]/i, 'e')
45
+ .gsub(/[íìîï]/i, 'i')
46
+ .gsub(/[óòôõö]/i, 'o')
47
+ .gsub(/[úùûü]/i, 'u')
48
+ .gsub(/[ç]/i, 'c')
49
+ .encode('ASCII', undef: :replace, replace: '?')
50
+ end
51
+ end
34
52
 
35
53
  def self.exportar_arquivo(origem, destino)
36
54
  conteudo = File.read(origem, encoding: 'utf-8')
@@ -59,7 +77,7 @@ module Bddgenx
59
77
  pdf.move_down 10
60
78
 
61
79
  conteudo.each_line do |linha|
62
- linha = fonte_existe ? linha.strip : sanitizar_utf8_para_ascii(linha.strip)
80
+ linha = fonte_existe ? linha.strip : sanitizar_utf8_para_ascii(linha.chomp)
63
81
 
64
82
  case linha
65
83
  when /^#/
@@ -1,3 +1,3 @@
1
1
  module Bddgenx
2
- VERSION = "0.1.20"
2
+ VERSION = "0.1.22-release"
3
3
  end
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.20
4
+ version: 0.1.22.pre.release
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Nascimento
@@ -54,9 +54,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
54
  version: 3.x
55
55
  required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - ">="
57
+ - - ">"
58
58
  - !ruby/object:Gem::Version
59
- version: '0'
59
+ version: 1.3.1
60
60
  requirements: []
61
61
  rubygems_version: 3.3.27
62
62
  signing_key: