proforma-prawn-renderer 1.0.0.pre.alpha.1 → 1.0.0.pre.alpha.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0479b9058c96eae6a94f416e7bce8e7e0fb31f91bc5d3021009fc8f4a54b58d9'
4
- data.tar.gz: 664abe0e730eb2d794d6c8b3dfd3cb03e383d2a26f0dc2c181d43e481a476836
3
+ metadata.gz: 54834a89ab263705e11f9b8360d96d5ac45aa764ee64330dad3126df0d8f3b54
4
+ data.tar.gz: 77e0b6216201450006e7a727a0b50acca19b2e9ede205aef8a43bfb80df1ab90
5
5
  SHA512:
6
- metadata.gz: a4f3016b95207055cff15d09ba98851b4af766bb97bd90a4880db1cd4d4f74f24318c227fb73fbc1a4d2d178981d54b7f8a70dc815c6193192a1c5bce912aeff
7
- data.tar.gz: e6d94a0e12d694f1e12f725fff86055711688c9e0a3c3784da80ec264a26fdb0a9a5b3a78d617ea60d6a0e5f378c85734661dc01c094d1f204a21b83a2b14999
6
+ metadata.gz: 20b72784ff62c4fa96cf57194d783d91d79c17d042a2ac5de30df0b27d4e38670d3ff2004c839f4853c236edcd12f6f5e78653e4aa34c99308b318cfa2359b67
7
+ data.tar.gz: 2b5e4807e1c37eabe5626f0171d0f04334c2233eb7e3a0a95bfb8b32dc362f529625584997d3987c7d972da6c1d797f1f588c82dd98ca27817580626d1e209b4
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- proforma-prawn-renderer (1.0.0.pre.alpha.1)
4
+ proforma-prawn-renderer (1.0.0.pre.alpha.2)
5
5
  prawn (~> 2)
6
6
  prawn-table (~> 0)
7
+ proforma (~> 1)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
@@ -64,7 +65,7 @@ GEM
64
65
  ttfunk (~> 1.5)
65
66
  prawn-table (0.2.2)
66
67
  prawn (>= 1.3.0, < 3.0.0)
67
- proforma (1.0.0.pre.alpha)
68
+ proforma (1.0.1)
68
69
  acts_as_hashable (~> 1)
69
70
  pry (0.12.2)
70
71
  coderay (~> 1.1.0)
@@ -117,7 +118,6 @@ PLATFORMS
117
118
  DEPENDENCIES
118
119
  guard-rspec (~> 4.7)
119
120
  pdf-inspector (~> 1)
120
- proforma (>= 1.0.0.pre.alpha)
121
121
  proforma-prawn-renderer!
122
122
  pry (~> 0)
123
123
  rspec (~> 3.8)
data/README.md CHANGED
@@ -47,8 +47,8 @@ template = {
47
47
  {
48
48
  type: 'DataTable',
49
49
  columns: [
50
- { header: 'Team ID #', body: '$:id' },
51
- { header: 'Team Name', body: '$:name' },
50
+ { header: 'Team ID #', body: '$id' },
51
+ { header: 'Team Name', body: '$name' },
52
52
  ]
53
53
  }
54
54
  ]
@@ -77,7 +77,7 @@ All options for Prawn are passed through the Proforma::PrawnRenderer::Options ob
77
77
 
78
78
  Name | Default
79
79
  ---------------- | -------
80
- bold_font_style | :bold
80
+ bold_font_style | bold
81
81
  header_font_size | 15
82
82
  text_font_size | 10
83
83
  font_name | null
data/bin/render CHANGED
@@ -1,6 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ #
5
+ # Copyright (c) 2019-present, Blue Marble Payroll, LLC
6
+ #
7
+ # This source code is licensed under the MIT license found in the
8
+ # LICENSE file in the root directory of this source tree.
9
+ #
10
+
4
11
  require 'bundler/setup'
5
12
  require 'proforma/prawn_renderer'
6
13
  require 'fileutils'
@@ -9,9 +16,7 @@ require 'pry'
9
16
  require 'pdf/inspector'
10
17
 
11
18
  def read_yaml(filename)
