rqrcode 0.8.2 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +20 -0
  3. data/.gitignore +9 -1
  4. data/Gemfile +3 -8
  5. data/LICENSE.txt +21 -0
  6. data/README.md +121 -123
  7. data/Rakefile +6 -10
  8. data/_config.yml +1 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/images/ansi-screen-shot.png +0 -0
  12. data/images/github-qrcode.png +0 -0
  13. data/images/github-qrcode.svg +32 -0
  14. data/lib/rqrcode.rb +7 -15
  15. data/{test/helper.rb → lib/rqrcode/export.rb} +3 -6
  16. data/lib/rqrcode/export/ansi.rb +77 -0
  17. data/lib/rqrcode/export/html.rb +6 -8
  18. data/lib/rqrcode/export/png.rb +18 -19
  19. data/lib/rqrcode/export/svg.rb +16 -7
  20. data/lib/rqrcode/qrcode.rb +3 -4
  21. data/lib/rqrcode/qrcode/qrcode.rb +17 -0
  22. data/lib/rqrcode/version.rb +3 -1
  23. data/rqrcode.gemspec +28 -24
  24. metadata +62 -55
  25. data/.travis.yml +0 -7
  26. data/CHANGELOG +0 -84
  27. data/LICENSE +0 -19
  28. data/TODO.md +0 -4
  29. data/lib/rqrcode/core_ext.rb +0 -5
  30. data/lib/rqrcode/core_ext/array.rb +0 -5
  31. data/lib/rqrcode/core_ext/array/behavior.rb +0 -12
  32. data/lib/rqrcode/core_ext/integer.rb +0 -5
  33. data/lib/rqrcode/core_ext/integer/bitwise.rb +0 -13
  34. data/lib/rqrcode/qrcode/qr_8bit_byte.rb +0 -36
  35. data/lib/rqrcode/qrcode/qr_alphanumeric.rb +0 -47
  36. data/lib/rqrcode/qrcode/qr_bit_buffer.rb +0 -99
  37. data/lib/rqrcode/qrcode/qr_code.rb +0 -492
  38. data/lib/rqrcode/qrcode/qr_math.rb +0 -63
  39. data/lib/rqrcode/qrcode/qr_numeric.rb +0 -66
  40. data/lib/rqrcode/qrcode/qr_polynomial.rb +0 -78
  41. data/lib/rqrcode/qrcode/qr_rs_block.rb +0 -314
  42. data/lib/rqrcode/qrcode/qr_util.rb +0 -272
  43. data/test/data.rb +0 -23
  44. data/test/test_regresions.rb +0 -10
  45. data/test/test_rqrcode.rb +0 -125
  46. data/test/test_rqrcode_export.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 537c13caf3f8d2e6896f4c4ca2e8f49aefd5a873
4
- data.tar.gz: a9ec155978d80c75928cc8a952b010f8682ad2dc
2
+ SHA256:
3
+ metadata.gz: 0db16b2bfb687e737b0059398da5727e95ded9567b62027639069c5b52b1924a
4
+ data.tar.gz: 29b82466d2dd00f773968b6d9219643e3801dadfae0dea062eb7c1a5de3c6295
5
5
  SHA512:
6
- metadata.gz: c9e472adeef166c9030acc1d3b12b3cff3578ac6283551c60822bf02178b2ab74ab82fb60178ac94b1260d73d14f8f3dbe9c540d9244d2c07a55094d216a5f24
7
- data.tar.gz: 7ea7baac645ccb7cff2dc714ff3127a9d7bdbd19e347f889efba97a04a8489ff39c0a8038e174bfe29b5ff07794c2b75cdb7d581ecb017df6d867bcca4b9b9b8
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
@@ -1,5 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
1
6
  /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /.devcontainer/
2
10
  .rvmrc
3
- Gemfile.lock
4
11
  *.sublime-project
5
12
  *.sublime-workspace
13
+ Gemfile.lock
data/Gemfile CHANGED
@@ -1,9 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
- gem "chunky_png", "~> 1.0"
4
-
5
- group :test, :development do
6
- gem 'rake'
7
- gem 'test-unit'
8
- gem 'minitest'
9
- end
3
+ # Specify your gem's dependencies in rqrcode-base.gemspec
4
+ gemspec
@@ -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
- # rQRCode, Encode QRCodes
1
+ # RQRCode
2
2
 
