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.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +31 -0
  3. data/.gitignore +9 -1
  4. data/.rspec +2 -0
  5. data/Gemfile +3 -8
  6. data/LICENSE.txt +21 -0
  7. data/README.md +125 -122
  8. data/Rakefile +7 -11
  9. data/_config.yml +1 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/images/ansi-screen-shot.png +0 -0
  13. data/images/github-qrcode.png +0 -0
  14. data/images/github-qrcode.svg +32 -0
  15. data/lib/rqrcode.rb +7 -15
  16. data/lib/rqrcode/export.rb +6 -0
  17. data/lib/rqrcode/export/ansi.rb +77 -0
  18. data/lib/rqrcode/export/html.rb +6 -8
  19. data/lib/rqrcode/export/png.rb +40 -31
  20. data/lib/rqrcode/export/svg.rb +16 -7
  21. data/lib/rqrcode/qrcode.rb +3 -4
  22. data/lib/rqrcode/qrcode/qrcode.rb +17 -0
  23. data/lib/rqrcode/version.rb +3 -1
  24. data/rqrcode.gemspec +28 -24
  25. metadata +67 -59
  26. data/.travis.yml +0 -7
  27. data/CHANGELOG +0 -85
  28. data/LICENSE +0 -19
  29. data/TODO.md +0 -4
  30. data/lib/rqrcode/core_ext.rb +0 -5
  31. data/lib/rqrcode/core_ext/array.rb +0 -5
  32. data/lib/rqrcode/core_ext/array/behavior.rb +0 -12
  33. data/lib/rqrcode/core_ext/integer.rb +0 -5
  34. data/lib/rqrcode/core_ext/integer/bitwise.rb +0 -13
  35. data/lib/rqrcode/qrcode/qr_8bit_byte.rb +0 -36
  36. data/lib/rqrcode/qrcode/qr_alphanumeric.rb +0 -47
  37. data/lib/rqrcode/qrcode/qr_bit_buffer.rb +0 -99
  38. data/lib/rqrcode/qrcode/qr_code.rb +0 -585
  39. data/lib/rqrcode/qrcode/qr_math.rb +0 -63
  40. data/lib/rqrcode/qrcode/qr_numeric.rb +0 -66
  41. data/lib/rqrcode/qrcode/qr_polynomial.rb +0 -78
  42. data/lib/rqrcode/qrcode/qr_rs_block.rb +0 -314
  43. data/lib/rqrcode/qrcode/qr_util.rb +0 -272
  44. data/test/data.rb +0 -23
  45. data/test/test_helper.rb +0 -5
  46. data/test/test_regresions.rb +0 -10
  47. data/test/test_rqrcode.rb +0 -155
  48. data/test/test_rqrcode_export.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1e8b487f591272b08e4fc7379f8ff16a7819459e
4
- data.tar.gz: 5fc8e96a42d136b0cd76941d8a77316d207208e9
2
+ SHA256:
3
+ metadata.gz: 818b3dab2ed7719eb45d3c4b02704258e92f4de8ec0fe4f7e9cbb62765aad507
4
+ data.tar.gz: 50efa7d1fe21cce41ea38d44b4864290110281fcfc6c575267550440acb7f41a
5
5
  SHA512:
6
- metadata.gz: e2c4d056dc95bca8bb1a268567a0f19a3d48eaaa96d6888874ee4abde3d85db7d6ae3197e840e2085651fb0ebd8ded890421174816a75d12052a29b41bfb3895
7
- data.tar.gz: b435943576d8a4c458e7392f0d7a69ed27a7ec3a05bc449523f2141b87e5f8c03e2fca35ce8ba64887787667d65c854655e2ec8449b1e2565daa40a1ad6f94a5
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
@@ -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/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
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,162 +1,184 @@
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.9.0* (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)
11
+
12
+ ## Installing
10
13
 
11
- - Added support for auto selecting qrcode size up to level 40. (only worked up to level 10 before)
12
- - Added numeric support during auto selection of qrcode mode.
14
+ Add this line to your application's `Gemfile`:
13
15
 
14
- *0.8.1* (Jan 3, 2016)
16
+ ```ruby
17
+ gem 'rqrcode'
18
+ ```
15
19
 
16
- - Remove active support specific `present?`.
17
- - Fix so that all tests are run.
20
+ or install manually:
21
+
22
+ ```ruby
23
+ gem install rqrcode
24
+ ```
18
25
 
19
- *0.8.0* (Dec 18, 2015)
26
+ ## Basic usage example
20
27
 
21
- - Added numeric QR code support
22
- - Dropped Ruby v1.8 support
28
+ ```ruby
29
+ require 'rqrcode'
23
30
 
24
- ## Overview
31
+ qr = RQRCode::QRCode.new('http://github.com')
32
+ result = ''
25
33
 
26
- 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
27
38
 
28
- Let's clear up some rQRCode stuff.
39
+ result << "\n"
40
+ end
29
41
 
30
- * rQRCode is a __ruby only library__ It requires no native libraries. Just Ruby!
31
- * It is an encoding library. You can't decode QR codes with it.
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
- ## Installing
45
+ ### Advanced Options
36
46
 
37
- 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).
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
- ## Using rQRCode
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
- image = qrcode.as_png
50
- svg = qrcode.as_svg
51
- html = qrcode.as_html
52
- 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
+ )
53
94
  ```
54
95
 
55
- ## Image Rendering
56
- ### SVG
96
+ ![QR code with github url](./images/github-qrcode.svg)
57
97
 
58
- 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.
59
101
 
60
102
  ```ruby
103
+ require 'rqrcode'
104
+
61
105
  qrcode = RQRCode::QRCode.new("http://github.com/")
62
- # With default options specified explicitly
63
- svg = qrcode.as_svg(offset: 0, color: '000',
64
- shape_rendering: 'crispEdges',
65
- 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
+ )
66
113
  ```
67
114
 
68
- ### PNG
115
+ ![QR code with github url](./images/ansi-screen-shot.png)
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
- ## HTML Rendering
88
- ### In your controller
89
- ```ruby
90
- @qr = RQRCode::QRCode.new( 'https://github.com/whomwah/rqrcode', :size => 4, :level => :h )
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
- ### In your view
94
- ```html
95
- <%= raw @qr.as_html %>
96
- ```
143
+ ![QR code with github url](./images/github-qrcode.png)
97
144
 
98
- ### CSS
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
- qr = RQRCode::QRCode.new( 'my string to generate', :size => 4, :level => :h )
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 x x x x x xx xxxxxxx
130
- x x xxx xxxxxx xxx x x
131
- x xxx x xxxxx x xx x xxx x
132
- ... etc
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
- ## Doing your own rendering
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
- Sometimes you may want to specify the QR code mode explicitly.
168
+ [http://www.rubydoc.info/gems/rqrcode](http://www.rubydoc.info/gems/rqrcode)
149
169
 
150
- It is done via the `mode` option. Allowed values are: `number`, `alphanumeric` and `byte_8bit`.
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
- ```ruby
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
- ## API Documentation
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
- [http://www.rubydoc.info/gems/rqrcode](http://www.rubydoc.info/gems/rqrcode)
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 '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'
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 => [: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__)