12
- # rubocop:disable Security/YAMLLoad
13
- YAML.load(read(filename))
14
- # rubocop:enable Security/YAMLLoad
19
+ YAML.safe_load(read(filename))
15
20
  end
16
21
 
17
22
  def read(filename)
@@ -7,15 +7,15 @@
7
7
  # LICENSE file in the root directory of this source tree.
8
8
  #
9
9
 
10
+ require 'forwardable'
10
11
  require 'prawn'
11
12
  require 'prawn/table'
12
13
  require 'proforma'
13
14
 
14
- require_relative 'prawn_renderer/renderer'
15
15
  require_relative 'prawn_renderer/banner_renderer'
16
16
  require_relative 'prawn_renderer/header_renderer'
17
- require_relative 'prawn_renderer/options'
18
17
  require_relative 'prawn_renderer/pane_renderer'
18
+ require_relative 'prawn_renderer/renderer'
19
19
  require_relative 'prawn_renderer/separator_renderer'
20
20
  require_relative 'prawn_renderer/spacer_renderer'
21
21
  require_relative 'prawn_renderer/table_renderer'
@@ -26,6 +26,13 @@ module Proforma
26
26
  class PrawnRenderer
27
27
  EXTENSION = '.pdf'
28
28
 
29
+ DEFAULT_OPTIONS = {
30
+ bold_font_style: :bold,
31
+ font_name: nil,
32
+ text_font_size: 10,
33
+ header_font_size: 15
34
+ }.freeze
35
+
29
36
  RENDERERS = {
30
37
  Modeling::Banner => BannerRenderer,
31
38
  Modeling::Header => HeaderRenderer,
@@ -40,8 +47,8 @@ module Proforma
40
47
 
41
48
  attr_reader :options
42
49
 
43
- def initialize(options = Options.new)
44
- @options = options || Options.new
50
+ def initialize(options = {})
51
+ @options = OpenStruct.new(DEFAULT_OPTIONS.merge(options))
45
52
 
46
53
  clear
47
54
  end
@@ -7,6 +7,8 @@
7
7
  # LICENSE file in the root directory of this source tree.
8
8
  #
9
9
 
10
+ require_relative 'renderer'
11
+
10
12
  module Proforma
11
13
  class PrawnRenderer
12
14
  # This class understands how to ender a Proforma::Modeling::Banner component.
@@ -63,8 +65,8 @@ module Proforma
63
65
  @cell_style ||= {
64
66
  border_width: 0,
65
67
  padding: 0,
66
- font: options.font_name,
67
- size: options.text_font_size
68
+ font: font_name,
69
+ size: text_font_size
68
70
  }
69
71
  end
70
72
 
@@ -16,9 +16,9 @@ module Proforma
16
16
  def render(text)
17
17
  pdf.text(
18
18
  text.value.to_s,
19
- font: options.font_name,
20
- size: options.header_font_size,
21
- style: options.bold_font_style
19
+ font: font_name,
20
+ size: header_font_size,
21
+ style: bold_font_style
22
22
  )
23
23
  end
24
24
  end
@@ -85,16 +85,16 @@ module Proforma
85
85
  def base_value_cell_style
86
86
  @base_value_cell_style ||= {
87
87
  border_width: 0,
88
- font: options.font_name,
88
+ font: font_name,
89
89
  padding: [2, 0, 2, 2],
90
- size: options.text_font_size
90
+ size: text_font_size
91
91
  }
92
92
  end
93
93
 
94
94
  def base_label_cell_style
95
95
  @base_label_cell_style ||= base_value_cell_style.merge(
96
96
  padding: [2, 2, 2, 0],
97
- font_style: options.bold_font_style
97
+ font_style: bold_font_style
98
98
  )
99
99
  end
100
100
  end
@@ -11,6 +11,13 @@ module Proforma
11
11
  class PrawnRenderer
12
12
  # The base class that contains common functionality across all sub-rendering components.
13
13
  class Renderer
14
+ extend Forwardable
15
+
16
+ def_delegators :options,
17
+ :font_name,
18
+ :header_font_size,
19
+ :text_font_size
20
+
14
21
  def initialize(pdf, options)
15
22
  @options = options
16
23
  @pdf = pdf
@@ -20,6 +27,10 @@ module Proforma
20
27
 
21
28
  attr_reader :options, :pdf
22
29
 
30
+ def bold_font_style
31
+ options.bold_font_style.to_s.to_sym
32
+ end
33
+
23
34
  def total_width
24
35
  pdf.bounds.width
25
36
  end
@@ -15,6 +15,8 @@ module Proforma
15
15
  class SeparatorRenderer < Renderer
16
16
  WIDTH = 0.5
17
17
 
18
+ private_constant :WIDTH
19
+
18
20
  def render(_separator)
19
21
  pdf.line_width(WIDTH)
20
22
  pdf.stroke_horizontal_rule
@@ -11,10 +11,12 @@ require_relative 'renderer'
11
11
 
12
12
  module Proforma
13
13
  class PrawnRenderer
14
- # This class understands how to ender a Proforma::Modeling::Separator component.
14
+ # This class understands how to ender a Proforma::Modeling::Spacer component.
15
15
  class SpacerRenderer < Renderer
16
16
  AMOUNT = 15
17
17
 
18
+ private_constant :AMOUNT
19
+
18
20
  def render(_separator)
19
21
  pdf.move_down(AMOUNT)
20
22
  end
@@ -35,9 +35,9 @@ module Proforma
35
35
  def make_rows(section, cell_style)
36
36
  section.rows.map do |row|
37
37
  row.cells.map do |cell|
38
- immediate_style = {}.tap do |hash|
39
- hash[:align] = cell.align.to_s.to_sym
40
- end
38
+ immediate_style = {
39
+ align: cell.align.to_s.to_sym
40
+ }
41
41
 
42
42
  pdf.make_cell(cell.text.to_s, cell_style.merge(immediate_style))
43
43
  end
@@ -59,9 +59,9 @@ module Proforma
59
59
  def cell_style
60
60
  @cell_style ||= {
61
61
  border_width: 0.5,
62
- font: options.font_name,
62
+ font: font_name,
63
63
  padding: 3,
64
- size: options.text_font_size
64
+ size: text_font_size
65
65
  }
66
66
  end
67
67
 
@@ -75,7 +75,7 @@ module Proforma
75
75
  @header_cell_style ||= cell_style.merge(
76
76
  background_color: 'D3D3D3',
77
77
  borders: [],
78
- font_style: options.bold_font_style
78
+ font_style: bold_font_style
79
79
  )
80
80
  end
81
81
 
@@ -83,7 +83,7 @@ module Proforma
83
83
  @footer_cell_style ||= cell_style.merge(
84
84
  background_color: 'F4F4F4',
85
85
  borders: [],
86
- font_style: options.bold_font_style
86
+ font_style: bold_font_style
87
87
  )
88
88
  end
89
89
  end
@@ -16,8 +16,8 @@ module Proforma
16
16
  def render(text)
17
17
  pdf.text(
18
18
  text.value.to_s,
19
- font: options.font_name,
20
- size: options.text_font_size
19
+ font: font_name,
20
+ size: text_font_size
21
21
  )
22
22
  end
23
23
  end
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Proforma
11
11
  class PrawnRenderer
12
- VERSION = '1.0.0-alpha.1'
12
+ VERSION = '1.0.0-alpha.2'
13
13
  end
14
14
  end
@@ -23,10 +23,10 @@ Gem::Specification.new do |s|
23
23
 
24
24
  s.add_dependency('prawn', '~>2')
25
25
  s.add_dependency('prawn-table', '~>0')
26
+ s.add_dependency('proforma', '~>1')
26
27
 
27
28
  s.add_development_dependency('guard-rspec', '~>4.7')
28
29
  s.add_development_dependency('pdf-inspector', '~>1')
29
- s.add_development_dependency('proforma', '>=1.0.0-alpha')
30
30
  s.add_development_dependency('pry', '~>0')
31
31
  s.add_development_dependency('rspec', '~> 3.8')
32
32
  s.add_development_dependency('rubocop', '~>0.63.1')
@@ -0,0 +1,184 @@
1
+ %PDF-1.3
2
+ %����
3
+ 1 0 obj
4
+ << /Creator <feff0050007200610077006e>
5
+ /Producer <feff0050007200610077006e>
6
+ >>
7
+ endobj
8
+ 2 0 obj
9
+ << /Type /Catalog
10
+ /Pages 3 0 R
11
+ >>
12
+ endobj
13
+ 3 0 obj
14
+ << /Type /Pages
15
+ /Count 1
16
+ /Kids [5 0 R]
17
+ >>
18
+ endobj
19
+ 4 0 obj
20
+ << /Length 1030
21
+ >>
22
+ stream
23
+ q
24
+ 1 w
25
+ /DeviceRGB CS
26
+ 0.0 0.0 0.0 SCN
27
+
28
+ BT
29
+ 36.0 746.192 Td
30
+ /F2.0 10 Tf
31
+ [<42616e6e6572205469746c65>] TJ
32
+ ET
33
+
34
+
35
+ BT
36
+ 36.0 734.632 Td
37
+ /F1.0 10 Tf
38
+ [<42616e6e65722044657461696c73>] TJ
39
+ ET
40
+
41
+
42
+ BT
43
+ 36.0 707.11 Td
44
+ /F2.0 15 Tf
45
+ [<486561646572>] TJ
46
+ ET
47
+
48
+ 0.5 w
49
+ 36.0 700.03 m
50
+ 576.0 700.03 l
51
+ S
52
+
53
+ BT
54
+ 36.0 687.85 Td
55
+ /F1.0 10 Tf
56
+ [<54> 120 <65> 30 <7874>] TJ
57
+ ET
58
+
59
+ /DeviceRGB cs
60
+ 0.8275 0.8275 0.8275 scn
61
+ 36.0 665.57 540.0 17.9 re
62
+ f
63
+ 0.0 0.0 0.0 scn
64
+ 0.5 w
65
+ 0.0 0.0 0.0 SCN
66
+
67
+ BT
68
+ 39.0 670.458 Td
69
+ /F2.0 10 Tf
70
+ [<4944204e756d626572>] TJ
71
+ ET
72
+
73
+ 0.5 w
74
+ 0.0 0.0 0.0 SCN
75
+ 36.0 665.57 m
76
+ 576.0 665.57 l
77
+ S
78
+ [] 0 d
79
+ 0.5 w
80
+ 0.0 0.0 0.0 SCN
81
+ 36.0 648.01 m
82
+ 576.0 648.01 l
83
+ S
84
+ [] 0 d
85
+ 0.5 w
86
+ 0.0 0.0 0.0 SCN
87
+
88
+ BT
89
+ 39.0 652.762 Td
90
+ /F1.0 10 Tf
91
+ [<32>] TJ
92
+ ET
93
+
94
+ 0.5 w
95
+ 0.0 0.0 0.0 SCN
96
+ 36.0 648.01 m
97
+ 576.0 648.01 l
98
+ S
99
+ [] 0 d
100
+ 0.5 w
101
+ 0.0 0.0 0.0 SCN
102
+ 36.0 630.45 m
103
+ 576.0 630.45 l
104
+ S
105
+ [] 0 d
106
+ 0.5 w
107
+ 0.0 0.0 0.0 SCN
108
+
109
+ BT
110
+ 39.0 635.202 Td
111
+ /F1.0 10 Tf
112
+ [<33>] TJ
113
+ ET
114
+
115
+ 0.5 w
116
+ 0.0 0.0 0.0 SCN
117
+
118
+ BT
119
+ 36.0 618.438 Td
120
+ /F2.0 10 Tf
121
+ [<4944204e756d626572>] TJ
122
+ ET
123
+
124
+ 0.5 w
125
+ 0.0 0.0 0.0 SCN
126
+
127
+ BT
128
+ 173.0 618.642 Td
129
+ /F1.0 10 Tf
130
+ [<31>] TJ
131
+ ET
132
+
133
+ Q
134
+
135
+ endstream
136
+ endobj
137
+ 5 0 obj
138
+ << /Type /Page
139
+ /Parent 3 0 R
140
+ /MediaBox [0 0 612.0 792.0]
141
+ /CropBox [0 0 612.0 792.0]
142
+ /BleedBox [0 0 612.0 792.0]
143
+ /TrimBox [0 0 612.0 792.0]
144
+ /ArtBox [0 0 612.0 792.0]
145
+ /Contents 4 0 R
146
+ /Resources << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI]
147
+ /Font << /F2.0 6 0 R
148
+ /F1.0 7 0 R
149
+ >>
150
+ >>
151
+ >>
152
+ endobj
153
+ 6 0 obj
154
+ << /Type /Font
155
+ /Subtype /Type1
156
+ /BaseFont /Helvetica-Bold
157
+ /Encoding /WinAnsiEncoding
158
+ >>
159
+ endobj
160
+ 7 0 obj
161
+ << /Type /Font
162
+ /Subtype /Type1
163
+ /BaseFont /Helvetica
164
+ /Encoding /WinAnsiEncoding
165
+ >>
166
+ endobj
167
+ xref
168
+ 0 8
169
+ 0000000000 65535 f
170
+ 0000000015 00000 n
171
+ 0000000109 00000 n
172
+ 0000000158 00000 n
173
+ 0000000215 00000 n
174
+ 0000001297 00000 n
175
+ 0000001595 00000 n
176
+ 0000001697 00000 n
177
+ trailer
178
+ << /Size 8
179
+ /Root 2 0 R
180
+ /Info 1 0 R
181
+ >>
182
+ startxref
183
+ 1794
184
+ %%EOF
@@ -0,0 +1,30 @@
1
+ data:
2
+ - id: 1
3
+ children:
4
+ - id: 2
5
+ - id: 3
6
+
7
+ template:
8
+ split: true
9
+ title: $id
10
+ children:
11
+ - type: Banner
12
+ details: Banner Details
13
+ title: Banner Title
14
+ - type: Spacer
15
+ - type: Header
16
+ value: Header
17
+ - type: Separator
18
+ - type: Text
19
+ value: Text
20
+ - type: DataTable
21
+ property: children
22
+ columns:
23
+ - header: ID Number
24
+ body: $id
25
+ - type: Pane
26
+ columns:
27
+ - label_width: 25.0
28
+ lines:
29
+ - label: ID Number
30
+ value: $id
@@ -38,15 +38,15 @@ template:
38
38
  - label_width: 20.0
