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.
data/spec/spec_helper.rb CHANGED
@@ -9,15 +9,15 @@ RSpec.configure do |config|
9
9
  end
10
10
 
11
11
  class SampleImager
12
- attr_reader :info, :reg_marks, :q_boxes, :code_string, :code_int
12
+ attr_reader :info, :reg_marks, :q_boxes, :barcode_string, :barcode_int
13
13
 
14
14
  def initialize(which)
15
15
  ya = YAML.load_file("./spec/samples/info.yml")
16
16
  @info = ya[which.to_s]
17
17
  @reg_marks = @info["reg_marks"]
18
18
  @q_boxes = @info["q_boxes"]
19
- @code_string = @info["code_string"]
20
- @code_int = @info["code_int"]
19
+ @barcode_string = @info["barcode_string"]
20
+ @barcode_int = @info["barcode_int"]
21
21
  end
22
22
 
23
23
  def filename
@@ -40,20 +40,3 @@ end
40
40
  def sample_img(which)
41
41
  SampleImager.new(which)
42
42
  end
43
-
44
- def some_pdf_content
45
- {
46
- code: 2345678,
47
- choices: [5] * 120,
48
- header: {
49
- name: "Bertini Giuseppe VR123456",
50
- title: "Esame di Fondamenti Morfologici e Funzionali della Vita - 18 gennaio 2013",
51
- code: "119.27",
52
- signature: "Firma"
53
- },
54
- control: {
55
- string: "Annerisci solo la casella ‘V’:",
56
- labels: ['V', 'F']
57
- }
58
- }
59
- end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mork
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
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-09 00:00:00.000000000 Z
11
+ date: 2014-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: narray
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rmagick
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.13'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.13'
41
41
  - !ruby/object:Gem::Dependency
@@ -56,84 +56,84 @@ dependencies:
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '10.3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '3.1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: guard
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '2.6'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '2.6'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: guard-rspec
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '4.3'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '4.3'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: guard-shell
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0.6'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0.6'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: awesome_print
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '1.2'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.2'
139
139
  description: Coming soon
@@ -143,42 +143,54 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
- - .gitignore
147
- - .rspec
148
- - .ruby-gemset
149
- - .ruby-version
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".ruby-gemset"
149
+ - ".ruby-version"
150
150
  - Gemfile
151
151
  - Guardfile
152
152
  - README.md
153
153
  - Rakefile
154
154
  - cucu.jpg
155
155
  - lib/mork.rb
156
+ - lib/mork/extensions.rb
156
157
  - lib/mork/grid.rb
157
158
  - lib/mork/grid_const.rb
159
+ - lib/mork/grid_omr.rb
160
+ - lib/mork/grid_pdf.rb
158
161
  - lib/mork/mimage.rb
159
162
  - lib/mork/mimage_list.rb
160
163
  - lib/mork/npatch.rb
161
- - lib/mork/sheet.rb
164
+ - lib/mork/sheet_omr.rb
162
165
  - lib/mork/sheet_pdf.rb
163
166
  - lib/mork/version.rb
164
167
  - mork.gemspec
168
+ - spec/mork/extensions_spec.rb
169
+ - spec/mork/grid_omr_spec.rb
165
170
  - spec/mork/grid_spec.rb
166
171
  - spec/mork/mimage_list_spec.rb
167
172
  - spec/mork/mimage_spec.rb
168
173
  - spec/mork/npatch_spec.rb
174
+ - spec/mork/sheet_omr_spec.rb
169
175
  - spec/mork/sheet_pdf_spec.rb
170
- - spec/mork/sheet_spec.rb
171
176
  - spec/samples/code_sample.pdf
172
177
  - spec/samples/code_sample.png
173
178
  - spec/samples/code_zero.pdf
174
179
  - spec/samples/content01.yml
175
180
  - spec/samples/grid01.yml
181
+ - spec/samples/grid02.yml
182
+ - spec/samples/grid160.yml
183
+ - spec/samples/grid_omr_01.yml
176
184
  - spec/samples/info.yml
177
185
  - spec/samples/reg_mark.jpg
178
186
  - spec/samples/sample01.jpg
179
187
  - spec/samples/sample02.jpg
180
188
  - spec/samples/sample03.jpg
181
189
  - spec/samples/sample04.jpg
