prawn-qrcode 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/Rakefile +8 -6
- data/lib/prawn/qrcode.rb +29 -23
- data/prawn-qrcode.gemspec +3 -3
- metadata +11 -8
data/README.md
CHANGED
@@ -26,14 +26,14 @@ end
|
|
26
26
|
# Render a code for raw content and a given total code size.
|
27
27
|
# Renders a QR Code at the cursor position measuring 1 in in width/height.
|
28
28
|
Prawn::Document::new do
|
29
|
-
print_qr_code(
|
29
|
+
print_qr_code(qrcode_content, :extent=>72)
|
30
30
|
render_file("qr2.pdf")
|
31
31
|
end
|
32
32
|
|
33
33
|
# Render a code for raw content with a given dot size
|
34
34
|
Prawn::Document::new do
|
35
35
|
# Renders a QR Code at he cursor position using a dot (module) size of 2.8/72 in (roughly 1 mm).
|
36
|
-
render_qr_code(
|
36
|
+
render_qr_code(qrcode_content, :dot=>2.8)
|
37
37
|
render_file("qr3.pdf")
|
38
38
|
end
|
39
39
|
```
|
data/Rakefile
CHANGED
@@ -16,10 +16,12 @@ require 'rake'
|
|
16
16
|
require "rubygems"
|
17
17
|
require "rubygems/package_task"
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
pkg.need_tar = true
|
24
|
-
end
|
19
|
+
spec = Gem::Specification.load "prawn-qrcode.gemspec"
|
20
|
+
Gem::PackageTask.new(spec).define do |pkg|
|
21
|
+
#pkg.need_zip = true
|
22
|
+
pkg.need_tar = true
|
25
23
|
end
|
24
|
+
|
25
|
+
task :default => :package
|
26
|
+
|
27
|
+
task :clean => :clobber_package
|
data/lib/prawn/qrcode.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
#--
|
1
2
|
# Copyright 2011 Jens Hausherr
|
2
3
|
#
|
3
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -11,31 +12,37 @@
|
|
11
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
13
|
# See the License for the specific language governing permissions and
|
13
14
|
# limitations under the License.
|
15
|
+
#++
|
14
16
|
require 'prawn'
|
15
17
|
require 'rqrcode'
|
16
18
|
|
17
|
-
#
|
19
|
+
# :title: Prawn/QRCode
|
18
20
|
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
21
|
+
# :main: This is an extension for Prawn::Document to simplify rendering QR Codes.
|
22
|
+
# The module registers itself as Prawn extension upon loading.
|
23
|
+
#
|
24
|
+
# *Author*:: Jens Hausherr (mailto:jabbrwcky@googlemail.com)
|
25
|
+
# *Copyright*:: Copyright (c) 2011 Jens Hausherr
|
26
|
+
# *License*:: Apache License, Version 2.0
|
22
27
|
#
|
23
28
|
module QRCode
|
24
29
|
|
25
30
|
# The default size for QR Code modules is 1/72 in
|
26
31
|
DEFAULT_DOTSIZE = 1
|
27
32
|
|
28
|
-
# Prints a QR Code to the PDF document. The QR
|
33
|
+
# Prints a QR Code to the PDF document. The QR Code creation happens on the fly.
|
34
|
+
#
|
35
|
+
# content:: The string to render as content of the QR Code
|
36
|
+
#
|
37
|
+
# *options:: Named optional parameters
|
29
38
|
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
35
|
-
# Defaults to [0,cursor]
|
36
|
-
# :dot:: Size of QR Code module/dot. Calculated from extent or defaulting to 1pt
|
37
|
-
# :stroke:: boolean value whether to draw bounds around the QR Code.
|
39
|
+
# +:level+:: Error correction level to use. One of: (:l,:m,:h,:q), Defaults to :m
|
40
|
+
# +:exent+:: Size of QR Code given in pt (1 pt == 1/72 in)
|
41
|
+
# +:pos+:: Two-element array containing the position at which the QR-Code should be rendered. Defaults to [0,cursor]
|
42
|
+
# +:dot+:: Size of QR Code module/dot. Calculated from extent or defaulting to 1pt
|
43
|
+
# +:stroke+:: boolean value whether to draw bounds around the QR Code.
|
38
44
|
# Defaults to true.
|
45
|
+
#
|
39
46
|
def print_qr_code(content, *options)
|
40
47
|
opt = options.extract_options!
|
41
48
|
qr_version = 0
|
@@ -57,22 +64,21 @@ module QRCode
|
|
57
64
|
end
|
58
65
|
end
|
59
66
|
|
60
|
-
# Renders a prepared QR Code object.
|
67
|
+
# Renders a prepared QR Code (RQRCode::QRCode) object.
|
61
68
|
#
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
#
|
69
|
-
# Defaults to true.
|
69
|
+
# qr_code:: The QR Code (an RQRCode::QRCode) to render
|
70
|
+
#
|
71
|
+
# *options:: Named optional parameters
|
72
|
+
# +:exent+:: Size of QR Code given in pt (1 pt == 1/72 in)
|
73
|
+
# +:pos+:: Two-element array containing the position at which the QR-Code should be rendered. Defaults to [0,cursor]
|
74
|
+
# +:dot+:: Size of QR Code module/dot. Calculated from extent or defaulting to 1pt
|
75
|
+
# +:stroke+:: boolean value whether to draw bounds around the QR Code. Defaults to true.
|
70
76
|
def render_qr_code(qr_code, *options)
|
71
77
|
opt = options.extract_options!
|
72
78
|
dot = opt[:dot] || DEFAULT_DOTSIZE
|
73
79
|
extent= opt[:extent] || (8+qr_code.modules.length) * dot
|
74
80
|
stroke = (opt.has_key?(:stroke) && opt[:stroke].nil?) || opt[:stroke]
|
75
|
-
pos = opt[:pos] ||[0,cursor]
|
81
|
+
pos = opt[:pos] ||[0, cursor]
|
76
82
|
|
77
83
|
bounding_box pos, :width => extent, :height => extent do |box|
|
78
84
|
if stroke
|
data/prawn-qrcode.gemspec
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
14
|
|
15
|
-
PRAWN_QRCODE_VERSION = "0.1.
|
15
|
+
PRAWN_QRCODE_VERSION = "0.1.1"
|
16
16
|
|
17
17
|
Gem::Specification.new do |spec|
|
18
18
|
spec.name = "prawn-qrcode"
|
@@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.authors = ["Jens Hausherr"]
|
32
32
|
spec.email = ["jabbrwcky@googlemail.com"]
|
33
33
|
#spec.rubyforge_project = "prawn-qrcode"
|
34
|
-
spec.add_dependency('prawn', '
|
35
|
-
spec.add_dependency('rqrcode', '
|
34
|
+
spec.add_dependency('prawn', '>= 0.11.1', '<= 0.13')
|
35
|
+
spec.add_dependency('rqrcode', '>=0.4.1')
|
36
36
|
spec.homepage = "http://github.com/jabbrwcky/prawn-qrcode"
|
37
37
|
spec.description = <<END_DESC
|
38
38
|
Prawn/QRCode simplifies the generation and rendering of QRCodes in Prawn PDF documents.
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,30 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-09-
|
12
|
+
date: 2011-09-08 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: prawn
|
16
|
-
requirement: &
|
16
|
+
requirement: &70156970180620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 0.11.1
|
22
|
+
- - <=
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: '0.13'
|
22
25
|
type: :runtime
|
23
26
|
prerelease: false
|
24
|
-
version_requirements: *
|
27
|
+
version_requirements: *70156970180620
|
25
28
|
- !ruby/object:Gem::Dependency
|
26
29
|
name: rqrcode
|
27
|
-
requirement: &
|
30
|
+
requirement: &70156970210100 !ruby/object:Gem::Requirement
|
28
31
|
none: false
|
29
32
|
requirements:
|
30
|
-
- -
|
33
|
+
- - ! '>='
|
31
34
|
- !ruby/object:Gem::Version
|
32
35
|
version: 0.4.1
|
33
36
|
type: :runtime
|
34
37
|
prerelease: false
|
35
|
-
version_requirements: *
|
38
|
+
version_requirements: *70156970210100
|
36
39
|
description: ! " Prawn/QRCode simplifies the generation and rendering of QRCodes
|
37
40
|
in Prawn PDF documents.\n QR Codes\n"
|
38
41
|
email:
|