rqrcode_core 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/rqrcode_core.rb +0 -1
- data/lib/rqrcode_core/qrcode/qr_bit_buffer.rb +3 -3
- data/lib/rqrcode_core/qrcode/qr_code.rb +7 -3
- data/lib/rqrcode_core/qrcode/qr_util.rb +6 -1
- data/lib/rqrcode_core/version.rb +1 -1
- data/rqrcode_core.gemspec +1 -1
- metadata +5 -10
- data/lib/rqrcode_core/core_ext.rb +0 -4
- data/lib/rqrcode_core/core_ext/array.rb +0 -7
- data/lib/rqrcode_core/core_ext/array/behavior.rb +0 -14
- data/lib/rqrcode_core/core_ext/integer.rb +0 -7
- data/lib/rqrcode_core/core_ext/integer/bitwise.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa65c1043ff732d79a7c945ebec22c3e58ec30824a10ea66ae2a83666cae0b54
|
4
|
+
data.tar.gz: cd413ba0b0c37980b57d017cc5910dde35cee7c09bf99d6d77ef5d4d74daf287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e74946cef2ab02b66431dd4e992198392166ae46e837194c2e7f361fcf6a25db37edfdc354ecbc531bbe58d713f6f3a61906c2a365a3b1df79dc03ffcd7296a
|
7
|
+
data.tar.gz: a87de6c5a59cd072c8ec9da9c655b63b519d435cb219ec54a533991eaeece40e4c3778df5f5a566e94f70e8831636454a40476b4e4670f79f3a782f1e3366490
|
data/Gemfile.lock
CHANGED
@@ -7,7 +7,7 @@ GEM
|
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
minitest (5.11.3)
|
10
|
-
rake (
|
10
|
+
rake (13.0.1)
|
11
11
|
|
12
12
|
PLATFORMS
|
13
13
|
ruby
|
@@ -15,7 +15,7 @@ PLATFORMS
|
|
15
15
|
DEPENDENCIES
|
16
16
|
bundler (~> 2.0)
|
17
17
|
minitest (~> 5.0)
|
18
|
-
rake (~>
|
18
|
+
rake (~> 13.0)
|
19
19
|
rqrcode_core!
|
20
20
|
|
21
21
|
BUNDLED WITH
|
data/lib/rqrcode_core.rb
CHANGED
@@ -16,13 +16,13 @@ module RQRCodeCore
|
|
16
16
|
|
17
17
|
def get( index )
|
18
18
|
buf_index = (index / 8).floor
|
19
|
-
(( (@buffer[buf_index]
|
19
|
+
(( QRUtil.rszf(@buffer[buf_index], 7 - index % 8)) & 1) == 1
|
20
20
|
end
|
21
21
|
|
22
22
|
|
23
23
|
def put( num, length )
|
24
24
|
( 0...length ).each do |i|
|
25
|
-
put_bit(((
|
25
|
+
put_bit(((QRUtil.rszf(num, length - i - 1)) & 1) == 1)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -39,7 +39,7 @@ module RQRCodeCore
|
|
39
39
|
end
|
40
40
|
|
41
41
|
if bit
|
42
|
-
@buffer[buf_index] |= (
|
42
|
+
@buffer[buf_index] |= (QRUtil.rszf(0x80, @length % 8))
|
43
43
|
end
|
44
44
|
|
45
45
|
@length += 1
|
@@ -174,7 +174,7 @@ module RQRCodeCore
|
|
174
174
|
raise QRCodeArgumentError, "The passed data is #{string.class}, not String"
|
175
175
|
end
|
176
176
|
|
177
|
-
options =
|
177
|
+
options = extract_options!(args)
|
178
178
|
level = (options[:level] || :h).to_sym
|
179
179
|
|
180
180
|
if !QRERRORCORRECTLEVEL.has_key?(level)
|
@@ -256,7 +256,7 @@ module RQRCodeCore
|
|
256
256
|
#
|
257
257
|
|
258
258
|
def to_s( *args )
|
259
|
-
options =
|
259
|
+
options = extract_options!(args)
|
260
260
|
dark = options[:dark] || options[:true] || 'x'
|
261
261
|
light = options[:light] || options[:false] || ' '
|
262
262
|
quiet_zone_size = options[:quiet_zone_size] || 0
|
@@ -461,7 +461,7 @@ module RQRCodeCore
|
|
461
461
|
if @modules[row][ col - c ].nil?
|
462
462
|
dark = false
|
463
463
|
if byte_index < data.size && !data[byte_index].nil?
|
464
|
-
dark = (( (data[byte_index]
|
464
|
+
dark = (( QRUtil.rszf(data[byte_index], bit_index) & 1) == 1 )
|
465
465
|
end
|
466
466
|
mask = QRUtil.get_mask( mask_pattern, row, col - c )
|
467
467
|
dark = !dark if mask
|
@@ -493,6 +493,10 @@ module RQRCodeCore
|
|
493
493
|
ver + 1
|
494
494
|
end
|
495
495
|
|
496
|
+
def extract_options!(arr) #:nodoc:
|
497
|
+
arr.last.is_a?(::Hash) ? arr.pop : {}
|
498
|
+
end
|
499
|
+
|
496
500
|
def QRCode.count_max_data_bits(rs_blocks)
|
497
501
|
max_data_bytes = rs_blocks.reduce(0) do |sum, rs_block|
|
498
502
|
sum + rs_block.data_count
|
@@ -73,6 +73,11 @@ module RQRCodeCore
|
|
73
73
|
(( data << 10 ) | d) ^ G15_MASK
|
74
74
|
end
|
75
75
|
|
76
|
+
def QRUtil.rszf( num, count )
|
77
|
+
# zero fill right shift
|
78
|
+
(num >> count) & ((2 ** ((num.size * 8) - count))-1)
|
79
|
+
end
|
80
|
+
|
76
81
|
def QRUtil.get_bch_version(data)
|
77
82
|
d = data << 12
|
78
83
|
while QRUtil.get_bch_digit(d) - QRUtil.get_bch_digit(G18) >= 0
|
@@ -86,7 +91,7 @@ module RQRCodeCore
|
|
86
91
|
|
87
92
|
while data != 0
|
88
93
|
digit = digit + 1
|
89
|
-
data =
|
94
|
+
data = QRUtil.rszf( data, 1 )
|
90
95
|
end
|
91
96
|
|
92
97
|
digit
|
data/lib/rqrcode_core/version.rb
CHANGED
data/rqrcode_core.gemspec
CHANGED
@@ -27,6 +27,6 @@ EOF
|
|
27
27
|
|
28
28
|
spec.required_ruby_version = '~> 2.3'
|
29
29
|
spec.add_development_dependency "bundler", "~> 2.0"
|
30
|
-
spec.add_development_dependency "rake", "~>
|
30
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
31
31
|
spec.add_development_dependency "minitest", "~> 5.0"
|
32
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rqrcode_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duncan Robertson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,11 +71,6 @@ files:
|
|
71
71
|
- bin/console
|
72
72
|
- bin/setup
|
73
73
|
- lib/rqrcode_core.rb
|
74
|
-
- lib/rqrcode_core/core_ext.rb
|
75
|
-
- lib/rqrcode_core/core_ext/array.rb
|
76
|
-
- lib/rqrcode_core/core_ext/array/behavior.rb
|
77
|
-
- lib/rqrcode_core/core_ext/integer.rb
|
78
|
-
- lib/rqrcode_core/core_ext/integer/bitwise.rb
|
79
74
|
- lib/rqrcode_core/qrcode.rb
|
80
75
|
- lib/rqrcode_core/qrcode/qr_8bit_byte.rb
|
81
76
|
- lib/rqrcode_core/qrcode/qr_alphanumeric.rb
|
@@ -107,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
102
|
- !ruby/object:Gem::Version
|
108
103
|
version: '0'
|
109
104
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
105
|
+
rubygems_version: 3.1.2
|
111
106
|
signing_key:
|
112
107
|
specification_version: 4
|
113
108
|
summary: A library to encode QR Codes
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RQRCodeCore
|
4
|
-
module CoreExtensions #:nodoc: all
|
5
|
-
module Array
|
6
|
-
module Behavior
|
7
|
-
def extract_options!
|
8
|
-
last.is_a?(::Hash) ? pop : {}
|
9
|
-
end unless [].respond_to?(:extract_options!)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RQRCodeCore
|
4
|
-
module CoreExtensions #:nodoc: all
|
5
|
-
module Integer
|
6
|
-
module Bitwise
|
7
|
-
def rszf(count)
|
8
|
-
# zero fill right shift
|
9
|
-
(self >> count) & ((2 ** ((self.size * 8) - count))-1)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|