39
39
  lines:
40
40
  - label: ID Number
41
- value: $:id
41
+ value: $id
42
42
  - label_width: 20.0
43
43
  lines:
44
44
  - label: First Name
45
- value: $:first
45
+ value: $first
46
46
  - label_width: 20.0
47
47
  lines:
48
48
  - label: Last Name
49
- value: $:last
49
+ value: $last
50
50
  - type: Spacer
51
51
  - type: Header
52
52
  value: Phone Numbers
@@ -55,9 +55,9 @@ template:
55
55
  empty_message: No phone numbers.
56
56
  columns:
57
57
  - header: Type
58
- body: $:type
58
+ body: $type
59
59
  - header: Number
60
- body: $:number
60
+ body: $number
61
61
  - type: Spacer
62
62
 
63
63
  strings:
@@ -25,15 +25,7 @@ data:
25
25
  login_count: 190890
26
26
  phone_numbers:
27
27
 
28
- renderer: !ruby/object:Proforma::PrawnRenderer
29
- options: !ruby/object:Proforma::PrawnRenderer::Options
30
- bold_font_style: :bold
31
- font_name: Helvetica
32
- header_font_size: 12
33
- text_font_size: 9
34
-
35
- template: !ruby/object:Proforma::Template
36
- output: :collection
28
+ template:
37
29
  title: User List