190
+ - spec/samples/sample_color.pdf
191
+ - spec/samples/sample_gray.jpg
192
+ - spec/samples/sheet666.jpg
193
+ - spec/samples/sheet666.pdf
182
194
  - spec/samples/two_pages.pdf
183
195
  - spec/spec_helper.rb
184
196
  homepage: ''
@@ -191,37 +203,47 @@ require_paths:
191
203
  - lib
192
204
  required_ruby_version: !ruby/object:Gem::Requirement
193
205
  requirements:
194
- - - '>='
206
+ - - ">="
195
207
  - !ruby/object:Gem::Version
196
208
  version: '0'
197
209
  required_rubygems_version: !ruby/object:Gem::Requirement
198
210
  requirements:
199
- - - '>='
211
+ - - ">="
200
212
  - !ruby/object:Gem::Version
201
213
  version: '0'
202
214
  requirements: []
203
215
  rubyforge_project: mork
204
- rubygems_version: 2.2.2
216
+ rubygems_version: 2.1.11
205
217
  signing_key:
206
218
  specification_version: 4
207
219
  summary: Optical mark recognition of multiple-choice response sheets
208
220
  test_files:
221
+ - spec/mork/extensions_spec.rb
222
+ - spec/mork/grid_omr_spec.rb
209
223
  - spec/mork/grid_spec.rb
210
224
  - spec/mork/mimage_list_spec.rb
211
225
  - spec/mork/mimage_spec.rb
212
226
  - spec/mork/npatch_spec.rb
227
+ - spec/mork/sheet_omr_spec.rb
213
228
  - spec/mork/sheet_pdf_spec.rb
214
- - spec/mork/sheet_spec.rb
215
229
  - spec/samples/code_sample.pdf
216
230
  - spec/samples/code_sample.png
217
231
  - spec/samples/code_zero.pdf
218
232
  - spec/samples/content01.yml
219
233
  - spec/samples/grid01.yml
234
+ - spec/samples/grid02.yml
235
+ - spec/samples/grid160.yml
236
+ - spec/samples/grid_omr_01.yml
220
237
  - spec/samples/info.yml
221
238
  - spec/samples/reg_mark.jpg
222
239
  - spec/samples/sample01.jpg
223
240
  - spec/samples/sample02.jpg
224
241
  - spec/samples/sample03.jpg
225
242
  - spec/samples/sample04.jpg
243
+ - spec/samples/sample_color.pdf
244
+ - spec/samples/sample_gray.jpg
245
+ - spec/samples/sheet666.jpg
246
+ - spec/samples/sheet666.pdf
226
247
  - spec/samples/two_pages.pdf
227
248
  - spec/spec_helper.rb
