rqrcode 0.9.0 → 1.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 +5 -5
- data/.github/workflows/ruby.yml +31 -0
- data/.gitignore +9 -1
- data/.rspec +2 -0
- data/Gemfile +3 -8
- data/LICENSE.txt +21 -0
- data/README.md +125 -122
- data/Rakefile +7 -11
- 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.rb +7 -15
- data/lib/rqrcode/export.rb +6 -0
- data/lib/rqrcode/export/ansi.rb +77 -0
- data/lib/rqrcode/export/html.rb +6 -8
- data/lib/rqrcode/export/png.rb +40 -31
- data/lib/rqrcode/export/svg.rb +16 -7
- data/lib/rqrcode/qrcode.rb +3 -4
- data/lib/rqrcode/qrcode/qrcode.rb +17 -0
- data/lib/rqrcode/version.rb +3 -1
- data/rqrcode.gemspec +28 -24
- metadata +67 -59
- data/.travis.yml +0 -7
- data/CHANGELOG +0 -85
- data/LICENSE +0 -19
- data/TODO.md +0 -4
- data/lib/rqrcode/core_ext.rb +0 -5
- data/lib/rqrcode/core_ext/array.rb +0 -5
- data/lib/rqrcode/core_ext/array/behavior.rb +0 -12
- data/lib/rqrcode/core_ext/integer.rb +0 -5
- data/lib/rqrcode/core_ext/integer/bitwise.rb +0 -13
- 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 -66
- 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 -23
- 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 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 818b3dab2ed7719eb45d3c4b02704258e92f4de8ec0fe4f7e9cbb62765aad507
|
4
|
+
data.tar.gz: 50efa7d1fe21cce41ea38d44b4864290110281fcfc6c575267550440acb7f41a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbda3d6822ef41ce25fed16754a921ea964c8a5fcfe629975146d1733de49f08dc337fc6b2f2213160289d623618961eb04a5531a22329ade90ac0ba777f57ed
|
7
|
+
data.tar.gz: 1834cab154c5819319ccd2cb22e7c8fddaa6dcd680648693e29e8ce98cb9f92a0d12c5f8072f9fa40ae09b0ffcecafa02ede7a7d26fef611397a3f693e4d9512
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: rqrcode
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
- release/*
|
8
|
+
pull_request:
|
9
|
+
branches:
|
10
|
+
- master
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
build:
|
14
|
+
name: Test Ruby ${{ matrix.ruby_version }} on ${{ matrix.os }}
|
15
|
+
runs-on: ${{ matrix.os }}
|
16
|
+
strategy:
|
17
|
+
matrix:
|
18
|
+
ruby_version: [2.5.x, 2.6.x]
|
19
|
+
os: [ubuntu-latest]
|
20
|
+
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v1
|
23
|
+
- name: Use Ruby ${{ matrix.ruby_version }}
|
24
|
+
uses: actions/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
ruby-version: ${{ matrix.ruby_version }}
|
27
|
+
- name: Gem install and test
|
28
|
+
run: |
|
29
|
+
gem install bundler
|
30
|
+
bundle install --jobs 4 --retry 3
|
31
|
+
bundle exec rake test
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/Gemfile
CHANGED
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,162 +1,184 @@
|
|
1
|
-
#
|
1
|
+
# RQRCode
|
2
2
|
|
3
|
-
|
3
|
+

|
4
4
|
|
5
|
-
**All users of rqrcode are highly recomended to upgrade to version 0.5.5 ore later!**
|
6
5
|
|
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
|
-
*
|
8
|
+
* QR code is trademarked by Denso Wave inc
|
9
|
+
* Minimum Ruby version is `~> 2.3`
|
10
|
+
* For `rqrcode` releases `< 1.0.0` please use [this README](https://github.com/whomwah/rqrcode/blob/cd2732a68434e6197c219e6c8cbdadfce0c4c4f3/README.md)
|
11
|
+
|
12
|
+
## Installing
|
10
13
|
|
11
|
-
|
12
|
-
- Added numeric support during auto selection of qrcode mode.
|
14
|
+
Add this line to your application's `Gemfile`:
|
13
15
|
|
14
|
-
|
16
|
+
```ruby
|
17
|
+
gem 'rqrcode'
|
18
|
+
```
|
15
19
|
|
16
|
-
|
17
|
-
|
20
|
+
or install manually:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem install rqrcode
|
24
|
+
```
|
18
25
|
|
19
|
-
|
26
|
+
## Basic usage example
|
20
27
|
|
21
|
-
|
22
|
-
|
28
|
+
```ruby
|
29
|
+
require 'rqrcode'
|
23
30
|
|
24
|
-
|
31
|
+
qr = RQRCode::QRCode.new('http://github.com')
|
32
|
+
result = ''
|
25
33
|
|
26
|
-
|
34
|
+
qr.qrcode.modules.each do |row|
|
35
|
+
row.each do |col|
|
36
|
+
result << (col ? 'X' : 'O')
|
37
|
+
end
|
27
38
|
|
28
|
-
|
39
|
+
result << "\n"
|
40
|
+
end
|
29
41
|
|
30
|
-
|
31
|
-
|
32
|
-
* The interface is simple and assumes you just want to encode a string into a QR code
|
33
|
-
* QR code is trademarked by Denso Wave inc
|
42
|
+
puts result
|
43
|
+
```
|
34
44
|
|
35
|
-
|
45
|
+
### Advanced Options
|
36
46
|
|
37
|
-
|
47
|
+
These are the various QR Code generation options provided by [rqrqcode_core](https://github.com/whomwah/rqrcode_core).
|
38
48
|
|
39
|
-
```ruby
|
40
|
-
gem install rqrcode
|
41
49
|
```
|
50
|
+
string - the string you wish to encode
|
51
|
+
|
52
|
+
size - the size of the qrcode (default 4)
|
53
|
+
|
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)
|
59
|
+
|
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
|
65
|
+
```
|
66
|
+
|
67
|
+
Example
|
68
|
+
|
69
|
+
```
|
70
|
+
qrcode = RQRCodeCore::QRCode.new('hello world', size: 1, level: :m, mode: :alphanumeric)
|
71
|
+
```
|
72
|
+
|
73
|
+
## Render types
|
74
|
+
|
75
|
+
You can output your QR code in various forms. These are detailed below:
|
42
76
|
|
43
|
-
|
77
|
+
### as SVG
|
78
|
+
|
79
|
+
The SVG renderer will produce a stand-alone SVG as a `String`
|
44
80
|
|
45
81
|
```ruby
|
46
82
|
require 'rqrcode'
|
47
83
|
|
48
84
|
qrcode = RQRCode::QRCode.new("http://github.com/")
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
85
|
+
|
86
|
+
# NOTE: showing with default options specified explicitly
|
87
|
+
svg = qrcode.as_svg(
|
88
|
+
offset: 0,
|
89
|
+
color: '000',
|
90
|
+
shape_rendering: 'crispEdges',
|
91
|
+
module_size: 6,
|
92
|
+
standalone: true
|
93
|
+
)
|
53
94
|
```
|
54
95
|
|
55
|
-
|
56
|
-
### SVG
|
96
|
+

|
57
97
|
|
58
|
-
|
98
|
+
### as ANSI
|
99
|
+
|
100
|
+
The ANSI renderer will produce as a string with ANSI color codes.
|
59
101
|
|
60
102
|
```ruby
|
103
|
+
require 'rqrcode'
|
104
|
+
|
61
105
|
qrcode = RQRCode::QRCode.new("http://github.com/")
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
106
|
+
|
107
|
+
# NOTE: showing with default options specified explicitly
|
108
|
+
svg = qrcode.as_ansi(
|
109
|
+
light: "\033[47m", dark: "\033[40m",
|
110
|
+
fill_character: ' ',
|
111
|
+
quiet_zone_size: 4
|
112
|
+
)
|
66
113
|
```
|
67
114
|
|
68
|
-
|
115
|
+

|
116
|
+
|
117
|
+
### as PNG
|
69
118
|
|
70
119
|
The library can produce a PNG. Result will be a `ChunkyPNG::Image` instance.
|
71
120
|
|
72
121
|
```ruby
|
122
|
+
require 'rqrcode'
|
123
|
+
|
73
124
|
qrcode = RQRCode::QRCode.new("http://github.com/")
|
74
|
-
# With default options specified explicitly
|
75
|
-
png = qrcode.as_png(
|
76
|
-
resize_gte_to: false,
|
77
|
-
resize_exactly_to: false,
|
78
|
-
fill: 'white',
|
79
|
-
color: 'black',
|
80
|
-
size: 120,
|
81
|
-
border_modules: 4,
|
82
|
-
module_px_size: 6,
|
83
|
-
file: nil # path to write
|
84
|
-
)
|
85
|
-
```
|
86
125
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
126
|
+
# NOTE: showing with default options specified explicitly
|
127
|
+
png = qrcode.as_png(
|
128
|
+
bit_depth: 1,
|
129
|
+
border_modules: 4,
|
130
|
+
color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
131
|
+
color: 'black',
|
132
|
+
file: nil,
|
133
|
+
fill: 'white',
|
134
|
+
module_px_size: 6,
|
135
|
+
resize_exactly_to: false,
|
136
|
+
resize_gte_to: false,
|
137
|
+
size: 120
|
138
|
+
)
|
139
|
+
|
140
|
+
IO.write("/tmp/github-qrcode.png", png.to_s)
|
91
141
|
```
|
92
142
|
|
93
|
-
|
94
|
-
```html
|
95
|
-
<%= raw @qr.as_html %>
|
96
|
-
```
|
143
|
+

|
97
144
|
|
98
|
-
###
|
99
|
-
```css
|
100
|
-
table {
|
101
|
-
border-width: 0;
|
102
|
-
border-style: none;
|
103
|
-
border-color: #0000ff;
|
104
|
-
border-collapse: collapse;
|
105
|
-
}
|
106
|
-
|
107
|
-
td {
|
108
|
-
border-left: solid 10px #000;
|
109
|
-
padding: 0;
|
110
|
-
margin: 0;
|
111
|
-
width: 0px;
|
112
|
-
height: 10px;
|
113
|
-
}
|
114
|
-
|
115
|
-
td.black { border-color: #000; }
|
116
|
-
td.white { border-color: #fff; }
|
117
|
-
```
|
118
|
-
|
119
|
-
## On the console
|
145
|
+
### On the console ( just because you can )
|
120
146
|
|
121
147
|
```ruby
|
122
|
-
|
148
|
+
require 'rqrcode'
|
149
|
+
|
150
|
+
qr = RQRCode::QRCode.new('http://kyan.com', size: 4, level: :h)
|
151
|
+
|
123
152
|
puts qr.to_s
|
124
153
|
```
|
125
154
|
|
126
155
|
Output:
|
127
156
|
|
128
157
|
```
|
129
|
-
xxxxxxx
|
130
|
-
x x
|
131
|
-
x xxx x
|
132
|
-
|
158
|
+
xxxxxxx x x xxx xxxxxxx
|
159
|
+
x x xxxxx x x x x
|
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
|
133
164
|
```
|
134
165
|
|
135
|
-
##
|
136
|
-
```ruby
|
137
|
-
qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )
|
138
|
-
qr.modules.each do |row|
|
139
|
-
row.each do |col|
|
140
|
-
print col ? "X" : " "
|
141
|
-
end
|
142
|
-
print "\n"
|
143
|
-
end
|
144
|
-
```
|
145
|
-
|
146
|
-
## Specifying QR code mode
|
166
|
+
## API Documentation
|
147
167
|
|
148
|
-
|
168
|
+
[http://www.rubydoc.info/gems/rqrcode](http://www.rubydoc.info/gems/rqrcode)
|
149
169
|
|
150
|
-
|
170
|
+
## Contributing
|
171
|
+
* Fork the project
|
172
|
+
* Send a pull request
|
173
|
+
* Don't touch the .gemspec, I'll do that when I release a new version
|
151
174
|
|
152
|
-
|
153
|
-
qr = RQRCode::QRCode.new( '1234567890', :size => 2, :level => :m, :mode => :number )
|
154
|
-
```
|
175
|
+
## Authors
|
155
176
|
|
177
|
+
Original RQRCode author: Duncan Robertson
|
156
178
|
|
157
|
-
|
179
|
+
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.
|
158
180
|
|
159
|
-
|
181
|
+
Oh, and thanks to my bosses at https://kyan.com for giving me time to maintain this project.
|
160
182
|
|
161
183
|
## Resources
|
162
184
|
|
@@ -164,25 +186,6 @@ qr = RQRCode::QRCode.new( '1234567890', :size => 2, :level => :m, :mode => :numb
|
|
164
186
|
* Denso-Wave website:: http://www.denso-wave.com/qrcode/index-e.html
|
165
187
|
* kaywa:: http://qrcode.kaywa.com
|
166
188
|
|
167
|
-
## Authors
|
168
|
-
|
169
|
-
Original author: Duncan Robertson
|
170
|
-
|
171
|
-
Special thanks to the following people for submitting patches:
|
172
|
-
|
173
|
-
* [Chris Mowforth](http://blog.99th.st)
|
174
|
-
* [Daniel Schierbeck](https://github.com/dasch)
|
175
|
-
* [Gioele Barabucci](https://github.com/gioele)
|
176
|
-
* [Ken Collins](https://github.com/metaskills)
|
177
|
-
* [Rob la Lau](https://github.com/ohreally)
|
178
|
-
* [Tore Darell](http://tore.darell.no)
|
179
|
-
* Vladislav Gorodetskiy
|
180
|
-
|
181
|
-
## Contributing
|
182
|
-
* Fork the project
|
183
|
-
* Send a pull request
|
184
|
-
* Don't touch the .gemspec, I'll do that when I release a new version
|
185
|
-
|
186
189
|
## Copyright
|
187
190
|
|
188
191
|
MIT License (http://www.opensource.org/licenses/mit-license.html)
|
data/Rakefile
CHANGED
@@ -1,14 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
t.libs << 'lib'
|
9
|
-
t.libs << 'test'
|
10
|
-
t.pattern = 'test/**/test_*.rb'
|
11
|
-
t.verbose = true
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.libs << "lib"
|
7
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
12
8
|
end
|
13
9
|
|
14
|
-
task :default =>
|
10
|
+
task :default => :test
|
data/_config.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
theme: jekyll-theme-slate
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rqrcode"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|