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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6532b18a40855c6c4424b2fb6a9d54edae0377499d85338e2f387547919329b
4
- data.tar.gz: 87019adc3b63c4e97ca659224011497b91e6d09f60767a24c3ae4d67ed5d21cf
3
+ metadata.gz: fa65c1043ff732d79a7c945ebec22c3e58ec30824a10ea66ae2a83666cae0b54
4
+ data.tar.gz: cd413ba0b0c37980b57d017cc5910dde35cee7c09bf99d6d77ef5d4d74daf287
5
5
  SHA512:
6
- metadata.gz: 5dacb728f9f5817ee1568871ba9c554433442739be2f4a4e9857bfbb1cfecdd536fe977d869be9d397a7ec9b9dfb0676dbd97e9aa39d6f9fcc3384bf6a0a594e
7
- data.tar.gz: cb51d2616d3d7c513155882a1a23bbde9f6c62c2b58bec3b4f20d08b9b7b5d33079dd85bf1203e9dfa650c67b0b35d019eedb2482b1e0f9f36d344004cf968b3
6
+ metadata.gz: 1e74946cef2ab02b66431dd4e992198392166ae46e837194c2e7f361fcf6a25db37edfdc354ecbc531bbe58d713f6f3a61906c2a365a3b1df79dc03ffcd7296a
7
+ data.tar.gz: a87de6c5a59cd072c8ec9da9c655b63b519d435cb219ec54a533991eaeece40e4c3778df5f5a566e94f70e8831636454a40476b4e4670f79f3a782f1e3366490
@@ -7,7 +7,7 @@ GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  minitest (5.11.3)
10
- rake (10.5.0)
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 (~> 10.0)
18
+ rake (~> 13.0)
19
19
  rqrcode_core!
20
20
 
21
21
  BUNDLED WITH
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RQRCodeCore
4
- require "rqrcode_core/core_ext"
5
4
  require "rqrcode_core/qrcode"
6
5
  require "rqrcode_core/version"
7
6
  end
@@ -16,13 +16,13 @@ module RQRCodeCore
16
16
 
17
17
  def get( index )
18
18
  buf_index = (index / 8).floor
19
- (( (@buffer[buf_index]).rszf(7 - index % 8)) & 1) == 1
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((((num).rszf(length - i - 1)) & 1) == 1)
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] |= ((0x80).rszf(@length % 8))
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 = args.extract_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 = args.extract_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]).rszf( bit_index ) & 1) == 1 )
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 = (data).rszf(1)
94
+ data = QRUtil.rszf( data, 1 )
90
95
  end
91
96
 
92
97
  digit
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RQRCodeCore
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -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", "~> 10.0"
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.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: 2019-11-07 00:00:00.000000000 Z
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: '10.0'
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: '10.0'
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.0.1
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,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rqrcode_core/core_ext/array'
4
- require 'rqrcode_core/core_ext/integer'
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rqrcode_core/core_ext/array/behavior'
4
-
5
- class Array #:nodoc: all
6
- include RQRCodeCore::CoreExtensions::Array::Behavior
7
- end
@@ -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,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rqrcode_core/core_ext/integer/bitwise'
4
-
5
- class Integer #:nodoc: all
6
- include RQRCodeCore::CoreExtensions::Integer::Bitwise
7
- end
@@ -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
-