mork 0.0.9 → 0.0.10

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.
@@ -3,75 +3,85 @@ require 'spec_helper'
3
3
  module Mork
4
4
 
5
5
  describe SheetPDF do
6
+ let(:content) {
7
+ {
8
+ barcode: 1234566,
9
+ choices: [5] * 120,
10
+ header: {
11
+ name: 'John Doe UI01234',
12
+ title: 'A really serious and difficult test - 18 January 2013',
13
+ code: '201.48',
14
+ signature: 'Signature'
15
+ }
16
+
17
+ }
18
+ }
19
+
6
20
  it 'assigns the grid to @grid' do
7
- s = SheetPDF.new(some_pdf_content)
8
- s.instance_variable_get("@grid").should be_a Grid
21
+ s = SheetPDF.new(content)
22
+ s.instance_variable_get('@grip').should be_a GridPDF
9
23
  end
10
24
 
11
25
  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
26
+ s = SheetPDF.new(content, 'spec/samples/grid01.yml')
27
+ s.instance_variable_get('@grip').should be_a GridPDF
14
28
  end
15
29
 
16
30
  it 'raises an error with an invalid init parameter' do
17
- lambda { SheetPDF.new(some_pdf_content, 2) }.should raise_error "Invalid initialization parameter"
31
+ lambda { SheetPDF.new(content, 2) }.should raise_error 'Invalid initialization parameter'
18
32
  end
19
33
 
20
34
  it 'assigns an array to @content' do
21
- s = SheetPDF.new(some_pdf_content)
22
- s.instance_variable_get("@content").should be_an Array
35
+ s = SheetPDF.new(content)
36
+ s.instance_variable_get('@content').should be_an Array
23
37
  end
24
38
 
25
39
  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
40
+ s = SheetPDF.new(content)
41
+ s.instance_variable_get('@content').first.should be_a Hash
28
42
  end
29
43
 
30
44
  it 'creates a basic PDF sheet' do
31
- s = SheetPDF.new(some_pdf_content)
32
- s.save("tmp/f1.pdf")
45
+ s = SheetPDF.new(content)
46
+ s.save('tmp/sheet.pdf')
33
47
  end
34
48
 
35
- it 'creates a PDF sheet with the maximum possible code' do
36
- content = {
37
- code: 1099511627775,
38
- choices: [5] * 120,
39
- header: {
40
- name: "Bonazza Sara vr354320",
41
- title: "Esame di Fondamenti Morfologici e Funzionali della Vita - 18 gennaio 2013",
42
- code: "201.48",
43
- signature: "Firma"
44
- }
45
- }
46
- s = SheetPDF.new(content)
47
- s.save("tmp/f2.pdf")
49
+ it 'creates a basic PDF sheet with a code of 15' do
50
+ s = SheetPDF.new(content.merge({barcode: 15}))
51
+ s.save('tmp/sheet16.pdf')
52
+ end
53
+
54
+ it 'creates a basic PDF sheet with a code of 666666666666' do
55
+ s = SheetPDF.new(content.merge({barcode: 666666666666}))
56
+ s.save('tmp/sheet666.pdf')
57
+ end
58
+
59
+ it 'creates a PDF sheet with the maximum possible barcode' do
60
+ s = SheetPDF.new(content.merge({barcode: 1099511627775}))
61
+ s.save('tmp/maxcode.pdf')
62
+ end
63
+
64
+ it 'creates a PDF sheet with 160 items' do
65
+ s = SheetPDF.new(content.merge({choices: [5] * 160}), 'spec/samples/grid160.yml')
66
+ s.save('tmp/i160.pdf')
48
67
  end
49
68
 
