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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb970ba18e7c0c2d194a661f91c5b18be86f9b9f
4
- data.tar.gz: aec91a7e72a9e9b0c9d35ff1f38e72ee4b9afd95
3
+ metadata.gz: e65e64a86710bff21654b860fa52152324c700b5
4
+ data.tar.gz: 615bf8c272a2db0688c0f83f51119eb8350a008d
5
5
  SHA512:
6
- metadata.gz: e1ce4c77f9c5f6f3f40c1be2848546e41af9319cd2152bf855927557d78ab15815ce77e277fd4dd0e0aefcae0a453ecac8ea3fd90f1a624159cfad15df645cd3
7
- data.tar.gz: 78dd22051997a54305d70dc1e5b65c1ae7c9ec1984b6ccc862b405fd0b5bdf83ad237f63b9bacf18334d6e8cfa6077c8e611071ce5965ffd2c4219f6e256eebf
6
+ metadata.gz: 31d465e61a9359e8af82f10880195e318edff3ebe9fb3837c013412725643568ad08ee49db7fb98ab05b061e0103d372c2a0c5ad8636babd9eb65a8fd207ea94
7
+ data.tar.gz: b309d96b83c2fa02cf7ad14d1d0aa0b9f80fadb82c6e724c765057b3aa903949567681386ce2cf7c3464aa40eafc40ce2b1698429c0905ffc6b54d208dc4f186
@@ -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
- RQRCode::QRCode.new(encoded_str(str), opts).as_png(png_opts)
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
@@ -1,3 +1,3 @@
1
1
  module RqrcodePngBin
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  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.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-14 00:00:00.000000000 Z
11
+ date: 2016-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rqrcode