rqrcode 2.0.0 → 2.1.1

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
  SHA256:
3
- metadata.gz: 9dad1e83dc97d564e2ec828cb8ba389c222fa4ae7662d6feaaed36fbfea194ba
4
- data.tar.gz: e3d901e23ba8dfb7cc6b300ae47bc11dcbc6913d2fce1a66824bffa670ca5cf5
3
+ metadata.gz: 6d9f9771040408819ab4ae97bc5b0de8814863e5b9dba0402268799eb03350d9
4
+ data.tar.gz: 2f811a4fed92cfa3bed1fdbe8609c57910c76184c97eafb00985422d83c02385
5
5
  SHA512:
6
- metadata.gz: 317ff35bc49042e5a7a0d9390c82051b9552bd5d2a4c7a56e99e2ea75e7d2d4cf9071516f1fb800e5fd1af3c964976c6354db675c33928a0fee99f54cf588a7c
7
- data.tar.gz: 167fc518c536b3bf32699dc09952fc5068db81d44040b0b768a4a220186438076992a8a3deb5eb85537c651d1d47ddabe7d4b2a29fbc490027a157b8265e3f77
6
+ metadata.gz: 6ece7165b08b181bd62a10069d5b60a849e0887c1c775b625cf691d3f7a439f0a5701d3fa362fb1263d7aae425e9a8a18c706ac621efb7f8f97955f5e7e11dbc
7
+ data.tar.gz: '0479794cb35208cffebf7355cbb3517b394f14b8af04eeebbcf51b2afdafd35f088fe2f9a60daf55752594578231411468f6eef090bd20b4e0c4864ea1cb00e4'
@@ -14,10 +14,10 @@ jobs:
14
14
  fail-fast: false
15
15
  matrix:
16
16
  os: [ubuntu-latest, macos-latest]
17
- ruby: [2.5, 2.6, 2.7, 3.0]
17
+ ruby: [2.5, 2.6, 2.7, '3.0', 3.1]
18
18
  runs-on: ${{ matrix.os }}
19
19
  steps:
20
- - uses: actions/checkout@v1
20
+ - uses: actions/checkout@v2
21
21
  - uses: ruby/setup-ruby@v1
22
22
  with:
23
23
  ruby-version: ${{ matrix.ruby }}
