rqrcode 0.10.1 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +28 -0
  3. data/.gitignore +13 -0
  4. data/.rspec +2 -0
  5. data/CHANGELOG.md +49 -0
  6. data/Gemfile +4 -0
  7. data/Gemfile.lock +68 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +223 -135
  10. data/Rakefile +10 -0
  11. data/_config.yml +1 -0
  12. data/bin/console +14 -0
  13. data/bin/setup +8 -0
  14. data/images/ansi-screen-shot.png +0 -0
  15. data/images/github-qrcode.png +0 -0
  16. data/images/github-qrcode.svg +32 -0
  17. data/lib/rqrcode/export/ansi.rb +22 -25
  18. data/lib/rqrcode/export/html.rb +8 -10
  19. data/lib/rqrcode/export/png.rb +62 -45
  20. data/lib/rqrcode/export/svg.rb +172 -24
  21. data/lib/rqrcode/export.rb +6 -0
  22. data/lib/rqrcode/qrcode/qrcode.rb +17 -0
  23. data/lib/rqrcode/qrcode.rb +3 -4
  24. data/lib/rqrcode/version.rb +3 -1
  25. data/lib/rqrcode.rb +8 -19
  26. data/rqrcode.gemspec +39 -0
  27. metadata +88 -57
  28. data/CHANGELOG +0 -97
  29. data/LICENSE +0 -19
  30. data/lib/rqrcode/core_ext/array/behavior.rb +0 -12
  31. data/lib/rqrcode/core_ext/array.rb +0 -5
  32. data/lib/rqrcode/core_ext/integer/bitwise.rb +0 -13
  33. data/lib/rqrcode/core_ext/integer.rb +0 -5
  34. data/lib/rqrcode/core_ext.rb +0 -5
  35. data/lib/rqrcode/qrcode/qr_8bit_byte.rb +0 -36
  36. data/lib/rqrcode/qrcode/qr_alphanumeric.rb +0 -47
  37. data/lib/rqrcode/qrcode/qr_bit_buffer.rb +0 -99
  38. data/lib/rqrcode/qrcode/qr_code.rb +0 -585
  39. data/lib/rqrcode/qrcode/qr_math.rb +0 -63
  40. data/lib/rqrcode/qrcode/qr_numeric.rb +0 -57
  41. data/lib/rqrcode/qrcode/qr_polynomial.rb +0 -78
  42. data/lib/rqrcode/qrcode/qr_rs_block.rb +0 -314
  43. data/lib/rqrcode/qrcode/qr_util.rb +0 -272
  44. data/test/data.rb +0 -25
  45. data/test/test_helper.rb +0 -5
  46. data/test/test_regresions.rb +0 -10
  47. data/test/test_rqrcode.rb +0 -155
  48. data/test/test_rqrcode_export.rb +0 -27
