rqrcode 0.10.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +31 -0
  3. data/.gitignore +13 -0
  4. data/.rspec +2 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +124 -135
  8. data/_config.yml +1 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +8 -0
  11. data/images/ansi-screen-shot.png +0 -0
  12. data/images/github-qrcode.png +0 -0
  13. data/images/github-qrcode.svg +32 -0
  14. data/lib/rqrcode/export/ansi.rb +14 -15
  15. data/lib/rqrcode/export/html.rb +6 -8
  16. data/lib/rqrcode/export/png.rb +40 -31
  17. data/lib/rqrcode/export/svg.rb +16 -7
  18. data/lib/rqrcode/export.rb +6 -0
  19. data/lib/rqrcode/qrcode/qrcode.rb +17 -0
  20. data/lib/rqrcode/qrcode.rb +3 -4
  21. data/lib/rqrcode/version.rb +3 -1
  22. data/lib/rqrcode.rb +8 -19
  23. data/rqrcode.gemspec +36 -0
  24. metadata +68 -56
  25. data/CHANGELOG +0 -97
  26. data/LICENSE +0 -19
  27. data/lib/rqrcode/core_ext/array/behavior.rb +0 -12
  28. data/lib/rqrcode/core_ext/array.rb +0 -5
  29. data/lib/rqrcode/core_ext/integer/bitwise.rb +0 -13
  30. data/lib/rqrcode/core_ext/integer.rb +0 -5
  31. data/lib/rqrcode/core_ext.rb +0 -5
  32. data/lib/rqrcode/qrcode/qr_8bit_byte.rb +0 -36
  33. data/lib/rqrcode/qrcode/qr_alphanumeric.rb +0 -47
  34. data/lib/rqrcode/qrcode/qr_bit_buffer.rb +0 -99
  35. data/lib/rqrcode/qrcode/qr_code.rb +0 -585
  36. data/lib/rqrcode/qrcode/qr_math.rb +0 -63
  37. data/lib/rqrcode/qrcode/qr_numeric.rb +0 -57
  38. data/lib/rqrcode/qrcode/qr_polynomial.rb +0 -78
  39. data/lib/rqrcode/qrcode/qr_rs_block.rb +0 -314
  40. data/lib/rqrcode/qrcode/qr_util.rb +0 -272
  41. data/test/data.rb +0 -25
  42. data/test/test_helper.rb +0 -5
  43. data/test/test_regresions.rb +0 -10
  44. data/test/test_rqrcode.rb +0 -155
  45. data/test/test_rqrcode_export.rb +0 -27
data/CHANGELOG DELETED
@@ -1,97 +0,0 @@
1
- *0.10.1* (Feb 11, 2016)
2
-
3
- - Changed so that gem wont include images and tests.
4
-
5
- *0.10.0* (Feb 11, 2016)
6
-
7
- - Merged as_ansi by [Andy Brody](https://github.com/ab)
8
-
9
- *0.8.2* (Jan 3, 2016)
10
-
11
- - Fix source encoding problem introduced in 0.8.1
12
-
13
- *0.9.0* (Jan 3, 2016)
14
-
15
- - Added support for auto selecting qrcode size up to level 40. (only worked up to level 10 before)
16
- - Added numeric support during auto selection of qrcode mode.
17
-
18
- *0.8.1* (Jan 3, 2016)
19
-
20
- - Remove active support specific `present?`.
21
- - Fix so that all tests are run.
22
-
23
- *0.8.0* (Dec 18, 2015)
24
-
25
- - Added numeric QR code support
26
- - Dropped Ruby v1.8 support
27
-
28
- *0.7.0* (Aug 15, 2015)
29
-
30
- - Added shape_rendering option for as_svg
31
-
32
- *0.6.0* (Jun 2, 2015)
33
-
34
- - Improved png rendering. Previous png rendering could result in hard to scan qrcodes.
35
- *Big thanks to Bart Jedrocha*
36
-
37
- *0.5.5* (Apr 25, 2015)
38
-
39
- - Fixed major bug. The rs block data was missing resulting in qr codes failing to be generated.
40
- *Upgrade highly recomended!!*
41
-
42
- *0.5.4* (Nov 11th, 2013)
43
-
44
- * Added as_html, Big thanks to Jon Evans!
45
-
46
- *0.4.2* (Sep 1st, 2011)
47
-
48
- * Proper namespace CoreExtensions and only extend when needed [https://github.com/metaskills]
49
- * fix for running tests on 1.9
50
-
51
- *0.4.1* (Aug 16th, 2011)
52
-
53
- * Compute common patterns only once (5% to 10% speedup) [https://github.com/gioele]
54
-
55
- *0.4.0* (Aug 13th, 2011)
56
-
57
- * Code optimization: 30% speedup [https://github.com/gioele]
58
- * refactor gem layout
59
-
60
- *0.3.4* (May 23rd, 2011)
61
-
62
- * add the more Rubyish QRCode#dark? alias for #is_dark [https://github.com/dasch]
63
-
64
- *0.3.3* (Feb 1st, 2011)
65
-
66
- * check to see if the level is valid
67
- * fix for 'rszf' bug by [Rob la Lau https://github.com/ohreally]
68
-
69
- *0.3.2* (Mar 15th, 2009)
70
-
71
- * Ruby 1.9 fixes by [Tore Darell http://tore.darell.no] [Chris Mowforth http://blog.99th.st]
72
-
73
- *0.3.1* (Nov 24th, 2008)
74
-
75
- * expanded RS block table to QRcode version 40 [Vladislav Gorodetskiy]
76
-
77
- *0.3.0* (Feb 28th, 2008)
78
-
79
- * added more documentation
80
- * changed to_console to to_s (what was I thinking)
81
- * add more tests
82
-
83
- *0.2.1* (Feb 24th, 2008)
84
-
85
- * small changes to rakefile and readme
86
- * small change to to_console method
87
- * make console_count method private (use modules.size instead)
88
- * slowy updating rdocs
89
-
90
- *0.2.0* (Feb 23rd, 2008)
91
-
92
- * Split files up [DR]
93
- * added rdoc comment ... more to do there
94
-
95
- *0.1.0* (Feb 22rd, 2008)
96
-
97
- * Initial Release [DR]
data/LICENSE DELETED
@@ -1,19 +0,0 @@
1
- Copyright (c) 2008 Duncan Robertson
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining a copy
4
- of this software and associated documentation files (the "Software"), to
5
- deal in the Software without restriction, including without limitation the
6
- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
- sell copies of the Software, and to permit persons to whom the Software is
8
- furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in
11
- all copies or substantial portions of the Software.
12
-
13
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
- THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
-
@@ -1,12 +0,0 @@
1
- module RQRCode
2
- module CoreExtensions #:nodoc:
3
- module Array #:nodoc:
4
- module Behavior
5
- def extract_options!
6
- last.is_a?(::Hash) ? pop : {}
7
- end unless [].respond_to?(:extract_options!)
8
- end
9
- end
10
- end
11
- end
12
-
@@ -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