3
- [![Build Status](https://travis-ci.org/whomwah/rqrcode.svg?branch=master)](https://travis-ci.org/whomwah/rqrcode)
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
- ## Short changelog
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
- *0.8.2* (Jan 3, 2016)
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
- - Fix source encoding problem introduced in 0.8.1
12
+ ## Installing
12
13
 
13
- *0.8.1* (Jan 3, 2016)
14
+ Add this line to your application's `Gemfile`:
14
15
 
15
- - Remove active support specific `present?`.
16
- - Fix so that all tests are run.
16
+ ```ruby
17
+ gem 'rqrcode'
18
+ ```
17
19
 
18
- *0.8.0* (Dec 18, 2015)
20
+ or install manually:
19
21
 
20
- - Added numeric QR code support
21
- - Dropped Ruby v1.8 support
22
+ ```ruby
23
+ gem install rqrcode
24
+ ```
22
25
 
23
- *0.7.0* (Aug 15, 2015)
26
+ ## Basic usage example
24
27
 
25
- - Added shape_rendering option for as_svg
28
+ ```ruby
29
+ require 'rqrcode'
26
30
 
27
- ## Overview
31
+ qr = RQRCode::QRCode.new('http://github.com')
32
+ result = ''
28
33
 
29
- rQRCode is a library for encoding QR Codes in Ruby. It has a simple interface with all the standard qrcode options. It was adapted from the Javascript library by Kazuhiko Arase.
34
+ qr.qrcode.modules.each do |row|
35
+ row.each do |col|
36
+ result << (col ? 'X' : 'O')
37
+ end
30
38
 
31
- Let's clear up some rQRCode stuff.
39
+ result << "\n"
40
+ end
32
41
 
33
- * rQRCode is a __standalone library__ It requires no other libraries. Just Ruby!
34
- * It is an encoding library. You can't decode QR codes with it.
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
- ## Installing
45
+ ### Advanced Options
39
46
 
40
- You may get the latest stable version from Rubygems.
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
- ## Using rQRCode
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
- image = qrcode.as_png
53
- svg = qrcode.as_svg
54
- html = qrcode.as_html
55
- string = qrcode.to_s
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
- ## Image Rendering
59
- ### SVG
96
+ ![QR code with github url](./images/github-qrcode.svg)
60
97
 
61
- The SVG renderer will produce a stand-alone SVG as a `String`
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
- # With default options specified explicitly
66
- svg = qrcode.as_svg(offset: 0, color: '000',
67
- shape_rendering: 'crispEdges',
68
- module_size: 11)
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
- ### PNG
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
- # With default options specified explicitly
125
+
126
+ # NOTE: showing with default options specified explicitly
78
127
  png = qrcode.as_png(
79
- resize_gte_to: false,
80
- resize_exactly_to: false,
81
- fill: 'white',
82
- color: 'black',
83
- size: 120,
84
- border_modules: 4,
85
- module_px_size: 6,
86
- file: nil # path to write
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
- ## HTML Rendering
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
- ### In your view
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
- qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )
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 x x x x x xx xxxxxxx
133
- x x xxx xxxxxx xxx x x
134
- x xxx x xxxxx x xx x xxx x
135
- ... etc
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
- ## Specifying QR code mode
164
+ ## API Documentation
150
165
 
151
- Sometimes you may want to specify the QR code mode explicitly.
166
+ [http://www.rubydoc.info/gems/rqrcode](http://www.rubydoc.info/gems/rqrcode)
152
167
 
153
- It is done via the `mode` option. Allowed values are: `number`, `alphanumeric` and `byte_8bit`.
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
- ```ruby
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
- ## API Documentation
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
- [http://www.rubydoc.info/gems/rqrcode](http://www.rubydoc.info/gems/rqrcode)
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 'rake/testtask'
2
- require 'bundler'
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
3
 
4
- Bundler::GemHelper.install_tasks
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.pattern = "test/**/test_*.rb"
11
- t.verbose = true
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
12
8
  end
13
9
 
14
- task :default => [:test]
10
+ task :default => :test
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-slate
@@ -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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here