38
30
  children:
39
31
  - type: Banner
@@ -60,23 +52,23 @@ template: !ruby/object:Proforma::Template
60
52
  name: login_count_ave
61
53
  columns:
62
54
  - header: ID Number
63
- body: $:id
55
+ body: $id
64
56
  footer: Login Count Ave.
65
57
  width: 20
66
58
  - header: First Name
67
- body: $:first
68
- footer: $:login_count_ave
59
+ body: $first
60
+ footer: $login_count_ave
69
61
  width: 20
70
62
  - header: Last Name
71
- body: $:last
63
+ body: $last
72
64
  width: 20
73
65
  - header: Username
74
- body: $:username
66
+ body: $username
75
67
  footer: Login Count Sum
76
68
  width: 20
77
69
  - header: Login Count
78
- footer: $:login_count_sum
79
- body: $:login_count
70
+ footer: $login_count_sum
71
+ body: $login_count
80
72
  width: 20
81
73
  - type: Grouping
82
74
  property: users
@@ -92,11 +84,11 @@ template: !ruby/object:Proforma::Template
92
84
  - label_width: 25.0
93
85
  lines:
94
86
  - label: ID Number
95
- value: $:id
87
+ value: $id
96
88
  - label: First Name
97
- value: $:first
89
+ value: $first
98
90
  - label: Last Name
