rqrcode 0.8.2 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +20 -0
  3. data/.gitignore +9 -1
  4. data/Gemfile +3 -8
  5. data/LICENSE.txt +21 -0
  6. data/README.md +121 -123
  7. data/Rakefile +6 -10
  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.rb +7 -15
  15. data/{test/helper.rb → lib/rqrcode/export.rb} +3 -6
  16. data/lib/rqrcode/export/ansi.rb +77 -0
  17. data/lib/rqrcode/export/html.rb +6 -8
  18. data/lib/rqrcode/export/png.rb +18 -19
  19. data/lib/rqrcode/export/svg.rb +16 -7
  20. data/lib/rqrcode/qrcode.rb +3 -4
  21. data/lib/rqrcode/qrcode/qrcode.rb +17 -0
  22. data/lib/rqrcode/version.rb +3 -1
  23. data/rqrcode.gemspec +28 -24
  24. metadata +62 -55
  25. data/.travis.yml +0 -7
  26. data/CHANGELOG +0 -84
  27. data/LICENSE +0 -19
  28. data/TODO.md +0 -4
  29. data/lib/rqrcode/core_ext.rb +0 -5
  30. data/lib/rqrcode/core_ext/array.rb +0 -5
  31. data/lib/rqrcode/core_ext/array/behavior.rb +0 -12
  32. data/lib/rqrcode/core_ext/integer.rb +0 -5
  33. data/lib/rqrcode/core_ext/integer/bitwise.rb +0 -13
  34. data/lib/rqrcode/qrcode/qr_8bit_byte.rb +0 -36
  35. data/lib/rqrcode/qrcode/qr_alphanumeric.rb +0 -47
  36. data/lib/rqrcode/qrcode/qr_bit_buffer.rb +0 -99
  37. data/lib/rqrcode/qrcode/qr_code.rb +0 -492
  38. data/lib/rqrcode/qrcode/qr_math.rb +0 -63
  39. data/lib/rqrcode/qrcode/qr_numeric.rb +0 -66
  40. data/lib/rqrcode/qrcode/qr_polynomial.rb +0 -78
  41. data/lib/rqrcode/qrcode/qr_rs_block.rb +0 -314
  42. data/lib/rqrcode/qrcode/qr_util.rb +0 -272
  43. data/test/data.rb +0 -23
  44. data/test/test_regresions.rb +0 -10
  45. data/test/test_rqrcode.rb +0 -125
  46. data/test/test_rqrcode_export.rb +0 -23
metadata CHANGED
@@ -1,16 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rqrcode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
- - Björn Blomqvist
8
7
  - Duncan Robertson
9
8
  autorequire:
10
- bindir: bin
9
+ bindir: exe
11
10
  cert_chain: []
12
- date: 2016-01-03 00:00:00.000000000 Z
11
+ date: 2019-09-18 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rqrcode_core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.0
14
27
  - !ruby/object:Gem::Dependency
15
28
  name: chunky_png
16
29
  requirement: !ruby/object:Gem::Requirement
@@ -25,83 +38,83 @@ dependencies:
25
38
  - - "~>"
26
39
  - !ruby/object:Gem::Version
27
40
  version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
28
55
  - !ruby/object:Gem::Dependency
29
56
  name: rake
30
57
  requirement: !ruby/object:Gem::Requirement
31
58
  requirements:
32
- - - ">="
59
+ - - "~>"
33
60
  - !ruby/object:Gem::Version
34
- version: '0'
61
+ version: '12.0'
35
62
  type: :development
36
63
  prerelease: false
37
64
  version_requirements: !ruby/object:Gem::Requirement
38
65
  requirements:
39
- - - ">="
66
+ - - "~>"
40
67
  - !ruby/object:Gem::Version
41
- version: '0'
68
+ version: '12.0'
42
69
  - !ruby/object:Gem::Dependency
43
- name: bundler
70
+ name: minitest
44
71
  requirement: !ruby/object:Gem::Requirement
45
72
  requirements:
46
- - - ">="
73
+ - - "~>"
47
74
  - !ruby/object:Gem::Version
48
- version: 1.0.0
75
+ version: '5.0'
49
76
  type: :development
