bddgenx 0.1.13 → 0.1.15

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: 063cc589906d3a3caef2e42e654878a91c500965a4471e5e24b159052d973736
4
- data.tar.gz: 53fbe77aa4c1998340f9d91d9ebdb44c1eb6441cc5adaca218d015a88e43b1db
3
+ metadata.gz: 0da9cd3383cb0aee1913bbc15027ca76e162583229057b73c875c635b39c9638
4
+ data.tar.gz: 20509237489c3e314c8092d06ec36bbbd6e366cd34c0103d7520ba98c5ddc8e6
5
5
  SHA512:
6
- metadata.gz: ebcfa55296ff8a48bb25a7c0397e59a7ecbfb50e586a51db56f3a96029b4d95e81c61f1e7c0e17888e3ec5202391d5b551365ccbcb84a76d67277e5b9b1c125a
7
- data.tar.gz: a1b23a726f8f94c1b9fe87d38c81a5a6ac51981ffde74e543257d1d3629a1d553b6c9309071af5829b345aabd93f799ed8e67b4f75782e0ef9a1a6a4646b6b13
6
+ metadata.gz: 30f2a4569e8332add1094d37de9db31ce39740b1c1c2414b474595fd2c41c3f64a106144f007903da15e97c93bcc9995532becf4ccb034fd280943af5f1ba347
7
+ data.tar.gz: d1ca7cd92079d1560cf59579a4cd90798616613e086956cbbc3480fd6c99fddd0c42c51293f67fad46aeb4987175b0b9210b79efd9b95d85654eab9aa1656136
@@ -22,61 +22,58 @@ module Bddgenx
22
22
  conteudo = File.read(origem, encoding: 'utf-8')
23
23
 
24
24
  Prawn::Document.generate(destino) do |pdf|
25
- # Fontes externas com suporte UTF-8
26
- pdf.font_families.update(
27
- "DejaVu" => {
28
- normal: "fonts/DejaVuSansMono.ttf",
29
- bold: "fonts/DejaVuSansMono-Bold.ttf",
30
- italic: "fonts/DejaVuSansMono-Oblique.ttf",
31
- bold_italic: "fonts/DejaVuSansMono-BoldOblique.ttf"
32
- }
33
- )
34
- pdf.font "DejaVu"
35
- pdf.font_size 10
25
+ fonte_existe = File.exist?("fonts/DejaVuSansMono.ttf")
26
+
27
+ if fonte_existe
28
+ pdf.font_families.update(
29
+ "DejaVu" => {
30
+ normal: "fonts/DejaVuSansMono.ttf",
31
+ bold: "fonts/DejaVuSansMono-Bold.ttf",
32
+ italic: "fonts/DejaVuSansMono-Oblique.ttf",
33
+ bold_italic: "fonts/DejaVuSansMono-BoldOblique.ttf"
34
+ }
35
+ )
36
+ pdf.font "DejaVu"
37
+ else
38
+ puts "⚠️ Fonte personalizada não encontrada. Usando fonte padrão."
39
+ pdf.font "Courier" # embutida no Prawn
40
+ end
36
41
 
37
- pdf.text "📄 #{File.basename(origem)}", style: :normal, size: 14
42
+ pdf.font_size 10
43
+ def self.sanitizar_utf8_para_ascii(linha)
44
+ linha.encode('Windows-1252', invalid: :replace, undef: :replace, replace: '?')
45
+ rescue Encoding::UndefinedConversionError
46
+ linha.tr('áéíóúãõçâêîôûÁÉÍÓÚÃÕÇÂÊÎÔÛ', 'aeiouaocaeiouAEIOUAOCAEOU')
47
+ end
48
+ pdf.text "📄 #{File.basename(origem)}", style: :bold, size: 14
38
49
  pdf.move_down 10
39
50
 
40
51
  conteudo.each_line do |linha|
41
- linha = linha.strip
52
+ linha = fonte_existe ? linha.strip : sanitizar_utf8_para_ascii(linha.strip)
42
53
 
43
54
  case linha
44
55
  when /^#/
45
56
  pdf.fill_color "888888"
46
57
  pdf.text linha, style: :italic, size: 8
47
58
  pdf.fill_color "000000"
48
-
49
59
  when /^Funcionalidade:|^Feature:/
50
60
  pdf.move_down 6
51
61
  pdf.text linha, style: :bold, size: 12
52
62
  pdf.move_down 4
53
-
54
63
  when /^Cenário:|^Scenario:|^Esquema do Cenário:|^Scenario Outline:/
55
64
  pdf.move_down 4
56
65
  pdf.text linha, style: :bold
57
-
58
66
  when /^@/
59
67
  pdf.text linha, style: :italic, color: "555555"
60
-
61
68
  when /^(Dado|Quando|Então|E|Mas|Given|When|Then|And|But)\b/
62
- pdf.indent(20) do
63
- pdf.text linha
64
- end
65
-
69
+ pdf.indent(20) { pdf.text linha }
66
70
  when /^Exemplos:|^Examples:/
67
71
  pdf.move_down 4
68
72
  pdf.text linha, style: :bold
69
-
70
73
  when /^\|.*\|$/
71
- pdf.indent(20) do
72
- pdf.font_size 9
73
- pdf.text linha, font: "DejaVu"
74
- pdf.font_size 10
75
- end
76
-
74
+ pdf.indent(20) { pdf.text linha }
77
75
  when /^\s*$/
78
76
  pdf.move_down 4
79
-
80
77
  else
81
78
  pdf.text linha
82
79
  end
@@ -85,8 +82,8 @@ module Bddgenx
85
82
  pdf.move_down 20
86
83
  pdf.number_pages "Página <page> de <total>", align: :right, size: 8
87
84
  end
88
- rescue => e
89
- puts "❌ Erro ao gerar PDF de #{origem}: #{e.message}"
85
+ rescue => e
86
+ puts "❌ Erro ao gerar PDF de #{origem}: #{e.message}"
90
87
  end
91
88
  end
92
89
  end
@@ -1,3 +1,3 @@
1
1
  module Bddgenx
2
- VERSION = "0.1.13"
2
+ VERSION = "0.1.15"
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.13
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Nascimento