rqrcode 1.0.0.pre → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +31 -0
- data/.rspec +2 -0
- data/README.md +29 -12
- data/lib/rqrcode/export/png.rb +25 -15
- data/lib/rqrcode/export/svg.rb +9 -1
- data/lib/rqrcode/qrcode/qrcode.rb +1 -1
- data/lib/rqrcode/version.rb +1 -1
- data/rqrcode.gemspec +6 -6
- metadata +17 -16
- data/Rakefile +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d8b2f0f6e33a545c3f0e5414b53eb5cffdc99138238d06118fbfec70d968c2e
|
4
|
+
data.tar.gz: 05df172d996fde577a4ce32504f243cd7d8feb440d70167d633c03956fa8d6e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73398ff5d4c89b362c850b6a293dace00e415738ec9944f4471d0d473dbbb7e0f8a9adec5026167a51535b619950487a556c126919045d1b289e949b82f2e171
|
7
|
+
data.tar.gz: 80c7718c260969fa52138620cd547d9c8564f9610dc951b1d06f4f4a2e20ac6979fca861b4ad6de22ef07e18daca15b86b187c5c963f47edeba24c99aa3fed5d
|
@@ -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 rspec
|
data/.rspec
ADDED
data/README.md
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
__UPDATE:__ A new pre-release has been made [v1.0.0.pre](https://github.com/whomwah/rqrcode/releases/tag/v1.0.0.pre). A fresh start after a _long_ pause. There is actually no new functionality in the release but there are some dependency changes. Minimum Ruby version is now `~> 2.3`. This release also cleans up the internals a bit. The core `QR Code` generation has been extracted into a new [rqrcode_core](https://github.com/whomwah/rqrcode_core) gem. This enables `qrqcode` to concentrate on rendering. Once `v1.0.0.pre` has had time for people to try I'll release `v1.0.0` of `rqrcode` and then concentrate on working through issues and PRs although I appreciate many of these may be old and out of date now! You can install this pre-release with `gem install rqrcode --pre` or `gem 'rqrcode', '>= 1.0.0.pre'` in your `Gemfile`.
|
2
|
-
|
3
|
-
|
4
1
|
# RQRCode
|
5
2
|
|
6
|
-
|
3
|
+
![](https://github.com/whomwah/rqrcode/workflows/rqrcode/badge.svg)
|
4
|
+
|
7
5
|
|
8
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.
|
9
7
|
|
10
8
|
* QR code is trademarked by Denso Wave inc
|
9
|
+
* Minimum Ruby version is `>= 2.3`
|
11
10
|
* For `rqrcode` releases `< 1.0.0` please use [this README](https://github.com/whomwah/rqrcode/blob/cd2732a68434e6197c219e6c8cbdadfce0c4c4f3/README.md)
|
12
11
|
|
13
12
|
## Installing
|
@@ -89,7 +88,8 @@ svg = qrcode.as_svg(
|
|
89
88
|
offset: 0,
|
90
89
|
color: '000',
|
91
90
|
shape_rendering: 'crispEdges',
|
92
|
-
module_size: 6
|
91
|
+
module_size: 6,
|
92
|
+
standalone: true
|
93
93
|
)
|
94
94
|
```
|
95
95
|
|
@@ -125,17 +125,19 @@ qrcode = RQRCode::QRCode.new("http://github.com/")
|
|
125
125
|
|
126
126
|
# NOTE: showing with default options specified explicitly
|
127
127
|
png = qrcode.as_png(
|
128
|
-
|
129
|
-
resize_exactly_to: false,
|
130
|
-
fill: 'white',
|
131
|
-
color: 'black',
|
132
|
-
size: 120,
|
128
|
+
bit_depth: 1,
|
133
129
|
border_modules: 4,
|
130
|
+
color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
131
|
+
color: 'black',
|
132
|
+
file: nil,
|
133
|
+
fill: 'white',
|
134
134
|
module_px_size: 6,
|
135
|
-
|
135
|
+
resize_exactly_to: false,
|
136
|
+
resize_gte_to: false,
|
137
|
+
size: 120
|
136
138
|
)
|
137
139
|
|
138
|
-
IO.
|
140
|
+
IO.binwrite("/tmp/github-qrcode.png", png.to_s)
|
139
141
|
```
|
140
142
|
|
141
143
|
![QR code with github url](./images/github-qrcode.png)
|
@@ -165,6 +167,21 @@ x xxx x xxx x x x x xxx x
|
|
165
167
|
|
166
168
|
[http://www.rubydoc.info/gems/rqrcode](http://www.rubydoc.info/gems/rqrcode)
|
167
169
|
|
170
|
+
## Tests
|
171
|
+
|
172
|
+
You can run the test suite using:
|
173
|
+
|
174
|
+
```
|
175
|
+
$ ./bin/setup
|
176
|
+
$ bundle exec rspec
|
177
|
+
```
|
178
|
+
|
179
|
+
or try the lib from the console with:
|
180
|
+
|
181
|
+
```
|
182
|
+
$ ./bin/console
|
183
|
+
```
|
184
|
+
|
168
185
|
## Contributing
|
169
186
|
* Fork the project
|
170
187
|
* Send a pull request
|
data/lib/rqrcode/export/png.rb
CHANGED
@@ -6,8 +6,7 @@ require 'chunky_png'
|
|
6
6
|
module RQRCode
|
7
7
|
module Export
|
8
8
|
module PNG
|
9
|
-
#
|
10
|
-
# Render the PNG from the Qrcode.
|
9
|
+
# Render the PNG from the QR Code.
|
11
10
|
#
|
12
11
|
# There are two sizing algoritams.
|
13
12
|
#
|
@@ -20,6 +19,12 @@ module RQRCode
|
|
20
19
|
# fill - Background ChunkyPNG::Color, defaults to 'white'
|
21
20
|
# color - Foreground ChunkyPNG::Color, defaults to 'black'
|
22
21
|
#
|
22
|
+
# When option :file is supplied you can use the following ChunkyPNG constraints
|
23
|
+
# color_mode - The color mode to use. Use one of the ChunkyPNG::COLOR_* constants. defaults to 'ChunkyPNG::COLOR_GRAYSCALE'
|
24
|
+
# bit_depth - The bit depth to use. This option is only used for indexed images. defaults to '1' bit
|
25
|
+
# interlace - Whether to use interlacing (true or false). defaults to ChunkyPNG default
|
26
|
+
# compression - The compression level for Zlib. This can be a value between 0 and 9, or a Zlib constant like Zlib::BEST_COMPRESSION, defaults to ChunkyPNG defaults
|
27
|
+
#
|
23
28
|
# *Googleis*
|
24
29
|
# size - Total size of PNG in pixels. The module size is calculated so it fits. (defaults to 90)
|
25
30
|
# border_modules - Width of white border around in modules. (defaults to 4).
|
@@ -35,24 +40,23 @@ module RQRCode
|
|
35
40
|
#
|
36
41
|
def as_png(options = {})
|
37
42
|
default_img_options = {
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
:
|
43
|
+
bit_depth: 1,
|
44
|
+
border_modules: 4,
|
45
|
+
color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
46
|
+
color: 'black',
|
47
|
+
file: false,
|
48
|
+
fill: 'white',
|
49
|
+
module_px_size: 6,
|
50
|
+
resize_exactly_to: false,
|
51
|
+
resize_gte_to: false,
|
52
|
+
size: 120
|
46
53
|
}
|
47
54
|
|
48
55
|
googleis = options.length == 0 || (options[:size] != nil)
|
49
|
-
|
50
56
|
options = default_img_options.merge(options) # reverse_merge
|
51
|
-
|
52
57
|
fill = ChunkyPNG::Color(options[:fill])
|
53
58
|
color = ChunkyPNG::Color(options[:color])
|
54
59
|
output_file = options[:file]
|
55
|
-
|
56
60
|
module_px_size = nil
|
57
61
|
border_px = nil
|
58
62
|
png = nil
|
@@ -103,10 +107,16 @@ module RQRCode
|
|
103
107
|
png = png.resize(resize_to, resize_to)
|
104
108
|
end
|
105
109
|
|
106
|
-
|
107
110
|
if output_file
|
108
|
-
|
111
|
+
constraints = {
|
112
|
+
color_mode: options[:color_mode],
|
113
|
+
bit_depth: options[:bit_depth]
|
114
|
+
}
|
115
|
+
constraints[:interlace] = options[:interlace] if options.has_key?(:interlace)
|
116
|
+
constraints[:compression] = options[:compression] if options.has_key?(:compression)
|
117
|
+
png.save(output_file, constraints)
|
109
118
|
end
|
119
|
+
|
110
120
|
png
|
111
121
|
end
|
112
122
|
end
|
data/lib/rqrcode/export/svg.rb
CHANGED
@@ -14,12 +14,15 @@ module RQRCode
|
|
14
14
|
# color - Foreground color for the code (e.g. "000000" or :black)
|
15
15
|
# module_size - The Pixel size of each module (e.g. 11)
|
16
16
|
# shape_rendering - Defaults to crispEdges
|
17
|
+
# standalone - wether to make this a full SVG file, or only svg to embed
|
18
|
+
# in other svg.
|
17
19
|
#
|
18
20
|
def as_svg(options={})
|
19
21
|
offset = options[:offset].to_i || 0
|
20
22
|
color = options[:color] || "000"
|
21
23
|
shape_rendering = options[:shape_rendering] || "crispEdges"
|
22
24
|
module_size = options[:module_size] || 11
|
25
|
+
standalone = options[:standalone].nil? ? true : options[:standalone]
|
23
26
|
|
24
27
|
# height and width dependent on offset and QR complexity
|
25
28
|
dimension = (@qrcode.module_count*module_size) + (2*offset)
|
@@ -45,7 +48,12 @@ module RQRCode
|
|
45
48
|
result.unshift %{<rect width="#{dimension}" height="#{dimension}" x="0" y="0" style="fill:##{options[:fill]}"/>}
|
46
49
|
end
|
47
50
|
|
48
|
-
|
51
|
+
if standalone
|
52
|
+
result.unshift(xml_tag, open_tag)
|
53
|
+
result << close_tag
|
54
|
+
end
|
55
|
+
|
56
|
+
result.join("\n")
|
49
57
|
end
|
50
58
|
end
|
51
59
|
end
|
data/lib/rqrcode/version.rb
CHANGED
data/rqrcode.gemspec
CHANGED
@@ -27,10 +27,10 @@ EOF
|
|
27
27
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
-
spec.required_ruby_version = '
|
31
|
-
spec.add_dependency 'rqrcode_core', '~> 0.
|
32
|
-
spec.add_dependency 'chunky_png',
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
30
|
+
spec.required_ruby_version = '>= 2.3'
|
31
|
+
spec.add_dependency 'rqrcode_core', '~> 0.2'
|
32
|
+
spec.add_dependency 'chunky_png', '~> 1.0'
|
33
|
+
spec.add_development_dependency 'bundler', '>= 2.0'
|
34
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
35
|
+
spec.add_development_dependency 'rspec', '~> 3.5'
|
36
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rqrcode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duncan Robertson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rqrcode_core
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: '0.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: '0.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: chunky_png
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '13.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '5
|
75
|
+
version: '3.5'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '5
|
82
|
+
version: '3.5'
|
83
83
|
description: |
|
84
84
|
rqrcode is a library for encoding QR Codes. The simple
|
85
85
|
interface allows you to create QR Code data structures
|
@@ -90,11 +90,12 @@ executables: []
|
|
90
90
|
extensions: []
|
91
91
|
extra_rdoc_files: []
|
92
92
|
files:
|
93
|
+
- ".github/workflows/ruby.yml"
|
93
94
|
- ".gitignore"
|
95
|
+
- ".rspec"
|
94
96
|
- Gemfile
|
95
97
|
- LICENSE.txt
|
96
98
|
- README.md
|
97
|
-
- Rakefile
|
98
99
|
- _config.yml
|
99
100
|
- bin/console
|
100
101
|
- bin/setup
|
@@ -121,16 +122,16 @@ require_paths:
|
|
121
122
|
- lib
|
122
123
|
required_ruby_version: !ruby/object:Gem::Requirement
|
123
124
|
requirements:
|
124
|
-
- - "
|
125
|
+
- - ">="
|
125
126
|
- !ruby/object:Gem::Version
|
126
127
|
version: '2.3'
|
127
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
128
129
|
requirements:
|
129
|
-
- - "
|
130
|
+
- - ">="
|
130
131
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
132
|
+
version: '0'
|
132
133
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
134
|
+
rubygems_version: 3.2.3
|
134
135
|
signing_key:
|
135
136
|
specification_version: 4
|
136
137
|
summary: A library to encode QR Codes
|