50
77
  prerelease: false
51
78
  version_requirements: !ruby/object:Gem::Requirement
52
79
  requirements:
53
- - - ">="
80
+ - - "~>"
54
81
  - !ruby/object:Gem::Version
55
- version: 1.0.0
82
+ version: '5.0'
56
83
  description: |
57
- rQRCode is a library for encoding QR Codes. The simple
84
+ rqrcode is a library for encoding QR Codes. The simple
58
85
  interface allows you to create QR Code data structures
59
- ready to be displayed in the way you choose.
86
+ and then render them in the way you choose.
60
87
  email:
61
- - darwin@bits2life.com
88
+ - duncan@whomwah.com
62
89
  executables: []
63
90
  extensions: []
64
- extra_rdoc_files:
65
- - README.md
66
- - CHANGELOG
67
- - LICENSE
91
+ extra_rdoc_files: []
68
92
  files:
93
+ - ".github/workflows/ruby.yml"
69
94
  - ".gitignore"
70
- - ".travis.yml"
71
- - CHANGELOG
72
95
  - Gemfile
73
- - LICENSE
96
+ - LICENSE.txt
74
97
  - README.md
75
98
  - Rakefile
76
- - TODO.md
99
+ - _config.yml
100
+ - bin/console
101
+ - bin/setup
102
+ - images/ansi-screen-shot.png
103
+ - images/github-qrcode.png
104
+ - images/github-qrcode.svg
77
105
  - lib/rqrcode.rb
78
- - lib/rqrcode/core_ext.rb
79
- - lib/rqrcode/core_ext/array.rb
80
- - lib/rqrcode/core_ext/array/behavior.rb
81
- - lib/rqrcode/core_ext/integer.rb
82
- - lib/rqrcode/core_ext/integer/bitwise.rb
106
+ - lib/rqrcode/export.rb
107
+ - lib/rqrcode/export/ansi.rb
83
108
  - lib/rqrcode/export/html.rb
84
109
  - lib/rqrcode/export/png.rb
85
110
  - lib/rqrcode/export/svg.rb
86
111
  - lib/rqrcode/qrcode.rb
87
- - lib/rqrcode/qrcode/qr_8bit_byte.rb
88
- - lib/rqrcode/qrcode/qr_alphanumeric.rb
89
- - lib/rqrcode/qrcode/qr_bit_buffer.rb
90
- - lib/rqrcode/qrcode/qr_code.rb
91
- - lib/rqrcode/qrcode/qr_math.rb
92
- - lib/rqrcode/qrcode/qr_numeric.rb
93
- - lib/rqrcode/qrcode/qr_polynomial.rb
94
- - lib/rqrcode/qrcode/qr_rs_block.rb
95
- - lib/rqrcode/qrcode/qr_util.rb
112
+ - lib/rqrcode/qrcode/qrcode.rb
96
113
  - lib/rqrcode/version.rb
97
114
  - rqrcode.gemspec
98
- - test/data.rb
99
- - test/helper.rb
100
- - test/test_regresions.rb
101
- - test/test_rqrcode.rb
102
- - test/test_rqrcode_export.rb
103
115
  homepage: https://github.com/whomwah/rqrcode
104
- licenses: []
116
+ licenses:
117
+ - MIT
105
118
  metadata: {}
106
119
  post_install_message:
107
120
  rdoc_options: []
@@ -109,23 +122,17 @@ require_paths:
109
122
  - lib
110
123
  required_ruby_version: !ruby/object:Gem::Requirement
111
124
  requirements:
112
- - - ">="
125
+ - - "~>"
113
126
  - !ruby/object:Gem::Version
114
- version: '0'
127
+ version: '2.3'
115
128
  required_rubygems_version: !ruby/object:Gem::Requirement
116
129
  requirements:
117
130
  - - ">="
118
131
  - !ruby/object:Gem::Version
119
- version: 1.3.6
132
+ version: '0'
120
133
  requirements: []
121
- rubyforge_project:
122
- rubygems_version: 2.4.6
134
+ rubygems_version: 3.0.1
123
135
  signing_key:
124
136
  specification_version: 4
125
137
  summary: A library to encode QR Codes
