prawn-qrcode 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3547745205acbd37a86057be36c2697e1d82c1c3
4
- data.tar.gz: 9331621f71449ea16e7160021a335e53a0a76dfa
3
+ metadata.gz: a01cff5d48f7ef32301abcabed5725ff3fe27248
4
+ data.tar.gz: eab2bb7b8f2a30f16bc2861762abfcd8ec038c7b
5
5
  SHA512:
6
- metadata.gz: 725829fe5354736f21527388e00bbe38ff41e986fe01c141eba4c9250df7df3a9feb646f39510a67b33950636c7ec539a89df2ad03e717dd9c68793b35bbff59
7
- data.tar.gz: 33564d102916ab2fb017899e4fe26db8d704f4c5ae1434a3ab4368a59e97483a0cb22edb1ac2fa7d41ec9e52720a7f198efef856057b7031e0deb3b891e43526
6
+ metadata.gz: ce1478d777591323be02c1969377a5edaffffbf0369b3412ff5264252aee8facbb974f8fde4b6fba49525f24f80c8d4d9f8dc5fbdbac0adae3ad02f2fba05408
7
+ data.tar.gz: da600a608bc3a03545d92d1b82c673d3b5ec2652f9cfb25249ef0c53a2162d90291b8cc206244f5bb91642957ab32c1f3855f33e9fc69eebf71c5f5c642d5f53
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
- # Prawn/QRCode: A simple extension to generate and/or render QRCodes for Prawn PDFs
1
+ # Prawn/QRCode
2
+
3
+ A simple extension to generate and/or render QRCodes for Prawn PDFs
4
+
5
+ ![TravisCI Build state](https://travis-ci.org/jabbrwcky/prawn-qrcode.svg?branch=master)
2
6
 
3
7
  Prawn/QRCode is a Prawn (>= 0.11.1) extension to simplify rendering of QR Codes*.
4
8
 
@@ -17,7 +21,7 @@ $ gem install prawn-qrcode
17
21
  require 'prawn/qrcode'
18
22
 
19
23
  qrcode_content = "http://github.com/jabbrwcky/prawn-qrcode"
20
- qrcode = RQRCode::QRCode.new("http://github.com/jabbrwcky/prawn-qrcode", :level=>:h, :size => 5)
24
+ qrcode = RQRCode::QRCode.new(qrcode_content, :level=>:h, :size => 5)
21
25
 
22
26
  # Render a prepared QRCode at he cursor position
23
27
  # using a default module (e.g. dot) size of 1pt or 1/72 in
@@ -43,11 +47,6 @@ end
43
47
 
44
48
  For a full list of examples, take a look in the `examples` folder.
45
49
 
46
- ## Contributors
47
-
48
- - [Jens Hausherr](mailto:jabbrwcky@googlemail.com)
49
- - [Brandon DuRette] (https://github.com/bdurette)
50
-
51
50
  ## Changelog
52
51
 
53
52
  ### 0.1.0
@@ -64,3 +63,10 @@ of the generated PDF (bdurette)
64
63
  Integrated patch from bdurette to align QR Code within its bounding box.
65
64
  Adds the optional parameter :align (:left, :center, :right) to both
66
65
  render_qr_code() and print_qr_code()
66
+
67
+ ### 0.2.1
68
+ Updated prawn dependnecy spec to >= 0.11.1.
69
+
70
+ ### 0.2.2
71
+ Fixed default stroke and explicit conversion of extents to floats.
72
+
data/lib/prawn/qrcode.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #--
2
- # Copyright 2011 Jens Hausherr
2
+ # Copyright 2010-2014 Jens Hausherr
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ require 'rqrcode'
28
28
  module QRCode
29
29
 
30
30
  # The default size for QR Code modules is 1/72 in
31
- DEFAULT_DOTSIZE = 1
31
+ DEFAULT_DOTSIZE = 1.to_f
32
32
 
33
33
  # Prints a QR Code to the PDF document. The QR Code creation happens on the fly.
34
34
  #
@@ -49,14 +49,14 @@ module QRCode
49
49
  opt = options.extract_options!
50
50
  qr_version = 0
51
51
  level = opt[:level] || :m
52
- extent = opt[:extent]
53
- dot_size = opt[:dot] || DEFAULT_DOTSIZE
52
+ extent = opt[:extent].to_f
53
+ dot_size = opt[:dot].to_f || DEFAULT_DOTSIZE
54
54
  begin
55
55
  qr_version +=1
56
56
  qr_code = RQRCode::QRCode.new(content, :size=>qr_version, :level=>level)
57
57
 
58
58
  dot_size = extent/(8+qr_code.modules.length) if extent
59
- render_qr_code(qr_code, :dot=>dot_size, :pos=>opt[:pos], :stroke=>opt[:stroke], :align=>opt[:align])
59
+ render_qr_code(qr_code, opt.merge(:dot=>dot_size))
60
60
  rescue RQRCode::QRCodeRunTimeError
61
61
  if qr_version <40
62
62
  retry
@@ -79,9 +79,9 @@ module QRCode
79
79
  # This option overrides the horizontal positioning specified in :pos. Defaults to nil.
80
80
  def render_qr_code(qr_code, *options)
81
81
  opt = options.extract_options!
82
- dot = opt[:dot] || DEFAULT_DOTSIZE
83
- extent= opt[:extent] || (8+qr_code.modules.length) * dot
84
- stroke = (opt.has_key?(:stroke) && opt[:stroke].nil?) || opt[:stroke]
82
+ dot = opt[:dot].to_f || DEFAULT_DOTSIZE
83
+ extent= opt[:extent].to_f || (8+qr_code.modules.length) * dot
84
+ stroke = !(opt.has_key?(:stroke) && opt[:stroke].nil?) || opt[:stroke]
85
85
  foreground_color = opt[:foreground_color] || '000000'
86
86
  background_color = opt[:background_color] || 'FFFFFF'
87
87
  stroke_color = opt[:stroke_color] || '000000'
@@ -91,7 +91,7 @@ module QRCode
91
91
  align = opt[:align]
92
92
  case(align)
93
93
  when :center
94
- pos[0] = (@bounding_box.right / 2) - (extent / 2)
94
+ pos[0] = (@bounding_box.right / 2) - (extent / 2)
95
95
  when :right
96
96
  pos[0] = @bounding_box.right - extent
97
97
  when :left
data/prawn-qrcode.gemspec CHANGED
@@ -14,8 +14,7 @@
14
14
 
15
15
  Gem::Specification.new do |spec|
16
16
  spec.name = "prawn-qrcode"
17
- spec.version = "0.2.1"
18
- spec.license = "APL"
17
+ spec.version = "0.2.2"
19
18
  spec.platform = Gem::Platform::RUBY
20
19
  spec.summary = "Print QR Codes in PDF"
21
20
  spec.files = Dir.glob("{examples,lib}/**/**/*") +
@@ -35,6 +34,5 @@ Gem::Specification.new do |spec|
35
34
  spec.homepage = "http://github.com/jabbrwcky/prawn-qrcode"
36
35
  spec.description = <<END_DESC
37
36
  Prawn/QRCode simplifies the generation and rendering of QRCodes in Prawn PDF documents.
38
- QR Codes
39
37
  END_DESC
40
38
  end
metadata CHANGED
@@ -1,46 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-qrcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Hausherr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-30 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.11.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.11.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rqrcode
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.4.1
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.4.1
41
41
  description: |2
42
42
  Prawn/QRCode simplifies the generation and rendering of QRCodes in Prawn PDF documents.
43
- QR Codes
44
43
  email:
45
44
  - jabbrwcky@googlemail.com
46
45
  executables: []
@@ -49,41 +48,39 @@ extra_rdoc_files:
49
48
  - README.md
50
49
  - LICENSE
51
50
  files:
51
+ - LICENSE
52
+ - README.md
53
+ - Rakefile
52
54
  - examples/autosize_qrcode.rb
53
55
  - examples/dotsize_qrcode.rb
54
- - examples/inheritance.rb
55
56
  - examples/prepared_qrcode.rb
56
57
  - lib/prawn/qrcode.rb
57
- - Rakefile
58
58
  - prawn-qrcode.gemspec
59
- - README.md
60
- - LICENSE
61
59
  homepage: http://github.com/jabbrwcky/prawn-qrcode
62
- licenses:
63
- - APL
60
+ licenses: []
64
61
  metadata: {}
65
62
  post_install_message:
66
63
  rdoc_options:
67
- - --title
64
+ - "--title"
68
65
  - Prawn/QRCode Documentation
69
- - --main
66
+ - "--main"
70
67
  - README.md
71
- - -q
68
+ - "-q"
72
69
  require_paths:
73
70
  - lib
74
71
  required_ruby_version: !ruby/object:Gem::Requirement
75
72
  requirements:
76
- - - '>='
73
+ - - ">="
77
74
  - !ruby/object:Gem::Version
78
75
  version: 1.8.7
79
76
  required_rubygems_version: !ruby/object:Gem::Requirement
80
77
  requirements:
81
- - - '>='
78
+ - - ">="
82
79
  - !ruby/object:Gem::Version
83
80
  version: 1.3.6
84
81
  requirements: []
85
82
  rubyforge_project:
86
- rubygems_version: 2.0.3
83
+ rubygems_version: 2.2.2
87
84
  signing_key:
88
85
  specification_version: 4
89
86
  summary: Print QR Codes in PDF
@@ -1,34 +0,0 @@
1
- # Copyright 2011 Jens Hausherr
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
- require 'rubygems'
15
- require 'prawn/core'
16
- require_relative '../lib/prawn/qrcode'
17
-
18
- class PdfDoc << Prawn::Document
19
-
20
- @qrcode = RQRCode::QRCode.new 'https://github.com/jabbrwcky/prawn-qrcode', :size=>5
21
-
22
- def initialize()
23
- super(:page_size => "A4")
24
- end
25
-
26
- def render()
27
- render_qr_code(@qrcode)
28
- render_file("prepared.pdf")
29
- end
30
-
31
- end
32
-
33
- pdf = PdfDoc::new
34
- pdf.render