mork 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mork/grid_pdf.rb +15 -14
- data/lib/mork/sheet_pdf.rb +8 -4
- data/lib/mork/version.rb +1 -1
- data/spec/mork/grid_omr_spec.rb +4 -4
- data/spec/mork/sheet_omr_spec.rb +4 -0
- data/spec/mork/sheet_pdf_spec.rb +12 -1
- data/spec/samples/boxy.yml +62 -0
- data/spec/samples/layout.yml +45 -45
- data/spec/samples/slanted.yml +1 -1
- data/spec/spec_helper.rb +4 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef3d30047bed71d952406b0a01de783f63eaf1ff
|
4
|
+
data.tar.gz: c926cabe1f1d46c600a068e1f0d579d945211ec9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b4450f335d7e68729fae7b1436a09edbd2cd80ebb4bfcec9c7e6ef80df1f686edd7c585fe612679243a2825879c610ae7e8e46d26141c09e6b1856851cee7c8
|
7
|
+
data.tar.gz: 661c1b3310f7ae120e4cdb9d098db1a8b9ce6c548e612dda731f99ac0b2162cbc0ff0dcdc6724fae71def879380f349fa101048a8b2c2b08ceb3f61d20101d39
|
data/lib/mork/grid_pdf.rb
CHANGED
@@ -7,7 +7,7 @@ module Mork
|
|
7
7
|
def initialize(options=nil)
|
8
8
|
super options
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def reg_marks
|
12
12
|
r = reg_radius.mm
|
13
13
|
[
|
@@ -17,30 +17,30 @@ module Mork
|
|
17
17
|
{ p: [reg_frame_width.mm, 0 ], r: r }
|
18
18
|
]
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def barcode_width
|
22
22
|
super.mm
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def barcode_height
|
26
26
|
super.mm
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def barcode_xy_for(code)
|
30
30
|
black = barcode_bits.times.reject { |x| (code>>x)[0]==0 }
|
31
31
|
black.collect { |x| barcode_xy x+1 }
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def ink_black_xy
|
35
35
|
barcode_xy 0
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def calibration_cells_xy
|
39
39
|
rows.times.collect do |q|
|
40
40
|
[(reg_frame_width-cell_spacing).mm, item_y(q).mm]
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
# Coordinates at which to place item numbers
|
45
45
|
def qnum_xy(q)
|
46
46
|
[
|
@@ -48,23 +48,23 @@ module Mork
|
|
48
48
|
item_y(q).mm
|
49
49
|
]
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
def width_of_cell
|
53
53
|
cell_width.mm
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
def height_of_cell
|
57
57
|
cell_height.mm
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def choice_spacing
|
61
61
|
cell_spacing.mm
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
def item_xy(q)
|
65
65
|
[item_x(q).mm, item_y(q).mm]
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
def cround
|
69
69
|
@cround ||= [width_of_cell, height_of_cell].min / 2
|
70
70
|
end
|
@@ -77,6 +77,7 @@ module Mork
|
|
77
77
|
def header_width(k) @params[:header][k][:width].to_f.mm end
|
78
78
|
def header_height(k) @params[:header][k][:height].to_f.mm end
|
79
79
|
def header_size(k) @params[:header][k][:size].to_f end
|
80
|
+
def header_align(k) @params[:header][k][:align] end
|
80
81
|
def header_boxed?(k) @params[:header][k][:box] == true end
|
81
82
|
|
82
83
|
def header_xy(k)
|
@@ -105,7 +106,7 @@ module Mork
|
|
105
106
|
barcode_height
|
106
107
|
]
|
107
108
|
end
|
108
|
-
|
109
|
+
|
109
110
|
def barcode_area(i)
|
110
111
|
{
|
111
112
|
p: [barcode_bit_x(i).mm, (reg_frame_height - barcode_y).mm],
|
@@ -114,4 +115,4 @@ module Mork
|
|
114
115
|
}
|
115
116
|
end
|
116
117
|
end
|
117
|
-
end
|
118
|
+
end
|
data/lib/mork/sheet_pdf.rb
CHANGED
@@ -85,15 +85,19 @@ module Mork
|
|
85
85
|
def header(content)
|
86
86
|
content.each do |k,v|
|
87
87
|
font_size @grip.header_size(k) do
|
88
|
+
align = @grip.header_align(k).nil?? :left : @grip.header_align(k).to_sym
|
88
89
|
if @grip.header_boxed?(k)
|
89
90
|
bounding_box @grip.header_xy(k), width: @grip.header_width(k), height: @grip.header_height(k) do
|
90
91
|
stroke_bounds
|
91
|
-
|
92
|
-
|
93
|
-
|
92
|
+
text_box v, at: @grip.header_padding(k),
|
93
|
+
width: @grip.header_width(k)-@grip.header_padding(k)[0]*2,
|
94
|
+
align: align
|
94
95
|
end
|
95
96
|
else
|
96
|
-
text_box v, at:
|
97
|
+
text_box v, at: @grip.header_xy(k),
|
98
|
+
width: @grip.header_width(k),
|
99
|
+
height: @grip.header_height(k),
|
100
|
+
align: align
|
97
101
|
end
|
98
102
|
end
|
99
103
|
end
|
data/lib/mork/version.rb
CHANGED
data/spec/mork/grid_omr_spec.rb
CHANGED
@@ -30,22 +30,22 @@ module Mork
|
|
30
30
|
describe '#rm_crop_area' do
|
31
31
|
it 'returns a Coord object for the :tl reg_mark corner' do
|
32
32
|
c = @grom.rm_crop_area :tl
|
33
|
-
expect(c). to have_coords(15, 15,
|
33
|
+
expect(c). to have_coords(15, 15, 152, 154)
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'returns a Coord object for the :tr reg_mark corner' do
|
37
37
|
c = @grom.rm_crop_area :tr
|
38
|
-
expect(c).to have_coords(
|
38
|
+
expect(c).to have_coords(1433, 15, 152, 154)
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'returns a Coord object for the :br reg_mark corner' do
|
42
42
|
c = @grom.rm_crop_area :br
|
43
|
-
expect(c).to have_coords(
|
43
|
+
expect(c).to have_coords(1433, 2112, 152, 154)
|
44
44
|
end
|
45
45
|
|
46
46
|
it 'returns a Coord object for the :bl reg_mark corner' do
|
47
47
|
c = @grom.rm_crop_area :bl
|
48
|
-
expect(c).to have_coords(15,
|
48
|
+
expect(c).to have_coords(15, 2112, 152, 154)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
data/spec/mork/sheet_omr_spec.rb
CHANGED
data/spec/mork/sheet_pdf_spec.rb
CHANGED
@@ -40,10 +40,21 @@ module Mork
|
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'creates a basic PDF sheet' do
|
43
|
-
s = SheetPDF.new(content)
|
43
|
+
s = SheetPDF.new(content, 'spec/samples/layout.yml')
|
44
44
|
s.save('spec/out/sheet.pdf')
|
45
45
|
end
|
46
46
|
|
47
|
+
it 'creates a boxed PDF sheet' do
|
48
|
+
h = {
|
49
|
+
name: lorem,
|
50
|
+
title: lorem,
|
51
|
+
code: '1000.10.100',
|
52
|
+
signature: 'Signature'
|
53
|
+
}
|
54
|
+
s = SheetPDF.new(content.merge({header: h}), 'spec/samples/boxy.yml')
|
55
|
+
s.save('spec/out/boxy.pdf')
|
56
|
+
end
|
57
|
+
|
47
58
|
it 'creates a basic PDF sheet with a code of 15' do
|
48
59
|
s = SheetPDF.new(content.merge({barcode: 15}))
|
49
60
|
s.save('spec/out/sheet16.pdf')
|
@@ -0,0 +1,62 @@
|
|
1
|
+
page_size: # all measurements in mm
|
2
|
+
width: 210 # width of the paper sheet
|
3
|
+
height: 297 # height of the paper sheet
|
4
|
+
reg_marks:
|
5
|
+
margin: 10 # distance from each page border to registration mark center
|
6
|
+
radius: 3 # registration mark radius
|
7
|
+
offset: 2 # distance between the search area and each page border (*)
|
8
|
+
crop: 20
|
9
|
+
offset: 2
|
10
|
+
blur: 2
|
11
|
+
dilate: 5
|
12
|
+
|
13
|
+
header:
|
14
|
+
name: # ‘name’ is just a label; you can add arbitrary header elements
|
15
|
+
top: 5 # margin relative to registration frame top side
|
16
|
+
left: 15 # margin relative to registration frame left side
|
17
|
+
width: 160 # text will be fitted to this width
|
18
|
+
height: 7 # text will be fitted to this height
|
19
|
+
size: 14 # font size
|
20
|
+
box: true
|
21
|
+
title:
|
22
|
+
top: 15
|
23
|
+
left: 15
|
24
|
+
width: 160
|
25
|
+
height: 12
|
26
|
+
size: 12
|
27
|
+
box: true
|
28
|
+
code:
|
29
|
+
top: 30
|
30
|
+
left: 155
|
31
|
+
width: 35
|
32
|
+
height: 10
|
33
|
+
size: 14
|
34
|
+
box: true
|
35
|
+
align: right
|
36
|
+
signature:
|
37
|
+
top: 30
|
38
|
+
left: 15
|
39
|
+
width: 120
|
40
|
+
height: 15
|
41
|
+
size: 7
|
42
|
+
box: true # header element will be enclosed in a box
|
43
|
+
items:
|
44
|
+
top: 55.5 # response area margin, relative to reg frame
|
45
|
+
left: 10.5 # response area margin, relative to reg frame
|
46
|
+
rows: 30 # number of items per column
|
47
|
+
columns: 4 # number of columns
|
48
|
+
column_width: 44 #
|
49
|
+
x_spacing: 7 # horizontal distance between ajacent cell centers
|
50
|
+
y_spacing: 7 # vertical distance between ajacent cell centers
|
51
|
+
cell_width: 6 # width of each choice and calibration cell
|
52
|
+
cell_height: 5 # height of each choice and calibration cell
|
53
|
+
max_cells: 5 # maximum number of choices per item
|
54
|
+
font_size: 9 # size of both the item number and choice cell letter
|
55
|
+
number_width: 8 #
|
56
|
+
number_margin: 2 # margin between
|
57
|
+
barcode:
|
58
|
+
bits: 40 # the maximum sheet identifier is 2 to the power or bits
|
59
|
+
left: 15 # distance between registration frame side and the first barcode bit
|
60
|
+
width: 3 # width of each barcode bit
|
61
|
+
height: 2.5 # height of each barcode bit from the registration frame bottom side
|
62
|
+
spacing: 4 # horizontal distance between adjacent barcode bit centers
|
data/spec/samples/layout.yml
CHANGED
@@ -1,56 +1,56 @@
|
|
1
1
|
page_size: # all measurements in mm
|
2
|
-
width:
|
3
|
-
height:
|
2
|
+
width: 210 # width of the paper sheet
|
3
|
+
height: 297 # height of the paper sheet
|
4
4
|
reg_marks:
|
5
|
-
margin:
|
6
|
-
radius:
|
7
|
-
offset:
|
8
|
-
crop:
|
9
|
-
offset:
|
10
|
-
blur:
|
11
|
-
dilate:
|
5
|
+
margin: 10 # distance from each page border to registration mark center
|
6
|
+
radius: 2.5 # registration mark radius
|
7
|
+
offset: 2 # distance between the search area and each page border (*)
|
8
|
+
crop: 20
|
9
|
+
offset: 2
|
10
|
+
blur: 2
|
11
|
+
dilate: 5
|
12
12
|
|
13
13
|
|
14
14
|
header:
|
15
15
|
name: # ‘name’ is just a label; you can add arbitrary header elements
|
16
|
-
top:
|
17
|
-
left:
|
18
|
-
width:
|
19
|
-
size:
|
16
|
+
top: 5 # margin relative to registration frame top side
|
17
|
+
left: 15 # margin relative to registration frame left side
|
18
|
+
width: 170 # text will be fitted to this width
|
19
|
+
size: 14 # font size
|
20
20
|
title:
|
21
|
-
top:
|
22
|
-
left:
|
23
|
-
width:
|
24
|
-
size:
|
21
|
+
top: 15
|
22
|
+
left: 15
|
23
|
+
width: 180
|
24
|
+
size: 12
|
25
25
|
code:
|
26
|
-
top:
|
27
|
-
left:
|
28
|
-
width:
|
29
|
-
size:
|
26
|
+
top: 5
|
27
|
+
left: 165
|
28
|
+
width: 20
|
29
|
+
size: 14
|
30
30
|
signature:
|
31
|
-
top:
|
32
|
-
left:
|
33
|
-
width:
|
34
|
-
height:
|
35
|
-
size:
|
36
|
-
box:
|
31
|
+
top: 30
|
32
|
+
left: 7.5
|
33
|
+
width: 120
|
34
|
+
height: 15
|
35
|
+
size: 7
|
36
|
+
box: true # header element will be enclosed in a box
|
37
37
|
items:
|
38
|
-
top:
|
39
|
-
left:
|
40
|
-
rows:
|
41
|
-
columns:
|
42
|
-
column_width:
|
43
|
-
x_spacing:
|
44
|
-
y_spacing:
|
45
|
-
cell_width:
|
46
|
-
cell_height:
|
47
|
-
max_cells:
|
48
|
-
font_size:
|
49
|
-
number_width:
|
50
|
-
number_margin:
|
38
|
+
top: 55.5 # response area margin, relative to reg frame
|
39
|
+
left: 10.5 # response area margin, relative to reg frame
|
40
|
+
rows: 30 # number of items per column
|
41
|
+
columns: 4 # number of columns
|
42
|
+
column_width: 44 #
|
43
|
+
x_spacing: 7 # horizontal distance between ajacent cell centers
|
44
|
+
y_spacing: 7 # vertical distance between ajacent cell centers
|
45
|
+
cell_width: 6 # width of each choice and calibration cell
|
46
|
+
cell_height: 5 # height of each choice and calibration cell
|
47
|
+
max_cells: 5 # maximum number of choices per item
|
48
|
+
font_size: 9 # size of both the item number and choice cell letter
|
49
|
+
number_width: 8 #
|
50
|
+
number_margin: 2 # margin between
|
51
51
|
barcode:
|
52
|
-
bits:
|
53
|
-
left:
|
54
|
-
width:
|
55
|
-
height:
|
56
|
-
spacing:
|
52
|
+
bits: 40 # the maximum sheet identifier is 2 to the power or bits
|
53
|
+
left: 15 # distance between registration frame side and the first barcode bit
|
54
|
+
width: 3 # width of each barcode bit
|
55
|
+
height: 2.5 # height of each barcode bit from the registration frame bottom side
|
56
|
+
spacing: 4 # horizontal distance between adjacent barcode bit centers
|
data/spec/samples/slanted.yml
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -64,3 +64,7 @@ end
|
|
64
64
|
def sample_img(which)
|
65
65
|
SampleImager.new(which)
|
66
66
|
end
|
67
|
+
|
68
|
+
def lorem
|
69
|
+
"Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
|
70
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mork
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giuseppe Bertini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: narray
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- spec/mork/sheet_pdf_spec.rb
|
181
181
|
- spec/out/.gitignore
|
182
182
|
- spec/samples/angolo.jpg
|
183
|
+
- spec/samples/boxy.yml
|
183
184
|
- spec/samples/grid.yml
|
184
185
|
- spec/samples/grid160.yml
|
185
186
|
- spec/samples/info.yml
|