rqrcode_png_bin 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rqrcode_png_bin/app.rb +18 -1
- data/lib/rqrcode_png_bin/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e65e64a86710bff21654b860fa52152324c700b5
|
4
|
+
data.tar.gz: 615bf8c272a2db0688c0f83f51119eb8350a008d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31d465e61a9359e8af82f10880195e318edff3ebe9fb3837c013412725643568ad08ee49db7fb98ab05b061e0103d372c2a0c5ad8636babd9eb65a8fd207ea94
|
7
|
+
data.tar.gz: b309d96b83c2fa02cf7ad14d1d0aa0b9f80fadb82c6e724c765057b3aa903949567681386ce2cf7c3464aa40eafc40ce2b1698429c0905ffc6b54d208dc4f186
|
data/lib/rqrcode_png_bin/app.rb
CHANGED
@@ -13,6 +13,7 @@ module RqrcodePngBin
|
|
13
13
|
@px_per_module = nil
|
14
14
|
@size = 4
|
15
15
|
@stdin = nil
|
16
|
+
@try_larger = false
|
16
17
|
|
17
18
|
parser.parse!(@argv)
|
18
19
|
end
|
@@ -21,6 +22,7 @@ module RqrcodePngBin
|
|
21
22
|
def run
|
22
23
|
if file
|
23
24
|
FileReader.new(file).each {|str, dest|
|
25
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
24
26
|
open(dest, 'wb') {|f|
|
25
27
|
f.puts generate_png(str)
|
26
28
|
}
|
@@ -33,7 +35,19 @@ module RqrcodePngBin
|
|
33
35
|
end
|
34
36
|
|
35
37
|
def generate_png(str)
|
36
|
-
|
38
|
+
qr_opts = opts.dup
|
39
|
+
|
40
|
+
begin
|
41
|
+
RQRCode::QRCode.new(encoded_str(str), qr_opts).as_png(png_opts)
|
42
|
+
rescue RQRCode::QRCodeRunTimeError => e
|
43
|
+
if @try_larger && qr_opts[:size] < 40
|
44
|
+
qr_opts[:size] = qr_opts[:size] + 1
|
45
|
+
STDERR.puts "retrying #{str} with options #{qr_opts}"
|
46
|
+
retry
|
47
|
+
else
|
48
|
+
raise e
|
49
|
+
end
|
50
|
+
end
|
37
51
|
end
|
38
52
|
|
39
53
|
def encoded_str(str)
|
@@ -139,6 +153,9 @@ module RqrcodePngBin
|
|
139
153
|
raise ArgumentError, "option size should match #{re}"
|
140
154
|
end
|
141
155
|
}
|
156
|
+
opt.on('-t', '--try-larger') {|v|
|
157
|
+
@try_larger = true
|
158
|
+
}
|
142
159
|
end
|
143
160
|
end
|
144
161
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rqrcode_png_bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wtnabe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rqrcode
|