99
- value: $:last
91
+ value: $last
100
92
  - type: Spacer
101
93
  - type: Header
102
94
  value: Phone Numbers
@@ -105,9 +97,9 @@ template: !ruby/object:Proforma::Template
105
97
  empty_message: No phone numbers.
106
98
  columns:
107
99
  - header: Type
108
- body: $:type
100
+ body: $type
109
101
  - header: Number
110
- body: $:number
102
+ body: $number
111
103
  - type: Spacer
112
104
 
113
105
  strings:
@@ -117,7 +109,7 @@ strings:
117
109
  Login Count
118
110
  1 Will Smith will_smith 9219 2 Martin Lawrence mlaw10 8077
119
111
  3 Will Ferrell will.ferrell 190890
120
- Login Count Ave. 69395.333333333333333 333 Login Count Sum 208186.0
112
+ Login Count Ave. 69395.3333333333333 33333 Login Count Sum 208186.0
121
113
  User Details ID Number 1 First Name Will Last Name Smith Phone Numbers Type Number
122
114
  cell 555-444-3333 fax 333-444-2222 User Details ID Number 2 First Name Martin Last Name
123
115
  Lawrence Phone Numbers Type Number home 999-888-7777 User Details ID Number 3 First Name
@@ -21,8 +21,7 @@ describe ::Proforma::PrawnRenderer do
21
21
  documents = Proforma.render(
22
22
  contents['data'],
23
23
  contents['template'],
24
- evaluator: contents['evaluator'] || Proforma::HashEvaluator.new,
25
- renderer: contents['renderer'] || Proforma::PrawnRenderer.new
24
+ renderer: Proforma::PrawnRenderer.new
26
25
  )
