rqrcode 0.8.2 → 1.0.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 +20 -0
- data/.gitignore +9 -1
- data/Gemfile +3 -8
- data/LICENSE.txt +21 -0
- data/README.md +121 -123
- data/Rakefile +6 -10
- 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/{test/helper.rb → lib/rqrcode/export.rb} +3 -6
- data/lib/rqrcode/export/ansi.rb +77 -0
- data/lib/rqrcode/export/html.rb +6 -8
- data/lib/rqrcode/export/png.rb +18 -19
- 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 +62 -55
- data/.travis.yml +0 -7
- data/CHANGELOG +0 -84
- 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 -492
- 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_regresions.rb +0 -10
- data/test/test_rqrcode.rb +0 -125
- 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: 0db16b2bfb687e737b0059398da5727e95ded9567b62027639069c5b52b1924a
|
4
|
+
data.tar.gz: 29b82466d2dd00f773968b6d9219643e3801dadfae0dea062eb7c1a5de3c6295
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90c75c5fc56d6d64be3b4896e40227a25394d7206c3afe3fe6940b7d91a2ecf1b7a158b9f096a0a7ab1e3d36ef6c65cd92fc9e77642e550dc53bc90c3452e711
|
7
|
+
data.tar.gz: 04f456be8601ea85f3fe79a4fb4f97a04dc23d93437719e5fceb24e4ba386572b33c87820c8a1f9102d6ad4f7c69cde25f9396da6e278bf50c629ad6f4eaa111
|
@@ -0,0 +1,20 @@
|
|
1
|
+
name: rqrcode
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v1
|
12
|
+
- name: Set up Ruby 2.6
|
13
|
+
uses: actions/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
ruby-version: 2.6.x
|
16
|
+
- name: Build and test with Rake
|
17
|
+
run: |
|
18
|
+
gem install bundler
|
19
|
+
bundle install --jobs 4 --retry 3
|
20
|
+
bundle exec rake test
|
data/.gitignore
CHANGED
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,165 +1,182 @@
|
|
1
|
-
#
|
1
|
+
# RQRCode
|
2
2
|
|
3
|
-
|
3
|
+
![](https://github.com/whomwah/rqrcode/workflows/rqrcode/badge.svg)
|
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)
|
10
11
|
|
11
|
-
|
12
|
+
## Installing
|
12
13
|
|
13
|
-
|
14
|
+
Add this line to your application's `Gemfile`:
|
14
15
|
|
15
|
-
|
16
|
-
|
16
|
+
```ruby
|
17
|
+
gem 'rqrcode'
|
18
|
+
```
|
17
19
|
|
18
|
-
|
20
|
+
or install manually:
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
+
```ruby
|
23
|
+
gem install rqrcode
|
24
|
+
```
|
22
25
|
|
23
|
-
|
26
|
+
## Basic usage example
|
24
27
|
|
25
|
-
|
28
|
+
```ruby
|
29
|
+
require 'rqrcode'
|
26
30
|
|
27
|
-
|
31
|
+
qr = RQRCode::QRCode.new('http://github.com')
|
32
|
+
result = ''
|
28
33
|
|
29
|
-
|
34
|
+
qr.qrcode.modules.each do |row|
|
35
|
+
row.each do |col|
|
36
|
+
result << (col ? 'X' : 'O')
|
37
|
+
end
|
30
38
|
|
31
|
-
|
39
|
+
result << "\n"
|
40
|
+
end
|
32
41
|
|
33
|
-
|
34
|
-
|
35
|
-
* The interface is simple and assumes you just want to encode a string into a QR code
|
36
|
-
* QR code is trademarked by Denso Wave inc
|
42
|
+
puts result
|
43
|
+
```
|
37
44
|
|
38
|
-
|
45
|
+
### Advanced Options
|
39
46
|
|
40
|
-
|
47
|
+
These are the various QR Code generation options provided by [rqrqcode_core](https://github.com/whomwah/rqrcode_core).
|
41
48
|
|
42
|
-
```ruby
|
43
|
-
gem install rqrcode
|
44
49
|
```
|
50
|
+
string - the string you wish to encode
|
51
|
+
|
52
|
+
size - the size of the qrcode (default 4)
|
45
53
|
|
46
|
-
|
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:
|
76
|
+
|
77
|
+
### as SVG
|
78
|
+
|
79
|
+
The SVG renderer will produce a stand-alone SVG as a `String`
|
47
80
|
|
48
81
|
```ruby
|
49
82
|
require 'rqrcode'
|
50
83
|
|
51
84
|
qrcode = RQRCode::QRCode.new("http://github.com/")
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
+
)
|
56
94
|
```
|
57
95
|
|
58
|
-
|
59
|
-
### SVG
|
96
|
+
![QR code with github url](./images/github-qrcode.svg)
|
60
97
|
|
61
|
-
|
98
|
+
### as ANSI
|
99
|
+
|
100
|
+
The ANSI renderer will produce as a string with ANSI color codes.
|
62
101
|
|
63
102
|
```ruby
|
103
|
+
require 'rqrcode'
|
104
|
+
|
64
105
|
qrcode = RQRCode::QRCode.new("http://github.com/")
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
+
)
|
69
113
|
```
|
70
114
|
|
71
|
-
|
115
|
+
![QR code with github url](./images/ansi-screen-shot.png)
|
116
|
+
|
117
|
+
### as PNG
|
72
118
|
|
73
119
|
The library can produce a PNG. Result will be a `ChunkyPNG::Image` instance.
|
74
120
|
|
75
121
|
```ruby
|
122
|
+
require 'rqrcode'
|
123
|
+
|
76
124
|
qrcode = RQRCode::QRCode.new("http://github.com/")
|
77
|
-
|
125
|
+
|
126
|
+
# NOTE: showing with default options specified explicitly
|
78
127
|
png = qrcode.as_png(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
128
|
+
resize_gte_to: false,
|
129
|
+
resize_exactly_to: false,
|
130
|
+
fill: 'white',
|
131
|
+
color: 'black',
|
132
|
+
size: 120,
|
133
|
+
border_modules: 4,
|
134
|
+
module_px_size: 6,
|
135
|
+
file: nil # path to write
|
136
|
+
)
|
137
|
+
|
138
|
+
IO.write("/tmp/github-qrcode.png", png.to_s)
|
88
139
|
```
|
89
140
|
|
90
|
-
|
91
|
-
### In your controller
|
92
|
-
```ruby
|
93
|
-
@qr = RQRCode::QRCode.new( 'https://github.com/whomwah/rqrcode', :size => 4, :level => :h )
|
94
|
-
```
|
141
|
+
![QR code with github url](./images/github-qrcode.png)
|
95
142
|
|
96
|
-
###
|
97
|
-
```html
|
98
|
-
<%= raw @qr.as_html %>
|
99
|
-
```
|
100
|
-
|
101
|
-
### CSS
|
102
|
-
```css
|
103
|
-
table {
|
104
|
-
border-width: 0;
|
105
|
-
border-style: none;
|
106
|
-
border-color: #0000ff;
|
107
|
-
border-collapse: collapse;
|
108
|
-
}
|
109
|
-
|
110
|
-
td {
|
111
|
-
border-left: solid 10px #000;
|
112
|
-
padding: 0;
|
113
|
-
margin: 0;
|
114
|
-
width: 0px;
|
115
|
-
height: 10px;
|
116
|
-
}
|
117
|
-
|
118
|
-
td.black { border-color: #000; }
|
119
|
-
td.white { border-color: #fff; }
|
120
|
-
```
|
121
|
-
|
122
|
-
## On the console
|
143
|
+
### On the console ( just because you can )
|
123
144
|
|
124
145
|
```ruby
|
125
|
-
|
146
|
+
require 'rqrcode'
|
147
|
+
|
148
|
+
qr = RQRCode::QRCode.new('http://kyan.com', size: 4, level: :h)
|
149
|
+
|
126
150
|
puts qr.to_s
|
127
151
|
```
|
128
152
|
|
129
153
|
Output:
|
130
154
|
|
131
155
|
```
|
132
|
-
xxxxxxx
|
133
|
-
x x
|
134
|
-
x xxx x
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
## Doing your own rendering
|
139
|
-
```ruby
|
140
|
-
qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )
|
141
|
-
qr.modules.each do |row|
|
142
|
-
row.each do |col|
|
143
|
-
print col ? "X" : " "
|
144
|
-
end
|
145
|
-
print "\n"
|
146
|
-
end
|
156
|
+
xxxxxxx x x xxx xxxxxxx
|
157
|
+
x x xxxxx x x x x
|
158
|
+
x xxx x x x x x xxx x
|
159
|
+
x xxx x xxx x xxx x xxx x
|
160
|
+
x xxx x xxx x x x x xxx x
|
161
|
+
... etc
|
147
162
|
```
|
148
163
|
|
149
|
-
##
|
164
|
+
## API Documentation
|
150
165
|
|
151
|
-
|
166
|
+
[http://www.rubydoc.info/gems/rqrcode](http://www.rubydoc.info/gems/rqrcode)
|
152
167
|
|
153
|
-
|
168
|
+
## Contributing
|
169
|
+
* Fork the project
|
170
|
+
* Send a pull request
|
171
|
+
* Don't touch the .gemspec, I'll do that when I release a new version
|
154
172
|
|
155
|
-
|
156
|
-
qr = RQRCode::QRCode.new( '1234567890', :size => 2, :level => :m, :mode => :number )
|
157
|
-
```
|
173
|
+
## Authors
|
158
174
|
|
175
|
+
Original RQRCode author: Duncan Robertson
|
159
176
|
|
160
|
-
|
177
|
+
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.
|
161
178
|
|
162
|
-
|
179
|
+
Oh, and thanks to my bosses at https://kyan.com for giving me time to maintain this project.
|
163
180
|
|
164
181
|
## Resources
|
165
182
|
|
@@ -167,25 +184,6 @@ qr = RQRCode::QRCode.new( '1234567890', :size => 2, :level => :m, :mode => :numb
|
|
167
184
|
* Denso-Wave website:: http://www.denso-wave.com/qrcode/index-e.html
|
168
185
|
* kaywa:: http://qrcode.kaywa.com
|
169
186
|
|
170
|
-
## Authors
|
171
|
-
|
172
|
-
Original author: Duncan Robertson
|
173
|
-
|
174
|
-
Special thanks to the following people for submitting patches:
|
175
|
-
|
176
|
-
* [Chris Mowforth](http://blog.99th.st)
|
177
|
-
* [Daniel Schierbeck](https://github.com/dasch)
|
178
|
-
* [Gioele Barabucci](https://github.com/gioele)
|
179
|
-
* [Ken Collins](https://github.com/metaskills)
|
180
|
-
* [Rob la Lau](https://github.com/ohreally)
|
181
|
-
* [Tore Darell](http://tore.darell.no)
|
182
|
-
* Vladislav Gorodetskiy
|
183
|
-
|
184
|
-
## Contributing
|
185
|
-
* Fork the project
|
186
|
-
* Send a pull request
|
187
|
-
* Don't touch the .gemspec, I'll do that when I release a new version
|
188
|
-
|
189
187
|
## Copyright
|
190
188
|
|
191
189
|
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
|
-
desc "Run tests"
|
7
|
-
Rake::TestTask.new do |t|
|
8
|
-
t.libs << "lib"
|
4
|
+
Rake::TestTask.new(:test) do |t|
|
9
5
|
t.libs << "test"
|
10
|
-
t.
|
11
|
-
t.
|
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__)
|
data/bin/setup
ADDED
Binary file
|