zxing 0.2.1 → 0.3.0

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/README.rdoc CHANGED
@@ -26,6 +26,11 @@ decodes a plethora of barcodes. Their site has a complete list.
26
26
  # string" embedded:
27
27
  ZXing.decode '/Users/ecin/qrcode.png' #=> "QRcode string"
28
28
 
29
+ # ZXing#decode_all returns an array of encoded values. For example if an
30
+ # image has a barcode encoded with the value "test123" and another barcode
31
+ # encoded with the value "test456":
32
+ ZXing.decode_all 'image_with_multiple_barcodes.png' #=> ["test456", "test123"]
33
+
29
34
  # You can also decode a URL...
30
35
  ZXing.decode 'http://2d-code.co.uk/images/bbc-logo-in-qr-code.gif'
31
36
 
@@ -44,7 +49,7 @@ decodes a plethora of barcodes. Their site has a complete list.
44
49
 
45
50
  # ZXing#decode! will raise an error if it can't decode the image.
46
51
  ZXing.decode! 'image_without_a_code.png' #=> raises ZXing::UndecodableError
47
-
52
+
48
53
  == Decodable module
49
54
 
50
55
  A Decodable module is included (pun intended) to ease using the library with objects that return the URL or file path to decode when #path or #to_s is called.
data/bin/zxing CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ require "rubygems"
2
3
  require "jruby-jars"
3
4
 
4
5
  port = ARGV[0]
