bddgenx 0.1.19 → 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: d91aa91f0a921c5828f508f01f0c346ab58e2c57b8149e467b41cbd0810e5096
4
- data.tar.gz: 25bb1a2ac19c2ffe6c7131e19dce7c266df59b01680865555a9c906b54ea3a61
3
+ metadata.gz: 4b9863ca789b2c68b3d7f3dd7c444f2a33ea9e0d3eeca72b37d982425944671f
4
+ data.tar.gz: c5bc1edcf74b776a44454345ce03d3aa66e686c3cb366937e181cb57af35d3ed
5
5
  SHA512:
6
- metadata.gz: 15de6079b1c8916bcdc9353716aea63da203db97b61e57fae5df146df253071ca0c9a176ec79a0af92addf80ae8d1e004d658b5344193e3a5f124f8551ab31f0
7
- data.tar.gz: 8bced858412d508de4c16abb1fb02767114455389e8c78906007b8c911cf9337e8046b5ff47ef256c8b5858d584ed5c73c1ea9325e62afb5ca66371715e9565d
6
+ metadata.gz: b41fb1d4c6fc45627b6f0a1f3a439470f18998c6911175856ccef752bf8040da86ee936d60f37a7b3acc01d9e074dc2f4422ecb64428c4b029f73fa13da0f1d6
7
+ data.tar.gz: 651ea97a793b44d3754802d5589cf3b14825ccd8de1eae2bf3db640ef5cabe6f4d6bdd8bc00a9404cc60529f050996b51f6d9a4a879f1b4dcb611abc5aa333b7
@@ -19,10 +19,26 @@ module Bddgenx
19
19
  end
20
20
  end
21
21
 
22
- def self.sanitizar_utf8_para_ascii(linha)
23
- linha.encode('Windows-1252', invalid: :replace, undef: :replace, replace: '?')
24
- rescue Encoding::UndefinedConversionError
25
- linha.tr('áéíóúãõçâêîôûÁÉÍÓÚÃÕÇÂÊÎÔÛ', 'aeiouaocaeiouAEIOUAOCAEOU')
22
+ def self.sanitizar_utf8_para_ascii(texto)
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
26
42
  end
27
43
 
28
44
  def self.exportar_arquivo(origem, destino)
@@ -52,7 +68,7 @@ module Bddgenx
52
68
  pdf.move_down 10
53
69
 
54
70
  conteudo.each_line do |linha|
55
- linha = fonte_existe ? linha.strip : sanitizar_utf8_para_ascii(linha.strip)
71
+ linha = fonte_existe ? linha.strip : sanitizar_utf8_para_ascii(linha.chomp)
56
72
 
57
73
  case linha
58
74
  when /^#/
@@ -1,3 +1,3 @@
1
1
  module Bddgenx
2
- VERSION = "0.1.19"
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.19
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Nascimento