rqr 0.2.0-x86-mswin32 → 0.2.1-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.2.1 2008-08-15
2
+
3
+ * Block available
4
+ * Fixed document and website
5
+
1
6
  == 0.2.0 2008-08-13
2
7
 
3
8
  * Added win32 package
data/README.txt CHANGED
@@ -4,23 +4,20 @@
4
4
 
5
5
  == DESCRIPTION:
6
6
 
7
- A ruby library to create QR code image. Output: PS, JPEG, PNG, EPS, TIFF.
7
+ A ruby library to create QR code. Output: PS, JPEG, PNG, EPS, TIFF.
8
8
 
9
9
  == SYNOPSIS:
10
10
 
11
11
  require "rubygem"
12
- require "rqrcode"
12
+ require "rqr"
13
13
 
14
- qr = RQR::QRCode.new()
15
-
16
- #Define a file format with extensions.
17
- qr.save("http://www.google.com", "path/to/qrcode.jpg")
14
+ # Block is available from version 0.2.1
15
+ RQR::QRCode.create do |qr|
16
+ qr.save("http://www.amazon.com", "path/to/qrcode.jpg")
17
+ end
18
18
 
19
- #Define a file format with symbol.
20
- qr.save("http://www.yahoo.com", "path/to/qrcodefile", :png)
21
19
 
22
-
23
- #QRCode options
20
+ # QRCode options
24
21
  #Use options with hash values.
25
22
  #:level L:0, M:1(default), Q:2, H:3
26
23
  #:version S:0(default), M:1, L:2
@@ -30,9 +27,21 @@ A ruby library to create QR code image. Output: PS, JPEG, PNG, EPS, TIFF.
30
27
  #:module_size module size (pixel)
31
28
  #:eps_preview true|false
32
29
 
33
- #This sample creates a EPS with preview.
34
- qr = QRCode.new(:eps_preview => true, :auto_extent=false)
35
- qr.save("http://www.ebay.com", "path/to/qrcode.eps")
30
+ # This sample creates a EPS with preview.
31
+ RQR::QRCode.new(:eps_preview => true, :auto_extent=false) do |qr|
32
+ qr.save("http://www.ebay.com", "path/to/qrcode.eps")
33
+ end
34
+
35
+
36
+ # Old style (0.2.0, 0.1.1, 0.1.0)
37
+ qr = RQR::QRCode.new()
38
+
39
+ #Define a file format with extensions.
40
+ qr.save("http://www.google.com", "path/to/qrcode.jpg")
41
+
42
+ #Define a file format with symbol.
43
+ qr.save("http://www.yahoo.com", "path/to/qrcodefile", :png)
44
+
36
45
 
37
46
  == REQUIREMENTS:
38
47
 
data/lib/rqr/errors.rb CHANGED
@@ -4,6 +4,8 @@ module RQR
4
4
 
5
5
  class FormatNotFoundException < Exception; end
6
6
 
7
+ class BlockNotFoundException < Exception; end
8
+
7
9
  class ImageException < Exception; end
8
10
 
9
11
  end
data/lib/rqr/qrcode.rb CHANGED
@@ -16,6 +16,13 @@ module RQR
16
16
  @imager = nil
17
17
  end
18
18
 
19
+ def self.create(options = {})
20
+ raise BlockNotFoundException.new("Block not found!") unless block_given?
21
+ qrcode = RQR::QRCode.new(options)
22
+ yield qrcode
23
+ qrcode.close
24
+ end
25
+
19
26
  # data:: data for qrcode
20
27
  # path:: path for qrcode image file
21
28
  # format:: image format. :jpg|:png|:tiff|:eps
@@ -46,7 +53,7 @@ module RQR
46
53
 
47
54
  def close()
48
55
  @encoder = nil if @encoder
49
- @imager = nil if @imager
56
+ (@imager.close; @imager = nil) if @imager
50
57
  end
51
58
 
52
59
  private
data/lib/rqr/version.rb CHANGED
@@ -2,7 +2,7 @@ module Rqr #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/test/test_rqr.rb CHANGED
@@ -6,6 +6,7 @@ class TestRqr < Test::Unit::TestCase
6
6
  TEST_PNG='test.png'
7
7
  TEST_EPS='test.eps'
8
8
  TEST_EPS_WITH_PREVIEW='test_preview.eps'
9
+ TEST_NO_EXT = 'test_qrcode'
9
10
 
10
11
  def setup
11
12
  clear_test_file
@@ -52,6 +53,27 @@ class TestRqr < Test::Unit::TestCase
52
53
  delete_file(TEST_EPS)
53
54
  end
54
55
 
56
+ def test_create_method
57
+ RQR::QRCode.create{|qrcode| qrcode.save('http://www.ebay.com', TEST_JPEG)}
58
+ assert_equal(true, File.exist?(TEST_JPEG))
59
+ delete_file(TEST_JPEG)
60
+ end
61
+
62
+ def test_create_method2
63
+
64
+ # Define a file format with extensions.
65
+ RQR::QRCode.create do |qr|
66
+ qr.save("http://www.amazon.com", TEST_JPEG)
67
+ qr.save("http://www.amazon.com", TEST_NO_EXT, :png)
68
+ end
69
+ assert_equal(true, File.exist?(TEST_JPEG))
70
+ delete_file(TEST_JPEG)
71
+ assert_equal(true, File.exist?(TEST_NO_EXT))
72
+ delete_file(TEST_NO_EXT)
73
+
74
+ end
75
+
76
+
55
77
  def clear_test_file
56
78
  delete_file(TEST_TIFF)
57
79
  delete_file(TEST_PNG)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rqr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: x86-mswin32
6
6
  authors:
7
7
  - Ryota Maruko
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-13 00:00:00 +09:00
12
+ date: 2008-08-15 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15