rqrcode 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/README +7 -2
- data/lib/rqrcode/qrcode/qr_code.rb +12 -22
- data/lib/rqrcode/qrcode/qr_rs_block.rb +185 -6
- data/lib/rqrcode.rb +1 -1
- metadata +3 -3
data/CHANGELOG
CHANGED
data/README
CHANGED
@@ -13,7 +13,7 @@ Let's clear up some rQRCode stuff.
|
|
13
13
|
# The interface is simple and assumes you just want to encode a string into a QR code
|
14
14
|
# QR code is trademarked by Denso Wave inc
|
15
15
|
|
16
|
-
==
|
16
|
+
== Resources
|
17
17
|
|
18
18
|
wikipedia:: http://en.wikipedia.org/wiki/QR_Code
|
19
19
|
Denso-Wave website:: http://www.denso-wave.com/qrcode/index-e.html
|
@@ -22,10 +22,15 @@ kaywa:: http://qrcode.kaywa.com
|
|
22
22
|
|
23
23
|
== Installing
|
24
24
|
|
25
|
-
You may get the latest stable version from Rubyforge.
|
25
|
+
You may get the latest stable version from Rubyforge.
|
26
26
|
|
27
27
|
$ gem install rqrcode
|
28
28
|
|
29
|
+
You can also get the source from http://github.com/whomwah/rqrcode/tree/master
|
30
|
+
|
31
|
+
$ git clone git://github.com/whomwah/rqrcode.git
|
32
|
+
|
33
|
+
|
29
34
|
=== Loading rQRCode Itself
|
30
35
|
|
31
36
|
You have installed the gem already, yeah?
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
#--
|
4
|
-
# Copyright
|
4
|
+
# Copyright 2008 by Duncan Robertson (duncan@whomwah.com).
|
5
5
|
# All rights reserved.
|
6
6
|
|
7
7
|
# Permission is granted for use, copying, modification, distribution,
|
@@ -59,8 +59,13 @@ module RQRCode #:nodoc:
|
|
59
59
|
# Expects a string to be parsed in, other args are optional
|
60
60
|
#
|
61
61
|
# # string - the string you wish to encode
|
62
|
-
# # size - the size of the qrcode
|
63
|
-
# # level - the error correction level
|
62
|
+
# # size - the size of the qrcode (default 4)
|
63
|
+
# # level - the error correction level, can be:
|
64
|
+
# * Level :l 7% of code can be restored
|
65
|
+
# * Level :m 15% of code can be restored
|
66
|
+
# * Level :q 25% of code can be restored
|
67
|
+
# * Level :h 30% of code can be restored (default :h)
|
68
|
+
#
|
64
69
|
# qr = RQRCode::QRCode.new('hello world', :size => 1, :level => :m )
|
65
70
|
#
|
66
71
|
|
@@ -201,14 +206,8 @@ module RQRCode #:nodoc:
|
|
201
206
|
|
202
207
|
|
203
208
|
def setup_timing_pattern #:nodoc:
|
204
|
-
( 8...@module_count - 8 ).each do |
|
205
|
-
|
206
|
-
@modules[r][6] = (r % 2 == 0)
|
207
|
-
end
|
208
|
-
|
209
|
-
( 8...@module_count - 8 ).each do |c|
|
210
|
-
next unless @modules[6][c].nil?
|
211
|
-
@modules[6][c] = (c % 2 == 0)
|
209
|
+
( 8...@module_count - 8 ).each do |i|
|
210
|
+
@modules[i][6] = @modules[6][i] = i % 2 == 0
|
212
211
|
end
|
213
212
|
end
|
214
213
|
|
@@ -243,10 +242,6 @@ module RQRCode #:nodoc:
|
|
243
242
|
( 0...18 ).each do |i|
|
244
243
|
mod = ( !test && ( (bits >> i) & 1) == 1 )
|
245
244
|
@modules[ (i / 3).floor ][ i % 3 + @module_count - 8 - 3 ] = mod
|
246
|
-
end
|
247
|
-
|
248
|
-
( 0...18 ).each do |i|
|
249
|
-
mod = ( !test && ( (bits >> i) & 1) == 1 )
|
250
245
|
@modules[ i % 3 + @module_count - 8 - 3 ][ (i / 3).floor ] = mod
|
251
246
|
end
|
252
247
|
end
|
@@ -256,10 +251,10 @@ module RQRCode #:nodoc:
|
|
256
251
|
data = (@error_correct_level << 3 | mask_pattern)
|
257
252
|
bits = QRUtil.get_bch_type_info( data )
|
258
253
|
|
259
|
-
# vertical
|
260
254
|
( 0...15 ).each do |i|
|
261
255
|
mod = (!test && ( (bits >> i) & 1) == 1)
|
262
256
|
|
257
|
+
# vertical
|
263
258
|
if i < 6
|
264
259
|
@modules[i][8] = mod
|
265
260
|
elsif i < 8
|
@@ -268,12 +263,7 @@ module RQRCode #:nodoc:
|
|
268
263
|
@modules[ @module_count - 15 + i ][8] = mod
|
269
264
|
end
|
270
265
|
|
271
|
-
|
272
|
-
|
273
|
-
# horizontal
|
274
|
-
( 0...15 ).each do |i|
|
275
|
-
mod = (!test && ( (bits >> i) & 1) == 1)
|
276
|
-
|
266
|
+
# horizontal
|
277
267
|
if i < 8
|
278
268
|
@modules[8][ @module_count - i - 1 ] = mod
|
279
269
|
elsif i < 9
|
@@ -19,7 +19,7 @@ module RQRCode #:nodoc:
|
|
19
19
|
@data_count = data_count
|
20
20
|
end
|
21
21
|
|
22
|
-
|
22
|
+
RQRCode::QRRSBlock::RS_BLOCK_TABLE = [
|
23
23
|
|
24
24
|
# L
|
25
25
|
# M
|
@@ -44,7 +44,7 @@ module RQRCode #:nodoc:
|
|
44
44
|
[2, 35, 17],
|
45
45
|
[2, 35, 13],
|
46
46
|
|
47
|
-
# 4
|
47
|
+
# 4
|
48
48
|
[1, 100, 80],
|
49
49
|
[2, 50, 32],
|
50
50
|
[2, 50, 24],
|
@@ -62,7 +62,7 @@ module RQRCode #:nodoc:
|
|
62
62
|
[4, 43, 19],
|
63
63
|
[4, 43, 15],
|
64
64
|
|
65
|
-
# 7
|
65
|
+
# 7
|
66
66
|
[2, 98, 78],
|
67
67
|
[4, 49, 31],
|
68
68
|
[2, 32, 14, 4, 33, 15],
|
@@ -80,14 +80,193 @@ module RQRCode #:nodoc:
|
|
80
80
|
[4, 36, 16, 4, 37, 17],
|
81
81
|
[4, 36, 12, 4, 37, 13],
|
82
82
|
|
83
|
-
# 10
|
83
|
+
# 10
|
84
84
|
[2, 86, 68, 2, 87, 69],
|
85
85
|
[4, 69, 43, 1, 70, 44],
|
86
86
|
[6, 43, 19, 2, 44, 20],
|
87
|
-
[6, 43, 15, 2, 44, 16]
|
87
|
+
[6, 43, 15, 2, 44, 16],
|
88
88
|
|
89
|
-
|
89
|
+
# 11
|
90
|
+
[4, 101, 81],
|
91
|
+
[1, 80, 50, 4, 81, 51],
|
92
|
+
[4, 50, 22, 4, 51, 23],
|
93
|
+
[3, 36, 12, 8, 37, 13],
|
94
|
+
|
95
|
+
# 12
|
96
|
+
[2, 116, 92, 2, 117, 93],
|
97
|
+
[6, 58, 36, 2, 59, 37],
|
98
|
+
[4, 46, 20, 6, 47, 21],
|
99
|
+
[7, 42, 14, 4, 43, 15],
|
100
|
+
|
101
|
+
# 13
|
102
|
+
[4, 133, 107],
|
103
|
+
[8, 59, 37, 1, 60, 38],
|
104
|
+
[8, 44, 20, 4, 45, 21],
|
105
|
+
[12, 33, 11, 4, 34, 12],
|
106
|
+
|
107
|
+
# 14
|
108
|
+
[3, 145, 115, 1, 146, 116],
|
109
|
+
[4, 64, 40, 5, 65, 41],
|
110
|
+
[11, 36, 16, 5, 37, 17],
|
111
|
+
[11, 36, 12, 5, 37, 13],
|
112
|
+
|
113
|
+
# 15
|
114
|
+
[5, 109, 87, 1, 110, 88],
|
115
|
+
[5, 65, 41, 5, 66, 42],
|
116
|
+
[5, 54, 24, 7, 55, 25],
|
117
|
+
[11, 36, 12],
|
118
|
+
|
119
|
+
# 16
|
120
|
+
[5, 122, 98, 1, 123, 99],
|
121
|
+
[7, 73, 45, 3, 74, 46],
|
122
|
+
[15, 43, 19, 2, 44, 20],
|
123
|
+
[3, 45, 15, 13, 46, 16],
|
124
|
+
|
125
|
+
# 17
|
126
|
+
[1, 135, 107, 5, 136, 108],
|
127
|
+
[10, 74, 46, 1, 75, 47],
|
128
|
+
[1, 50, 22, 15, 51, 23],
|
129
|
+
[2, 42, 14, 17, 43, 15],
|
130
|
+
|
131
|
+
# 18
|
132
|
+
[5, 150, 120, 1, 151, 121],
|
133
|
+
[9, 69, 43, 4, 70, 44],
|
134
|
+
[17, 50, 22, 1, 51, 23],
|
135
|
+
[2, 42, 14, 19, 43, 15],
|
136
|
+
|
137
|
+
# 19
|
138
|
+
[3, 141, 113, 4, 142, 114],
|
139
|
+
[3, 70, 44, 11, 71, 45],
|
140
|
+
[17, 47, 21, 4, 48, 22],
|
141
|
+
[9, 39, 13, 16, 40, 14],
|
142
|
+
|
143
|
+
# 20
|
144
|
+
[3, 135, 107, 5, 136, 108],
|
145
|
+
[3, 67, 41, 13, 68, 42],
|
146
|
+
[15, 54, 24, 5, 55, 25],
|
147
|
+
[15, 43, 15, 10, 44, 16],
|
148
|
+
|
149
|
+
# 21
|
150
|
+
[4, 144, 116, 4, 145, 117],
|
151
|
+
[17, 68, 42],
|
152
|
+
[17, 50, 22, 6, 51, 23],
|
153
|
+
[19, 46, 16, 6, 47, 17],
|
154
|
+
|
155
|
+
# 22
|
156
|
+
[2, 139, 111, 7, 140, 112],
|
157
|
+
[17, 74, 46],
|
158
|
+
[7, 54, 24, 16, 55, 25],
|
159
|
+
[34, 37, 13],
|
160
|
+
|
161
|
+
# 23
|
162
|
+
[4, 151, 121, 5, 152, 122],
|
163
|
+
[4, 75, 47, 14, 76, 48],
|
164
|
+
[11, 54, 24, 14, 55, 25],
|
165
|
+
[16, 45, 15, 14, 46, 16],
|
166
|
+
|
167
|
+
# 24
|
168
|
+
[6, 147, 117, 4, 148, 118],
|
169
|
+
[6, 73, 45, 14, 74, 46],
|
170
|
+
[11, 54, 24, 16, 55, 25],
|
171
|
+
[30, 46, 16, 2, 47, 17],
|
172
|
+
|
173
|
+
# 25
|
174
|
+
[8, 132, 106, 4, 133, 107],
|
175
|
+
[8, 75, 47, 13, 76, 48],
|
176
|
+
[7, 54, 24, 22, 55, 25],
|
177
|
+
[22, 45, 15, 13, 46, 16],
|
178
|
+
|
179
|
+
# 26
|
180
|
+
[10, 142, 114, 2, 143, 115],
|
181
|
+
[19, 74, 46, 4, 75, 47],
|
182
|
+
[28, 50, 22, 6, 51, 23],
|
183
|
+
[33, 46, 16, 4, 47, 17],
|
90
184
|
|
185
|
+
# 27
|
186
|
+
[8, 152, 122, 4, 153, 123],
|
187
|
+
[22, 73, 45, 3, 74, 46],
|
188
|
+
[8, 53, 23, 26, 54, 24],
|
189
|
+
[12, 45, 15, 28, 46, 16],
|
190
|
+
|
191
|
+
# 28
|
192
|
+
[3, 147, 117, 10, 148, 118],
|
193
|
+
[3, 73, 45, 23, 74, 46],
|
194
|
+
[4, 54, 24, 31, 55, 25],
|
195
|
+
[11, 45, 15, 31, 46, 16],
|
196
|
+
|
197
|
+
# 29
|
198
|
+
[7, 146, 116, 7, 147, 117],
|
199
|
+
[21, 73, 45, 7, 74, 46],
|
200
|
+
[1, 53, 23, 37, 54, 24],
|
201
|
+
[19, 45, 15, 26, 46, 16],
|
202
|
+
|
203
|
+
# 30
|
204
|
+
[5, 145, 115, 10, 146, 116],
|
205
|
+
[19, 75, 47, 10, 76, 48],
|
206
|
+
[15, 54, 24, 25, 55, 25],
|
207
|
+
[23, 45, 15, 25, 46, 16],
|
208
|
+
|
209
|
+
# 31
|
210
|
+
[13, 145, 115, 3, 146, 116],
|
211
|
+
[2, 74, 46, 29, 75, 47],
|
212
|
+
[42, 54, 24, 1, 55, 25],
|
213
|
+
[23, 45, 15, 28, 46, 16],
|
214
|
+
|
215
|
+
# 32
|
216
|
+
[17, 145, 115],
|
217
|
+
[10, 74, 46, 23, 75, 47],
|
218
|
+
[10, 54, 24, 35, 55, 25],
|
219
|
+
[19, 45, 15, 35, 46, 16],
|
220
|
+
|
221
|
+
# 33
|
222
|
+
[17, 145, 115, 1, 146, 116],
|
223
|
+
[14, 74, 46, 21, 75, 47],
|
224
|
+
[29, 54, 24, 19, 55, 25],
|
225
|
+
[11, 45, 15, 46, 46, 16],
|
226
|
+
|
227
|
+
# 34
|
228
|
+
[13, 145, 115, 6, 146, 116],
|
229
|
+
[14, 74, 46, 23, 75, 47],
|
230
|
+
[44, 54, 24, 7, 55, 25],
|
231
|
+
[59, 46, 16, 1, 47, 17],
|
232
|
+
|
233
|
+
# 35
|
234
|
+
[12, 151, 121, 7, 152, 122],
|
235
|
+
[12, 75, 47, 26, 76, 48],
|
236
|
+
[39, 54, 24, 14, 55, 25],
|
237
|
+
[22, 45, 15, 41, 46, 16],
|
238
|
+
|
239
|
+
# 36
|
240
|
+
[6, 151, 121, 14, 152, 122],
|
241
|
+
[6, 75, 47, 34, 76, 48],
|
242
|
+
[46, 54, 24, 10, 55, 25],
|
243
|
+
[2, 45, 15, 64, 46, 16],
|
244
|
+
|
245
|
+
# 37
|
246
|
+
[17, 152, 122, 4, 153, 123],
|
247
|
+
[29, 74, 46, 14, 75, 47],
|
248
|
+
[49, 54, 24, 10, 55, 25],
|
249
|
+
[24, 45, 15, 46, 46, 16],
|
250
|
+
|
251
|
+
# 38
|
252
|
+
[4, 152, 122, 18, 153, 123],
|
253
|
+
[13, 74, 46, 32, 75, 47],
|
254
|
+
[48, 54, 24, 14, 55, 25],
|
255
|
+
[42, 45, 15, 32, 46, 16],
|
256
|
+
|
257
|
+
# 39
|
258
|
+
[20, 147, 117, 4, 148, 118],
|
259
|
+
[40, 75, 47, 7, 76, 48],
|
260
|
+
[43, 54, 24, 22, 55, 25],
|
261
|
+
[10, 45, 15, 67, 46, 16],
|
262
|
+
|
263
|
+
# 40
|
264
|
+
[19, 148, 118, 6, 149, 119],
|
265
|
+
[18, 75, 47, 31, 76, 48],
|
266
|
+
[34, 54, 24, 34, 55, 25],
|
267
|
+
[20, 45, 15, 61, 46, 16]
|
268
|
+
|
269
|
+
]
|
91
270
|
|
92
271
|
def QRRSBlock.get_rs_blocks( type_no, error_correct_level )
|
93
272
|
rs_block = QRRSBlock.get_rs_block_table( type_no, error_correct_level )
|
data/lib/rqrcode.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rqrcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duncan Robertson
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-11-24 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description: rQRCode is a library for encoding QR Codes. The simple interface allows you to
|
16
|
+
description: rQRCode is a library for encoding QR Codes. The simple interface allows you to create QR Code data structures ready to be displayed in the way you choose.
|
17
17
|
email: duncan@whomwah.com
|
18
18
|
executables: []
|
19
19
|
|