barby 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/lib/barby.rb +3 -0
- data/lib/barby/barcode.rb +5 -0
- data/lib/barby/barcode/code_128.rb +41 -5
- data/lib/barby/barcode/code_25.rb +35 -3
- data/lib/barby/barcode/code_25_iata.rb +23 -0
- data/lib/barby/barcode/code_25_interleaved.rb +37 -37
- data/lib/barby/barcode/code_39.rb +5 -0
- data/lib/barby/barcode/code_93.rb +5 -0
- data/lib/barby/barcode/ean_13.rb +5 -0
- data/lib/barby/barcode/gs1_128.rb +6 -1
- data/lib/barby/barcode/qr_code.rb +5 -0
- data/lib/barby/outputter/rmagick_outputter.rb +14 -3
- data/lib/barby/outputter/svg_outputter.rb +225 -0
- data/lib/barby/version.rb +1 -1
- data/vendor/rqrcode/CHANGELOG +4 -0
- data/vendor/rqrcode/Rakefile +1 -1
- data/vendor/rqrcode/lib/rqrcode/qrcode/qr_8bit_byte.rb +3 -1
- data/vendor/rqrcode/lib/rqrcode/qrcode/qr_util.rb +12 -12
- metadata +4 -2
data/lib/barby.rb
CHANGED
@@ -10,5 +10,8 @@ require 'barby/barcode/ean_13'
|
|
10
10
|
require 'barby/barcode/ean_8'
|
11
11
|
require 'barby/barcode/bookland'
|
12
12
|
require 'barby/barcode/qr_code'
|
13
|
+
require 'barby/barcode/code_25'
|
14
|
+
require 'barby/barcode/code_25_interleaved'
|
15
|
+
require 'barby/barcode/code_25_iata'
|
13
16
|
|
14
17
|
require 'barby/outputter'
|
data/lib/barby/barcode.rb
CHANGED
@@ -170,10 +170,40 @@ module Barby
|
|
170
170
|
end
|
171
171
|
|
172
172
|
|
173
|
+
def to_s
|
174
|
+
full_data
|
175
|
+
end
|
176
|
+
|
177
|
+
|
173
178
|
def data
|
174
179
|
@data
|
175
180
|
end
|
176
181
|
|
182
|
+
#Returns the data for this barcode plus that for the entire extra chain,
|
183
|
+
#excluding all change codes
|
184
|
+
def full_data
|
185
|
+
data + full_extra_data
|
186
|
+
end
|
187
|
+
|
188
|
+
#Returns the data for this barcode plus that for the entire extra chain,
|
189
|
+
#including all change codes prefixing each extra
|
190
|
+
def full_data_with_change_codes
|
191
|
+
data + full_extra_data_with_change_code
|
192
|
+
end
|
193
|
+
|
194
|
+
#Returns the full_data for the extra or an empty string if there is no extra
|
195
|
+
def full_extra_data
|
196
|
+
return '' unless extra
|
197
|
+
extra.full_data
|
198
|
+
end
|
199
|
+
|
200
|
+
#Returns the full_data for the extra with the change code for the extra
|
201
|
+
#prepended. If there is no extra, an empty string is returned
|
202
|
+
def full_extra_data_with_change_code
|
203
|
+
return '' unless extra
|
204
|
+
change_code_for(extra) + extra.full_data_with_change_codes
|
205
|
+
end
|
206
|
+
|
177
207
|
#Set the data for this barcode. If the barcode changes
|
178
208
|
#character set, an extra will be created.
|
179
209
|
def data=(data)
|
@@ -296,14 +326,20 @@ module Barby
|
|
296
326
|
encodings[values[char]]
|
297
327
|
end
|
298
328
|
|
329
|
+
def change_code_for_class(klass)
|
330
|
+
{Code128A => CODEA, Code128B => CODEB, Code128C => CODEC}[klass]
|
331
|
+
end
|
332
|
+
|
333
|
+
#Find the character that changes the character set to the one
|
334
|
+
#represented in +barcode+
|
335
|
+
def change_code_for(barcode)
|
336
|
+
change_code_for_class(barcode.class)
|
337
|
+
end
|
338
|
+
|
299
339
|
#Find the numeric value for the character that changes the character
|
300
340
|
#set to the one represented in +barcode+
|
301
341
|
def change_code_number_for(barcode)
|
302
|
-
|
303
|
-
when Code128A then values[CODEA]
|
304
|
-
when Code128B then values[CODEB]
|
305
|
-
when Code128C then values[CODEC]
|
306
|
-
end
|
342
|
+
values[change_code_for(barcode)]
|
307
343
|
end
|
308
344
|
|
309
345
|
#Find the encoding to change to the character set in +barcode+
|
@@ -41,7 +41,7 @@ module Barby
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def data_encoding_with_checksum
|
44
|
-
|
44
|
+
digit_encodings_with_checksum.join
|
45
45
|
end
|
46
46
|
|
47
47
|
def encoding
|
@@ -53,10 +53,18 @@ module Barby
|
|
53
53
|
data.split(//)
|
54
54
|
end
|
55
55
|
|
56
|
+
def characters_with_checksum
|
57
|
+
characters.push(checksum.to_s)
|
58
|
+
end
|
59
|
+
|
56
60
|
def digits
|
57
61
|
characters.map{|c| c.to_i }
|
58
62
|
end
|
59
63
|
|
64
|
+
def digits_with_checksum
|
65
|
+
digits.push(checksum)
|
66
|
+
end
|
67
|
+
|
60
68
|
def even_and_odd_digits
|
61
69
|
alternater = false
|
62
70
|
digits.reverse.partition{ alternater = !alternater }
|
@@ -64,10 +72,17 @@ module Barby
|
|
64
72
|
|
65
73
|
|
66
74
|
def digit_encodings
|
75
|
+
raise_invalid unless valid?
|
67
76
|
digits.map{|d| encoding_for(d) }
|
68
77
|
end
|
69
78
|
alias character_encodings digit_encodings
|
70
79
|
|
80
|
+
def digit_encodings_with_checksum
|
81
|
+
raise_invalid unless valid?
|
82
|
+
digits_with_checksum.map{|d| encoding_for(d) }
|
83
|
+
end
|
84
|
+
alias character_encodings_with_checksum digit_encodings_with_checksum
|
85
|
+
|
71
86
|
|
72
87
|
#Returns the encoding for a single digit
|
73
88
|
def encoding_for(digit)
|
@@ -82,6 +97,10 @@ module Barby
|
|
82
97
|
end
|
83
98
|
end
|
84
99
|
|
100
|
+
def encoding_for_bars_without_end_space(*a)
|
101
|
+
encoding_for_bars(*a).gsub(/0+$/, '')
|
102
|
+
end
|
103
|
+
|
85
104
|
|
86
105
|
#Mod10
|
87
106
|
def checksum
|
@@ -117,6 +136,8 @@ module Barby
|
|
117
136
|
end
|
118
137
|
|
119
138
|
|
139
|
+
#2 of 5 doesn't require a checksum, but you can include a Mod10 checksum
|
140
|
+
#by setting +include_checksum+ to true
|
120
141
|
def include_checksum?
|
121
142
|
include_checksum
|
122
143
|
end
|
@@ -132,8 +153,7 @@ module Barby
|
|
132
153
|
end
|
133
154
|
|
134
155
|
def stop_encoding
|
135
|
-
|
136
|
-
encoding_for_bars(STOP_ENCODING).gsub(/0+$/, '')
|
156
|
+
encoding_for_bars_without_end_space(STOP_ENCODING)
|
137
157
|
end
|
138
158
|
|
139
159
|
|
@@ -155,6 +175,18 @@ module Barby
|
|
155
175
|
end
|
156
176
|
|
157
177
|
|
178
|
+
def to_s
|
179
|
+
(include_checksum? ? characters_with_checksum : characters).join
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
private
|
184
|
+
|
185
|
+
def raise_invalid
|
186
|
+
raise ArgumentError, "data not valid"
|
187
|
+
end
|
188
|
+
|
189
|
+
|
158
190
|
end
|
159
191
|
|
160
192
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'barby/barcode/code_25'
|
2
|
+
|
3
|
+
module Barby
|
4
|
+
|
5
|
+
#The IATA version of 2 of 5 is identical to its parent except for different
|
6
|
+
#start and stop codes. This is the one used on the tags they put on your
|
7
|
+
#luggage when you check it in at the airport.
|
8
|
+
class Code25IATA < Code25
|
9
|
+
|
10
|
+
START_ENCODING = [N,N]
|
11
|
+
STOP_ENCODING = [W,N]
|
12
|
+
|
13
|
+
def start_encoding
|
14
|
+
encoding_for_bars(START_ENCODING)
|
15
|
+
end
|
16
|
+
|
17
|
+
def stop_encoding
|
18
|
+
encoding_for_bars_without_end_space(STOP_ENCODING)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -2,69 +2,69 @@ require 'barby/barcode/code_25'
|
|
2
2
|
|
3
3
|
module Barby
|
4
4
|
|
5
|
+
#Code 2 of 5 interleaved. Same as standard 2 of 5, but spaces are used
|
6
|
+
#for encoding as well as the bars. Each pair of numbers get interleaved,
|
7
|
+
#that is, the first is encoded in the bars and the second is encoded
|
8
|
+
#in the spaced. This means an interleaved 2/5 barcode must have an even
|
9
|
+
#number of digits.
|
5
10
|
class Code25Interleaved < Code25
|
6
11
|
|
7
12
|
START_ENCODING = [N,N,N,N]
|
8
13
|
STOP_ENCODING = [W,N,N]
|
9
14
|
|
10
15
|
|
11
|
-
def
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
chars = characters
|
18
|
-
pairs = Array.new((chars.size/2.0).ceil){ [] }
|
19
|
-
chars.each_with_index{|c,i| pairs[(i/2.0).floor] << c }
|
20
|
-
pairs
|
16
|
+
def digit_pairs(d=nil)
|
17
|
+
(d || digits).inject [] do |ary,d|
|
18
|
+
ary << [] if !ary.last || ary.last.size == 2
|
19
|
+
ary.last << d
|
20
|
+
ary
|
21
|
+
end
|
21
22
|
end
|
22
23
|
|
23
|
-
def
|
24
|
-
|
25
|
-
pairs = Array.new((d.size/2.0).ceil){ [] }
|
26
|
-
d.each_with_index{|dd,i| pairs[(i/2.0).floor] << dd }
|
27
|
-
pairs
|
24
|
+
def digit_pairs_with_checksum
|
25
|
+
digit_pairs(digits_with_checksum)
|
28
26
|
end
|
29
27
|
|
30
28
|
|
31
|
-
def
|
29
|
+
def digit_encodings
|
30
|
+
raise_invalid unless valid?
|
32
31
|
digit_pairs.map{|p| encoding_for_pair(p) }
|
33
32
|
end
|
34
33
|
|
34
|
+
def digit_encodings_with_checksum
|
35
|
+
digit_pairs_with_checksum.map{|p| encoding_for_pair(p) }
|
36
|
+
end
|
37
|
+
|
35
38
|
|
36
39
|
def encoding_for_pair(pair)
|
37
40
|
bars, spaces = ENCODINGS[pair.first], ENCODINGS[pair.last]
|
38
|
-
bars.zip(spaces)
|
39
|
-
bar, space = *p
|
40
|
-
enc + ('1' * (bar == WIDE ? wide_width : narrow_width)) +
|
41
|
-
('0' * (space == WIDE ? wide_width : narrow_width))
|
42
|
-
end
|
41
|
+
encoding_for_interleaved(bars.zip(spaces))
|
43
42
|
end
|
44
43
|
|
45
|
-
#def encoding_for_bars(*bars_and_spaces)
|
46
|
-
# bar = false
|
47
|
-
# bars_and_spaces.flatten.inject '' do |enc,bar_or_space|
|
48
|
-
# bar = !bar
|
49
|
-
# enc + (bar ? '1' : '0')*(bar_or_space == WIDE ? wide_width : narrow_width)
|
50
|
-
# end
|
51
|
-
#end
|
52
|
-
|
53
44
|
|
54
|
-
|
55
|
-
|
56
|
-
|
45
|
+
#Encodes an array of interleaved W or N bars and spaces
|
46
|
+
#ex: [W,N,W,W,N,N] => "111011100010"
|
47
|
+
def encoding_for_interleaved(*bars_and_spaces)
|
48
|
+
bar = false#starts with bar
|
49
|
+
bars_and_spaces.flatten.inject '' do |enc,bar_or_space|
|
57
50
|
bar = !bar
|
58
51
|
enc << (bar ? '1' : '0') * (bar_or_space == WIDE ? wide_width : narrow_width)
|
59
52
|
end
|
60
53
|
end
|
61
54
|
|
55
|
+
|
56
|
+
def start_encoding
|
57
|
+
encoding_for_interleaved(START_ENCODING)
|
58
|
+
end
|
59
|
+
|
62
60
|
def stop_encoding
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
61
|
+
encoding_for_interleaved(STOP_ENCODING)
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def valid?
|
66
|
+
# When checksum is included, it's included when determining "evenness"
|
67
|
+
super && digits.size % 2 == (include_checksum? ? 1 : 0)
|
68
68
|
end
|
69
69
|
|
70
70
|
|
data/lib/barby/barcode/ean_13.rb
CHANGED
@@ -13,7 +13,8 @@ module Barby
|
|
13
13
|
super(data, type)
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
|
17
|
+
#TODO: Not sure this is entirely right
|
17
18
|
def data
|
18
19
|
FNC1+application_identifier+super
|
19
20
|
end
|
@@ -30,6 +31,10 @@ module Barby
|
|
30
31
|
encodings[application_identifier_number]
|
31
32
|
end
|
32
33
|
|
34
|
+
def to_s
|
35
|
+
"(#{application_identifier}) #{partial_data}"
|
36
|
+
end
|
37
|
+
|
33
38
|
|
34
39
|
end
|
35
40
|
|
@@ -16,17 +16,28 @@ module Barby
|
|
16
16
|
|
17
17
|
#Returns a string containing a PNG image
|
18
18
|
def to_png(*a)
|
19
|
-
|
19
|
+
to_blob('png', *a)
|
20
20
|
end
|
21
21
|
|
22
22
|
#Returns a string containint a GIF image
|
23
23
|
def to_gif(*a)
|
24
|
-
|
24
|
+
to_blob('gif', *a)
|
25
25
|
end
|
26
26
|
|
27
27
|
#Returns a string containing a JPEG image
|
28
28
|
def to_jpg(*a)
|
29
|
-
|
29
|
+
to_blob('jpg', *a)
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_blob(format, *a)
|
33
|
+
img = to_image(*a)
|
34
|
+
blob = img.to_blob{|i| i.format = format }
|
35
|
+
|
36
|
+
#Release the memory used by RMagick explicitly. Ruby's GC
|
37
|
+
#isn't aware of it and can't clean it up automatically
|
38
|
+
img.destroy! if img.respond_to?(:destroy!)
|
39
|
+
|
40
|
+
blob
|
30
41
|
end
|
31
42
|
|
32
43
|
#Returns an instance of Magick::Image
|
@@ -0,0 +1,225 @@
|
|
1
|
+
require 'barby/outputter'
|
2
|
+
|
3
|
+
module Barby
|
4
|
+
|
5
|
+
#Renders the barcode to a simple SVG image using pure ruby
|
6
|
+
#
|
7
|
+
#Registers the to_svg, bars_to_path, and bars_to_rects method
|
8
|
+
#
|
9
|
+
#Bars can be rendered as a stroked path or as filled rectangles. Path
|
10
|
+
#generally yields smaller files, but this doesn't render cleanly in Firefox
|
11
|
+
#3 for odd xdims. My guess is that the renderer tries to put half a pixel
|
12
|
+
#on one side of the path and half on the other, leading to fuzzy dithering
|
13
|
+
#instead of sharp, clean b&w.
|
14
|
+
#
|
15
|
+
#Therefore, default behavior is to use a path for even xdims, and
|
16
|
+
#rectangles for odd. This can be overridden by calling with explicit
|
17
|
+
#:use => 'rects' or :use => 'path' options.
|
18
|
+
class SvgOutputter < Outputter
|
19
|
+
|
20
|
+
register :to_svg, :bars_to_rects, :bars_to_path
|
21
|
+
|
22
|
+
attr_writer :title, :xdim, :ydim, :height, :rmargin, :lmargin, :tmargin, :bmargin, :xmargin, :ymargin, :margin
|
23
|
+
|
24
|
+
|
25
|
+
def to_svg(opts={})
|
26
|
+
with_options opts do
|
27
|
+
case opts[:use]
|
28
|
+
when 'rects' then bars = bars_to_rects
|
29
|
+
when 'path' then bars = bars_to_path
|
30
|
+
else
|
31
|
+
xdim_odd = (xdim % 2 == 1)
|
32
|
+
bars = xdim_odd ? bars_to_rects : bars_to_path
|
33
|
+
end
|
34
|
+
|
35
|
+
<<-"EOT"
|
36
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
37
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="#{svg_width(opts)}px" height="#{svg_height(opts)}px" viewBox="0 0 #{svg_width(opts)} #{svg_height(opts)}" version="1.1">
|
38
|
+
<title>#{escape title}</title>
|
39
|
+
<g id="canvas" #{transform(opts)}>
|
40
|
+
<rect x="0" y="0" width="#{full_width}px" height="#{full_height}px" fill="white" />
|
41
|
+
<g id="barcode" fill="black">
|
42
|
+
#{bars}
|
43
|
+
</g></g>
|
44
|
+
</svg>
|
45
|
+
EOT
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def bars_to_rects(opts={})
|
51
|
+
rects = ''
|
52
|
+
with_options opts do
|
53
|
+
x, y = lmargin, tmargin
|
54
|
+
|
55
|
+
if barcode.two_dimensional?
|
56
|
+
boolean_groups.each do |line|
|
57
|
+
line.each do |bar, amount|
|
58
|
+
bar_width = xdim * amount
|
59
|
+
if bar
|
60
|
+
rects << %Q|<rect x="#{x}" y="#{y}" width="#{bar_width}px" height="#{ydim}px" />\n|
|
61
|
+
end
|
62
|
+
x += bar_width
|
63
|
+
end
|
64
|
+
y += ydim
|
65
|
+
x = lmargin
|
66
|
+
end
|
67
|
+
|
68
|
+
else
|
69
|
+
boolean_groups.each do |bar, amount|
|
70
|
+
bar_width = xdim * amount
|
71
|
+
if bar
|
72
|
+
rects << %Q|<rect x="#{x}" y="#{y}" width="#{bar_width}px" height="#{height}px" />\n|
|
73
|
+
end
|
74
|
+
x += bar_width
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end # with_options
|
79
|
+
|
80
|
+
rects
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
def bars_to_path(opts={})
|
85
|
+
with_options opts do
|
86
|
+
%Q|<path stroke="black" stroke-width="#{xdim}" d="#{bars_to_path_data(opts)}" />|
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
def bars_to_path_data(opts={})
|
92
|
+
path_data = ''
|
93
|
+
with_options opts do
|
94
|
+
x, y = lmargin+(xdim/2), tmargin
|
95
|
+
|
96
|
+
if barcode.two_dimensional?
|
97
|
+
booleans.each do |line|
|
98
|
+
line.each do |bar|
|
99
|
+
if bar
|
100
|
+
path_data << "M#{x} #{y}V #{y+ydim}"
|
101
|
+
end
|
102
|
+
x += xdim
|
103
|
+
end
|
104
|
+
y += ydim
|
105
|
+
x = lmargin+(xdim/2)
|
106
|
+
end
|
107
|
+
|
108
|
+
else
|
109
|
+
booleans.each do |bar|
|
110
|
+
if bar
|
111
|
+
path_data << "M#{x} #{y}V#{y+height}"
|
112
|
+
end
|
113
|
+
x += xdim
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
end # with_options
|
118
|
+
|
119
|
+
path_data
|
120
|
+
end
|
121
|
+
|
122
|
+
|
123
|
+
def title
|
124
|
+
@title || barcode.to_s
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
def width
|
129
|
+
length * xdim
|
130
|
+
end
|
131
|
+
|
132
|
+
def height
|
133
|
+
barcode.two_dimensional? ? (ydim * encoding.length) : (@height || 100)
|
134
|
+
end
|
135
|
+
|
136
|
+
def full_width
|
137
|
+
width + lmargin + rmargin
|
138
|
+
end
|
139
|
+
|
140
|
+
def full_height
|
141
|
+
height + tmargin + bmargin
|
142
|
+
end
|
143
|
+
|
144
|
+
def xdim
|
145
|
+
@xdim || 1
|
146
|
+
end
|
147
|
+
|
148
|
+
def ydim
|
149
|
+
@ydim || xdim
|
150
|
+
end
|
151
|
+
|
152
|
+
def lmargin
|
153
|
+
@lmargin || _xmargin
|
154
|
+
end
|
155
|
+
|
156
|
+
def rmargin
|
157
|
+
@rmargin || _xmargin
|
158
|
+
end
|
159
|
+
|
160
|
+
def tmargin
|
161
|
+
@tmargin || _ymargin
|
162
|
+
end
|
163
|
+
|
164
|
+
def bmargin
|
165
|
+
@bmargin || _ymargin
|
166
|
+
end
|
167
|
+
|
168
|
+
def xmargin
|
169
|
+
return nil if @lmargin || @rmargin
|
170
|
+
_margin
|
171
|
+
end
|
172
|
+
|
173
|
+
def ymargin
|
174
|
+
return nil if @tmargin || @bmargin
|
175
|
+
_margin
|
176
|
+
end
|
177
|
+
|
178
|
+
def margin
|
179
|
+
return nil if @ymargin || @xmargin || @tmargin || @bmargin || @lmargin || @rmargin
|
180
|
+
_margin
|
181
|
+
end
|
182
|
+
|
183
|
+
def length
|
184
|
+
barcode.two_dimensional? ? encoding.first.length : encoding.length
|
185
|
+
end
|
186
|
+
|
187
|
+
|
188
|
+
def svg_width(opts={})
|
189
|
+
opts[:rot] ? full_height : full_width
|
190
|
+
end
|
191
|
+
|
192
|
+
def svg_height(opts={})
|
193
|
+
opts[:rot] ? full_width : full_height
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
def transform(opts={})
|
198
|
+
opts[:rot] ? %Q|transform="rotate(-90) translate(-#{full_width}, 0)"| : nil
|
199
|
+
end
|
200
|
+
|
201
|
+
|
202
|
+
private
|
203
|
+
|
204
|
+
def _xmargin
|
205
|
+
@xmargin || _margin
|
206
|
+
end
|
207
|
+
|
208
|
+
def _ymargin
|
209
|
+
@ymargin || _margin
|
210
|
+
end
|
211
|
+
|
212
|
+
def _margin
|
213
|
+
@margin || 10
|
214
|
+
end
|
215
|
+
|
216
|
+
#Escape XML special characters <, & and >
|
217
|
+
def escape(str)
|
218
|
+
str.gsub('&', '&').gsub('<', '<').gsub('>', '>')
|
219
|
+
end
|
220
|
+
|
221
|
+
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
end
|
data/lib/barby/version.rb
CHANGED
data/vendor/rqrcode/CHANGELOG
CHANGED
data/vendor/rqrcode/Rakefile
CHANGED
@@ -27,7 +27,9 @@ module RQRCode
|
|
27
27
|
|
28
28
|
def write( buffer )
|
29
29
|
( 0...@data.size ).each do |i|
|
30
|
-
|
30
|
+
c = @data[i]
|
31
|
+
c = c.ord if c.respond_to?(:ord)#String#[] returns single-char string in 1.9, .ord gets ASCII pos
|
32
|
+
buffer.put( c, 8 )
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -137,10 +137,10 @@ module RQRCode #:nodoc:
|
|
137
137
|
|
138
138
|
# 1 - 9
|
139
139
|
case mode
|
140
|
-
when QRMODE[:mode_number]
|
141
|
-
when QRMODE[:mode_alpha_num]
|
142
|
-
when QRMODE[:mode_8bit_byte]
|
143
|
-
when QRMODE[:mode_kanji]
|
140
|
+
when QRMODE[:mode_number] then 10
|
141
|
+
when QRMODE[:mode_alpha_num] then 9
|
142
|
+
when QRMODE[:mode_8bit_byte] then 8
|
143
|
+
when QRMODE[:mode_kanji] then 8
|
144
144
|
else
|
145
145
|
raise QRCodeRunTimeError, "mode: #{mode}"
|
146
146
|
end
|
@@ -149,10 +149,10 @@ module RQRCode #:nodoc:
|
|
149
149
|
|
150
150
|
# 10 -26
|
151
151
|
case mode
|
152
|
-
when QRMODE[:mode_number]
|
153
|
-
when QRMODE[:mode_alpha_num]
|
154
|
-
when QRMODE[:mode_8bit_byte]
|
155
|
-
when QRMODE[:mode_kanji]
|
152
|
+
when QRMODE[:mode_number] then 12
|
153
|
+
when QRMODE[:mode_alpha_num] then 11
|
154
|
+
when QRMODE[:mode_8bit_byte] then 16
|
155
|
+
when QRMODE[:mode_kanji] then 10
|
156
156
|
else
|
157
157
|
raise QRCodeRunTimeError, "mode: #{mode}"
|
158
158
|
end
|
@@ -161,10 +161,10 @@ module RQRCode #:nodoc:
|
|
161
161
|
|
162
162
|
# 27 - 40
|
163
163
|
case mode
|
164
|
-
when QRMODE[:mode_number]
|
165
|
-
when QRMODE[:mode_alpha_num]
|
166
|
-
when QRMODE[:mode_8bit_byte]
|
167
|
-
when QRMODE[:mode_kanji]
|
164
|
+
when QRMODE[:mode_number] then 14
|
165
|
+
when QRMODE[:mode_alpha_num] then 13
|
166
|
+
when QRMODE[:mode_8bit_byte] then 16
|
167
|
+
when QRMODE[:mode_kanji] then 12
|
168
168
|
else
|
169
169
|
raise QRCodeRunTimeError, "mode: #{mode}"
|
170
170
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tore Darell
|
@@ -9,7 +9,7 @@ autorequire: barby
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-05-25 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- lib/barby/outputter/png_outputter.rb
|
35
35
|
- lib/barby/outputter/prawn_outputter.rb
|
36
36
|
- lib/barby/outputter/cairo_outputter.rb
|
37
|
+
- lib/barby/outputter/svg_outputter.rb
|
37
38
|
- lib/barby/barcode
|
38
39
|
- lib/barby/barcode/code_25.rb
|
39
40
|
- lib/barby/barcode/ean_13.rb
|
@@ -44,6 +45,7 @@ files:
|
|
44
45
|
- lib/barby/barcode/code_39.rb
|
45
46
|
- lib/barby/barcode/bookland.rb
|
46
47
|
- lib/barby/barcode/code_128.rb
|
48
|
+
- lib/barby/barcode/code_25_iata.rb
|
47
49
|
- lib/barby/barcode/gs1_128.rb
|
48
50
|
- lib/barby.rb
|
49
51
|
- bin/barby
|