27
26
 
28
27
  documents.each_with_index do |document, index|
@@ -50,8 +49,8 @@ describe ::Proforma::PrawnRenderer do
50
49
  {
51
50
  type: 'DataTable',
52
51
  columns: [
53
- { header: 'Team ID #', body: '$:id' },
54
- { header: 'Team Name', body: '$:name' }
52
+ { header: 'Team ID #', body: '$id' },
53
+ { header: 'Team Name', body: '$name' }
55
54
  ]
56
55
  }
57
56
  ]
@@ -68,4 +67,17 @@ describe ::Proforma::PrawnRenderer do
68
67
  expect(actual_document.title).to eq('nba_team_list')
69
68
  expect(actual_document.extension).to eq('.pdf')
70
69
  end
70
+
71
+ specify 'a pdf-to-pdf comparison should be equal' do
72
+ pdf = read(File.join('spec', 'fixtures', 'component_test.pdf'))
73
+ config = yaml_read(File.join('spec', 'fixtures', 'component_test.yml'))
74
+
75
+ documents = Proforma.render(
76
+ config['data'],
77
+ config['template'],
78
+ renderer: Proforma::PrawnRenderer.new
79
+ )
80
+
81
+ expect(documents.first.contents).to eq(pdf)
82
+ end
71
83
  end
data/spec/spec_helper.rb CHANGED
@@ -18,10 +18,12 @@ SimpleCov.start
18
18
 
19
19
  require './lib/proforma/prawn_renderer'
