bddgenx 0.1.20 → 0.1.21

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: 4b9863ca789b2c68b3d7f3dd7c444f2a33ea9e0d3eeca72b37d982425944671f
4
+ data.tar.gz: c5bc1edcf74b776a44454345ce03d3aa66e686c3cb366937e181cb57af35d3ed
5
5
  SHA512:
6
- metadata.gz: 172de9e09a66b96d69e7e340001b8c04f659aa513ea8fc033fe7b3d78955e841717f8ebaab0aaeed268689d8ac928c3662069bf417d6990a67eb7b15ad0f0219
7
- data.tar.gz: 781b4cfcab32df206a2415d5c92029c54666c7dcad944cda1c9305da748bbd333a5de47010ffca07fa37b998b882c95c45f84195c8dc9f726296e337ba3aa4c8
6
+ metadata.gz: b41fb1d4c6fc45627b6f0a1f3a439470f18998c6911175856ccef752bf8040da86ee936d60f37a7b3acc01d9e074dc2f4422ecb64428c4b029f73fa13da0f1d6
7
+ data.tar.gz: 651ea97a793b44d3754802d5589cf3b14825ccd8de1eae2bf3db640ef5cabe6f4d6bdd8bc00a9404cc60529f050996b51f6d9a4a879f1b4dcb611abc5aa333b7
@@ -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
@@ -21,17 +20,27 @@ module Bddgenx
21
20
  end
22
21
 
23
22
  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: '?')
23
+ if texto.respond_to?(:unicode_normalize)
24
+ # Decompõe em base + acentos, remove acentos, e garante ASCII
25
+ texto
26
+ .unicode_normalize(:nfkd) # separa letra + marca
27
+ .chars
28
+ .reject { |c| c.match?(/\p{Mn}/) } # descarta marcas de acento
29
+ .join
30
+ .encode('ASCII', undef: :replace, replace: '?')
31
+ else
32
+ # Fallback simples se por algum motivo unicode_normalize não existir
33
+ texto
34
+ .gsub(/[áàâãä]/i, 'a')
35
+ .gsub(/[éèêë]/i, 'e')
36
+ .gsub(/[íìîï]/i, 'i')
37
+ .gsub(/[óòôõö]/i, 'o')
38
+ .gsub(/[úùûü]/i, 'u')
39
+ .gsub(/[ç]/i, 'c')
40
+ .encode('ASCII', undef: :replace, replace: '?')
41
+ end
32
42
  end
33
43
 
34
-
35
44
  def self.exportar_arquivo(origem, destino)
36
45
  conteudo = File.read(origem, encoding: 'utf-8')
37
46
 
@@ -59,7 +68,7 @@ module Bddgenx
59
68
  pdf.move_down 10
60
69
 
61
70
  conteudo.each_line do |linha|
62
- linha = fonte_existe ? linha.strip : sanitizar_utf8_para_ascii(linha.strip)
71
+ linha = fonte_existe ? linha.strip : sanitizar_utf8_para_ascii(linha.chomp)
63
72
 
64
73
  case linha
65
74
  when /^#/
@@ -1,3 +1,3 @@
1
1
  module Bddgenx
2
- VERSION = "0.1.20"
2
+ VERSION = "0.1.21"
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.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Nascimento