249
+ has_rdoc:
@@ -1,178 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Mork
4
- describe Sheet do
5
- context 'highlighting' do
6
- # since these specs change the @crop, they must be run in isolation
7
- # with the Sheet rebuilt each time, even though it is time consuming!
8
- let(:sheet) { Sheet.new('spec/samples/sample01.jpg') }
9
-
10
- it "should highlight all cells" do
11
- sheet.highlight_all
12
- sheet.write 'tmp/all_highlights.jpg'
13
- end
14
-
15
- it "should highlight marked cells" do
16
- sheet.highlight
17
- sheet.write 'tmp/highlights.jpg'
18
- end
19
-
20
- it "should highlight the dark calibration bit" do
21
- sheet.highlight_dark_calibration_bit
22
- sheet.write "tmp/dark_code_bit.jpg"
23
- end
24
-
25
- it "should highlight the light calibration bit" do
26
- sheet.highlight_light_calibration_bit
27
- sheet.write "tmp/light_code_bit.jpg"
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
40
- end
41
-
42
- context "a nicely printed and scanned sheet" do
43
- before(:all) do
44
- @sheet = Sheet.new('spec/samples/sample01.jpg', Grid.new('spec/samples/grid01.yml'))
45
- end
46
-
47
- describe '#valid?' do
48
- it 'returns true' do
49
- @sheet.valid?.should be_truthy
50
- end
51
- end
52
-
53
- describe '#status' do
54
- it 'returns :ok' do
55
- @sheet.status.should == {
56
- tl: { status: :ok, x: 54, y: 49},
57
- tr: { status: :ok, x: 1543, y: 43},
58
- br: { status: :ok, x: 1548, y: 2224},
59
- bl: { status: :ok, x: 59, y: 2230}
60
- }
61
- end
62
- end
63
-
64
- describe "#marked?" do
65
- it "should return true for some darkened choices" do
66
- @sheet.marked?(0,0).should be_truthy
67
- @sheet.marked?(1,1).should be_truthy
68
- @sheet.marked?(2,2).should be_truthy
69
- end
70
-
71
- it "should return false for some blank choices" do
72
- @sheet.marked?(0,1).should be_falsy
73
- @sheet.marked?(1,0).should be_falsy
74
- @sheet.marked?(2,3).should be_falsy
75
- end
76
-
77
- it "prints the average whiteness of the first 40 sets of choices" do
78
- 40.times do |q|
79
- t = (0..4).collect do |c|
80
- @sheet.send(:shade_of, q, c).round
81
- end
82
- puts "#{q+1}: #{t.join(" ")}"
83
- end
84
- end
85
- end
86
-
87
- describe "#mark_array" do
88
- it "should return an array of marked choices for each of the first 5 questions" do
89
- @sheet.mark_array(5).should == [[0], [1], [2], [3], [4]]
90
- end
91
-
92
- it "should return an array of marked choices for the specified question set" do
93
- @sheet.mark_array([0, 1, 15, 16, 31, 7, 26]).should == [[0], [1], [0], [1], [], [1, 3], []]
94
- end
95
-
96
- it "should return an array of @grid.max_questions length if called without arguments" do
97
- @sheet.mark_array.length.should == 120
98
- end
99
- end
100
-
101
- describe "#mark_logical_array" do
102
- it "should return an array of booleans for each of the first questions" do
103
- @sheet.mark_logical_array(5).should == [
104
- [true, false, false, false, false],
105
- [false, true, false, false, false],
106
- [false, false, true, false, false],
107
- [false, false, false, true, false],
108
- [false, false, false, false, true],
109
- ]
110
- end
111
- end
112
-
113
- describe "codes" do
114
- it "should read the bit string as all ones" do
115
- @sheet.code_string.should == '1111111111111111111111111111111111111111'
116
- @sheet.code.should == 1099511627775
117
- end
118
-
119
- it 'should read another bit string' do
120
- code_string = '0000000000000000000000000010000110100000'
121
- s2 = Sheet.new('spec/samples/sample02.jpg')
122
- s2.code_string.should == code_string
123
- s2.code.should == 8608
124
- s2.highlight_code
125
- s2.write 'tmp/code_bits.jpg'
126
- end
127
- end
128
-
129
- end
130
-
131
- context "a faded, b&w, distorted sheet" do
132
- before(:all) do
133
- @sheet = Sheet.new('spec/samples/sample03.jpg')
134
- end
135
-
136
- it "should return the correct code" do
137
- @sheet.code.should == 8608
138
- end
139
-
140
- it "should return the darkened choices" do
141
- @sheet.mark_array(16).should == [[3],[3],[4],[0],[4],[4],[0],[1],[4],[0],[],[2,3],[0],[0,1,2,3,4],[1],[]]
142
- end
143
- end
144
-
145
- # context "multi-page pdf" do
146
- # before(:all) do
147
- # @mlist = MimageList.new('spec/samples/two_pages.pdf')
148
- # end
149
- #
150
- # describe "reading the codes" do
151
- # it "should read the right code for the first page" do
152
- # s = Sheet.new(@mlist[0], Grid.new)
153
- # s.code.should == 18446744073709551615
154
- # end
155
- # it "should read the right code for the second page" do
156
- # s = Sheet.new(@mlist[1], Grid.new)
157
- # s.code.should == 283764283738
158
- # end
159
- # end
160
- #
161
- # describe "getting the answers" do
162
- # it "should read the correct choices for the first page" do
163
- # s = Sheet.new(@mlist[0], Grid.new)
164
- # s.marked?( 0, 0).should be_truthy
165
- # s.marked?( 0, 1).should be_falsy
166
- # s.marked?(15, 3).should be_falsy
167
- # s.marked?(15, 4).should be_truthy
168
- # end
169
- #
170
- # it "should read the correct choices for the second page" do
171
- # s = Sheet.new(@mlist[1], Grid.new)
172
- # s.mark_array(15).should == [[0], [1], [2], [3], [4], [0], [1], [2, 3], [4], [1, 2, 3], [0], [1], [2], [3], [4]]
173
- # end
174
- # end
175
- # end
176
- end
177
- end
178
-