mork 0.0.10 → 0.0.11
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/lib/mork/mimage.rb +4 -2
- data/lib/mork/version.rb +1 -1
- data/mork.gemspec +1 -1
- data/spec/mork/sheet_omr_spec.rb +8 -8
- data/spec/mork/sheet_pdf_spec.rb +8 -23
- data/spec/out/.gitignore +4 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f6fdf479e1ce97ef698e1dfb43d571a86b580c7
|
4
|
+
data.tar.gz: 3e8f988b67a5f11bb3cb62541bfff93865c1e236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 571d163c91f8ed00ce47d2423c02f22603ce1287c9e61cc62c25670156e6a08ffd931287655673a120df91e6dbc01b35d47995da592316bdb41c42b625c9461d
|
7
|
+
data.tar.gz: c604bffbb932a0657b327471f82a56b95ddfc4ce85aa0d0f18241b50b789287043906f09da73be9d70aa2d9049edb95074fb464e4c33a098472d71c0d1bea7b7
|
data/lib/mork/mimage.rb
CHANGED
@@ -24,12 +24,13 @@ module Mork
|
|
24
24
|
# draws on the Mimage a set of cell outlines
|
25
25
|
# typically used to highlight the expected responses
|
26
26
|
def outline!(cells, roundedness=nil)
|
27
|
+
cells = [cells] if cells.is_a? Hash
|
28
|
+
return if cells.empty?
|
29
|
+
roundedness ||= [cells[0][:h], cells[0][:w]].min / 2
|
27
30
|
out = Magick::Draw.new
|
28
31
|
out.stroke 'green'
|
29
32
|
out.stroke_width 4
|
30
33
|
out.fill_opacity 0
|
31
|
-
cells = [cells] if cells.is_a? Hash
|
32
|
-
roundedness ||= [cells[0][:h], cells[0][:w]].min / 2
|
33
34
|
cells.each do |c|
|
34
35
|
out.roundrectangle c[:x], c[:y], c[:x]+c[:w], c[:y]+c[:h], roundedness, roundedness
|
35
36
|
out.draw @image
|
@@ -41,6 +42,7 @@ module Mork
|
|
41
42
|
# =============
|
42
43
|
def highlight_cells!(cells, roundedness=nil)
|
43
44
|
cells = [cells] if cells.is_a? Hash
|
45
|
+
return if cells.empty?
|
44
46
|
roundedness ||= [cells[0][:h], cells[0][:w]].min / 2
|
45
47
|
cells.each do |c|
|
46
48
|
out = Magick::Draw.new
|
data/lib/mork/version.rb
CHANGED
data/mork.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.email = ["giuseppe.bertini@gmail.com"]
|
11
11
|
s.homepage = ""
|
12
12
|
s.summary = %q{Optical mark recognition of multiple-choice response sheets}
|
13
|
-
s.description = %q{
|
13
|
+
s.description = %q{sorry, no docs until v.0.1.0}
|
14
14
|
s.rubyforge_project = "mork"
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
data/spec/mork/sheet_omr_spec.rb
CHANGED
@@ -9,18 +9,18 @@ module Mork
|
|
9
9
|
|
10
10
|
it 'highlights the registration areas and frame' do
|
11
11
|
sheet.highlight_reg_area
|
12
|
-
sheet.write_raw '
|
12
|
+
sheet.write_raw 'spec/out/reg_areas.jpg'
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'should highlight all areas' do
|
16
16
|
sheet.highlight_all
|
17
|
-
sheet.write '
|
17
|
+
sheet.write 'spec/out/all_highlights.jpg'
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should highlight marked cells and outline correct responses' do
|
21
21
|
sheet.highlight_marked
|
22
22
|
sheet.outline [[1],[1],[2],[2],[3,4],[],[0,1,2,3,4]]
|
23
|
-
sheet.write '
|
23
|
+
sheet.write 'spec/out/marked_highlights.jpg'
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -50,7 +50,7 @@ module Mork
|
|
50
50
|
|
51
51
|
it 'writes out average whiteness of choice cells' do
|
52
52
|
puts "Choice threshold: #{@sheet.send :choice_threshold}"
|
53
|
-
File.open('
|
53
|
+
File.open('spec/out/choices.txt', 'w') do |f|
|
54
54
|
120.times do |q|
|
55
55
|
t = (0..4).collect do |c|
|
56
56
|
@sheet.send(:shade_of, q, c).round
|
@@ -59,8 +59,8 @@ module Mork
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
mf = File.open('
|
63
|
-
uf = File.open('
|
62
|
+
mf = File.open('spec/out/marked.txt', 'w')
|
63
|
+
uf = File.open('spec/out/unmarked.txt', 'w')
|
64
64
|
120.times do |q|
|
65
65
|
5.times do |c|
|
66
66
|
shade = @sheet.send(:shade_of, q, c)
|
@@ -110,14 +110,14 @@ module Mork
|
|
110
110
|
s2.barcode_string.should == barcode_string
|
111
111
|
s2.barcode.should == 8608
|
112
112
|
s2.highlight_barcode
|
113
|
-
s2.write '
|
113
|
+
s2.write 'spec/out/code_bits.jpg'
|
114
114
|
end
|
115
115
|
|
116
116
|
it 'should read the 666 bit string' do
|
117
117
|
s2 = SheetOMR.new('spec/samples/sheet666.jpg')
|
118
118
|
s2.barcode.should == 666666666666
|
119
119
|
s2.highlight_barcode
|
120
|
-
s2.write '
|
120
|
+
s2.write 'spec/out/code_bits666.jpg'
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
data/spec/mork/sheet_pdf_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Mork
|
4
|
-
|
5
4
|
describe SheetPDF do
|
6
5
|
let(:content) {
|
7
6
|
{
|
@@ -13,7 +12,6 @@ module Mork
|
|
13
12
|
code: '201.48',
|
14
13
|
signature: 'Signature'
|
15
14
|
}
|
16
|
-
|
17
15
|
}
|
18
16
|
}
|
19
17
|
|
@@ -43,45 +41,32 @@ module Mork
|
|
43
41
|
|
44
42
|
it 'creates a basic PDF sheet' do
|
45
43
|
s = SheetPDF.new(content)
|
46
|
-
s.save('
|
44
|
+
s.save('spec/out/sheet.pdf')
|
47
45
|
end
|
48
46
|
|
49
47
|
it 'creates a basic PDF sheet with a code of 15' do
|
50
48
|
s = SheetPDF.new(content.merge({barcode: 15}))
|
51
|
-
s.save('
|
49
|
+
s.save('spec/out/sheet16.pdf')
|
52
50
|
end
|
53
51
|
|
54
52
|
it 'creates a basic PDF sheet with a code of 666666666666' do
|
55
53
|
s = SheetPDF.new(content.merge({barcode: 666666666666}))
|
56
|
-
s.save('
|
54
|
+
s.save('spec/out/sheet666.pdf')
|
57
55
|
end
|
58
56
|
|
59
57
|
it 'creates a PDF sheet with the maximum possible barcode' do
|
60
58
|
s = SheetPDF.new(content.merge({barcode: 1099511627775}))
|
61
|
-
s.save('
|
59
|
+
s.save('spec/out/maxcode.pdf')
|
62
60
|
end
|
63
61
|
|
64
62
|
it 'creates a PDF sheet with 160 items' do
|
65
63
|
s = SheetPDF.new(content.merge({choices: [5] * 160}), 'spec/samples/grid160.yml')
|
66
|
-
s.save('
|
64
|
+
s.save('spec/out/i160.pdf')
|
67
65
|
end
|
68
66
|
|
69
|
-
it '
|
70
|
-
|
71
|
-
|
72
|
-
barcode: 18446744073,
|
73
|
-
choices: [5] * 100,
|
74
|
-
header: {
|
75
|
-
name: 'Jane Roe',
|
76
|
-
title: 'Same difficult test',
|
77
|
-
code: '119.27',
|
78
|
-
signature: 'Signed'
|
79
|
-
}
|
80
|
-
},
|
81
|
-
content
|
82
|
-
]
|
83
|
-
s = SheetPDF.new(content2)
|
84
|
-
s.save('tmp/p2.pdf')
|
67
|
+
it 'creates a multipage pdf' do
|
68
|
+
s = SheetPDF.new([content, content, content])
|
69
|
+
s.save('spec/out/p2.pdf')
|
85
70
|
end
|
86
71
|
end
|
87
72
|
end
|
data/spec/out/.gitignore
ADDED
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.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giuseppe Bertini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: narray
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '1.2'
|
139
|
-
description:
|
139
|
+
description: sorry, no docs until v.0.1.0
|
140
140
|
email:
|
141
141
|
- giuseppe.bertini@gmail.com
|
142
142
|
executables: []
|
@@ -173,6 +173,7 @@ files:
|
|
173
173
|
- spec/mork/npatch_spec.rb
|
174
174
|
- spec/mork/sheet_omr_spec.rb
|
175
175
|
- spec/mork/sheet_pdf_spec.rb
|
176
|
+
- spec/out/.gitignore
|
176
177
|
- spec/samples/code_sample.pdf
|
177
178
|
- spec/samples/code_sample.png
|
178
179
|
- spec/samples/code_zero.pdf
|
@@ -226,6 +227,7 @@ test_files:
|
|
226
227
|
- spec/mork/npatch_spec.rb
|
227
228
|
- spec/mork/sheet_omr_spec.rb
|
228
229
|
- spec/mork/sheet_pdf_spec.rb
|
230
|
+
- spec/out/.gitignore
|
229
231
|
- spec/samples/code_sample.pdf
|
230
232
|
- spec/samples/code_sample.png
|
231
233
|
- spec/samples/code_zero.pdf
|