mork 0.0.6 → 0.0.7
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 +4 -4
- data/.gitignore +1 -1
- data/Guardfile +1 -1
- data/lib/mork/grid.rb +31 -24
- data/lib/mork/grid_const.rb +1 -1
- data/lib/mork/npatch.rb +1 -1
- data/lib/mork/sheet.rb +24 -13
- data/lib/mork/sheet_pdf.rb +24 -20
- data/lib/mork/version.rb +1 -1
- data/mork.gemspec +11 -12
- data/spec/mork/grid_spec.rb +9 -9
- data/spec/mork/sheet_pdf_spec.rb +36 -114
- data/spec/mork/sheet_spec.rb +87 -105
- data/spec/spec_helper.rb +24 -4
- metadata +41 -59
- data/config/grids.yml +0 -46
- data/spec/samples/sheet1.jpg +0 -0
- data/spec/samples/sheet1.pdf +0 -10060
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77cd220a9af15fb52c434ad78e5436e922a92d9b
|
4
|
+
data.tar.gz: 7ec01ec5ef0fe665822dbcf2da5b4c59682db51c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f59e836632c2cb223193480692b52631b09a7739b61e8b839f36babdd77ccef7785a0515c54cc670327547b9ca1f26e99bc8a389914b2864d51547de249e575
|
7
|
+
data.tar.gz: 29829dc19f2217b4beadd263f181290c585f5e54f0463b6b62d10b489b517deac42ffdf76d3c543a5942d84dbad364f0e7b4db871bb3fde87d7ce9a0ff5d0e30
|
data/.gitignore
CHANGED
data/Guardfile
CHANGED
data/lib/mork/grid.rb
CHANGED
@@ -221,7 +221,13 @@ module Mork
|
|
221
221
|
|
222
222
|
def pdf_ctrl_area_light
|
223
223
|
{
|
224
|
-
p: [
|
224
|
+
p: [
|
225
|
+
cell_spacing.mm +
|
226
|
+
pdf_control_xy[0] +
|
227
|
+
pdf_control_width +
|
228
|
+
ctrl_margin.mm,
|
229
|
+
pdf_control_xy[1]
|
230
|
+
],
|
225
231
|
w: cell_width.mm,
|
226
232
|
h: cell_height.mm
|
227
233
|
}
|
@@ -355,28 +361,29 @@ module Mork
|
|
355
361
|
# ===============================
|
356
362
|
# = Simple parameter extraction =
|
357
363
|
# ===============================
|
358
|
-
def ctrl_cell_x() @params[:control][:left].to_f +
|
359
|
-
def ctrl_margin() @params[:control][:margin].to_f
|
360
|
-
def
|
361
|
-
def
|
362
|
-
def
|
363
|
-
def
|
364
|
-
def
|
365
|
-
def
|
366
|
-
def
|
367
|
-
def
|
368
|
-
def
|
369
|
-
def
|
370
|
-
def
|
371
|
-
def
|
372
|
-
def
|
373
|
-
def
|
374
|
-
def
|
375
|
-
def
|
376
|
-
def
|
377
|
-
def
|
378
|
-
def
|
379
|
-
def
|
380
|
-
def
|
364
|
+
def ctrl_cell_x() @params[:control][:left].to_f + ctrl_width + ctrl_margin end
|
365
|
+
def ctrl_margin() @params[:control][:margin].to_f end
|
366
|
+
def ctrl_width() @params[:control][:width].to_f end
|
367
|
+
def ctrl_cell_y() @params[:control][:top].to_f end
|
368
|
+
def code_height() @params[:code][:height].to_f end
|
369
|
+
def code_width() @params[:code][:width].to_f end
|
370
|
+
def page_width() @params[:page_size][:width].to_f end
|
371
|
+
def page_height() @params[:page_size][:height].to_f end
|
372
|
+
def cell_width() @params[:items][:cell_width].to_f end
|
373
|
+
def cell_height() @params[:items][:cell_height].to_f end
|
374
|
+
def cell_spacing() @params[:items][:x_spacing].to_f end
|
375
|
+
def item_spacing() @params[:items][:y_spacing].to_f end
|
376
|
+
def column_width() @params[:items][:column_width].to_f end
|
377
|
+
def row_spacing() @params[:items][:y_spacing].to_f end
|
378
|
+
def first_x() @params[:items][:first_x].to_f end
|
379
|
+
def first_y() @params[:items][:first_y].to_f end
|
380
|
+
def rows() @params[:items][:rows] end
|
381
|
+
def columns() @params[:items][:columns] end
|
382
|
+
def reg_margin() @params[:regmarks][:margin].to_f end
|
383
|
+
def reg_search() @params[:regmarks][:search].to_f end
|
384
|
+
def reg_radius() @params[:regmarks][:radius].to_f end
|
385
|
+
def reg_frame_width() page_width - reg_margin * 2 end
|
386
|
+
def reg_frame_height() page_height - reg_margin * 2 end
|
387
|
+
def reg_off() @params[:regmarks][:offset].to_f end
|
381
388
|
end
|
382
389
|
end
|
data/lib/mork/grid_const.rb
CHANGED
data/lib/mork/npatch.rb
CHANGED
data/lib/mork/sheet.rb
CHANGED
@@ -4,10 +4,10 @@ module Mork
|
|
4
4
|
@raw = case im.class.to_s
|
5
5
|
when "String"
|
6
6
|
Mimage.new im
|
7
|
-
when "Mimage"
|
7
|
+
when "Mork::Mimage"
|
8
8
|
im
|
9
9
|
else
|
10
|
-
raise "A new sheet requires either a Mimage or the name of the source image file"
|
10
|
+
raise "A new sheet requires either a Mimage or the name of the source image file, but it was a: #{im.class}"
|
11
11
|
end
|
12
12
|
@grid = grid
|
13
13
|
# send page size to the grid, so that all later measurements can be done within the
|
@@ -42,6 +42,7 @@ module Mork
|
|
42
42
|
# false otherwise
|
43
43
|
def marked?(q, c)
|
44
44
|
return if not_registered
|
45
|
+
# puts "SHADE: #{shade_of(q, c)}, Q: #{q}, C: #{c}, THR: #{choice_threshold}"
|
45
46
|
shade_of(q, c) < choice_threshold
|
46
47
|
end
|
47
48
|
|
@@ -102,23 +103,30 @@ module Mork
|
|
102
103
|
@crop.highlight! @grid.choice_cell_area(q, c)
|
103
104
|
end
|
104
105
|
|
105
|
-
def
|
106
|
+
def highlight_code_areas
|
106
107
|
return if not_registered
|
107
108
|
@grid.code_bits.times do |bit|
|
108
109
|
@crop.highlight! @grid.code_bit_area bit
|
109
110
|
end
|
110
111
|
end
|
111
112
|
|
112
|
-
def
|
113
|
-
|
113
|
+
def highlight_code
|
114
|
+
return if not_registered
|
115
|
+
@grid.code_bits.times do |bit|
|
116
|
+
if code_string.reverse[bit] == '1'
|
117
|
+
@crop.highlight! @grid.code_bit_area bit
|
118
|
+
end
|
119
|
+
end
|
114
120
|
end
|
115
|
-
|
121
|
+
|
116
122
|
def highlight_dark_calibration_bit
|
117
|
-
|
123
|
+
return if not_registered
|
124
|
+
@crop.highlight!(@grid.cal_area_black)
|
118
125
|
end
|
119
126
|
|
120
127
|
def highlight_light_calibration_bit
|
121
|
-
|
128
|
+
return if not_registered
|
129
|
+
@crop.highlight!(@grid.cal_area_white)
|
122
130
|
end
|
123
131
|
|
124
132
|
def highlight_reg_area
|
@@ -126,11 +134,13 @@ module Mork
|
|
126
134
|
@raw.highlight! @rmsa[:tr]
|
127
135
|
@raw.highlight! @rmsa[:br]
|
128
136
|
@raw.highlight! @rmsa[:bl]
|
129
|
-
|
137
|
+
return if not_registered
|
138
|
+
@raw.join!(@rm)
|
130
139
|
end
|
131
140
|
|
132
141
|
def write(fname)
|
133
|
-
|
142
|
+
return if not_registered
|
143
|
+
@crop.write(fname)
|
134
144
|
end
|
135
145
|
|
136
146
|
def write_raw(fname)
|
@@ -144,8 +154,10 @@ module Mork
|
|
144
154
|
(0...@grid.max_questions)
|
145
155
|
elsif r.is_a? Fixnum
|
146
156
|
(0...r)
|
147
|
-
|
157
|
+
elsif r.is_a? Array
|
148
158
|
r
|
159
|
+
else
|
160
|
+
raise "Invalid argument"
|
149
161
|
end
|
150
162
|
end
|
151
163
|
|
@@ -165,7 +177,7 @@ module Mork
|
|
165
177
|
end
|
166
178
|
|
167
179
|
def choice_threshold
|
168
|
-
@choice_threshold ||= (naverage(@grid.ctrl_area_dark) +
|
180
|
+
@choice_threshold ||= (naverage(@grid.ctrl_area_dark) +
|
169
181
|
naverage(@grid.ctrl_area_light)) / 2
|
170
182
|
end
|
171
183
|
|
@@ -202,7 +214,6 @@ module Mork
|
|
202
214
|
def reg_centroid_on(img, corner)
|
203
215
|
1000.times do |i|
|
204
216
|
@rmsa[corner] = @grid.rm_search_area(corner, i)
|
205
|
-
puts "RM: #{@rmsa[corner].inspect}"
|
206
217
|
cx, cy = NPatch.new(img.crop(@rmsa[corner])).dark_centroid
|
207
218
|
if cx.nil?
|
208
219
|
status = :insufficient_contrast
|
data/lib/mork/sheet_pdf.rb
CHANGED
@@ -2,12 +2,16 @@ require 'prawn'
|
|
2
2
|
|
3
3
|
module Mork
|
4
4
|
class SheetPDF < Prawn::Document
|
5
|
-
def initialize(
|
6
|
-
@grid = grid
|
5
|
+
def initialize(content, grid=Grid.new)
|
6
|
+
@grid = case grid.class.to_s
|
7
|
+
when "String"; Grid.new grid
|
8
|
+
when "Mork::Grid"; grid
|
9
|
+
else raise "Invalid initialization parameter"
|
10
|
+
end
|
7
11
|
super my_page_params
|
8
|
-
# @
|
12
|
+
# @content should be an array of hashes, one per page;
|
9
13
|
# convert to array if a single hash was passed
|
10
|
-
@
|
14
|
+
@content = content.class == Hash ? [content] : content
|
11
15
|
process
|
12
16
|
end
|
13
17
|
|
@@ -23,16 +27,16 @@ module Mork
|
|
23
27
|
|
24
28
|
def process
|
25
29
|
# for each response sheet
|
26
|
-
@
|
30
|
+
@content.each_with_index do |content, i|
|
27
31
|
start_new_page if i>0
|
28
32
|
fill_color "000000"
|
29
33
|
stroke_color "000000"
|
30
34
|
line_width 0.3
|
31
35
|
registration_marks
|
32
|
-
calibration_and_code
|
33
|
-
header
|
34
|
-
control
|
35
|
-
questions_and_choices
|
36
|
+
calibration_and_code content[:code]
|
37
|
+
header content[:header]
|
38
|
+
control content[:control] if content[:control]
|
39
|
+
questions_and_choices content[:choices]
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
@@ -64,9 +68,9 @@ module Mork
|
|
64
68
|
end
|
65
69
|
end
|
66
70
|
|
67
|
-
def control(
|
71
|
+
def control(content)
|
68
72
|
font_size @grid.pdf_control_size do
|
69
|
-
text_box
|
73
|
+
text_box content[:string], at: @grid.pdf_control_xy,
|
70
74
|
width: @grid.pdf_control_width,
|
71
75
|
align: :right
|
72
76
|
stroke do
|
@@ -76,19 +80,19 @@ module Mork
|
|
76
80
|
a = @grid.pdf_ctrl_area_dark
|
77
81
|
rounded_rectangle a[:p], a[:w], a[:h], [a[:h], a[:w]].min / 2
|
78
82
|
fill_color "ff0000"
|
79
|
-
draw_text
|
83
|
+
draw_text content[:labels][0], at: @grid.pdf_dark_control_letter_xy
|
80
84
|
# light
|
81
85
|
a = @grid.pdf_ctrl_area_light
|
82
86
|
rounded_rectangle a[:p], a[:w], a[:h], [a[:h], a[:w]].min / 2
|
83
87
|
fill_color "ff0000"
|
84
|
-
draw_text
|
88
|
+
draw_text content[:labels][1], at: @grid.pdf_light_control_letter_xy
|
85
89
|
|
86
90
|
end
|
87
91
|
end
|
88
92
|
end
|
89
93
|
|
90
|
-
def header(
|
91
|
-
|
94
|
+
def header(content)
|
95
|
+
content.each do |k,v|
|
92
96
|
font_size @grid.pdf_header_size(k) do
|
93
97
|
if @grid.pdf_header_boxed?(k)
|
94
98
|
bounding_box @grid.pdf_header_xy(k), width: @grid.pdf_header_width(k), height: @grid.pdf_header_height(k) do
|
@@ -104,9 +108,9 @@ module Mork
|
|
104
108
|
end
|
105
109
|
end
|
106
110
|
|
107
|
-
def questions_and_choices(
|
111
|
+
def questions_and_choices(content)
|
108
112
|
stroke do
|
109
|
-
|
113
|
+
content.length.times do |q|
|
110
114
|
fill_color "000000"
|
111
115
|
text_box "#{q+1}", at: @grid.pdf_qnum_xy(q),
|
112
116
|
width: @grid.pdf_qnum_width,
|
@@ -114,7 +118,7 @@ module Mork
|
|
114
118
|
size: @grid.pdf_qnum_size
|
115
119
|
stroke_color "ff0000"
|
116
120
|
font_size @grid.pdf_chlett_size
|
117
|
-
|
121
|
+
content[q].times do |c|
|
118
122
|
a = @grid.pdf_choice_cell_area q, c
|
119
123
|
rounded_rectangle a[:p], a[:w], a[:h], [a[:h], a[:w]].min / 2
|
120
124
|
fill_color "ff0000"
|
@@ -125,11 +129,11 @@ module Mork
|
|
125
129
|
end
|
126
130
|
|
127
131
|
# def nquestions
|
128
|
-
# @
|
132
|
+
# @content[:choices].length
|
129
133
|
# end
|
130
134
|
#
|
131
135
|
# def nchoices(i)
|
132
|
-
# @
|
136
|
+
# @content[:choices][i]
|
133
137
|
# end
|
134
138
|
end
|
135
139
|
end
|
data/lib/mork/version.rb
CHANGED
data/mork.gemspec
CHANGED
@@ -5,6 +5,7 @@ require "mork/version"
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "mork"
|
7
7
|
s.version = Mork::VERSION
|
8
|
+
s.licenses = ['MIT']
|
8
9
|
s.authors = ["Giuseppe Bertini"]
|
9
10
|
s.email = ["giuseppe.bertini@gmail.com"]
|
10
11
|
s.homepage = ""
|
@@ -18,16 +19,14 @@ Gem::Specification.new do |s|
|
|
18
19
|
s.require_paths = ["lib"]
|
19
20
|
|
20
21
|
# dependencies:
|
21
|
-
s.add_dependency
|
22
|
-
s.add_dependency
|
23
|
-
s.add_dependency
|
24
|
-
s.add_development_dependency 'rake'
|
25
|
-
s.add_development_dependency
|
26
|
-
s.add_development_dependency
|
27
|
-
s.add_development_dependency
|
28
|
-
s.add_development_dependency
|
29
|
-
s.add_development_dependency
|
30
|
-
s.add_development_dependency
|
31
|
-
|
32
|
-
# s.add_runtime_dependency "rest-client"
|
22
|
+
s.add_dependency 'narray', '~> 0.6'
|
23
|
+
s.add_dependency 'rmagick', '~> 2.13'
|
24
|
+
s.add_dependency 'prawn', '1.0.0.rc2'
|
25
|
+
s.add_development_dependency 'rake', '~> 10.3'
|
26
|
+
s.add_development_dependency 'rspec', '~> 3.1'
|
27
|
+
s.add_development_dependency 'guard', '~> 2.6'
|
28
|
+
s.add_development_dependency 'guard-rspec', '~> 4.3'
|
29
|
+
s.add_development_dependency 'guard-shell', '~> 0.6'
|
30
|
+
# s.add_development_dependency 'rb-fsevent'
|
31
|
+
s.add_development_dependency 'awesome_print', '~> 1.2'
|
33
32
|
end
|
data/spec/mork/grid_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module Mork
|
4
4
|
describe Grid do
|
5
|
-
context 'default grid'
|
5
|
+
context 'default grid' do
|
6
6
|
before(:all) do
|
7
7
|
@grid = Grid.new
|
8
8
|
@grid.set_page_size 1601, 2281 # the size of sample01.jpg
|
@@ -34,44 +34,44 @@ module Mork
|
|
34
34
|
context 'on the first iteration' do
|
35
35
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :tl reg_mark corner' do
|
36
36
|
c = @grid.rm_search_area :tl, 0
|
37
|
-
c.should == {
|
37
|
+
c.should == {:x=>15, :y=>15, :w=>76, :h=>77}
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :tr reg_mark corner' do
|
41
41
|
c = @grid.rm_search_area :tr, 0
|
42
|
-
c.should == { x:
|
42
|
+
c.should == { x: 1510, y: 15, w: 76, h: 77 }
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :br reg_mark corner' do
|
46
46
|
c = @grid.rm_search_area :br, 0
|
47
|
-
c.should == { x:
|
47
|
+
c.should == { x: 1510, y: 2189, w: 76, h: 77 }
|
48
48
|
end
|
49
49
|
|
50
50
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :bl reg_mark corner' do
|
51
51
|
c = @grid.rm_search_area :bl, 0
|
52
|
-
c.should == { x:
|
52
|
+
c.should == { x: 15, y: 2189, w: 76, h: 77 }
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
context 'on the third iteration' do
|
57
57
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :tl reg_mark corner' do
|
58
58
|
c = @grid.rm_search_area :tl, 2
|
59
|
-
c.should == { x:
|
59
|
+
c.should == { x: 15, y: 15, w: 114, h: 115 }
|
60
60
|
end
|
61
61
|
|
62
62
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :tr reg_mark corner' do
|
63
63
|
c = @grid.rm_search_area :tr, 2
|
64
|
-
c.should == { x:
|
64
|
+
c.should == { x: 1471, y: 15, w: 114, h: 115 }
|
65
65
|
end
|
66
66
|
|
67
67
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :br reg_mark corner' do
|
68
68
|
c = @grid.rm_search_area :br, 2
|
69
|
-
c.should == { x:
|
69
|
+
c.should == { x: 1471, y: 2150, w: 114, h: 115 }
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'returns an {:x, :y, :w, :h} hash of coordinates in pixels for the :bl reg_mark corner' do
|
73
73
|
c = @grid.rm_search_area :bl, 2
|
74
|
-
c.should == { x:
|
74
|
+
c.should == { x: 15, y: 2150, w: 114, h: 115 }
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
data/spec/mork/sheet_pdf_spec.rb
CHANGED
@@ -1,106 +1,41 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Mork
|
4
|
+
|
4
5
|
describe SheetPDF do
|
6
|
+
it 'assigns the grid to @grid' do
|
7
|
+
s = SheetPDF.new(some_pdf_content)
|
8
|
+
s.instance_variable_get("@grid").should be_a Grid
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'creates a grid by loading the specified file' do
|
12
|
+
s = SheetPDF.new(some_pdf_content, 'spec/samples/grid01.yml')
|
13
|
+
s.instance_variable_get('@grid').should be_a Grid
|
14
|
+
end
|
5
15
|
|
6
|
-
it
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
signature: "Firma"
|
15
|
-
},
|
16
|
-
control: {
|
17
|
-
string: "Annerisci solo la casella ‘V’:",
|
18
|
-
labels: ['V', 'F']
|
19
|
-
}
|
20
|
-
}
|
21
|
-
|
22
|
-
grid_opts = {
|
23
|
-
regmarks: {
|
24
|
-
margin: 10,
|
25
|
-
radius: 2.5,
|
26
|
-
search: 10
|
27
|
-
},
|
28
|
-
header: {
|
29
|
-
name: {
|
30
|
-
top: 5,
|
31
|
-
left: 7.5,
|
32
|
-
width: 170,
|
33
|
-
size: 14,
|
34
|
-
},
|
35
|
-
title: {
|
36
|
-
top: 15,
|
37
|
-
left: 7.5,
|
38
|
-
width: 180,
|
39
|
-
size: 12
|
40
|
-
},
|
41
|
-
code: {
|
42
|
-
top: 5,
|
43
|
-
left: 165,
|
44
|
-
width: 20,
|
45
|
-
size: 14
|
46
|
-
},
|
47
|
-
signature: {
|
48
|
-
top: 30,
|
49
|
-
left: 7.5,
|
50
|
-
width: 120,
|
51
|
-
height: 15,
|
52
|
-
size: 7,
|
53
|
-
box: true,
|
54
|
-
}
|
55
|
-
}, # header end
|
56
|
-
items: {
|
57
|
-
columns: 4,
|
58
|
-
column_width: 49,
|
59
|
-
rows: 30,
|
60
|
-
# from the top-left registration mark
|
61
|
-
# to the center of the first choice cell
|
62
|
-
first_x: 10.5,
|
63
|
-
first_y: 55.5,
|
64
|
-
# between choices
|
65
|
-
x_spacing: 7.0,
|
66
|
-
# between rows
|
67
|
-
y_spacing: 7.0,
|
68
|
-
# darkened area
|
69
|
-
cell_width: 6.0,
|
70
|
-
cell_height: 5.0,
|
71
|
-
# the maximum number of choices per question
|
72
|
-
max_cells: 5,
|
73
|
-
# font size for the question number
|
74
|
-
number_size: 10,
|
75
|
-
# distance between right side of q num and left side of first choice cell
|
76
|
-
number_width: 8,
|
77
|
-
# width of question number text box
|
78
|
-
number_margin: 2,
|
79
|
-
# font size for the choice letter
|
80
|
-
letter_size: 8
|
81
|
-
},
|
82
|
-
code: {
|
83
|
-
bits: 40,
|
84
|
-
left: 15,
|
85
|
-
width: 3.0,
|
86
|
-
height: 2.5,
|
87
|
-
spacing: 4
|
88
|
-
},
|
89
|
-
control: {
|
90
|
-
top: 40,
|
91
|
-
left: 123,
|
92
|
-
width: 50,
|
93
|
-
size: 9,
|
94
|
-
margin: 2.5
|
95
|
-
}
|
96
|
-
}
|
16
|
+
it 'raises an error with an invalid init parameter' do
|
17
|
+
lambda { SheetPDF.new(some_pdf_content, 2) }.should raise_error "Invalid initialization parameter"
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'assigns an array to @content' do
|
21
|
+
s = SheetPDF.new(some_pdf_content)
|
22
|
+
s.instance_variable_get("@content").should be_an Array
|
23
|
+
end
|
97
24
|
|
98
|
-
|
99
|
-
|
25
|
+
it 'assigns an array of hashes to @content' do
|
26
|
+
s = SheetPDF.new(some_pdf_content)
|
27
|
+
s.instance_variable_get("@content").first.should be_a Hash
|
28
|
+
end
|
100
29
|
|
101
|
-
|
102
|
-
|
103
|
-
|
30
|
+
it 'creates a basic PDF sheet' do
|
31
|
+
s = SheetPDF.new(some_pdf_content)
|
32
|
+
s.save("tmp/f1.pdf")
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'creates a PDF sheet with the maximum possible code' do
|
36
|
+
content = {
|
37
|
+
code: 1099511627775,
|
38
|
+
choices: [5] * 120,
|
104
39
|
header: {
|
105
40
|
name: "Bonazza Sara vr354320",
|
106
41
|
title: "Esame di Fondamenti Morfologici e Funzionali della Vita - 18 gennaio 2013",
|
@@ -108,27 +43,14 @@ module Mork
|
|
108
43
|
signature: "Firma"
|
109
44
|
}
|
110
45
|
}
|
111
|
-
s = SheetPDF.new(
|
46
|
+
s = SheetPDF.new(content)
|
112
47
|
s.save("tmp/f2.pdf")
|
113
|
-
|
114
|
-
info = {
|
115
|
-
code: 8928348236,
|
116
|
-
choices: [5] * 160,
|
117
|
-
header: {
|
118
|
-
name: "G" * 60,
|
119
|
-
title: "E" * 100,
|
120
|
-
code: "119.28",
|
121
|
-
signature: "Firma"
|
122
|
-
}
|
123
|
-
}
|
124
|
-
s = SheetPDF.new(Grid.new, info)
|
125
|
-
s.save("tmp/f3.pdf")
|
126
48
|
end
|
127
49
|
|
128
50
|
it "should create a multipage pdf" do
|
129
|
-
|
51
|
+
content = [
|
130
52
|
{
|
131
|
-
code:
|
53
|
+
code: 18446744073,
|
132
54
|
choices: [5] * 100,
|
133
55
|
header: {
|
134
56
|
name: "Bertini Giuseppe VR123456 Bertini Giuseppe VR123456",
|
@@ -139,7 +61,7 @@ module Mork
|
|
139
61
|
},
|
140
62
|
{
|
141
63
|
code: 5512,
|
142
|
-
choices: [5] *
|
64
|
+
choices: [5] * 100,
|
143
65
|
header: {
|
144
66
|
name: "Bonazza Sara vr354320",
|
145
67
|
title: "Esame di Fondamenti Morfologici e Funzionali della Vita - 18 gennaio 2013",
|
@@ -148,7 +70,7 @@ module Mork
|
|
148
70
|
}
|
149
71
|
}
|
150
72
|
]
|
151
|
-
s = SheetPDF.new(
|
73
|
+
s = SheetPDF.new(content)
|
152
74
|
s.save("tmp/p2.pdf")
|
153
75
|
end
|
154
76
|
end
|