@@ -1,5 +0,0 @@
1
- require 'rqrcode/core_ext/array/behavior'
2
-
3
- class Array #:nodoc:
4
- include RQRCode::CoreExtensions::Array::Behavior
5
- end
@@ -1,13 +0,0 @@
1
- module RQRCode
2
- module CoreExtensions #:nodoc:
3
- module Integer #:nodoc:
4
- module Bitwise
5
- def rszf(count)
6
- # zero fill right shift
7
- (self >> count) & ((2 ** ((self.size * 8) - count))-1)
8
- end
9
- end
10
- end
11
- end
12
- end
13
-
@@ -1,5 +0,0 @@
1
- require 'rqrcode/core_ext/integer/bitwise'
2
-
3
- class Integer #:nodoc:
4
- include RQRCode::CoreExtensions::Integer::Bitwise
5
- end
@@ -1,5 +0,0 @@
1
- Dir[File.dirname(__FILE__) + "/core_ext/*.rb"].sort.each do |path|
2
- filename = File.basename(path)
3
- require "rqrcode/core_ext/#{filename}"
4
- end
5
-
@@ -1,36 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #--
4
- # Copyright 2004 by Duncan Robertson (duncan@whomwah.com).
5
- # All rights reserved.
6
-
7
- # Permission is granted for use, copying, modification, distribution,
8
- # and distribution of modified versions of this work as long as the
9
- # above copyright notice is included.
10
- #++
11
-
12
- module RQRCode
13
-
14
- class QR8bitByte
15
- attr_reader :mode
16
-
17
- def initialize( data )
18
- @mode = QRMODE[:mode_8bit_byte]
19
- @data = data;
20
- end
21
-
22
-
23
- def get_length
24
- @data.bytesize
25
- end
26
-
27
-
28
- def write( buffer)
29
- buffer.byte_encoding_start(get_length)
30
- @data.each_byte do |b|
31
- buffer.put(b, 8)
32
- end
33
- end
34
- end
35
-
36
- end
@@ -1,47 +0,0 @@
1
- module RQRCode
2
-
3
- ALPHANUMERIC = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ','$','%','*','+','-','.','/',':']
4
-
5
- class QRAlphanumeric
6
- attr_reader :mode
7
-
8
- def initialize( data )
9
- @mode = QRMODE[:mode_alpha_numk]
10
-
11
- raise QRCodeArgumentError, "Not a alpha numeric uppercase string `#{data}`" unless QRAlphanumeric.valid_data?(data)
12
-
13
- @data = data;
14
- end
15
-
16
-
17
- def get_length
18
- @data.size
19
- end
20
-
21
- def self.valid_data? data
22
- data.each_char do |s|
23
- return false if ALPHANUMERIC.index(s).nil?
24
- end
25
- true
26
- end
27
-
28
-
29
- def write( buffer)
30
- buffer.alphanumeric_encoding_start(get_length)
31
-
32
- (@data.size).times do |i|
33
- if i % 2 == 0
34
- if i == (@data.size - 1)
35
- value = ALPHANUMERIC.index(@data[i])
36
- buffer.put( value, 6 )
37
- else
38
- value = (ALPHANUMERIC.index(@data[i]) * 45) + ALPHANUMERIC.index(@data[i+1])
39
- buffer.put( value, 11 )
40
- end
41
- end
42
- end
43
-
44
-
45
- end
46
- end
47
- end
@@ -1,99 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- #--
4
- # Copyright 2004 by Duncan Robertson (duncan@whomwah.com).
5
- # All rights reserved.
6
-
7
- # Permission is granted for use, copying, modification, distribution,
8
- # and distribution of modified versions of this work as long as the
9
- # above copyright notice is included.
10
- #++
11
-
12
- module RQRCode
13
-
14
- class QRBitBuffer
15
- attr_reader :buffer
16
-
17
- PAD0 = 0xEC
18
- PAD1 = 0x11
19
-
20
- def initialize(version)
21
- @version = version
22
- @buffer = []
23
- @length = 0
24
- end
25
-
26
-
27
- def get( index )
28
- buf_index = (index / 8).floor
29
- (( (@buffer[buf_index]).rszf(7 - index % 8)) & 1) == 1
30
- end
31
-
32
-
33
- def put( num, length )
34
- ( 0...length ).each do |i|
35
- put_bit((((num).rszf(length - i - 1)) & 1) == 1)
36
- end
37
- end
38
-
39
-
40
- def get_length_in_bits
41
- @length
42
- end
43
-
44
-
45
- def put_bit( bit )
46
- buf_index = ( @length / 8 ).floor
47
- if @buffer.size <= buf_index
48
- @buffer << 0
49
- end
50
-
51
- if bit
52
- @buffer[buf_index] |= ((0x80).rszf(@length % 8))
53
- end
54
-
55
- @length += 1
56
- end
57
-
58
- def byte_encoding_start(length)
59
-
60
- put( QRMODE[:mode_8bit_byte], 4 )
61
- put(length, QRUtil.get_length_in_bits(QRMODE[:mode_8bit_byte], @version))
62
-
63
- end
64
-
65
- def alphanumeric_encoding_start(length)
66
-
67
- put( QRMODE[:mode_alpha_numk], 4 )
68
- put(length, QRUtil.get_length_in_bits(QRMODE[:mode_alpha_numk], @version))
69
-
70
- end
71
-
72
- def numeric_encoding_start(length)
73
-
74
- put( QRMODE[:mode_number], 4 )
75
- put(length, QRUtil.get_length_in_bits(QRMODE[:mode_number], @version))
76
-
77
- end
78
-
79
- def pad_until(prefered_size)
80
- # Align on byte
81
- while get_length_in_bits % 8 != 0
82
- put_bit( false )
83
- end
84
-
85
- # Pad with padding code words
86
- while get_length_in_bits < prefered_size
87
- put( QRBitBuffer::PAD0, 8 )
88
- put( QRBitBuffer::PAD1, 8 ) if get_length_in_bits < prefered_size
89
- end
90
- end
91
-
92
- def end_of_message(max_data_bits)
93
- put( 0, 4 ) unless get_length_in_bits+4 > max_data_bits
94
- end
95
-
96
-
97
- end
98
-
99
- end