126
- test_files:
127
- - test/data.rb
128
- - test/helper.rb
129
- - test/test_regresions.rb
130
- - test/test_rqrcode.rb
131
- - test/test_rqrcode_export.rb
138
+ test_files: []
@@ -1,7 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.3
4
- - 2.1.6
5
- - 2.0.0
6
- - 1.9.3
7
- - jruby-19mode
data/CHANGELOG DELETED
@@ -1,84 +0,0 @@
1
- *0.8.2* (Jan 3, 2016)
2
-
3
- - Fix source encoding problem introduced in 0.8.1
4
-
5
- *0.8.1* (Jan 3, 2016)
6
-
7
- - Remove active support specific `present?`.
8
- - Fix so that all tests are run.
9
-
10
- *0.8.0* (Dec 18, 2015)
11
-
12
- - Added numeric QR code support
13
- - Dropped Ruby v1.8 support
14
-
15
- *0.7.0* (Aug 15, 2015)
16
-
17
- - Added shape_rendering option for as_svg
18
-
19
- *0.6.0* (Jun 2, 2015)
20
-
21
- - Improved png rendering. Previous png rendering could result in hard to scan qrcodes.
22
- *Big thanks to Bart Jedrocha*
23
-
24
- *0.5.5* (Apr 25, 2015)
25
-
26
- - Fixed major bug. The rs block data was missing resulting in qr codes failing to be generated.
27
- *Upgrade highly recomended!!*
28
-
29
- *0.5.4* (Nov 11th, 2013)
30
-
31
- * Added as_html, Big thanks to Jon Evans!
32
-
33
- *0.4.2* (Sep 1st, 2011)
34
-
35
- * Proper namespace CoreExtensions and only extend when needed [https://github.com/metaskills]
36
- * fix for running tests on 1.9
37
-
38
- *0.4.1* (Aug 16th, 2011)
39
-
40
- * Compute common patterns only once (5% to 10% speedup) [https://github.com/gioele]
41
-
42
- *0.4.0* (Aug 13th, 2011)
43
-
44
- * Code optimization: 30% speedup [https://github.com/gioele]
45
- * refactor gem layout
46
-
47
- *0.3.4* (May 23rd, 2011)
48
-
49
- * add the more Rubyish QRCode#dark? alias for #is_dark [https://github.com/dasch]
50
-
51
- *0.3.3* (Feb 1st, 2011)
52
-
53
- * check to see if the level is valid
54
- * fix for 'rszf' bug by [Rob la Lau https://github.com/ohreally]
55
-
56
- *0.3.2* (Mar 15th, 2009)
57
-
58
- * Ruby 1.9 fixes by [Tore Darell http://tore.darell.no] [Chris Mowforth http://blog.99th.st]
59
-
60
- *0.3.1* (Nov 24th, 2008)
61
-
62
- * expanded RS block table to QRcode version 40 [Vladislav Gorodetskiy]
63
-
64
- *0.3.0* (Feb 28th, 2008)
65
-
66
- * added more documentation
67
- * changed to_console to to_s (what was I thinking)
68
- * add more tests
69
-
70
- *0.2.1* (Feb 24th, 2008)
71
-
72
- * small changes to rakefile and readme
73
- * small change to to_console method
74
- * make console_count method private (use modules.size instead)
75
- * slowy updating rdocs
76
-
77
- *0.2.0* (Feb 23rd, 2008)
78
-
79
- * Split files up [DR]
80
- * added rdoc comment ... more to do there
81
-
82
- *0.1.0* (Feb 22rd, 2008)
83
-
84
- * 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
-
data/TODO.md DELETED
@@ -1,4 +0,0 @@
1
- - Add to_ansi rendering_
2
- - Add Kanji mode
3
- - Add ECI Mode
4
- - Improved performance for large QR codes
@@ -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,5 +0,0 @@
1
- require 'rqrcode/core_ext/array/behavior'
2
-
3
- class Array #:nodoc:
4
- include RQRCode::CoreExtensions::Array::Behavior
5
- end
@@ -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/integer/bitwise'
2
-
3
- class Integer #:nodoc:
4
- include RQRCode::CoreExtensions::Integer::Bitwise
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,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