rqrcode 0.10.1 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +28 -0
- data/.gitignore +13 -0
- data/.rspec +2 -0
- data/CHANGELOG.md +54 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +68 -0
- data/LICENSE.txt +21 -0
- data/README.md +223 -135
- data/Rakefile +10 -0
- data/_config.yml +1 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/images/ansi-screen-shot.png +0 -0
- data/images/github-qrcode.png +0 -0
- data/images/github-qrcode.svg +32 -0
- data/lib/rqrcode/export/ansi.rb +22 -25
- data/lib/rqrcode/export/html.rb +8 -10
- data/lib/rqrcode/export/png.rb +62 -45
- data/lib/rqrcode/export/svg.rb +180 -24
- data/lib/rqrcode/export.rb +6 -0
- data/lib/rqrcode/qrcode/qrcode.rb +17 -0
- data/lib/rqrcode/qrcode.rb +3 -4
- data/lib/rqrcode/version.rb +3 -1
- data/lib/rqrcode.rb +8 -19
- data/rqrcode.gemspec +39 -0
- metadata +91 -60
- data/CHANGELOG +0 -97
- data/LICENSE +0 -19
- data/lib/rqrcode/core_ext/array/behavior.rb +0 -12
- data/lib/rqrcode/core_ext/array.rb +0 -5
- data/lib/rqrcode/core_ext/integer/bitwise.rb +0 -13
- data/lib/rqrcode/core_ext/integer.rb +0 -5
- data/lib/rqrcode/core_ext.rb +0 -5
- data/lib/rqrcode/qrcode/qr_8bit_byte.rb +0 -36
- data/lib/rqrcode/qrcode/qr_alphanumeric.rb +0 -47
- data/lib/rqrcode/qrcode/qr_bit_buffer.rb +0 -99
- data/lib/rqrcode/qrcode/qr_code.rb +0 -585
- data/lib/rqrcode/qrcode/qr_math.rb +0 -63
- data/lib/rqrcode/qrcode/qr_numeric.rb +0 -57
- data/lib/rqrcode/qrcode/qr_polynomial.rb +0 -78
- data/lib/rqrcode/qrcode/qr_rs_block.rb +0 -314
- data/lib/rqrcode/qrcode/qr_util.rb +0 -272
- data/test/data.rb +0 -25
- data/test/test_helper.rb +0 -5
- data/test/test_regresions.rb +0 -10
- data/test/test_rqrcode.rb +0 -155
- data/test/test_rqrcode_export.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6d9f9771040408819ab4ae97bc5b0de8814863e5b9dba0402268799eb03350d9
|
4
|
+
data.tar.gz: 2f811a4fed92cfa3bed1fdbe8609c57910c76184c97eafb00985422d83c02385
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ece7165b08b181bd62a10069d5b60a849e0887c1c775b625cf691d3f7a439f0a5701d3fa362fb1263d7aae425e9a8a18c706ac621efb7f8f97955f5e7e11dbc
|
7
|
+
data.tar.gz: '0479794cb35208cffebf7355cbb3517b394f14b8af04eeebbcf51b2afdafd35f088fe2f9a60daf55752594578231411468f6eef090bd20b4e0c4864ea1cb00e4'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: rqrcode
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
Build:
|
13
|
+
strategy:
|
14
|
+
fail-fast: false
|
15
|
+
matrix:
|
16
|
+
os: [ubuntu-latest, macos-latest]
|
17
|
+
ruby: [2.5, 2.6, 2.7, '3.0', 3.1]
|
18
|
+
runs-on: ${{ matrix.os }}
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v2
|
21
|
+
- uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
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
ADDED
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,54 @@
|
|
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.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
|
+
|
23
|
+
## [2.0.0] - 2021-05-06
|
24
|
+
|
25
|
+
### Added
|
26
|
+
|
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]
|
30
|
+
|
31
|
+
### Changed
|
32
|
+
|
33
|
+
- README updated
|
34
|
+
- Rakefile cleaned up. You can now just run `rake` which will run specs and fix linting using `standardrb`
|
35
|
+
- Small documentation clarification [@smnscp](https://github.com/smnscp)
|
36
|
+
- Bump `rqrcode_core` to `~> 1.0`
|
37
|
+
|
38
|
+
### Breaking Change
|
39
|
+
|
40
|
+
- 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
|
41
|
+
|
42
|
+
## [1.2.0] - 2020-12-26
|
43
|
+
|
44
|
+
### Changed
|
45
|
+
|
46
|
+
- README updated
|
47
|
+
- bump dependencies
|
48
|
+
- fix `required_ruby_version` for Ruby 3 support
|
49
|
+
|
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
|
53
|
+
[2.0.0]: https://github.com/whomwah/rqrcode/compare/v1.2.0...v2.0.0
|
54
|
+
[1.2.0]: https://github.com/whomwah/rqrcode/compare/v1.1.1...v1.2.0
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rqrcode (2.1.1)
|
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.4.4)
|
14
|
+
parallel (1.21.0)
|
15
|
+
parser (3.1.0.0)
|
16
|
+
ast (~> 2.4.1)
|
17
|
+
rainbow (3.0.0)
|
18
|
+
rake (13.0.3)
|
19
|
+
regexp_parser (2.2.0)
|
20
|
+
rexml (3.2.5)
|
21
|
+
rqrcode_core (1.2.0)
|
22
|
+
rspec (3.10.0)
|
23
|
+
rspec-core (~> 3.10.0)
|
24
|
+
rspec-expectations (~> 3.10.0)
|
25
|
+
rspec-mocks (~> 3.10.0)
|
26
|
+
rspec-core (3.10.1)
|
27
|
+
rspec-support (~> 3.10.0)
|
28
|
+
rspec-expectations (3.10.1)
|
29
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
+
rspec-support (~> 3.10.0)
|
31
|
+
rspec-mocks (3.10.2)
|
32
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
+
rspec-support (~> 3.10.0)
|
34
|
+
rspec-support (3.10.2)
|
35
|
+
rubocop (1.24.1)
|
36
|
+
parallel (~> 1.10)
|
37
|
+
parser (>= 3.0.0.0)
|
38
|
+
rainbow (>= 2.2.2, < 4.0)
|
39
|
+
regexp_parser (>= 1.8, < 3.0)
|
40
|
+
rexml
|
41
|
+
rubocop-ast (>= 1.15.1, < 2.0)
|
42
|
+
ruby-progressbar (~> 1.7)
|
43
|
+
unicode-display_width (>= 1.4.0, < 3.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
|
+
rubocop-ast (>= 0.4.0)
|
49
|
+
ruby-progressbar (1.11.0)
|
50
|
+
standard (1.6.0)
|
51
|
+
rubocop (= 1.24.1)
|
52
|
+
rubocop-performance (= 1.13.1)
|
53
|
+
standardrb (1.0.0)
|
54
|
+
standard
|
55
|
+
unicode-display_width (2.1.0)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
ruby
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
bundler (~> 2.0)
|
62
|
+
rake (~> 13.0)
|
63
|
+
rqrcode!
|
64
|
+
rspec (~> 3.5)
|
65
|
+
standardrb (~> 1.0)
|
66
|
+
|
67
|
+
BUNDLED WITH
|
68
|
+
2.2.32
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2008 Duncan Robertson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,217 +1,305 @@
|
|
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
|
-
**All users of rqrcode are highly recomended to upgrade to version 0.5.5 ore later!**
|
6
6
|
|
7
|
-
|
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.
|
8
8
|
|
9
|
-
*
|
9
|
+
* QR code is trademarked by Denso Wave inc
|
10
|
+
* Minimum Ruby version is `>= 2.3`
|
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)
|
10
13
|
|
11
|
-
|
14
|
+
## Installing
|
12
15
|
|
13
|
-
|
16
|
+
Add this line to your application's `Gemfile`:
|
14
17
|
|
15
|
-
|
18
|
+
```ruby
|
19
|
+
gem "rqrcode", "~> 2.0"
|
20
|
+
```
|
16
21
|
|
17
|
-
|
22
|
+
or install manually:
|
18
23
|
|
19
|
-
|
20
|
-
|
24
|
+
```ruby
|
25
|
+
gem install rqrcode
|
26
|
+
```
|
21
27
|
|
22
|
-
|
28
|
+
## Basic usage example
|
23
29
|
|
24
|
-
|
25
|
-
|
30
|
+
```ruby
|
31
|
+
require "rqrcode"
|
26
32
|
|
27
|
-
|
33
|
+
qr = RQRCode::QRCode.new("https://kyan.com")
|
28
34
|
|
29
|
-
|
30
|
-
|
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
|
+
...
|
45
|
+
```
|
31
46
|
|
32
|
-
|
47
|
+
Easy, but unlikely to be readable. For this you will need to use one of the many [rendering options](#render-types) below.
|
33
48
|
|
34
|
-
|
49
|
+
### Advanced Options
|
35
50
|
|
36
|
-
|
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.
|
37
52
|
|
38
|
-
|
39
|
-
|
40
|
-
* The interface is simple and assumes you just want to encode a string into a QR code
|
41
|
-
* QR code is trademarked by Denso Wave inc
|
53
|
+
```
|
54
|
+
Expects a string or array (for multi-segment encoding) to be parsed in, other args are optional
|
42
55
|
|
43
|
-
|
56
|
+
data - the string, QRSegment or array of Hashes (with data:, mode: keys) you wish to encode
|
44
57
|
|
45
|
-
|
58
|
+
size - the size (Integer) of the QR Code (defaults to smallest size needed to encode the data)
|
46
59
|
|
47
|
-
|
48
|
-
|
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
|
49
74
|
```
|
50
75
|
|
51
|
-
|
76
|
+
Example
|
52
77
|
|
53
78
|
```ruby
|
54
|
-
|
79
|
+
simple_qrcode = RQRCodeCore::QRCode.new("https://kyan.com", size: 1, level: :m, mode: :alphanumeric)
|
55
80
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
+
])
|
62
87
|
```
|
63
88
|
|
64
|
-
##
|
65
|
-
|
89
|
+
## Render types
|
90
|
+
|
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:
|
92
|
+
|
93
|
+
### `as_svg`
|
66
94
|
|
67
95
|
The SVG renderer will produce a stand-alone SVG as a `String`
|
68
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
|
+
and quality. 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
|
69
122
|
```ruby
|
123
|
+
require "rqrcode"
|
124
|
+
|
70
125
|
qrcode = RQRCode::QRCode.new("http://github.com/")
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
126
|
+
|
127
|
+
# NOTE: showing with default options specified explicitly
|
128
|
+
svg = qrcode.as_svg(
|
129
|
+
color: "000",
|
130
|
+
shape_rendering: "crispEdges",
|
131
|
+
module_size: 11,
|
132
|
+
standalone: true,
|
133
|
+
use_path: true
|
134
|
+
)
|
75
135
|
```
|
76
136
|
|
77
137
|
![QR code with github url](./images/github-qrcode.svg)
|
78
138
|
|
79
|
-
###
|
139
|
+
### `as_png`
|
80
140
|
|
81
|
-
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.
|
82
142
|
|
83
|
-
```ruby
|
84
|
-
qrcode = RQRCode::QRCode.new("http://github.com/")
|
85
|
-
# With default options specified explicitly
|
86
|
-
svg = qrcode.as_ansi_(light: "\033[47m", dark: "\033[40m",
|
87
|
-
fill_character: ' ',
|
88
|
-
quiet_zone_size: 4)
|
89
143
|
```
|
144
|
+
Options:
|
90
145
|
|
91
|
-
|
146
|
+
fill - Background ChunkyPNG::Color, defaults to 'white'
|
147
|
+
color - Foreground ChunkyPNG::Color, defaults to 'black'
|
92
148
|
|
93
|
-
|
149
|
+
When option :file is supplied you can use the following ChunkyPNG constraints:
|
94
150
|
|
95
|
-
The
|
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)
|
96
160
|
|
97
|
-
|
98
|
-
qrcode = RQRCode::QRCode.new("http://github.com/")
|
99
|
-
# With default options specified explicitly
|
100
|
-
png = qrcode.as_png(
|
101
|
-
resize_gte_to: false,
|
102
|
-
resize_exactly_to: false,
|
103
|
-
fill: 'white',
|
104
|
-
color: 'black',
|
105
|
-
size: 120,
|
106
|
-
border_modules: 4,
|
107
|
-
module_px_size: 6,
|
108
|
-
file: nil # path to write
|
109
|
-
)
|
110
|
-
IO.write("/tmp/github-qrcode.png", png.to_s)
|
111
|
-
```
|
161
|
+
There are two sizing algorithms.
|
112
162
|
|
113
|
-
|
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.
|
114
165
|
|
115
|
-
|
116
|
-
### In your controller
|
117
|
-
```ruby
|
118
|
-
@qr = RQRCode::QRCode.new( 'https://github.com/whomwah/rqrcode', :size => 4, :level => :h )
|
119
|
-
```
|
166
|
+
The Google one will be used when no options are given or when the new size option is used.
|
120
167
|
|
121
|
-
|
122
|
-
```html
|
123
|
-
<%= raw @qr.as_html %>
|
124
|
-
```
|
168
|
+
*Google Sizing*
|
125
169
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
border-style: none;
|
131
|
-
border-color: #0000ff;
|
132
|
-
border-collapse: collapse;
|
133
|
-
}
|
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).
|
134
174
|
|
135
|
-
|
136
|
-
border-left: solid 10px #000;
|
137
|
-
padding: 0;
|
138
|
-
margin: 0;
|
139
|
-
width: 0px;
|
140
|
-
height: 10px;
|
141
|
-
}
|
175
|
+
-- DONT USE border_modules OPTION UNLESS YOU KNOW ABOUT THE QUIET ZONE NEEDS OF QR CODES --
|
142
176
|
|
143
|
-
|
144
|
-
|
177
|
+
*Original Sizing*
|
178
|
+
|
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.
|
145
184
|
```
|
146
|
-
|
147
|
-
|
185
|
+
|
186
|
+
Example
|
148
187
|
|
149
188
|
```ruby
|
150
|
-
|
151
|
-
puts qr.to_s
|
152
|
-
```
|
189
|
+
require "rqrcode"
|
153
190
|
|
154
|
-
|
191
|
+
qrcode = RQRCode::QRCode.new("http://github.com/")
|
155
192
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
193
|
+
# NOTE: showing with default options specified explicitly
|
194
|
+
png = qrcode.as_png(
|
195
|
+
bit_depth: 1,
|
196
|
+
border_modules: 4,
|
197
|
+
color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
198
|
+
color: "black",
|
199
|
+
file: nil,
|
200
|
+
fill: "white",
|
201
|
+
module_px_size: 6,
|
202
|
+
resize_exactly_to: false,
|
203
|
+
resize_gte_to: false,
|
204
|
+
size: 120
|
205
|
+
)
|
206
|
+
|
207
|
+
IO.binwrite("/tmp/github-qrcode.png", png.to_s)
|
161
208
|
```
|
162
209
|
|
163
|
-
|
164
|
-
```ruby
|
165
|
-
qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )
|
166
|
-
qr.modules.each do |row|
|
167
|
-
row.each do |col|
|
168
|
-
print col ? "X" : " "
|
169
|
-
end
|
170
|
-
print "\n"
|
171
|
-
end
|
172
|
-
```
|
210
|
+
![QR code with github url](./images/github-qrcode.png)
|
173
211
|
|
174
|
-
## Specifying QR code mode
|
175
212
|
|
176
|
-
|
213
|
+
### `as_ansi`
|
177
214
|
|
178
|
-
|
215
|
+
The ANSI renderer will produce as a string with ANSI color codes.
|
179
216
|
|
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
|
180
230
|
```ruby
|
181
|
-
|
231
|
+
require "rqrcode"
|
232
|
+
|
233
|
+
qrcode = RQRCode::QRCode.new("http://github.com/")
|
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
|
+
)
|
182
241
|
```
|
183
242
|
|
243
|
+
![QR code with github url](./images/ansi-screen-shot.png)
|
184
244
|
|
185
245
|
## API Documentation
|
186
246
|
|
187
247
|
[http://www.rubydoc.info/gems/rqrcode](http://www.rubydoc.info/gems/rqrcode)
|
188
248
|
|
189
|
-
##
|
249
|
+
## Tests
|
190
250
|
|
191
|
-
|
192
|
-
* Denso-Wave website:: http://www.denso-wave.com/qrcode/index-e.html
|
193
|
-
* kaywa:: http://qrcode.kaywa.com
|
251
|
+
You can run the test suite using:
|
194
252
|
|
195
|
-
|
253
|
+
```
|
254
|
+
$ ./bin/setup
|
255
|
+
$ rake # runs specs and standard:fix
|
256
|
+
$ rake spec # just runs the specs
|
257
|
+
```
|
258
|
+
|
259
|
+
or try the lib from the console with:
|
196
260
|
|
197
|
-
|
261
|
+
```
|
262
|
+
$ ./bin/console
|
263
|
+
```
|
264
|
+
|
265
|
+
## Linting
|
198
266
|
|
199
|
-
|
267
|
+
The project uses [standardrb](https://github.com/testdouble/standard) and can be used with:
|
200
268
|
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
* [Rob la Lau](https://github.com/ohreally)
|
207
|
-
* [Tore Darell](http://tore.darell.no)
|
208
|
-
* Vladislav Gorodetskiy
|
269
|
+
```
|
270
|
+
$ ./bin/setup
|
271
|
+
$ rake standard # checks
|
272
|
+
$ rake standard:fix # fixes
|
273
|
+
```
|
209
274
|
|
210
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
|
+
|
211
283
|
* Fork the project
|
212
284
|
* Send a pull request
|
213
285
|
* Don't touch the .gemspec, I'll do that when I release a new version
|
214
286
|
|
287
|
+
Thanks D.
|
288
|
+
|
289
|
+
## Authors
|
290
|
+
|
291
|
+
Original RQRCode author: Duncan Robertson
|
292
|
+
|
293
|
+
A massive thanks to [all the contributors of the library over the years](https://github.com/whomwah/rqrcode/graphs/contributors). It wouldn't exist if it wasn't for you all.
|
294
|
+
|
295
|
+
Oh, and thanks to my bosses at https://kyan.com for giving me time to maintain this project.
|
296
|
+
|
297
|
+
## Resources
|
298
|
+
|
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
|
+
|
215
303
|
## Copyright
|
216
304
|
|
217
305
|
MIT License (http://www.opensource.org/licenses/mit-license.html)
|
data/Rakefile
ADDED
data/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-slate
|