rqrcode 3.0.0 → 3.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b36678dab893b7737a87335397f977752eb01a3b935e8ac8a0025163d9fb4b7
4
- data.tar.gz: 9938a0bf2f27ab46db54bf5d6171b3c52bbbd0e650f13bbe5d692ee769f08e88
3
+ metadata.gz: f2e5b37e7950d851e7d30a741c8e5f864672aea6ddbcba04cd795c3c7baeb537
4
+ data.tar.gz: fb7717b92ed60dad9148af306f5e9f27af0db52edf4ee91fff954e26bdbfb8dc
5
5
  SHA512:
6
- metadata.gz: 4effb47e47d8d89935fb07957960b5ec6fddcefbe8259b03311b62b6721bdb1838227c1066745fd564a70faab521598a932cf1a6acea2470957458d4415737ff
7
- data.tar.gz: a0d482a08eb97e2b5347a248a9ee52daa840d295e04b5d4c4b5c7e6618a6b4e0a3bba6e39f228a77e56048236f87fc76dcd6b49942cbae2a00dc904317af55ee
6
+ metadata.gz: 3d95f1e28d62071296333f5ac5bd92fc8e5b874aaf0a2336b78c59321edf89f2e5a17a00490613fa9d4cd95e6bf9cb6a3bf765e1ce7a5acbe7f14dec89659d96
7
+ data.tar.gz: 1a8e90c80aa7596199a67119d493891597e13e4dd5b400e2f62fc0e57057947aa7ea9234fab34b0a1fc324cd39fed9069a1ff92da061673627cba8c7fbb95ea1
data/CHANGELOG.md CHANGED
@@ -7,10 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [3.1.1] - 2025-11-25
11
+
12
+ - Update required_ruby_version to support >= rather than ~> ready for Ruby 4
13
+
14
+ ## [3.1.0] - 2025-04-28
15
+
16
+ - Added support for `offset_x` and `offset_y` options in the `as_svg` method for independent x and y padding around QR codes [#153]
17
+
10
18
  ## [3.0.0] - 2025-04-24
11
19
 
12
20
  - Drop support for Ruby <3.0 in order to keep up with dev dependencies.
13
- - **Breaking Change**: The `rqrcode_core` gem has been updated to version 3.0.0, which includes breaking changes. Please refer to the [rqrcode_core changelog](https://github.com/whomwah/rqrcode/blob/main/CHANGELOG.md)
21
+ - **Breaking Change**: The `rqrcode_core` gem has been updated to version 2.0.0, which includes breaking changes. Please refer to the [rqrcode_core changelog](https://github.com/whomwah/rqrcode_core/blob/main/CHANGELOG.md)
14
22
 
15
23
  ## [2.2.0] - 2023-06-17
16
24
 
@@ -75,7 +83,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
75
83
  - bump dependencies
76
84
  - fix `required_ruby_version` for Ruby 3 support
77
85
 
78
- [unreleased]: https://github.com/whomwah/rqrcode/compare/v2.2.0...HEAD
86
+ [unreleased]: https://github.com/whomwah/rqrcode/compare/v3.1.1...HEAD
87
+ [3.1.1]: https://github.com/whomwah/rqrcode/compare/v3.1.0...v3.1.1
88
+ [3.1.0]: https://github.com/whomwah/rqrcode/compare/v3.0.0...v3.1.0
89
+ [3.0.0]: https://github.com/whomwah/rqrcode/compare/v2.2.0...v3.0.0
79
90
  [2.2.0]: https://github.com/whomwah/rqrcode/compare/v2.1.2...v2.2.0
80
91
  [2.1.2]: https://github.com/whomwah/rqrcode/compare/v2.1.1...v2.1.2
81
92
  [2.1.1]: https://github.com/whomwah/rqrcode/compare/v2.1.0...v2.1.1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rqrcode (3.0.0)
4
+ rqrcode (3.1.1)
5
5
  chunky_png (~> 1.0)
6
6
  rqrcode_core (~> 2.0)
7
7
 
@@ -22,7 +22,7 @@ GEM
22
22
  rainbow (3.1.1)
23
23
  rake (13.2.1)
24
24
  regexp_parser (2.9.2)
25
- rqrcode_core (2.0.0)
25
+ rqrcode_core (2.0.1)
26
26
  rspec (3.13.0)
27
27
  rspec-core (~> 3.13.0)
28
28
  rspec-expectations (~> 3.13.0)
data/README.md CHANGED
@@ -3,20 +3,17 @@
3
3
  ![](https://github.com/whomwah/rqrcode/actions/workflows/ruby.yml/badge.svg)
4
4
  [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
5
5
 
6
-
7
6
  [RQRCode](https://github.com/whomwah/rqrcode) is a library for creating and rendering QR codes into various formats. It has a simple interface with all the standard QR code options. It was adapted from the Javascript library by Kazuhiko Arase.
8
7
 
9
- * QR code is trademarked by Denso Wave inc
10
- * Minimum Ruby version is `>= 3.0.0`
11
- * For `rqrcode` releases `< 2.0.0` please use [this README](https://github.com/whomwah/rqrcode/blob/v1.2.0/README.md)
12
- * For `rqrcode` releases `< 1.0.0` please use [this README](https://github.com/whomwah/rqrcode/blob/v0.9.0/README.md)
8
+ - QR code is trademarked by Denso Wave inc
9
+ - Minimum Ruby version is `>= 3.0.0`
13
10
 
14
11
  ## Installing
15
12
 
16
13
  Add this line to your application's `Gemfile`:
17
14
 
18
15
  ```ruby
19
- gem "rqrcode", "~> 2.0"
16
+ gem "rqrcode", "~> 3.0"
20
17
  ```
21
18
 
22
19
  or install manually:
@@ -70,7 +67,6 @@ Expects a string or array (for multi-segment encoding) to be parsed in, other ar
70
67
  * :number
71
68
  * :alphanumeric
72
69
  * :byte_8bit
73
- * :kanji
74
70
  ```
75
71
 
76
72
  Example
@@ -99,6 +95,10 @@ Options:
99
95
 
100
96
  offset - Padding around the QR Code in pixels
101
97
  (default 0)
98
+ offset_x - X Padding around the QR Code in pixels
99
+ (default offset)
100
+ offset_y - Y Padding around the QR Code in pixels
101
+ (default offset)
102
102
  fill - Background color e.g "ffffff" or :white or :currentColor
103
103
  (default none)
104
104
  color - Foreground color e.g "000" or :black or :currentColor
@@ -118,7 +118,9 @@ viewbox - Replace the `svg.width` and `svg.height` attribute with `svg.v
118
118
  svg_attributes - A optional hash of custom <svg> attributes. Existing attributes will remain.
119
119
  (default {})
120
120
  ```
121
+
121
122
  Example
123
+
122
124
  ```ruby
123
125
  require "rqrcode"
124
126
 
@@ -209,7 +211,6 @@ IO.binwrite("/tmp/github-qrcode.png", png.to_s)
209
211
 
210
212
  ![QR code with github url](./images/github-qrcode.png)
211
213
 
212
-
213
214
  ### `as_ansi`
214
215
 
215
216
  The ANSI renderer will produce as a string with ANSI color codes.
@@ -226,7 +227,9 @@ fill_character - The written character
226
227
  quiet_zone_size - Padding around the edge
227
228
  (default 4)
228
229
  ```
230
+
229
231
  Example
232
+
230
233
  ```ruby
231
234
  require "rqrcode"
232
235
 
@@ -280,9 +283,9 @@ The motivation for the above is because the rendering side of this gem takes up
280
283
 
281
284
  Any contribution PR's will be greatly accepted. It's important that they are well tested and backwards compatible.
282
285
 
283
- * Fork the project
284
- * Send a pull request
285
- * Don't touch the .gemspec, I'll do that when I release a new version
286
+ - Fork the project
287
+ - Send a pull request
288
+ - Don't touch the .gemspec, I'll do that when I release a new version
286
289
 
287
290
  Thanks D.
288
291
 
@@ -296,9 +299,9 @@ Oh, and thanks to my bosses at https://kyan.com for giving me time to maintain t
296
299
 
297
300
  ## Resources
298
301
 
299
- * wikipedia:: http://en.wikipedia.org/wiki/QR_Code
300
- * Denso-Wave website:: http://www.denso-wave.com/qrcode/index-e.html
301
- * kaywa:: http://qrcode.kaywa.com
302
+ - wikipedia:: http://en.wikipedia.org/wiki/QR_Code
303
+ - Denso-Wave website:: http://www.denso-wave.com/qrcode/index-e.html
304
+ - kaywa:: http://qrcode.kaywa.com
302
305
 
303
306
  ## Copyright
304
307
 
@@ -15,7 +15,15 @@ module RQRCode
15
15
  end
16
16
 
17
17
  class Path < BaseOutputSVG
18
- def build(module_size, offset, color)
18
+ def build(module_size, options = {})
19
+ # Extract values from options
20
+ color = options[:color]
21
+ offset_x = options[:offset_x].to_i
22
+ offset_y = options[:offset_y].to_i
23
+
24
+ # Prefix hexadecimal colors unless using a named color (symbol)
25
+ color = "##{color}" unless color.is_a?(Symbol)
26
+
19
27
  modules_array = @qrcode.modules
20
28
  matrix_width = matrix_height = modules_array.length + 1
21
29
  empty_row = [Array.new(matrix_width - 1, false)]
@@ -76,23 +84,25 @@ module RQRCode
76
84
  path << edge_loop_string
77
85
  end
78
86
 
79
- # Prefix hexadecimal colors unless using a named color (symbol)
80
- color = "##{color}" unless color.is_a?(Symbol)
81
-
82
- @result << %{<path d="#{path.join}" fill="#{color}" transform="translate(#{offset},#{offset}) scale(#{module_size})"/>}
87
+ @result << %{<path d="#{path.join}" fill="#{color}" transform="translate(#{offset_x},#{offset_y}) scale(#{module_size})"/>}
83
88
  end
84
89
  end
85
90
 
86
91
  class Rect < BaseOutputSVG
87
- def build(module_size, offset, color)
92
+ def build(module_size, options = {})
93
+ # Extract values from options
94
+ color = options[:color]
95
+ offset_x = options[:offset_x].to_i
96
+ offset_y = options[:offset_y].to_i
97
+
88
98
  # Prefix hexadecimal colors unless using a named color (symbol)
89
99
  color = "##{color}" unless color.is_a?(Symbol)
90
100
 
91
101
  @qrcode.modules.each_index do |c|
92
102
  tmp = []
93
103
  @qrcode.modules.each_index do |r|
94
- y = c * module_size + offset
95
- x = r * module_size + offset
104
+ x = r * module_size + offset_x
105
+ y = c * module_size + offset_y
96
106
 
97
107
  next unless @qrcode.checked?(c, r)
98
108
  tmp << %(<rect width="#{module_size}" height="#{module_size}" x="#{x}" y="#{y}" fill="#{color}"/>)
@@ -143,6 +153,10 @@ module RQRCode
143
153
  # Options:
144
154
  # offset - Padding around the QR Code in pixels
145
155
  # (default 0)
156
+ # offset_x - X Padding around the QR Code in pixels
157
+ # (default offset)
158
+ # offset_y - Y Padding around the QR Code in pixels
159
+ # (default offset)
146
160
  # fill - Background color e.g "ffffff"
147
161
  # (default none)
148
162
  # color - Foreground color e.g "000"
@@ -164,7 +178,9 @@ module RQRCode
164
178
  def as_svg(options = {})
165
179
  fill = options[:fill]
166
180
  use_path = options[:use_path]
167
- offset = options[:offset].to_i || 0
181
+ offset = options[:offset].to_i
182
+ offset_x = options.key?(:offset_x) ? options[:offset_x].to_i : offset
183
+ offset_y = options.key?(:offset_y) ? options[:offset_y].to_i : offset
168
184
  color = options[:color] || "000"
169
185
  shape_rendering = options[:shape_rendering] || "crispEdges"
170
186
  module_size = options[:module_size] || 11
@@ -173,9 +189,11 @@ module RQRCode
173
189
  svg_attributes = options[:svg_attributes] || {}
174
190
 
175
191
  # height and width dependent on offset and QR complexity
176
- dimension = (@qrcode.module_count * module_size) + (2 * offset)
192
+ width = (@qrcode.module_count * module_size) + (2 * offset_x)
193
+ height = (@qrcode.module_count * module_size) + (2 * offset_y)
194
+ dimension = [width, height].max
177
195
  # use dimensions differently if we are using a viewBox
178
- dimensions_attr = viewbox ? %(viewBox="0 0 #{dimension} #{dimension}") : %(width="#{dimension}" height="#{dimension}")
196
+ dimensions_attr = viewbox ? %(viewBox="0 0 #{width} #{height}") : %(width="#{width}" height="#{height}")
179
197
 
180
198
  svg_tag_attributes = (DEFAULT_SVG_ATTRIBUTES + [
181
199
  dimensions_attr,
@@ -187,7 +205,7 @@ module RQRCode
187
205
  close_tag = "</svg>"
188
206
 
189
207
  output_tag = (use_path ? Path : Rect).new(@qrcode)
190
- output_tag.build(module_size, offset, color)
208
+ output_tag.build(module_size, offset_x: offset_x, offset_y: offset_y, color: color)
191
209
 
192
210
  if fill
193
211
  # Prefix hexadecimal colors unless using a named color (symbol)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RQRCode
4
- VERSION = "3.0.0"
4
+ VERSION = "3.1.1"
5
5
  end
data/rqrcode.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ["lib"]
31
31
 
32
- spec.required_ruby_version = "~> 3.0"
32
+ spec.required_ruby_version = ">= 3.0"
33
33
  spec.add_dependency "rqrcode_core", "~> 2.0"
34
34
  spec.add_dependency "chunky_png", "~> 1.0"
35
35
  spec.add_development_dependency "bundler", "~> 2.0"
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rqrcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duncan Robertson
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-04-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rqrcode_core
@@ -136,13 +135,12 @@ licenses:
136
135
  metadata:
137
136
  bug_tracker_uri: https://github.com/whomwah/rqrcode/issues
138
137
  changelog_uri: https://github.com/whomwah/rqrcode/blob/main/CHANGELOG.md
139
- post_install_message:
140
138
  rdoc_options: []
141
139
  require_paths:
142
140
  - lib
143
141
  required_ruby_version: !ruby/object:Gem::Requirement
144
142
  requirements:
145
- - - "~>"
143
+ - - ">="
146
144
  - !ruby/object:Gem::Version
147
145
  version: '3.0'
148
146
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -151,8 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
151
149
  - !ruby/object:Gem::Version
152
150
  version: '0'
153
151
  requirements: []
154
- rubygems_version: 3.5.11
155
- signing_key:
152
+ rubygems_version: 3.7.2
156
153
  specification_version: 4
157
154
  summary: A library to encode QR Codes
158
155
  test_files: []