data/CHANGELOG.md CHANGED
@@ -7,13 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.1.1] - 2022-02-11
11
+
12
+ - Added in a handler for when color arguments are passed in as symbols e.g `color: :yellow`. This also allows for the use of the `:currentColor` keyword. [#122]
13
+
14
+ ## [2.1.0] - 2021-08-26
15
+
16
+ - Sync Gemfile.lock with `rqrcode_core.1.2.0` [Adds Multimode Support](https://github.com/whomwah/rqrcode_core#multiple-encoding-support)
17
+ - Add badge for Standard linting
18
+
19
+ ### Changed
20
+
21
+ - Corrected method name referred to in CHANGELOG.
22
+
10
23
  ## [2.0.0] - 2021-05-06
11
24
 
12
25
  ### Added
13
26
 
14
- - A new `use_path:` option on `.to_svg`. This uses a `<path>` node to greatly reduce the final SVG size. [#108]
15
- - A new `viewbox:` option on `.to_svg`. Replaces the `svg.width` and `svg.height` attribute with `svg.viewBox` to allow CSS scaling. [#112]
16
- - A new `svg_attributes:` option on `.to_svg`. Allows you to pass in custom SVG attributes to be used in the `<svg>` tag. [#113]
27
+ - A new `use_path:` option on `.as_svg`. This uses a `<path>` node to greatly reduce the final SVG size. [#108]
28
+ - A new `viewbox:` option on `.as_svg`. Replaces the `svg.width` and `svg.height` attribute with `svg.viewBox` to allow CSS scaling. [#112]
29
+ - A new `svg_attributes:` option on `.as_svg`. Allows you to pass in custom SVG attributes to be used in the `<svg>` tag. [#113]
17
30
 
18
31
  ### Changed
19
32
 
@@ -34,6 +47,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
34
47
  - bump dependencies
35
48
  - fix `required_ruby_version` for Ruby 3 support
36
49
 
37
- [unreleased]: https://github.com/whomwah/rqrcode/compare/v2.0.0...HEAD
50
+ [unreleased]: https://github.com/whomwah/rqrcode/compare/v2.1.1...HEAD
51
+ [2.1.1]: https://github.com/whomwah/rqrcode/compare/v2.1.0...v2.1.1
52
+ [2.1.0]: https://github.com/whomwah/rqrcode/compare/v2.0.0...v2.1.0
38
53
  [2.0.0]: https://github.com/whomwah/rqrcode/compare/v1.2.0...v2.0.0
39
54
  [1.2.0]: https://github.com/whomwah/rqrcode/compare/v1.1.1...v1.2.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rqrcode (2.0.0)
4
+ rqrcode (2.1.1)
5
5
  chunky_png (~> 1.0)
6
6
  rqrcode_core (~> 1.0)
7
7
 
@@ -11,14 +11,14 @@ GEM
11
11
  ast (2.4.2)
12
12
  chunky_png (1.4.0)
13
13
  diff-lcs (1.4.4)
14
- parallel (1.20.1)
15
- parser (3.0.1.0)
14
+ parallel (1.21.0)
15
+ parser (3.1.0.0)
16
16
  ast (~> 2.4.1)
17
17
  rainbow (3.0.0)
18
18
  rake (13.0.3)
19
- regexp_parser (2.1.1)
19
+ regexp_parser (2.2.0)
20
20
  rexml (3.2.5)
21
- rqrcode_core (1.0.0)
21
+ rqrcode_core (1.2.0)
22
22
  rspec (3.10.0)
23
23
  rspec-core (~> 3.10.0)
24
24
  rspec-expectations (~> 3.10.0)
@@ -32,27 +32,27 @@ GEM
32
32
  diff-lcs (>= 1.2.0, < 2.0)
33
33
  rspec-support (~> 3.10.0)
34
34
  rspec-support (3.10.2)
35
- rubocop (1.12.1)
35
+ rubocop (1.24.1)
36
36
  parallel (~> 1.10)
37
37
  parser (>= 3.0.0.0)
38
38
  rainbow (>= 2.2.2, < 4.0)
39
39
  regexp_parser (>= 1.8, < 3.0)
40
40
  rexml
41
- rubocop-ast (>= 1.2.0, < 2.0)
41
+ rubocop-ast (>= 1.15.1, < 2.0)
42
42
  ruby-progressbar (~> 1.7)
43
43
  unicode-display_width (>= 1.4.0, < 3.0)
44
- rubocop-ast (1.4.1)
45
- parser (>= 2.7.1.5)
46
- rubocop-performance (1.10.1)
47
- rubocop (>= 0.90.0, < 2.0)
44
+ rubocop-ast (1.15.1)
45
+ parser (>= 3.0.1.1)
46
+ rubocop-performance (1.13.1)
47
+ rubocop (>= 1.7.0, < 2.0)
48
48
  rubocop-ast (>= 0.4.0)
49
49
  ruby-progressbar (1.11.0)
50
- standard (1.0.5)
51
- rubocop (= 1.12.1)
52
- rubocop-performance (= 1.10.1)
50
+ standard (1.6.0)
51
+ rubocop (= 1.24.1)
52
+ rubocop-performance (= 1.13.1)
53
53
  standardrb (1.0.0)
54
54
  standard
55
- unicode-display_width (2.0.0)
55
+ unicode-display_width (2.1.0)
56
56
 
57
57
  PLATFORMS
58
58
  ruby
@@ -65,4 +65,4 @@ DEPENDENCIES
65
65
  standardrb (~> 1.0)
66
66
 
67
67
  BUNDLED WITH
68
- 2.2.15
68
+ 2.2.32
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # RQRCode
2
2
 
3
3
  ![](https://github.com/whomwah/rqrcode/actions/workflows/ruby.yml/badge.svg)
4
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://github.com/testdouble/standard)
4
5
 
5
6
 
6
7
  [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.
@@ -32,6 +33,7 @@ require "rqrcode"
32
33
  qr = RQRCode::QRCode.new("https://kyan.com")
33
34
 
34
35
  puts qr.to_s
36
+ # to_s( dark: "x", light: " " ) # defaults
35
37
 
36
38
  xxxxxxx xxxxxxx xxx xxxxxxx
37
39
  x x x xxx xx x x
@@ -42,32 +44,46 @@ x x xxx x xx x x x x
42
44
  ...
43
45
  ```
44
46
 
47
+ Easy, but unlikely to be readable. For this you will need to use one of the many [rendering options](#render-types) below.
48
+
45
49
  ### Advanced Options
46
50
 
47
- These are the various QR Code generation options provided by [rqrqcode_core](https://github.com/whomwah/rqrcode_core).
51
+ These are the various QR code generation options provided by the underlying [rqrcode_core](https://github.com/whomwah/rqrcode_core). You may actually only need this library if you don't need the various rendering options `rqrcode` provides, but just need the data structure.
48
52
 
49
53
  ```
50
- string - the string you wish to encode
54
+ Expects a string or array (for multi-segment encoding) to be parsed in, other args are optional
55
+
56
+ data - the string, QRSegment or array of Hashes (with data:, mode: keys) you wish to encode
51
57
 
52
- size - the size (Integer) of the qrcode (defaults to smallest size needed to encode the string)
58
+ size - the size (Integer) of the QR Code (defaults to smallest size needed to encode the data)
53
59
 
54
- level - the error correction level, can be:
55
- * Level :l 7% of code can be restored
56
- * Level :m 15% of code can be restored
57
- * Level :q 25% of code can be restored
58
- * Level :h 30% of code can be restored (default :h)
60
+ max_size - the max_size (Integer) of the QR Code (default RQRCodeCore::QRUtil.max_size)
59
61
 
60
- mode - the mode of the qrcode (defaults to alphanumeric or byte_8bit, depending on the input data):
61
- * :number
62
- * :alphanumeric
63
- * :byte_8bit
64
- * :kanji
62
+ level - the error correction level, can be:
63
+ * Level :l 7% of code can be restored
64
+ * Level :m 15% of code can be restored
65
+ * Level :q 25% of code can be restored
66
+ * Level :h 30% of code can be restored (default :h)
67
+
68
+ mode - the mode of the QR Code (defaults to :alphanumeric or :byte_8bit, depending on the input data,
69
+ only used when data is a string):
70
+ * :number
71
+ * :alphanumeric
72
+ * :byte_8bit
73
+ * :kanji
65
74
  ```
66
75
 
67
76
  Example
68
77
 
69
- ```
70
- qrcode = RQRCodeCore::QRCode.new('hello world', size: 1, level: :m, mode: :alphanumeric)
78
+ ```ruby
79
+ simple_qrcode = RQRCodeCore::QRCode.new("https://kyan.com", size: 1, level: :m, mode: :alphanumeric)
80
+
81
+ segment_qrcode = QRCodeCore::QRCode.new({ data: "foo", mode: :byte_8bit })
82
+
83
+ multi_qrcode = RQRCodeCore::QRCode.new([
84
+ { data: 'foo', mode: :byte_8bit },
85
+ { data: 'bar1', mode: :alphanumeric }
86
+ ])
71
87
  ```
72
88
 
73
89
  ## Render types
@@ -83,9 +99,9 @@ Options:
83
99
 
84
100
  offset - Padding around the QR Code in pixels
85
101
  (default 0)
86
- fill - Background color e.g "ffffff" or :white
102
+ fill - Background color e.g "ffffff" or :white or :currentColor
87
103
  (default none)
88
- color - Foreground color e.g "000" or :black
104
+ color - Foreground color e.g "000" or :black or :currentColor
89
105
  (default "000")
90
106
  module_size - The Pixel size of each module
91
107
  (defaults 11)
@@ -114,10 +130,7 @@ svg = qrcode.as_svg(
114
130
  shape_rendering: "crispEdges",
115
131
  module_size: 11,
116
132
  standalone: true,
117
- use_path: true,
118
- svg_attributes: {
119
- id: "myUniqueId"
120
- }
133
+ use_path: true
121
134
  )
122
135
  ```
123
136
 
@@ -76,12 +76,18 @@ module RQRCode
76
76
  path << edge_loop_string
77
77
  end
78
78
 
79
- @result << %{<path d="#{path.join}" style="fill:##{color}" transform="translate(#{offset},#{offset}) scale(#{module_size})"/>}
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}" style="fill:#{color}" transform="translate(#{offset},#{offset}) scale(#{module_size})"/>}
80
83
  end
81
84
  end
82
85
 
83
86
  class Rect < BaseOutputSVG
84
87
  def build(module_size, offset, color)
88
+ # Prefix hexadecimal colors unless using a named color (symbol)
89
+ color = "##{color}" unless color.is_a?(Symbol)
90
+
85
91
  @qrcode.modules.each_index do |c|
86
92
  tmp = []
87
93
  @qrcode.modules.each_index do |r|
@@ -89,7 +95,7 @@ module RQRCode
89
95
  x = r * module_size + offset
90
96
 
91
97
  next unless @qrcode.checked?(c, r)
92
- tmp << %(<rect width="#{module_size}" height="#{module_size}" x="#{x}" y="#{y}" style="fill:##{color}"/>)
98
+ tmp << %(<rect width="#{module_size}" height="#{module_size}" x="#{x}" y="#{y}" style="fill:#{color}"/>)
93
99
  end
94
100
 
95
101
  @result << tmp.join
@@ -184,7 +190,9 @@ module RQRCode
184
190
  output_tag.build(module_size, offset, color)
185
191
 
186
192
  if fill
187
- output_tag.result.unshift %(<rect width="#{dimension}" height="#{dimension}" x="0" y="0" style="fill:##{fill}"/>)
193
+ # Prefix hexadecimal colors unless using a named color (symbol)
194
+ fill = "##{fill}" unless fill.is_a?(Symbol)
195
+ output_tag.result.unshift %(<rect width="#{dimension}" height="#{dimension}" x="0" y="0" style="fill:#{fill}"/>)
188
196
  end
189
197
 
190
198
  if standalone
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "forwardable"
4
4
 
5
- module RQRCode #:nodoc:
5
+ module RQRCode # :nodoc:
6
6
  class QRCode
7
7
  extend Forwardable
8
8
  def_delegators :@qrcode, :to_s
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RQRCode
4
- VERSION = "2.0.0"
4
+ VERSION = "2.1.1"
5
5
  end
data/rqrcode.gemspec CHANGED
@@ -17,6 +17,10 @@ Gem::Specification.new do |spec|
17
17
  EOF
18
18
  spec.homepage = "https://github.com/whomwah/rqrcode"
19
19
  spec.license = "MIT"
20
+ spec.metadata = {
21
+ "bug_tracker_uri" => "https://github.com/whomwah/rqrcode/issues",
22
+ "changelog_uri" => "https://github.com/whomwah/rqrcode/blob/master/CHANGELOG.md"
23
+ }
20
24
 
21
25
  spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
22
26
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rqrcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duncan Robertson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-06 00:00:00.000000000 Z
11
+ date: 2022-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rqrcode_core
@@ -132,8 +132,10 @@ files:
132
132
  homepage: https://github.com/whomwah/rqrcode
133
133
  licenses:
134
134
  - MIT
135
- metadata: {}
136
- post_install_message:
135
+ metadata:
136
+ bug_tracker_uri: https://github.com/whomwah/rqrcode/issues
137
+ changelog_uri: https://github.com/whomwah/rqrcode/blob/master/CHANGELOG.md
138
+ post_install_message:
137
139
  rdoc_options: []
138
140
  require_paths:
139
141
  - lib
@@ -148,8 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
150
  - !ruby/object:Gem::Version
149
151
  version: '0'
150
152
  requirements: []
151
- rubygems_version: 3.2.15
152
- signing_key:
153
+ rubygems_version: 3.3.3
154
+ signing_key:
153
155
  specification_version: 4
154
156
  summary: A library to encode QR Codes
155
157
  test_files: []