rqrcode 1.0.1 → 1.1.1
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 +17 -6
- data/.rspec +2 -0
- data/README.md +8 -6
- data/lib/rqrcode/export/png.rb +25 -15
- data/lib/rqrcode/version.rb +1 -1
- data/rqrcode.gemspec +4 -4
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
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
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,19 +1,30 @@
|
|
1
1
|
name: rqrcode
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
- release/*
|
8
|
+
pull_request:
|
9
|
+
branches:
|
10
|
+
- master
|
4
11
|
|
5
12
|
jobs:
|
6
13
|
build:
|
7
|
-
|
8
|
-
runs-on:
|
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]
|
9
20
|
|
10
21
|
steps:
|
11
22
|
- uses: actions/checkout@v1
|
12
|
-
- name:
|
23
|
+
- name: Use Ruby ${{ matrix.ruby_version }}
|
13
24
|
uses: actions/setup-ruby@v1
|
14
25
|
with:
|
15
|
-
ruby-version:
|
16
|
-
- name:
|
26
|
+
ruby-version: ${{ matrix.ruby_version }}
|
27
|
+
- name: Gem install and test
|
17
28
|
run: |
|
18
29
|
gem install bundler
|
19
30
|
bundle install --jobs 4 --retry 3
|
data/.rspec
ADDED
data/README.md
CHANGED
@@ -125,14 +125,16 @@ 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
140
|
IO.write("/tmp/github-qrcode.png", png.to_s)
|
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/version.rb
CHANGED
data/rqrcode.gemspec
CHANGED
@@ -29,8 +29,8 @@ EOF
|
|
29
29
|
|
30
30
|
spec.required_ruby_version = '~> 2.3'
|
31
31
|
spec.add_dependency 'rqrcode_core', '~> 0.1.0'
|
32
|
-
spec.add_dependency 'chunky_png',
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
32
|
+
spec.add_dependency 'chunky_png', '~> 1.0'
|
33
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
34
|
+
spec.add_development_dependency 'rake', '~> 12.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.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duncan Robertson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rqrcode_core
|
@@ -67,19 +67,19 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '12.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
|
@@ -92,6 +92,7 @@ extra_rdoc_files: []
|
|
92
92
|
files:
|
93
93
|
- ".github/workflows/ruby.yml"
|
94
94
|
- ".gitignore"
|
95
|
+
- ".rspec"
|
95
96
|
- Gemfile
|
96
97
|
- LICENSE.txt
|
97
98
|
- README.md
|