rqrcode 1.2.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +13 -16
- data/.gitignore +1 -1
- data/CHANGELOG.md +79 -0
- data/Gemfile.lock +72 -0
- data/README.md +171 -72
- data/Rakefile +10 -0
- data/lib/rqrcode/export/ansi.rb +9 -11
- data/lib/rqrcode/export/html.rb +3 -3
- data/lib/rqrcode/export/png.rb +33 -26
- data/lib/rqrcode/export/svg.rb +176 -29
- data/lib/rqrcode/export.rb +4 -4
- data/lib/rqrcode/qrcode/qrcode.rb +2 -2
- data/lib/rqrcode/qrcode.rb +1 -1
- data/lib/rqrcode/version.rb +1 -1
- data/lib/rqrcode.rb +4 -4
- data/rqrcode.gemspec +27 -24
- metadata +31 -13
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46c752f56b2f26a71997009f105896a93874304e47b5453f6d399790ec5d67ee
|
4
|
+
data.tar.gz: 3a32e1b77c24d1118510084ad0b0f700ff54c8605c5e5cf77aca2c5efc782438
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28ae604413d674f2c8fe6aac337aab7253874357d6d0e4e656c7e3cf743c8a65d102a5eeb8790601678d4c65172bbdd882cf1a51766d23df99b4253f0801a11d
|
7
|
+
data.tar.gz: 34fbe27e846970fe5b8571c446d6bee7327d46c3b645aaf07b141cf96d98c7beb918f6cc929408fd612940d260a0258c5656937f7283acbcf6cab0d00e09c082
|
data/.github/workflows/ruby.yml
CHANGED
@@ -4,28 +4,25 @@ on:
|
|
4
4
|
push:
|
5
5
|
branches:
|
6
6
|
- master
|
7
|
-
- release/*
|
8
7
|
pull_request:
|
9
8
|
branches:
|
10
9
|
- master
|
11
10
|
|
12
11
|
jobs:
|
13
|
-
|
14
|
-
name: Test Ruby ${{ matrix.ruby_version }} on ${{ matrix.os }}
|
15
|
-
runs-on: ${{ matrix.os }}
|
12
|
+
Build:
|
16
13
|
strategy:
|
14
|
+
fail-fast: false
|
17
15
|
matrix:
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
os: [ubuntu-latest, macos-latest]
|
17
|
+
ruby: ['2.6', '2.7', '3.0', '3.1', '3.2']
|
18
|
+
runs-on: ${{ matrix.os }}
|
21
19
|
steps:
|
22
|
-
- uses: actions/checkout@
|
23
|
-
-
|
24
|
-
uses: actions/setup-ruby@v1
|
20
|
+
- uses: actions/checkout@v3
|
21
|
+
- uses: ruby/setup-ruby@v1
|
25
22
|
with:
|
26
|
-
ruby-version: ${{ matrix.
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
ruby-version: ${{ matrix.ruby }}
|
24
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
25
|
+
- name: Run Tests for Ruby ${{ matrix.ruby }} on ${{ matrix.os }}
|
26
|
+
run: bundle exec rake spec
|
27
|
+
- name: StandardRB check for Ruby ${{ matrix.ruby }} on ${{ matrix.os }}
|
28
|
+
run: bundle exec standardrb --format progress
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [2.2.0] - 2023-06-17
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
|
14
|
+
* Allow all ChunkyPNG::Color options to be passed into `fill` and `color` on `as_png` [#135]
|
15
|
+
* Add 3.2 to CI [@petergoldstein](https://github.com/petergoldstein) [#133]
|
16
|
+
* Development dependency upgrades. Minimum Ruby change [#130]
|
17
|
+
* README updates
|
18
|
+
|
19
|
+
## [2.1.2] - 2022-07-26
|
20
|
+
|
21
|
+
### Changed
|
22
|
+
|
23
|
+
* Remove setup script as it just calls bundle install [#128]
|
24
|
+
* Change inline styles to the fill property to allow for strict CSP style-src directive [#127]
|
25
|
+
|
26
|
+
## [2.1.1] - 2022-02-11
|
27
|
+
|
28
|
+
### Added
|
29
|
+
|
30
|
+
- 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]
|
31
|
+
|
32
|
+
## [2.1.0] - 2021-08-26
|
33
|
+
|
34
|
+
### Changed
|
35
|
+
|
36
|
+
- Sync Gemfile.lock with `rqrcode_core.1.2.0` [Adds Multimode Support](https://github.com/whomwah/rqrcode_core#multiple-encoding-support)
|
37
|
+
|
38
|
+
### Added
|
39
|
+
|
40
|
+
- Add badge for Standard linting
|
41
|
+
|
42
|
+
### Changed
|
43
|
+
|
44
|
+
- Corrected method name referred to in CHANGELOG.
|
45
|
+
|
46
|
+
## [2.0.0] - 2021-05-06
|
47
|
+
|
48
|
+
### Added
|
49
|
+
|
50
|
+
- A new `use_path:` option on `.as_svg`. This uses a `<path>` node to greatly reduce the final SVG size. [#108]
|
51
|
+
- A new `viewbox:` option on `.as_svg`. Replaces the `svg.width` and `svg.height` attribute with `svg.viewBox` to allow CSS scaling. [#112]
|
52
|
+
- A new `svg_attributes:` option on `.as_svg`. Allows you to pass in custom SVG attributes to be used in the `<svg>` tag. [#113]
|
53
|
+
|
54
|
+
### Changed
|
55
|
+
|
56
|
+
- README updated
|
57
|
+
- Rakefile cleaned up. You can now just run `rake` which will run specs and fix linting using `standardrb`
|
58
|
+
- Small documentation clarification [@smnscp](https://github.com/smnscp)
|
59
|
+
- Bump `rqrcode_core` to `~> 1.0`
|
60
|
+
|
61
|
+
### Breaking Change
|
62
|
+
|
63
|
+
- The dependency `rqrcode_core-1.0.0` has a tiny breaking change to the `to_s` public method. https://github.com/whomwah/rqrcode_core/blob/master/CHANGELOG.md#breaking-changes
|
64
|
+
|
65
|
+
## [1.2.0] - 2020-12-26
|
66
|
+
|
67
|
+
### Changed
|
68
|
+
|
69
|
+
- README updated
|
70
|
+
- bump dependencies
|
71
|
+
- fix `required_ruby_version` for Ruby 3 support
|
72
|
+
|
73
|
+
[unreleased]: https://github.com/whomwah/rqrcode/compare/v2.2.0...HEAD
|
74
|
+
[2.2.0]: https://github.com/whomwah/rqrcode/compare/v2.1.2...v2.2.0
|
75
|
+
[2.1.2]: https://github.com/whomwah/rqrcode/compare/v2.1.1...v2.1.2
|
76
|
+
[2.1.1]: https://github.com/whomwah/rqrcode/compare/v2.1.0...v2.1.1
|
77
|
+
[2.1.0]: https://github.com/whomwah/rqrcode/compare/v2.0.0...v2.1.0
|
78
|
+
[2.0.0]: https://github.com/whomwah/rqrcode/compare/v1.2.0...v2.0.0
|
79
|
+
[1.2.0]: https://github.com/whomwah/rqrcode/compare/v1.1.1...v1.2.0
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rqrcode (2.2.0)
|
5
|
+
chunky_png (~> 1.0)
|
6
|
+
rqrcode_core (~> 1.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.4.2)
|
12
|
+
chunky_png (1.4.0)
|
13
|
+
diff-lcs (1.5.0)
|
14
|
+
json (2.6.3)
|
15
|
+
language_server-protocol (3.17.0.2)
|
16
|
+
parallel (1.22.1)
|
17
|
+
parser (3.1.3.0)
|
18
|
+
ast (~> 2.4.1)
|
19
|
+
rainbow (3.1.1)
|
20
|
+
rake (13.0.6)
|
21
|
+
regexp_parser (2.6.1)
|
22
|
+
rexml (3.2.5)
|
23
|
+
rqrcode_core (1.2.0)
|
24
|
+
rspec (3.12.0)
|
25
|
+
rspec-core (~> 3.12.0)
|
26
|
+
rspec-expectations (~> 3.12.0)
|
27
|
+
rspec-mocks (~> 3.12.0)
|
28
|
+
rspec-core (3.12.0)
|
29
|
+
rspec-support (~> 3.12.0)
|
30
|
+
rspec-expectations (3.12.1)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.12.0)
|
33
|
+
rspec-mocks (3.12.1)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.12.0)
|
36
|
+
rspec-support (3.12.0)
|
37
|
+
rubocop (1.40.0)
|
38
|
+
json (~> 2.3)
|
39
|
+
parallel (~> 1.10)
|
40
|
+
parser (>= 3.1.2.1)
|
41
|
+
rainbow (>= 2.2.2, < 4.0)
|
42
|
+
regexp_parser (>= 1.8, < 3.0)
|
43
|
+
rexml (>= 3.2.5, < 4.0)
|
44
|
+
rubocop-ast (>= 1.23.0, < 2.0)
|
45
|
+
ruby-progressbar (~> 1.7)
|
46
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
47
|
+
rubocop-ast (1.24.0)
|
48
|
+
parser (>= 3.1.1.0)
|
49
|
+
rubocop-performance (1.15.1)
|
50
|
+
rubocop (>= 1.7.0, < 2.0)
|
51
|
+
rubocop-ast (>= 0.4.0)
|
52
|
+
ruby-progressbar (1.11.0)
|
53
|
+
standard (1.20.0)
|
54
|
+
language_server-protocol (~> 3.17.0.2)
|
55
|
+
rubocop (= 1.40.0)
|
56
|
+
rubocop-performance (= 1.15.1)
|
57
|
+
standardrb (1.0.1)
|
58
|
+
standard
|
59
|
+
unicode-display_width (2.3.0)
|
60
|
+
|
61
|
+
PLATFORMS
|
62
|
+
ruby
|
63
|
+
|
64
|
+
DEPENDENCIES
|
65
|
+
bundler (~> 2.0)
|
66
|
+
rake (~> 13.0)
|
67
|
+
rqrcode!
|
68
|
+
rspec (~> 3.5)
|
69
|
+
standardrb (~> 1.0)
|
70
|
+
|
71
|
+
BUNDLED WITH
|
72
|
+
2.3.26
|
data/README.md
CHANGED
@@ -1,20 +1,22 @@
|
|
1
1
|
# RQRCode
|
2
2
|
|
3
|
-
![](https://github.com/whomwah/rqrcode/workflows/
|
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.
|
7
8
|
|
8
9
|
* QR code is trademarked by Denso Wave inc
|
9
|
-
* Minimum Ruby version is `>= 2.
|
10
|
-
* For `rqrcode` releases `<
|
10
|
+
* Minimum Ruby version is `>= 2.6`
|
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)
|
11
13
|
|
12
14
|
## Installing
|
13
15
|
|
14
16
|
Add this line to your application's `Gemfile`:
|
15
17
|
|
16
18
|
```ruby
|
17
|
-
gem
|
19
|
+
gem "rqrcode", "~> 2.0"
|
18
20
|
```
|
19
21
|
|
20
22
|
or install manually:
|
@@ -26,100 +28,165 @@ gem install rqrcode
|
|
26
28
|
## Basic usage example
|
27
29
|
|
28
30
|
```ruby
|
29
|
-
require
|
31
|
+
require "rqrcode"
|
30
32
|
|
31
|
-
qr = RQRCode::QRCode.new(
|
32
|
-
result = ''
|
33
|
+
qr = RQRCode::QRCode.new("https://kyan.com")
|
33
34
|
|
34
|
-
qr.
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
35
|
+
puts qr.to_s
|
36
|
+
# to_s( dark: "x", light: " " ) # defaults
|
37
|
+
|
38
|
+
xxxxxxx xxxxxxx xxx xxxxxxx
|
39
|
+
x x x xxx xx x x
|
40
|
+
x xxx x xx x x xx x xxx x
|
41
|
+
x xxx x xx xx xx x xxx x
|
42
|
+
x xxx x x x xxx x xxx x
|
43
|
+
x x xxx x xx x x x x
|
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
|
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
|
54
|
+
Expects a string or array (for multi-segment encoding) to be parsed in, other args are optional
|
51
55
|
|
52
|
-
|
56
|
+
data - the string, QRSegment or array of Hashes (with data:, mode: keys) you wish to encode
|
53
57
|
|
54
|
-
|
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)
|
58
|
+
size - the size (Integer) of the QR Code (defaults to smallest size needed to encode the data)
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
max_size - the max_size (Integer) of the QR Code (default RQRCodeCore::QRUtil.max_size)
|
61
|
+
|
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
|
-
|
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
|
74
90
|
|
75
|
-
You
|
91
|
+
You probably want to output your QR code in a specific format. We make this easy by providing a bunch of formats to choose from below, each with their own set of options:
|
76
92
|
|
77
|
-
###
|
93
|
+
### `as_svg`
|
78
94
|
|
79
95
|
The SVG renderer will produce a stand-alone SVG as a `String`
|
80
96
|
|
97
|
+
```
|
98
|
+
Options:
|
99
|
+
|
100
|
+
offset - Padding around the QR Code in pixels
|
101
|
+
(default 0)
|
102
|
+
fill - Background color e.g "ffffff" or :white or :currentColor
|
103
|
+
(default none)
|
104
|
+
color - Foreground color e.g "000" or :black or :currentColor
|
105
|
+
(default "000")
|
106
|
+
module_size - The Pixel size of each module
|
107
|
+
(defaults 11)
|
108
|
+
shape_rendering - SVG Attribute: auto | optimizeSpeed | crispEdges | geometricPrecision
|
109
|
+
(defaults crispEdges)
|
110
|
+
standalone - Whether to make this a full SVG file, or only an svg to embed in other svg
|
111
|
+
(default true)
|
112
|
+
use_path - Use <path> to render SVG rather than <rect> to significantly reduce size.
|
113
|
+
This will become the default in future versions.
|
114
|
+
(default false)
|
115
|
+
viewbox - Replace the `svg.width` and `svg.height` attribute with `svg.viewBox` to
|
116
|
+
allow CSS scaling
|
117
|
+
(default false)
|
118
|
+
svg_attributes - A optional hash of custom <svg> attributes. Existing attributes will remain.
|
119
|
+
(default {})
|
120
|
+
```
|
121
|
+
Example
|
81
122
|
```ruby
|
82
|
-
require
|
123
|
+
require "rqrcode"
|
83
124
|
|
84
125
|
qrcode = RQRCode::QRCode.new("http://github.com/")
|
85
126
|
|
86
127
|
# NOTE: showing with default options specified explicitly
|
87
128
|
svg = qrcode.as_svg(
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
129
|
+
color: "000",
|
130
|
+
shape_rendering: "crispEdges",
|
131
|
+
module_size: 11,
|
132
|
+
standalone: true,
|
133
|
+
use_path: true
|
93
134
|
)
|
94
135
|
```
|
95
136
|
|
96
137
|
![QR code with github url](./images/github-qrcode.svg)
|
97
138
|
|
98
|
-
###
|
139
|
+
### `as_png`
|
99
140
|
|
100
|
-
The
|
141
|
+
The will produce a PNG using the [ChunkyPNG gem](https://github.com/wvanbergen/chunky_png). The result will be a `ChunkyPNG::Image` instance.
|
101
142
|
|
102
|
-
```
|
103
|
-
|
143
|
+
```
|
144
|
+
Options:
|
104
145
|
|
105
|
-
|
146
|
+
fill - Background <ChunkyPNG::Color>, defaults to 'white'. Use [] for multi args
|
147
|
+
color - Foreground <ChunkyPNG::Color>, defaults to 'black'. Use [] for multi args
|
106
148
|
|
107
|
-
|
108
|
-
svg = qrcode.as_ansi(
|
109
|
-
light: "\033[47m", dark: "\033[40m",
|
110
|
-
fill_character: ' ',
|
111
|
-
quiet_zone_size: 4
|
112
|
-
)
|
113
|
-
```
|
149
|
+
When option :file is supplied you can use the following ChunkyPNG constraints:
|
114
150
|
|
115
|
-
|
151
|
+
color_mode - The color mode to use. Use one of the ChunkyPNG::COLOR_* constants.
|
152
|
+
(defaults to 'ChunkyPNG::COLOR_GRAYSCALE')
|
153
|
+
bit_depth - The bit depth to use. This option is only used for indexed images.
|
154
|
+
(defaults to 1 bit)
|
155
|
+
interlace - Whether to use interlacing (true or false).
|
156
|
+
(defaults to ChunkyPNG default)
|
157
|
+
compression - The compression level for Zlib. This can be a value between 0 and 9, or a
|
158
|
+
Zlib constant like Zlib::BEST_COMPRESSION
|
159
|
+
(defaults to ChunkyPNG default)
|
160
|
+
|
161
|
+
There are two sizing algorithms.
|
162
|
+
|
163
|
+
* Original that can result in blurry and hard to scan images
|
164
|
+
* Google's Chart API inspired sizing that resizes the module size to fit within the given image size.
|
165
|
+
|
166
|
+
The Google one will be used when no options are given or when the new size option is used.
|
167
|
+
|
168
|
+
*Google Sizing*
|
169
|
+
|
170
|
+
size - Total size of PNG in pixels. The module size is calculated so it fits.
|
171
|
+
(defaults to 120)
|
172
|
+
border_modules - Width of white border around the modules.
|
173
|
+
(defaults to 4).
|
174
|
+
|
175
|
+
-- DONT USE border_modules OPTION UNLESS YOU KNOW ABOUT THE QUIET ZONE NEEDS OF QR CODES --
|
116
176
|
|
117
|
-
|
177
|
+
*Original Sizing*
|
118
178
|
|
119
|
-
|
179
|
+
module_px_size - Image size, in pixels.
|
180
|
+
border - Border thickness, in pixels
|
181
|
+
|
182
|
+
It first creates an image where 1px = 1 module, then resizes.
|
183
|
+
Defaults to 120x120 pixels, customizable by option.
|
184
|
+
```
|
185
|
+
|
186
|
+
Example
|
120
187
|
|
121
188
|
```ruby
|
122
|
-
require
|
189
|
+
require "rqrcode"
|
123
190
|
|
124
191
|
qrcode = RQRCode::QRCode.new("http://github.com/")
|
125
192
|
|
@@ -128,9 +195,9 @@ png = qrcode.as_png(
|
|
128
195
|
bit_depth: 1,
|
129
196
|
border_modules: 4,
|
130
197
|
color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
131
|
-
color:
|
198
|
+
color: "black",
|
132
199
|
file: nil,
|
133
|
-
fill:
|
200
|
+
fill: "white",
|
134
201
|
module_px_size: 6,
|
135
202
|
resize_exactly_to: false,
|
136
203
|
resize_gte_to: false,
|
@@ -142,26 +209,38 @@ IO.binwrite("/tmp/github-qrcode.png", png.to_s)
|
|
142
209
|
|
143
210
|
![QR code with github url](./images/github-qrcode.png)
|
144
211
|
|
145
|
-
### On the console ( just because you can )
|
146
212
|
|
147
|
-
|
148
|
-
require 'rqrcode'
|
213
|
+
### `as_ansi`
|
149
214
|
|
150
|
-
|
215
|
+
The ANSI renderer will produce as a string with ANSI color codes.
|
151
216
|
|
152
|
-
puts qr.to_s
|
153
217
|
```
|
218
|
+
Options:
|
219
|
+
|
220
|
+
light - Foreground ANSI code
|
221
|
+
(default "\033[47m")
|
222
|
+
dark - Background ANSI code
|
223
|
+
(default "\033[40m")
|
224
|
+
fill_character - The written character
|
225
|
+
(default ' ')
|
226
|
+
quiet_zone_size - Padding around the edge
|
227
|
+
(default 4)
|
228
|
+
```
|
229
|
+
Example
|
230
|
+
```ruby
|
231
|
+
require "rqrcode"
|
154
232
|
|
155
|
-
|
233
|
+
qrcode = RQRCode::QRCode.new("http://github.com/")
|
156
234
|
|
235
|
+
# NOTE: showing with default options specified explicitly
|
236
|
+
svg = qrcode.as_ansi(
|
237
|
+
light: "\033[47m", dark: "\033[40m",
|
238
|
+
fill_character: " ",
|
239
|
+
quiet_zone_size: 4
|
240
|
+
)
|
157
241
|
```
|
158
|
-
|
159
|
-
|
160
|
-
x xxx x x x x x xxx x
|
161
|
-
x xxx x xxx x xxx x xxx x
|
162
|
-
x xxx x xxx x x x x xxx x
|
163
|
-
... etc
|
164
|
-
```
|
242
|
+
|
243
|
+
![QR code with github url](./images/ansi-screen-shot.png)
|
165
244
|
|
166
245
|
## API Documentation
|
167
246
|
|
@@ -172,8 +251,9 @@ x xxx x xxx x x x x xxx x
|
|
172
251
|
You can run the test suite using:
|
173
252
|
|
174
253
|
```
|
175
|
-
$
|
176
|
-
$
|
254
|
+
$ bundle install
|
255
|
+
$ rake # runs specs and standard:fix
|
256
|
+
$ rake spec # just runs the specs
|
177
257
|
```
|
178
258
|
|
179
259
|
or try the lib from the console with:
|
@@ -182,11 +262,30 @@ or try the lib from the console with:
|
|
182
262
|
$ ./bin/console
|
183
263
|
```
|
184
264
|
|
265
|
+
## Linting
|
266
|
+
|
267
|
+
The project uses [standardrb](https://github.com/testdouble/standard) and can be used with:
|
268
|
+
|
269
|
+
```
|
270
|
+
$ bundle install
|
271
|
+
$ rake standard # checks
|
272
|
+
$ rake standard:fix # fixes
|
273
|
+
```
|
274
|
+
|
185
275
|
## Contributing
|
276
|
+
|
277
|
+
I am not currently accepting any new renderers as the current `as_png`, `as_svg` and `as_ansi` work for most cases. If you need something different from what's available, the [`rqrcode_core`](https://github.com/whomwah/rqrcode_core) gem gives you access to all the QR Code information you will need so makes it simple to generate your own.
|
278
|
+
|
279
|
+
The motivation for the above is because the rendering side of this gem takes up the most time. It seems that many people want a slightly different version of a QR Code so supporting all the variations would be hard. The easiest way is to empower people to create their own versions which they can manage and share. This is what `rqrcode_core` does.
|
280
|
+
|
281
|
+
Any contribution PR's will be greatly accepted. It's important that they are well tested and backwards compatible.
|
282
|
+
|
186
283
|
* Fork the project
|
187
284
|
* Send a pull request
|
188
285
|
* Don't touch the .gemspec, I'll do that when I release a new version
|
189
286
|
|
287
|
+
Thanks D.
|
288
|
+
|
190
289
|
## Authors
|
191
290
|
|
192
291
|
Original RQRCode author: Duncan Robertson
|
data/Rakefile
ADDED
data/lib/rqrcode/export/ansi.rb
CHANGED
@@ -9,15 +9,15 @@ module RQRCode
|
|
9
9
|
#
|
10
10
|
# Options:
|
11
11
|
# light: Foreground ("\033[47m")
|
12
|
-
# dark: Background ANSI code. ("\033[
|
12
|
+
# dark: Background ANSI code. ("\033[40m")
|
13
13
|
# fill_character: The written character. (' ')
|
14
14
|
# quiet_zone_size: (4)
|
15
15
|
#
|
16
|
-
def as_ansi(options={})
|
16
|
+
def as_ansi(options = {})
|
17
17
|
options = {
|
18
18
|
light: "\033[47m",
|
19
19
|
dark: "\033[40m",
|
20
|
-
fill_character:
|
20
|
+
fill_character: " ",
|
21
21
|
quiet_zone_size: 4
|
22
22
|
}.merge(options)
|
23
23
|
|
@@ -39,15 +39,13 @@ module RQRCode
|
|
39
39
|
row << dark
|
40
40
|
previous_dark = true
|
41
41
|
end
|
42
|
-
|
43
|
-
else
|
42
|
+
elsif previous_dark != false
|
44
43
|
# light
|
45
|
-
|
46
|
-
|
47
|
-
previous_dark = false
|
48
|
-
end
|
49
|
-
row << fill_character
|
44
|
+
row << light
|
45
|
+
previous_dark = false
|
50
46
|
end
|
47
|
+
|
48
|
+
row << fill_character
|
51
49
|
end
|
52
50
|
|
53
51
|
# add quiet zone
|
@@ -68,7 +66,7 @@ module RQRCode
|
|
68
66
|
quiet_row = light + fill_character * width + normal
|
69
67
|
quiet_rows = quiet_row * quiet_zone_size
|
70
68
|
|
71
|
-
|
69
|
+
quiet_rows + output.join + quiet_rows
|
72
70
|
end
|
73
71
|
end
|
74
72
|
end
|
data/lib/rqrcode/export/html.rb
CHANGED
@@ -6,7 +6,7 @@ module RQRCode
|
|
6
6
|
#
|
7
7
|
# Use this module to HTML-ify the QR code if you just want the default HTML
|
8
8
|
def as_html
|
9
|
-
[
|
9
|
+
["<table>", rows.as_html, "</table>"].join
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
@@ -27,7 +27,7 @@ module RQRCode
|
|
27
27
|
|
28
28
|
class Row < Struct.new(:qr, :qr_module, :row_index)
|
29
29
|
def as_html
|
30
|
-
[
|
30
|
+
["<tr>", cells.map(&:as_html).join, "</tr>"].join
|
31
31
|
end
|
32
32
|
|
33
33
|
def cells
|
@@ -41,7 +41,7 @@ module RQRCode
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def html_class
|
44
|
-
qr.checked?(row_index, col_index) ?
|
44
|
+
qr.checked?(row_index, col_index) ? "black" : "white"
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
data/lib/rqrcode/export/png.rb
CHANGED
@@ -1,61 +1,68 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
2
|
+
|
3
|
+
require "chunky_png"
|
3
4
|
|
4
5
|
# This class creates PNG files.
|
5
|
-
# Code from: https://github.com/DCarper/rqrcode
|
6
6
|
module RQRCode
|
7
7
|
module Export
|
8
8
|
module PNG
|
9
9
|
# Render the PNG from the QR Code.
|
10
10
|
#
|
11
|
-
#
|
11
|
+
# Options:
|
12
|
+
# fill - Background ChunkyPNG::Color, defaults to 'white'.
|
13
|
+
# color - Foreground ChunkyPNG::Color, defaults to 'black'.
|
14
|
+
#
|
15
|
+
# When option :file is supplied you can use the following ChunkyPNG constraints
|
16
|
+
# color_mode - The color mode to use. Use one of the ChunkyPNG::COLOR_* constants.
|
17
|
+
# (defaults to 'ChunkyPNG::COLOR_GRAYSCALE')
|
18
|
+
# bit_depth - The bit depth to use. This option is only used for indexed images.
|
19
|
+
# (defaults to 1 bit)
|
20
|
+
# interlace - Whether to use interlacing (true or false).
|
21
|
+
# (defaults to ChunkyPNG default)
|
22
|
+
# compression - The compression level for Zlib. This can be a value between 0 and 9, or a
|
23
|
+
# Zlib constant like Zlib::BEST_COMPRESSION
|
24
|
+
# (defaults to ChunkyPNG default)
|
25
|
+
#
|
26
|
+
# There are two sizing algorithms.
|
12
27
|
#
|
13
28
|
# - Original that can result in blurry and hard to scan images
|
14
29
|
# - Google's Chart API inspired sizing that resizes the module size to fit within the given image size.
|
15
30
|
#
|
16
31
|
# The Googleis one will be used when no options are given or when the new size option is used.
|
17
32
|
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# color_mode - The color mode to use. Use one of the ChunkyPNG::COLOR_* constants. defaults to 'ChunkyPNG::COLOR_GRAYSCALE'
|
24
|
-
# bit_depth - The bit depth to use. This option is only used for indexed images. defaults to '1' bit
|
25
|
-
# interlace - Whether to use interlacing (true or false). defaults to ChunkyPNG default
|
26
|
-
# compression - The compression level for Zlib. This can be a value between 0 and 9, or a Zlib constant like Zlib::BEST_COMPRESSION, defaults to ChunkyPNG defaults
|
27
|
-
#
|
28
|
-
# *Googleis*
|
29
|
-
# size - Total size of PNG in pixels. The module size is calculated so it fits. (defaults to 90)
|
30
|
-
# border_modules - Width of white border around in modules. (defaults to 4).
|
33
|
+
# *Google*
|
34
|
+
# size - Total size of PNG in pixels. The module size is calculated so it fits.
|
35
|
+
# (defaults to 120)
|
36
|
+
# border_modules - Width of white border around in modules.
|
37
|
+
# (defaults to 4).
|
31
38
|
#
|
32
39
|
# -- DONT USE border_modules OPTION UNLESS YOU KNOW ABOUT THE QUIET ZONE NEEDS OF QR CODES --
|
33
40
|
#
|
34
41
|
# *Original*
|
35
42
|
# module_px_size - Image size, in pixels.
|
36
|
-
# border
|
43
|
+
# border - Border thickness, in pixels
|
37
44
|
#
|
38
45
|
# It first creates an image where 1px = 1 module, then resizes.
|
39
|
-
# Defaults to
|
46
|
+
# Defaults to 120x120 pixels, customizable by option.
|
40
47
|
#
|
41
48
|
def as_png(options = {})
|
42
49
|
default_img_options = {
|
43
50
|
bit_depth: 1,
|
44
51
|
border_modules: 4,
|
45
52
|
color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
46
|
-
color:
|
53
|
+
color: "black",
|
47
54
|
file: false,
|
48
|
-
fill:
|
55
|
+
fill: "white",
|
49
56
|
module_px_size: 6,
|
50
57
|
resize_exactly_to: false,
|
51
58
|
resize_gte_to: false,
|
52
59
|
size: 120
|
53
60
|
}
|
54
61
|
|
55
|
-
googleis = options.length == 0 ||
|
62
|
+
googleis = options.length == 0 || !options[:size].nil?
|
56
63
|
options = default_img_options.merge(options) # reverse_merge
|
57
|
-
fill
|
58
|
-
color
|
64
|
+
fill = ChunkyPNG::Color(*(options[:fill].is_a?(Array) ? options[:fill] : [options[:fill]]))
|
65
|
+
color = ChunkyPNG::Color(*(options[:color].is_a?(Array) ? options[:color] : [options[:color]]))
|
59
66
|
output_file = options[:file]
|
60
67
|
module_px_size = nil
|
61
68
|
border_px = nil
|
@@ -81,7 +88,7 @@ module RQRCode
|
|
81
88
|
else
|
82
89
|
options[:module_px_size]
|
83
90
|
end
|
84
|
-
border_px = border *
|
91
|
+
border_px = border * module_px_size
|
85
92
|
total_border_px = border_px * 2
|
86
93
|
resize_to = options[:resize_exactly_to]
|
87
94
|
|
@@ -96,7 +103,7 @@ module RQRCode
|
|
96
103
|
if @qrcode.checked?(x, y)
|
97
104
|
(0...module_px_size).each do |i|
|
98
105
|
(0...module_px_size).each do |j|
|
99
|
-
png[(y * module_px_size) + border_px + j
|
106
|
+
png[(y * module_px_size) + border_px + j, (x * module_px_size) + border_px + i] = color
|
100
107
|
end
|
101
108
|
end
|
102
109
|
end
|
@@ -112,7 +119,7 @@ module RQRCode
|
|
112
119
|
color_mode: options[:color_mode],
|
113
120
|
bit_depth: options[:bit_depth]
|
114
121
|
}
|
115
|
-
constraints[:interlace]
|
122
|
+
constraints[:interlace] = options[:interlace] if options.has_key?(:interlace)
|
116
123
|
constraints[:compression] = options[:compression] if options.has_key?(:compression)
|
117
124
|
png.save(output_file, constraints)
|
118
125
|
end
|
data/lib/rqrcode/export/svg.rb
CHANGED
@@ -1,59 +1,206 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# This class creates a SVG files.
|
4
|
-
#
|
4
|
+
# Initial code from: https://github.com/samvincent/rqrcode-rails3
|
5
5
|
module RQRCode
|
6
6
|
module Export
|
7
7
|
module SVG
|
8
|
+
class BaseOutputSVG
|
9
|
+
attr_reader :result
|
10
|
+
|
11
|
+
def initialize(qrcode)
|
12
|
+
@qrcode = qrcode
|
13
|
+
@result = []
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class Path < BaseOutputSVG
|
18
|
+
def build(module_size, offset, color)
|
19
|
+
modules_array = @qrcode.modules
|
20
|
+
matrix_width = matrix_height = modules_array.length + 1
|
21
|
+
empty_row = [Array.new(matrix_width - 1, false)]
|
22
|
+
edge_matrix = Array.new(matrix_height) { Array.new(matrix_width) }
|
23
|
+
|
24
|
+
(empty_row + modules_array + empty_row).each_cons(2).with_index do |row_pair, row_index|
|
25
|
+
first_row, second_row = row_pair
|
26
|
+
|
27
|
+
# horizontal edges
|
28
|
+
first_row.zip(second_row).each_with_index do |cell_pair, column_index|
|
29
|
+
edge = case cell_pair
|
30
|
+
when [true, false] then Edge.new column_index + 1, row_index, :left
|
31
|
+
when [false, true] then Edge.new column_index, row_index, :right
|
32
|
+
end
|
33
|
+
|
34
|
+
(edge_matrix[edge.start_y][edge.start_x] ||= []) << edge if edge
|
35
|
+
end
|
36
|
+
|
37
|
+
# vertical edges
|
38
|
+
([false] + second_row + [false]).each_cons(2).each_with_index do |cell_pair, column_index|
|
39
|
+
edge = case cell_pair
|
40
|
+
when [true, false] then Edge.new column_index, row_index, :down
|
41
|
+
when [false, true] then Edge.new column_index, row_index + 1, :up
|
42
|
+
end
|
43
|
+
|
44
|
+
(edge_matrix[edge.start_y][edge.start_x] ||= []) << edge if edge
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
edge_count = edge_matrix.flatten.compact.count
|
49
|
+
path = []
|
50
|
+
|
51
|
+
while edge_count > 0
|
52
|
+
edge_loop = []
|
53
|
+
next_matrix_cell = edge_matrix.find(&:any?).find { |cell| cell&.any? }
|
54
|
+
edge = next_matrix_cell.first
|
55
|
+
|
56
|
+
while edge
|
57
|
+
edge_loop << edge
|
58
|
+
matrix_cell = edge_matrix[edge.start_y][edge.start_x]
|
59
|
+
matrix_cell.delete edge
|
60
|
+
edge_matrix[edge.start_y][edge.start_x] = nil if matrix_cell.empty?
|
61
|
+
edge_count -= 1
|
62
|
+
|
63
|
+
# try to find an edge continuing the current edge
|
64
|
+
edge = edge_matrix[edge.end_y][edge.end_x]&.first
|
65
|
+
end
|
66
|
+
|
67
|
+
first_edge = edge_loop.first
|
68
|
+
edge_loop_string = SVG_PATH_COMMANDS[:move]
|
69
|
+
edge_loop_string += "#{first_edge.start_x} #{first_edge.start_y}"
|
70
|
+
|
71
|
+
edge_loop.chunk(&:direction).to_a[0...-1].each do |direction, edges|
|
72
|
+
edge_loop_string << "#{SVG_PATH_COMMANDS[direction]}#{edges.length}"
|
73
|
+
end
|
74
|
+
edge_loop_string << SVG_PATH_COMMANDS[:close]
|
75
|
+
|
76
|
+
path << edge_loop_string
|
77
|
+
end
|
78
|
+
|
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})"/>}
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class Rect < BaseOutputSVG
|
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
|
+
|
91
|
+
@qrcode.modules.each_index do |c|
|
92
|
+
tmp = []
|
93
|
+
@qrcode.modules.each_index do |r|
|
94
|
+
y = c * module_size + offset
|
95
|
+
x = r * module_size + offset
|
96
|
+
|
97
|
+
next unless @qrcode.checked?(c, r)
|
98
|
+
tmp << %(<rect width="#{module_size}" height="#{module_size}" x="#{x}" y="#{y}" fill="#{color}"/>)
|
99
|
+
end
|
100
|
+
|
101
|
+
@result << tmp.join
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
class Edge < Struct.new(:start_x, :start_y, :direction)
|
107
|
+
def end_x
|
108
|
+
case direction
|
109
|
+
when :right then start_x + 1
|
110
|
+
when :left then start_x - 1
|
111
|
+
else start_x
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def end_y
|
116
|
+
case direction
|
117
|
+
when :down then start_y + 1
|
118
|
+
when :up then start_y - 1
|
119
|
+
else start_y
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
DEFAULT_SVG_ATTRIBUTES = [
|
125
|
+
%(version="1.1"),
|
126
|
+
%(xmlns="http://www.w3.org/2000/svg"),
|
127
|
+
%(xmlns:xlink="http://www.w3.org/1999/xlink"),
|
128
|
+
%(xmlns:ev="http://www.w3.org/2001/xml-events")
|
129
|
+
]
|
130
|
+
|
131
|
+
SVG_PATH_COMMANDS = {
|
132
|
+
move: "M",
|
133
|
+
up: "v-",
|
134
|
+
down: "v",
|
135
|
+
left: "h-",
|
136
|
+
right: "h",
|
137
|
+
close: "z"
|
138
|
+
}
|
139
|
+
|
8
140
|
#
|
9
141
|
# Render the SVG from the Qrcode.
|
10
142
|
#
|
11
143
|
# Options:
|
12
|
-
# offset
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
18
|
-
#
|
144
|
+
# offset - Padding around the QR Code in pixels
|
145
|
+
# (default 0)
|
146
|
+
# fill - Background color e.g "ffffff"
|
147
|
+
# (default none)
|
148
|
+
# color - Foreground color e.g "000"
|
149
|
+
# (default "000")
|
150
|
+
# module_size - The Pixel size of each module
|
151
|
+
# (defaults 11)
|
152
|
+
# shape_rendering - SVG Attribute: auto | optimizeSpeed | crispEdges | geometricPrecision
|
153
|
+
# (defaults crispEdges)
|
154
|
+
# standalone - Whether to make this a full SVG file, or only an svg to embed in other svg
|
155
|
+
# (default true)
|
156
|
+
# use_path - Use <path> to render SVG rather than <rect> to significantly reduce size
|
157
|
+
# and quality. This will become the default in future versions.
|
158
|
+
# (default false)
|
159
|
+
# viewbox - replace `width` and `height` in <svg> with a viewBox, allows CSS scaling
|
160
|
+
# (default false)
|
161
|
+
# svg_attributes - A optional hash of custom <svg> attributes. Existing attributes will remain.
|
162
|
+
# (default {})
|
19
163
|
#
|
20
|
-
def as_svg(options={})
|
164
|
+
def as_svg(options = {})
|
165
|
+
fill = options[:fill]
|
166
|
+
use_path = options[:use_path]
|
21
167
|
offset = options[:offset].to_i || 0
|
22
168
|
color = options[:color] || "000"
|
23
169
|
shape_rendering = options[:shape_rendering] || "crispEdges"
|
24
170
|
module_size = options[:module_size] || 11
|
25
171
|
standalone = options[:standalone].nil? ? true : options[:standalone]
|
172
|
+
viewbox = options[:viewbox].nil? ? false : options[:viewbox]
|
173
|
+
svg_attributes = options[:svg_attributes] || {}
|
26
174
|
|
27
175
|
# height and width dependent on offset and QR complexity
|
28
|
-
dimension = (@qrcode.module_count*module_size) + (2*offset)
|
176
|
+
dimension = (@qrcode.module_count * module_size) + (2 * offset)
|
177
|
+
# use dimensions differently if we are using a viewBox
|
178
|
+
dimensions_attr = viewbox ? %(viewBox="0 0 #{dimension} #{dimension}") : %(width="#{dimension}" height="#{dimension}")
|
29
179
|
|
30
|
-
|
31
|
-
|
32
|
-
|
180
|
+
svg_tag_attributes = (DEFAULT_SVG_ATTRIBUTES + [
|
181
|
+
dimensions_attr,
|
182
|
+
%(shape-rendering="#{shape_rendering}")
|
183
|
+
] + svg_attributes.map { |k, v| %(#{k}="#{v}") }).join(" ")
|
33
184
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
@qrcode.modules.each_index do |r|
|
38
|
-
y = c*module_size + offset
|
39
|
-
x = r*module_size + offset
|
185
|
+
xml_tag = %(<?xml version="1.0" standalone="yes"?>)
|
186
|
+
open_tag = %(<svg #{svg_tag_attributes}>)
|
187
|
+
close_tag = "</svg>"
|
40
188
|
|
41
|
-
|
42
|
-
|
43
|
-
end
|
44
|
-
result << tmp.join
|
45
|
-
end
|
189
|
+
output_tag = (use_path ? Path : Rect).new(@qrcode)
|
190
|
+
output_tag.build(module_size, offset, color)
|
46
191
|
|
47
|
-
if
|
48
|
-
|
192
|
+
if 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" fill="#{fill}"/>)
|
49
196
|
end
|
50
197
|
|
51
198
|
if standalone
|
52
|
-
result.unshift(xml_tag, open_tag)
|
53
|
-
result << close_tag
|
199
|
+
output_tag.result.unshift(xml_tag, open_tag)
|
200
|
+
output_tag.result << close_tag
|
54
201
|
end
|
55
202
|
|
56
|
-
result.join
|
203
|
+
output_tag.result.join
|
57
204
|
end
|
58
205
|
end
|
59
206
|
end
|
data/lib/rqrcode/export.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
3
|
+
require "rqrcode/export/ansi"
|
4
|
+
require "rqrcode/export/html"
|
5
|
+
require "rqrcode/export/png"
|
6
|
+
require "rqrcode/export/svg"
|
data/lib/rqrcode/qrcode.rb
CHANGED
data/lib/rqrcode/version.rb
CHANGED
data/lib/rqrcode.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RQRCode
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
4
|
+
require "rqrcode_core"
|
5
|
+
require "rqrcode/qrcode"
|
6
|
+
require "rqrcode/export"
|
7
|
+
require "rqrcode/version"
|
8
8
|
end
|
data/rqrcode.gemspec
CHANGED
@@ -1,36 +1,39 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
1
|
lib = File.expand_path("../lib", __FILE__)
|
4
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
3
|
require "rqrcode/version"
|
6
4
|
|
7
5
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name
|
9
|
-
spec.version
|
10
|
-
spec.platform
|
11
|
-
spec.authors
|
12
|
-
spec.email
|
6
|
+
spec.name = "rqrcode"
|
7
|
+
spec.version = RQRCode::VERSION
|
8
|
+
spec.platform = Gem::Platform::RUBY
|
9
|
+
spec.authors = ["Duncan Robertson"]
|
10
|
+
spec.email = ["duncan@whomwah.com"]
|
13
11
|
|
14
|
-
spec.summary
|
15
|
-
spec.description =
|
16
|
-
rqrcode is a library for encoding QR Codes. The simple
|
17
|
-
interface allows you to create QR Code data structures
|
18
|
-
and then render them in the way you choose.
|
19
|
-
EOF
|
20
|
-
spec.homepage
|
21
|
-
spec.license
|
12
|
+
spec.summary = "A library to encode QR Codes"
|
13
|
+
spec.description = <<~EOF
|
14
|
+
rqrcode is a library for encoding QR Codes. The simple
|
15
|
+
interface allows you to create QR Code data structures
|
16
|
+
and then render them in the way you choose.
|
17
|
+
EOF
|
18
|
+
spec.homepage = "https://github.com/whomwah/rqrcode"
|
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
|
+
}
|
22
24
|
|
23
|
-
spec.files
|
25
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
24
26
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
27
|
end
|
26
|
-
spec.bindir
|
27
|
-
spec.executables
|
28
|
+
spec.bindir = "exe"
|
29
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
30
|
spec.require_paths = ["lib"]
|
29
31
|
|
30
|
-
spec.required_ruby_version =
|
31
|
-
spec.add_dependency
|
32
|
-
spec.add_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
32
|
+
spec.required_ruby_version = ">= 2.6"
|
33
|
+
spec.add_dependency "rqrcode_core", "~> 1.0"
|
34
|
+
spec.add_dependency "chunky_png", "~> 1.0"
|
35
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
36
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
38
|
+
spec.add_development_dependency "standardrb", "~> 1.0"
|
36
39
|
end
|
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:
|
4
|
+
version: 2.2.0
|
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:
|
11
|
+
date: 2023-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rqrcode_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '1.0'
|
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
|
-
version: '0
|
26
|
+
version: '1.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: chunky_png
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.5'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: standardrb
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.0'
|
83
97
|
description: |
|
84
98
|
rqrcode is a library for encoding QR Codes. The simple
|
85
99
|
interface allows you to create QR Code data structures
|
@@ -93,12 +107,14 @@ files:
|
|
93
107
|
- ".github/workflows/ruby.yml"
|
94
108
|
- ".gitignore"
|
95
109
|
- ".rspec"
|
110
|
+
- CHANGELOG.md
|
96
111
|
- Gemfile
|
112
|
+
- Gemfile.lock
|
97
113
|
- LICENSE.txt
|
98
114
|
- README.md
|
115
|
+
- Rakefile
|
99
116
|
- _config.yml
|
100
117
|
- bin/console
|
101
|
-
- bin/setup
|
102
118
|
- images/ansi-screen-shot.png
|
103
119
|
- images/github-qrcode.png
|
104
120
|
- images/github-qrcode.svg
|
@@ -115,8 +131,10 @@ files:
|
|
115
131
|
homepage: https://github.com/whomwah/rqrcode
|
116
132
|
licenses:
|
117
133
|
- MIT
|
118
|
-
metadata:
|
119
|
-
|
134
|
+
metadata:
|
135
|
+
bug_tracker_uri: https://github.com/whomwah/rqrcode/issues
|
136
|
+
changelog_uri: https://github.com/whomwah/rqrcode/blob/master/CHANGELOG.md
|
137
|
+
post_install_message:
|
120
138
|
rdoc_options: []
|
121
139
|
require_paths:
|
122
140
|
- lib
|
@@ -124,15 +142,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
142
|
requirements:
|
125
143
|
- - ">="
|
126
144
|
- !ruby/object:Gem::Version
|
127
|
-
version: '2.
|
145
|
+
version: '2.6'
|
128
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
147
|
requirements:
|
130
148
|
- - ">="
|
131
149
|
- !ruby/object:Gem::Version
|
132
150
|
version: '0'
|
133
151
|
requirements: []
|
134
|
-
rubygems_version: 3.
|
135
|
-
signing_key:
|
152
|
+
rubygems_version: 3.4.6
|
153
|
+
signing_key:
|
136
154
|
specification_version: 4
|
137
155
|
summary: A library to encode QR Codes
|
138
156
|
test_files: []
|