@@ -0,0 +1,390 @@
1
+ !RBIX
2
+ 2390329161478264409
3
+ x
4
+ M
5
+ 1
6
+ n
7
+ n
8
+ x
9
+ 10
10
+ __script__
11
+ i
12
+ 180
13
+ 5
14
+ 7
15
+ 0
16
+ 64
17
+ 47
18
+ 49
19
+ 1
20
+ 1
21
+ 15
22
+ 5
23
+ 7
24
+ 2
25
+ 64
26
+ 47
27
+ 49
28
+ 1
29
+ 1
30
+ 15
31
+ 45
32
+ 3
33
+ 4
34
+ 78
35
+ 49
36
+ 5
37
+ 1
38
+ 19
39
+ 0
40
+ 15
41
+ 45
42
+ 6
43
+ 7
44
+ 49
45
+ 8
46
+ 0
47
+ 19
48
+ 1
49
+ 15
50
+ 45
51
+ 6
52
+ 9
53
+ 49
54
+ 10
55
+ 0
56
+ 19
57
+ 2
58
+ 15
59
+ 7
60
+ 11
61
+ 64
62
+ 45
63
+ 6
64
+ 12
65
+ 49
66
+ 8
67
+ 0
68
+ 45
69
+ 6
70
+ 13
71
+ 49
72
+ 10
73
+ 0
74
+ 35
75
+ 2
76
+ 7
77
+ 14
78
+ 64
79
+ 49
80
+ 15
81
+ 1
82
+ 7
83
+ 16
84
+ 64
85
+ 35
86
+ 3
87
+ 19
88
+ 3
89
+ 15
90
+ 45
91
+ 17
92
+ 18
93
+ 7
94
+ 19
95
+ 64
96
+ 65
97
+ 49
98
+ 20
99
+ 0
100
+ 49
101
+ 21
102
+ 2
103
+ 19
104
+ 4
105
+ 15
106
+ 99
107
+ 43
108
+ 22
109
+ 7
110
+ 23
111
+ 49
112
+ 5
113
+ 1
114
+ 20
115
+ 4
116
+ 49
117
+ 24
118
+ 1
119
+ 9
120
+ 111
121
+ 1
122
+ 8
123
+ 124
124
+ 99
125
+ 43
126
+ 22
127
+ 7
128
+ 23
129
+ 49
130
+ 5
131
+ 1
132
+ 20
133
+ 4
134
+ 49
135
+ 25
136
+ 1
137
+ 15
138
+ 20
139
+ 4
140
+ 47
141
+ 101
142
+ 26
143
+ 7
144
+ 27
145
+ 63
146
+ 2
147
+ 19
148
+ 5
149
+ 15
150
+ 7
151
+ 28
152
+ 64
153
+ 20
154
+ 5
155
+ 7
156
+ 29
157
+ 64
158
+ 7
159
+ 30
160
+ 20
161
+ 0
162
+ 47
163
+ 101
164
+ 26
165
+ 7
166
+ 31
167
+ 63
168
+ 3
169
+ 35
170
+ 4
171
+ 19
172
+ 6
173
+ 15
174
+ 5
175
+ 7
176
+ 32
177
+ 64
178
+ 20
179
+ 3
180
+ 20
181
+ 6
182
+ 81
183
+ 33
184
+ 36
185
+ 1
186
+ 47
187
+ 51
188
+ 34
189
+ 1
190
+ 15
191
+ 2
192
+ 11
193
+ I
194
+ d
195
+ I
196
+ 7
197
+ I
198
+ 0
199
+ I
200
+ 0
201
+ n
202
+ p
203
+ 35
204
+ s
205
+ 8
206
+ rubygems
207
+ x
208
+ 7
209
+ require
210
+ s
211
+ 10
212
+ jruby-jars
213
+ x
214
+ 4
215
+ ARGV
216
+ n
217
+ x
218
+ 2
219
+ []
220
+ x
221
+ 9
222
+ JRubyJars
223
+ n
224
+ x
225
+ 13
226
+ core_jar_path
227
+ n
228
+ x
229
+ 15
230
+ stdlib_jar_path
231
+ s
232
+ 3
233
+ -cp
234
+ n
235
+ n
236
+ s
237
+ 1
238
+ :
239
+ x
240
+ 4
241
+ join
242
+ s
243
+ 14
244
+ org.jruby.Main
245
+ x
246
+ 4
247
+ File
248
+ n
249
+ s
250
+ 9
251
+ ../../lib
252
+ x
253
+ 11
254
+ active_path
255
+ x
256
+ 11
257
+ expand_path
258
+ x
259
+ 7
260
+ Globals
261
+ x
262
+ 2
263
+ $:
264
+ x
265
+ 8
266
+ include?
267
+ x
268
+ 7
269
+ unshift
270
+ x
271
+ 4
272
+ to_s
273
+ s
274
+ 16
275
+ /zxing/server.rb
276
+ s
277
+ 2
278
+ -r
279
+ s
280
+ 2
281
+ -e
282
+ s
283
+ 21
284
+ ZXing::Server.start!(
285
+ s
286
+ 1
287
+ )
288
+ s
289
+ 4
290
+ java
291
+ x
292
+ 1
293
+ +
294
+ x
295
+ 4
296
+ exec
297
+ p
298
+ 33
299
+ I
300
+ 0
301
+ I
302
+ 2
303
+ I
304
+ 9
305
+ I
306
+ 3
307
+ I
308
+ 12
309
+ I
310
+ 5
311
+ I
312
+ 1c
313
+ I
314
+ 7
315
+ I
316
+ 25
317
+ I
318
+ 8
319
+ I
320
+ 2e
321
+ I
322
+ b
323
+ I
324
+ 45
325
+ I
326
+ c
327
+ I
328
+ 4a
329
+ I
330
+ a
331
+ I
332
+ 4d
333
+ I
334
+ f
335
+ I
336
+ 5d
337
+ I
338
+ 10
339
+ I
340
+ 7c
341
+ I
342
+ 0
343
+ I
344
+ 7d
345
+ I
346
+ 12
347
+ I
348
+ 89
349
+ I
350
+ 15
351
+ I
352
+ 8e
353
+ I
354
+ 16
355
+ I
356
+ 9e
357
+ I
358
+ 14
359
+ I
360
+ a1
361
+ I
362
+ 19
363
+ I
364
+ b4
365
+ x
366
+ 50
367
+ /Users/ncrespo/Developer/ruby/ruby/zxing/bin/zxing
368
+ p
369
+ 7
370
+ x
371
+ 4
372
+ port
373
+ x
374
+ 5
375
+ jruby
376
+ x
377
+ 12
378
+ jruby_stdlib
379
+ x
380
+ 9
381
+ java_args
382
+ x
383
+ 3
384
+ lib
385
+ x
386
+ 4
387
+ path
388
+ x
389
+ 9
390
+ ruby_args
data/lib/zxing.rb CHANGED
@@ -39,6 +39,40 @@ module ZXing
39
39
  Decoder.decode! normalize(file)
40
40
  end
41
41
 
42
+ ##
43
+ # Decodes barcodes from an image file, and returns an array of encoded
44
+ # values.
45
+ #
46
+ # +file+ should be the path to the image file to decode, as a string.
47
+ #
48
+ # Example:
49
+ #
50
+ # path = "path/to/file.png"
51
+ # ZXing.decode_all(path) #=> ["First encoded text","Second encoded text"]
52
+ #
53
+ # When the image cannot be decoded, +decode_all+ returns +nil+:
54
+ #
55
+ # path = "./no_encoded_image.png"
56
+ # ZXing.decode_all(path) #=> nil
57
+ #
58
+ def self.decode_all(file)
59
+ Decoder.decode_all normalize(file)
60
+ end
61
+
62
+ ##
63
+ # Same as +decode_all+, but raises an exception when image cannot be decoded.
64
+ #
65
+ # +file+ should be the path to the image file to decode, as a string.
66
+ #
67
+ # Example:
68
+ #
69
+ # path = "./no_encoded_image.png"
70
+ # ZXing.decode(path) #=> ZXing::UndecodableError
71
+ #
72
+ def self.decode_all!(file)
73
+ Decoder.decode_all! normalize(file)
74
+ end
75
+
42
76
  private
43
77
  def self.normalize(file)
44
78
  file.respond_to?(:path) ? file.path : file