prawn-qrcode 0.1.2 → 0.2.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.md +22 -1
- data/lib/prawn/qrcode.rb +17 -3
- data/prawn-qrcode.gemspec +1 -1
- metadata +6 -6
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# Prawn/QRCode: A simple extension to generate and/or render QRCodes for Prawn PDFs
|
2
2
|
|
3
|
-
Prawn/QRCode is a Prawn (
|
3
|
+
Prawn/QRCode is a Prawn (>= 0.11.1) extension to simplify rendering of QR Codes*.
|
4
|
+
|
5
|
+
(*) QR Code is registered trademark of DENSO WAVE INCORPORATED.
|
6
|
+
See http://www.denso-wave.com/qrcode/ for more information.
|
4
7
|
|
5
8
|
## Install
|
6
9
|
|
@@ -43,3 +46,21 @@ For a full list of examples, take a look in the `examples` folder.
|
|
43
46
|
## Contributors
|
44
47
|
|
45
48
|
- [Jens Hausherr](mailto:jabbrwcky@googlemail.com)
|
49
|
+
- [Brandon DuRette] (https://github.com/bdurette)
|
50
|
+
|
51
|
+
## Changelog
|
52
|
+
|
53
|
+
### 0.1.0
|
54
|
+
Initial Release
|
55
|
+
|
56
|
+
### 0.1.1
|
57
|
+
Updated prawn dependency from exact requirement of 0.11.1 to an >=0.11.1, <0.13
|
58
|
+
|
59
|
+
### 0.1.2
|
60
|
+
Integrated patch to reduce rectangle count, which leads to a overall size reduction
|
61
|
+
of the generated PDF (bdurette)
|
62
|
+
|
63
|
+
### 0.2.0
|
64
|
+
Integrated patch from bdurette to align QR Code within its bounding box.
|
65
|
+
Adds the optional parameter :align (:left, :center, :right) to both
|
66
|
+
render_qr_code() and print_qr_code()
|
data/lib/prawn/qrcode.rb
CHANGED
@@ -37,11 +37,13 @@ module QRCode
|
|
37
37
|
# *options:: Named optional parameters
|
38
38
|
#
|
39
39
|
# +:level+:: Error correction level to use. One of: (:l,:m,:h,:q), Defaults to :m
|
40
|
-
# +:
|
40
|
+
# +:extent+:: Size of QR Code given in pt (1 pt == 1/72 in)
|
41
41
|
# +:pos+:: Two-element array containing the position at which the QR-Code should be rendered. Defaults to [0,cursor]
|
42
42
|
# +:dot+:: Size of QR Code module/dot. Calculated from extent or defaulting to 1pt
|
43
43
|
# +:stroke+:: boolean value whether to draw bounds around the QR Code.
|
44
44
|
# Defaults to true.
|
45
|
+
# +:align+:: Optional alignment within the current bounding box. Valid values are :left, :right, and :center. If set
|
46
|
+
# This option overrides the horizontal positioning specified in :pos. Defaults to nil.
|
45
47
|
#
|
46
48
|
def print_qr_code(content, *options)
|
47
49
|
opt = options.extract_options!
|
@@ -54,7 +56,7 @@ module QRCode
|
|
54
56
|
qr_code = RQRCode::QRCode.new(content, :size=>qr_version, :level=>level)
|
55
57
|
|
56
58
|
dot_size = extent/(8+qr_code.modules.length) if extent
|
57
|
-
render_qr_code(qr_code, :dot=>dot_size, :pos=>opt[:pos], :stroke=>opt[:stroke])
|
59
|
+
render_qr_code(qr_code, :dot=>dot_size, :pos=>opt[:pos], :stroke=>opt[:stroke], :align=>opt[:align])
|
58
60
|
rescue RQRCode::QRCodeRunTimeError
|
59
61
|
if qr_version <40
|
60
62
|
retry
|
@@ -69,10 +71,12 @@ module QRCode
|
|
69
71
|
# qr_code:: The QR Code (an RQRCode::QRCode) to render
|
70
72
|
#
|
71
73
|
# *options:: Named optional parameters
|
72
|
-
# +:
|
74
|
+
# +:extent+:: Size of QR Code given in pt (1 pt == 1/72 in)
|
73
75
|
# +:pos+:: Two-element array containing the position at which the QR-Code should be rendered. Defaults to [0,cursor]
|
74
76
|
# +:dot+:: Size of QR Code module/dot. Calculated from extent or defaulting to 1pt
|
75
77
|
# +:stroke+:: boolean value whether to draw bounds around the QR Code. Defaults to true.
|
78
|
+
# +:align+:: Optional alignment within the current bounding box. Valid values are :left, :right, and :center. If set
|
79
|
+
# This option overrides the horizontal positioning specified in :pos. Defaults to nil.
|
76
80
|
def render_qr_code(qr_code, *options)
|
77
81
|
opt = options.extract_options!
|
78
82
|
dot = opt[:dot] || DEFAULT_DOTSIZE
|
@@ -80,6 +84,16 @@ module QRCode
|
|
80
84
|
stroke = (opt.has_key?(:stroke) && opt[:stroke].nil?) || opt[:stroke]
|
81
85
|
pos = opt[:pos] ||[0, cursor]
|
82
86
|
|
87
|
+
align = opt[:align]
|
88
|
+
case(align)
|
89
|
+
when :center
|
90
|
+
pos[0] = (@bounding_box.right / 2) - (extent / 2)
|
91
|
+
when :right
|
92
|
+
pos[0] = @bounding_box.right - extent
|
93
|
+
when :left
|
94
|
+
pos[0] = 0;
|
95
|
+
end
|
96
|
+
|
83
97
|
bounding_box pos, :width => extent, :height => extent do |box|
|
84
98
|
if stroke
|
85
99
|
stroke_bounds
|
data/prawn-qrcode.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prawn-qrcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-10 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: prawn
|
16
|
-
requirement: &
|
16
|
+
requirement: &70349245069560 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -24,10 +24,10 @@ dependencies:
|
|
24
24
|
version: '0.13'
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *70349245069560
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rqrcode
|
30
|
-
requirement: &
|
30
|
+
requirement: &70349245068840 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ! '>='
|
@@ -35,7 +35,7 @@ dependencies:
|
|
35
35
|
version: 0.4.1
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *70349245068840
|
39
39
|
description: ! " Prawn/QRCode simplifies the generation and rendering of QRCodes
|
40
40
|
in Prawn PDF documents.\n QR Codes\n"
|
41
41
|
email:
|