20
20
 
21
+ def read(file)
22
+ File.open(file, 'rb').read
23
+ end
24
+
21
25
  def yaml_read(file)
22
- # rubocop:disable Security/YAMLLoad
23
- YAML.load(File.open(file))
24
- # rubocop:enable Security/YAMLLoad
26
+ YAML.safe_load(File.open(file))
25
27
  end
26
28
 
27
29
  def pdf_strings(rendered_pdf)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proforma-prawn-renderer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.alpha.1
4
+ version: 1.0.0.pre.alpha.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Ruggio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-22 00:00:00.000000000 Z
11
+ date: 2019-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -39,47 +39,47 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: guard-rspec
42
+ name: proforma
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '4.7'
48
- type: :development
47
+ version: '1'
48
+ type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '4.7'
54
+ version: '1'
55
55
  - !ruby/object:Gem::Dependency
56
- name: pdf-inspector
56
+ name: guard-rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1'
61
+ version: '4.7'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1'
68
+ version: '4.7'
69
69
  - !ruby/object:Gem::Dependency
70
- name: proforma
70
+ name: pdf-inspector
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.0.0.pre.alpha
75
+ version: '1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.0.0.pre.alpha
82
+ version: '1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: pry
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -175,7 +175,6 @@ files:
175
175
  - lib/proforma/prawn_renderer.rb
176
176
  - lib/proforma/prawn_renderer/banner_renderer.rb
177
177
  - lib/proforma/prawn_renderer/header_renderer.rb
178
- - lib/proforma/prawn_renderer/options.rb
179
178
  - lib/proforma/prawn_renderer/pane_renderer.rb
180
179
  - lib/proforma/prawn_renderer/renderer.rb
181
180
  - lib/proforma/prawn_renderer/separator_renderer.rb
@@ -184,6 +183,8 @@ files:
184
183
  - lib/proforma/prawn_renderer/text_renderer.rb
185
184
  - lib/proforma/prawn_renderer/version.rb
186
185
  - proforma-prawn-renderer.gemspec
186
+ - spec/fixtures/component_test.pdf
187
+ - spec/fixtures/component_test.yml
187
188
  - spec/fixtures/snapshots/user_details.yml
188
189
  - spec/fixtures/snapshots/user_list.yml
189
190
  - spec/proforma/prawn_renderer_spec.rb
@@ -212,6 +213,8 @@ signing_key:
212
213
  specification_version: 4
213
214
  summary: Proforma renderer plugin for generating PDFs using Prawn
214
215
  test_files:
216
+ - spec/fixtures/component_test.pdf
217
+ - spec/fixtures/component_test.yml
215
218
  - spec/fixtures/snapshots/user_details.yml
216
219
  - spec/fixtures/snapshots/user_list.yml
217
220
  - spec/proforma/prawn_renderer_spec.rb
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- #
4
- # Copyright (c) 2019-present, Blue Marble Payroll, LLC
5
- #
6
- # This source code is licensed under the MIT license found in the
7
- # LICENSE file in the root directory of this source tree.
8
- #
9
-
10
- module Proforma
11
- class PrawnRenderer
12
- # A list of options available for customizing the rendering engine.
13
- class Options
14
- DEFAULT_BOLD_FONT_STYLE = :bold
15
- DEFAULT_FONT_NAME = ''
16
- DEFAULT_TEXT_FONT_SIZE = 10
17
- DEFAULT_HEADER_FONT_SIZE = DEFAULT_TEXT_FONT_SIZE + 5
18
-
19
- attr_writer :bold_font_style,
20
- :header_font_size,
21
- :text_font_size
22
-
23
- attr_accessor :font_name
24
-
25
- def bold_font_style
26
- @bold_font_style || DEFAULT_BOLD_FONT_STYLE
27
- end
28
-
29
- def header_font_size
30
- @header_font_size ? @header_font_size.to_f : DEFAULT_HEADER_FONT_SIZE
31
- end
32
-
33
- def text_font_size
34
- @text_font_size ? @text_font_size.to_f : DEFAULT_TEXT_FONT_SIZE
35
- end
36
- end
37
- end
38
- end