50
- it "should create a multipage pdf" do
51
- content = [
69
+ it 'should create a multipage pdf' do
70
+ content2 = [
52
71
  {
53
- code: 18446744073,
72
+ barcode: 18446744073,
54
73
  choices: [5] * 100,
55
74
  header: {
56
- name: "Bertini Giuseppe VR123456 Bertini Giuseppe VR123456",
57
- title: "Esame di Fondamenti Morfologici e Funzionali della Vita - 18 gennaio 2013 Esame di Fondamenti Morfologici e Funzionali della Vita - 18 gennaio 2013",
58
- code: "119.27",
59
- signature: "Firma"
75
+ name: 'Jane Roe',
76
+ title: 'Same difficult test',
77
+ code: '119.27',
78
+ signature: 'Signed'
60
79
  }
61
80
  },
62
- {
63
- code: 5512,
64
- choices: [5] * 100,
65
- header: {
66
- name: "Bonazza Sara vr354320",
67
- title: "Esame di Fondamenti Morfologici e Funzionali della Vita - 18 gennaio 2013",
68
- code: "201.48",
69
- signature: "Firma"
70
- }
71
- }
81
+ content
72
82
  ]
73
- s = SheetPDF.new(content)
74
- s.save("tmp/p2.pdf")
83
+ s = SheetPDF.new(content2)
84
+ s.save('tmp/p2.pdf')
75
85
  end
76
86
  end
77
87
  end
@@ -31,7 +31,7 @@ header:
31
31
  box: true
32
32
  items:
33
33
  columns: 4
34
- column_width: 49
34
+ column_width: 44
35
35
  rows: 30
36
36
  first_x: 10.5
37
37
  first_y: 55.5
@@ -40,11 +40,10 @@ items:
40
40
  cell_width: 6.0
41
41
  cell_height: 5.0
42
42
  max_cells: 5
43
- number_size: 10
43
+ font_size: 9
44
44
  number_width: 8
45
45
  number_margin: 2
46
- letter_size: 8
47
- code:
46
+ barcode:
48
47
  bits: 40
49
48
  left: 15
50
49
  width: 3.0
@@ -0,0 +1,57 @@
1
+ page_size:
2
+ width: 210
3
+ height: 297
4
+ regmarks:
5
+ margin: 10
6
+ radius: 2.5
7
+ search: 12
8
+ offset: 2
9
+ header:
10
+ name:
11
+ top: 5
12
+ left: 7.5
13
+ width: 170
14
+ size: 14
15
+ title:
16
+ top: 15
17
+ left: 7.5
18
+ width: 180
19
+ size: 12
20
+ code:
21
+ top: 5
22
+ left: 165
23
+ width: 20
24
+ size: 14
25
+ signature:
26
+ top: 30
27
+ left: 7.5
28
+ width: 120
29
+ height: 15
30
+ size: 7
31
+ box: true
32
+ items:
33
+ columns: 4
34
+ column_width: 44
35
+ rows: 30
36
+ first_x: 10.5
37
+ first_y: 55.5
38
+ x_spacing: 7.0
39
+ y_spacing: 7.0
40
+ cell_width: 6.0
41
+ cell_height: 5.0
42
+ max_cells: 5
43
+ font_size: 9
44
+ number_width: 8
45
+ number_margin: 2
46
+ barcode:
47
+ bits: 40
48
+ left: 15
49
+ width: 3.0
50
+ height: 2.5
51
+ spacing: 4
52
+ control:
53
+ top: 40
54
+ left: 123
55
+ width: 50
56
+ size: 9
57
+ margin: 2.5
@@ -0,0 +1,57 @@
1
+ page_size:
2
+ width: 210
3
+ height: 297
4
+ regmarks:
5
+ margin: 10
6
+ radius: 2.5
7
+ search: 12
8
+ offset: 2
9
+ header:
10
+ name:
11
+ top: 5
12
+ left: 7.5
13
+ width: 170
14
+ size: 14
15
+ title:
16
+ top: 12
17
+ left: 7.5
18
+ width: 85
19
+ size: 12
20
+ code:
21
+ top: 5
22
+ left: 165
23
+ width: 20
24
+ size: 14
25
+ signature:
26
+ top: 12
27
+ left: 100
28
+ width: 80
29
+ height: 16
30
+ size: 7
31
+ box: true
32
+ items:
33
+ columns: 4
34
+ column_width: 44
35
+ rows: 40
36
+ first_x: 10.5
37
+ first_y: 40
38
+ x_spacing: 7.0
39
+ y_spacing: 5.5
40
+ cell_width: 6.0
41
+ cell_height: 4.0
42
+ max_cells: 5
43
+ font_size: 8
44
+ number_width: 8
45
+ number_margin: 2
46
+ barcode:
47
+ bits: 40
48
+ left: 15
49
+ width: 3.0
50
+ height: 2.5
51
+ spacing: 4
52
+ control:
53
+ top: 40
54
+ left: 123
55
+ width: 50
56
+ size: 9
57
+ margin: 2.5
@@ -0,0 +1,28 @@
1
+ page_size:
2
+ width: 210
3
+ height: 297
4
+ regmarks:
5
+ margin: 10
6
+ radius: 2.5
7
+ search: 12
8
+ offset: 2
9
+ items:
10
+ columns: 4
11
+ column_width: 44
12
+ rows: 30
13
+ first_x: 10.5
14
+ first_y: 55.5
15
+ x_spacing: 7
16
+ y_spacing: 7
17
+ cell_width: 6
18
+ cell_height: 5
19
+ max_cells: 5
20
+ font_size: 9
21
+ number_width: 8
22
+ number_margin: 2
23
+ barcode:
24
+ bits: 40
25
+ left: 15
26
+ width: 3
27
+ height: 2.5
28
+ spacing: 4
Binary file
Binary file
Binary file