rqrcode 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,8 @@
1
+ *0.3.3* (Feb 1st, 2011)
2
+
3
+ * check to see if the level is valid
4
+ * fix for 'rszf' bug by [Rob la Lau https://github.com/toretore]
5
+
1
6
  *0.3.2* (Mar 15th, 2009)
2
7
 
3
8
  * Ruby 1.9 fixes by [Tore Darell http://tore.darell.no] [Chris Mowforth http://blog.99th.st]
data/README CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  rQRCode is a library for encoding QR Codes in Ruby. It has a simple interface with all the standard qrcode options. It was adapted from the Javascript library by Kazuhiko Arase.
4
4
 
5
- RubyForge Project Page http://rubyforge.org/projects/rqrcode/
6
-
7
5
  == An Overview
8
6
 
9
7
  Let's clear up some rQRCode stuff.
@@ -69,18 +69,21 @@ module RQRCode #:nodoc:
69
69
  # qr = RQRCode::QRCode.new('hello world', :size => 1, :level => :m )
70
70
  #
71
71
 
72
- def initialize( *args )
72
+ def initialize( *args )
73
73
  raise QRCodeArgumentError unless args.first.kind_of?( String )
74
74
 
75
75
  @data = args.shift
76
76
  options = args.extract_options!
77
77
  level = options[:level] || :h
78
+
79
+ raise QRCodeArgumentError unless %w(l m q h).include?(level.to_s)
80
+
78
81
  @error_correct_level = QRERRORCORRECTLEVEL[ level.to_sym ]
79
82
  @type_number = options[:size] || 4
80
83
  @module_count = @type_number * 4 + 17
81
- @modules = nil
82
- @data_cache = nil
84
+ @modules = Array.new( @module_count )
83
85
  @data_list = QR8bitByte.new( @data )
86
+ @data_cache = nil
84
87
 
85
88
  self.make
86
89
  end
@@ -149,7 +152,6 @@ module RQRCode #:nodoc:
149
152
 
150
153
 
151
154
  def make_impl( test, mask_pattern ) #:nodoc:
152
- @modules = Array.new( @module_count )
153
155
 
154
156
  ( 0...@module_count ).each do |row|
155
157
  @modules[row] = Array.new( @module_count )
@@ -292,7 +294,7 @@ module RQRCode #:nodoc:
292
294
 
293
295
  if @modules[row][ col - c ].nil?
294
296
  dark = false
295
- if byte_index < data.size
297
+ if byte_index < data.size && !data[byte_index].nil?
296
298
  dark = (( (data[byte_index]).rszf( bit_index ) & 1) == 1 )
297
299
  end
298
300
  mask = QRUtil.get_mask( mask_pattern, row, col - c )
data/test/runtest.rb CHANGED
@@ -72,7 +72,27 @@ class QRCodeTest < Test::Unit::TestCase
72
72
  def test_to_s
73
73
  qr = RQRCode::QRCode.new( 'duncan', :size => 1 )
74
74
  assert_equal qr.to_s[0..21], "xxxxxxx xx x xxxxxxx\n"
75
- assert_equal qr.to_s( :true => 'q', :false => 'n' )[0..21], "qqqqqqqnqqnqnnqqqqqqq\n"
75
+ assert_equal qr.to_s( :true => 'q', :false => 'n' )[0..21],
76
+ "qqqqqqqnqqnqnnqqqqqqq\n"
76
77
  assert_equal qr.to_s( :true => '@' )[0..21], "@@@@@@@ @@ @ @@@@@@@\n"
77
78
  end
79
+
80
+ def test_rszf_error_not_thrown
81
+ assert RQRCode::QRCode.new('2 1058 657682')
82
+ assert RQRCode::QRCode.new("40952", :size => 1, :level => :h)
83
+ assert RQRCode::QRCode.new("40932", :size => 1, :level => :h)
84
+ end
85
+
86
+ def test_levels
87
+ assert RQRCode::QRCode.new("duncan", :level => :l)
88
+ assert RQRCode::QRCode.new("duncan", :level => :m)
89
+ assert RQRCode::QRCode.new("duncan", :level => :q)
90
+ assert RQRCode::QRCode.new("duncan", :level => :h)
91
+ assert_raise(RQRCode::QRCodeArgumentError) {
92
+ %w(a b c d e f g i j k n o p r s t u v w x y z).each do |ltr|
93
+ RQRCode::QRCode.new( "duncan", :level => ltr.to_sym )
94
+ end
95
+ }
96
+ end
97
+
78
98
  end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rqrcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ hash: 21
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 3
10
+ version: 0.3.3
5
11
  platform: ruby
6
12
  authors:
7
13
  - Duncan Robertson
@@ -9,11 +15,15 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2009-03-15 00:00:00 +00:00
18
+ date: 2011-02-01 00:00:00 +00:00
13
19
  default_executable:
14
20
  dependencies: []
15
21
 
16
- description: rQRCode is a library for encoding QR Codes. The simple interface allows you to create QR Code data structures ready to be displayed in the way you choose.
22
+ description: |
23
+ rQRCode is a library for encoding QR Codes. The simple
24
+ interface allows you to create QR Code data structures
25
+ ready to be displayed in the way you choose.
26
+
17
27
  email: duncan@whomwah.com
18
28
  executables: []
19
29
 
@@ -24,16 +34,11 @@ extra_rdoc_files:
24
34
  - CHANGELOG
25
35
  - COPYING
26
36
  files:
27
- - lib/rqrcode
28
- - lib/rqrcode/core_ext
29
- - lib/rqrcode/core_ext/array
30
37
  - lib/rqrcode/core_ext/array/behavior.rb
31
38
  - lib/rqrcode/core_ext/array.rb
32
- - lib/rqrcode/core_ext/integer
33
39
  - lib/rqrcode/core_ext/integer/bitwise.rb
34
40
  - lib/rqrcode/core_ext/integer.rb
35
41
  - lib/rqrcode/core_ext.rb
36
- - lib/rqrcode/qrcode
37
42
  - lib/rqrcode/qrcode/qr_8bit_byte.rb
38
43
  - lib/rqrcode/qrcode/qr_bit_buffer.rb
39
44
  - lib/rqrcode/qrcode/qr_code.rb
@@ -49,30 +54,38 @@ files:
49
54
  - CHANGELOG
50
55
  - COPYING
51
56
  has_rdoc: true
52
- homepage: http://rqrcode.rubyforge.org
57
+ homepage: http://whomwah.github.com/rqrcode/
58
+ licenses: []
59
+
53
60
  post_install_message:
54
61
  rdoc_options: []
55
62
 
56
63
  require_paths:
57
64
  - lib
58
65
  required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
59
67
  requirements:
60
68
  - - ">="
61
69
  - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
62
73
  version: "0"
63
- version:
64
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
65
76
  requirements:
66
77
  - - ">="
67
78
  - !ruby/object:Gem::Version
79
+ hash: 3
80
+ segments:
81
+ - 0
68
82
  version: "0"
69
- version:
70
83
  requirements: []
71
84
 
72
85
  rubyforge_project: rqrcode
73
- rubygems_version: 1.3.1
86
+ rubygems_version: 1.5.0
74
87
  signing_key:
75
- specification_version: 2
88
+ specification_version: 3
76
89
  summary: A library to encode QR Codes
77
90
  test_files:
78
91
  - test/runtest.rb