mork 0.0.8 → 0.0.9
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 +27 -3
- data/lib/mork/sheet.rb +23 -19
- data/lib/mork/version.rb +1 -1
- data/spec/mork/sheet_spec.rb +11 -0
- data/spec/samples/sample04.jpg +0 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3929e72d06e1a597ab7bdd0dcc207487da5e3bcc
|
4
|
+
data.tar.gz: e4edcffb033afeed7317f439e7857611d45f6b7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc76809688ef966f779724a0eb358de007d79eaa4a1b14bbe37a0791f7e77da0678d68219b2fb184d57c2bc3cbdaeaf03fd14f03b9e8a74eebc823633557cc77
|
7
|
+
data.tar.gz: a410e9ad165da458bcc27cd7d3928af11a548ae78c51dfcc0410b9e683012c3837ff571fcea7a3d2400d9530f5ba281ccb10d73417bea1ea1eaf8a7b23fec72d
|
data/lib/mork/mimage.rb
CHANGED
@@ -19,12 +19,36 @@ module Mork
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
+
# outline!(cells, roundedness)
|
23
|
+
#
|
24
|
+
# draws on the Mimage a set of cell outlines
|
25
|
+
# typically used to highlight the expected responses
|
26
|
+
def outline!(cells, roundedness=nil)
|
27
|
+
out = Magick::Draw.new
|
28
|
+
out.stroke 'green'
|
29
|
+
out.stroke_width 4
|
30
|
+
out.fill_opacity 0
|
31
|
+
cells = [cells] if cells.is_a? Hash
|
32
|
+
roundedness ||= [cells[0][:h], cells[0][:w]].min / 2
|
33
|
+
cells.each do |c|
|
34
|
+
out.roundrectangle c[:x], c[:y], c[:x]+c[:w], c[:y]+c[:h], roundedness, roundedness
|
35
|
+
out.draw @image
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
22
39
|
# =============
|
23
40
|
# = Highlight =
|
24
41
|
# =============
|
25
|
-
def highlight!(
|
26
|
-
|
27
|
-
|
42
|
+
def highlight!(cells, roundedness=nil)
|
43
|
+
cells = [cells] if cells.is_a? Hash
|
44
|
+
roundedness ||= [cells[0][:h], cells[0][:w]].min / 2
|
45
|
+
cells.each do |c|
|
46
|
+
out = Magick::Draw.new
|
47
|
+
out.fill 'yellow'
|
48
|
+
out.opacity '40%'
|
49
|
+
out.roundrectangle c[:x], c[:y], c[:x]+c[:w], c[:y]+c[:h], roundedness, roundedness
|
50
|
+
out.draw @image
|
51
|
+
end
|
28
52
|
end
|
29
53
|
|
30
54
|
def join!(p)
|
data/lib/mork/sheet.rb
CHANGED
@@ -85,33 +85,27 @@ module Mork
|
|
85
85
|
# = HIGHLIGHTING =
|
86
86
|
# ================
|
87
87
|
|
88
|
-
def
|
88
|
+
def outline(cells)
|
89
89
|
return if not_registered
|
90
|
-
@
|
91
|
-
@grid.max_choices_per_question.times do |j|
|
92
|
-
highlight_choice i, j
|
93
|
-
end
|
94
|
-
end
|
95
|
-
@crop.highlight! @grid.ctrl_area_dark
|
96
|
-
@crop.highlight! @grid.ctrl_area_light
|
90
|
+
@crop.outline! array_of cells
|
97
91
|
end
|
98
92
|
|
99
|
-
def
|
93
|
+
def highlight_ctrl
|
100
94
|
return if not_registered
|
101
|
-
|
102
|
-
qa.each do |cho|
|
103
|
-
highlight_choice i, cho
|
104
|
-
end
|
105
|
-
end
|
106
|
-
@crop.highlight! @grid.ctrl_area_dark
|
107
|
-
@crop.highlight! @grid.ctrl_area_light
|
95
|
+
@crop.highlight! [@grid.ctrl_area_dark, @grid.ctrl_area_light]
|
108
96
|
end
|
109
97
|
|
110
|
-
def
|
98
|
+
def highlight_all
|
111
99
|
return if not_registered
|
112
|
-
|
100
|
+
cells = (0...@grid.max_questions).collect { |i| (0...@grid.max_choices_per_question).to_a }
|
101
|
+
@crop.highlight! array_of cells
|
113
102
|
end
|
114
|
-
|
103
|
+
|
104
|
+
def highlight
|
105
|
+
return if not_registered
|
106
|
+
@crop.highlight! array_of mark_array
|
107
|
+
end
|
108
|
+
|
115
109
|
def highlight_code_areas
|
116
110
|
return if not_registered
|
117
111
|
@grid.code_bits.times do |bit|
|
@@ -157,6 +151,16 @@ module Mork
|
|
157
151
|
end
|
158
152
|
|
159
153
|
private
|
154
|
+
|
155
|
+
def array_of(cells)
|
156
|
+
out = []
|
157
|
+
cells.each_with_index do |q, i|
|
158
|
+
q.each do |c|
|
159
|
+
out << @grid.choice_cell_area(i, c)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
out
|
163
|
+
end
|
160
164
|
|
161
165
|
def question_range(r)
|
162
166
|
if r.nil?
|
data/lib/mork/version.rb
CHANGED
data/spec/mork/sheet_spec.rb
CHANGED
@@ -26,6 +26,17 @@ module Mork
|
|
26
26
|
sheet.highlight_light_calibration_bit
|
27
27
|
sheet.write "tmp/light_code_bit.jpg"
|
28
28
|
end
|
29
|
+
|
30
|
+
it "should highlight the control cells" do
|
31
|
+
sheet.highlight_ctrl
|
32
|
+
sheet.write "tmp/controls.jpg"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should outline the correct responses" do
|
36
|
+
sheet.highlight
|
37
|
+
sheet.outline [[1],[1],[2],[2],[3,4],[],[0,1,2,3,4]]
|
38
|
+
sheet.write "tmp/outline.jpg"
|
39
|
+
end
|
29
40
|
end
|
30
41
|
|
31
42
|
context "a nicely printed and scanned sheet" do
|
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giuseppe Bertini
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- spec/samples/sample01.jpg
|
179
179
|
- spec/samples/sample02.jpg
|
180
180
|
- spec/samples/sample03.jpg
|
181
|
+
- spec/samples/sample04.jpg
|
181
182
|
- spec/samples/two_pages.pdf
|
182
183
|
- spec/spec_helper.rb
|
183
184
|
homepage: ''
|
@@ -221,5 +222,6 @@ test_files:
|
|
221
222
|
- spec/samples/sample01.jpg
|
222
223
|
- spec/samples/sample02.jpg
|
223
224
|
- spec/samples/sample03.jpg
|
225
|
+
- spec/samples/sample04.jpg
|
224
226
|
- spec/samples/two_pages.pdf
|
225
227
|
- spec/spec_helper.rb
|