qrcode_pix_ruby 0.3.2 → 0.3.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84a357b21f2470212773cc92b26e4c6342e03ab211bc143890dd3f1d9d83fc12
4
- data.tar.gz: ff3a3f5132cd865a342abab66622adeb4e1bdfc3d3b2f09cbfc045856a8b7a02
3
+ metadata.gz: 52492ab7a9acf126608e98b81527ed1dace5f8acd90519b5caee3c555e43a9f0
4
+ data.tar.gz: 295667fb9a0927cb28d8969629b72d2ded040ed6d99d26009de22fa51c5b6508
5
5
  SHA512:
6
- metadata.gz: 4d07fafa359a2cc609e7eebd6518af234367e961b5cd427e0520ec15c0d920c5f5c236276157fd9bf73632e60c9543b3de682195cc5f6110790131a89920df49
7
- data.tar.gz: 702724974cb6e1842d576977c7fa155528136b189c0751d022ae2b4f39fc055959b0a992d6fd42d561305763757d0be82367a15cc2dfedc14315f0bb6ce901f7
6
+ metadata.gz: 4fc1af95bea11a989799aa457fe2c54e8c782e4428dc1efc0f9911dd9e9e0ed0433bebcef29ee2cf76bd17f7a6cf9a54ac58e5e8a862ab3b0df30f31a88444eb
7
+ data.tar.gz: ce85d33b412995d7a8ef16b08a704c184cb7c73d57a35520d12d3957921172546dfe3dac5298cccaa5050fcf8a7151f688521f90366bf93b3d8c56b2b0400c73
@@ -7,7 +7,7 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby-version: [2.7, 3.0]
10
+ ruby-version: [2.3, 2.4, 2.5, 2.6, 2.7, 3.0]
11
11
  env:
12
12
  CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}
13
13
  steps:
data/.rubocop.yml ADDED
@@ -0,0 +1,28 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ SuggestExtensions: false
4
+ Exclude:
5
+ - spec/*
6
+
7
+ Layout/LineLength:
8
+ Max: 120
9
+ Exclude:
10
+ - qrcode_pix_ruby.gemspec
11
+
12
+ Metrics/MethodLength:
13
+ Max: 20
14
+
15
+ Gemspec/RequiredRubyVersion:
16
+ Enabled: false
17
+
18
+ Style/Documentation:
19
+ Enabled: false
20
+
21
+ Metrics/AbcSize:
22
+ Enabled: false
23
+
24
+ Metrics/BlockNesting:
25
+ Enabled: false
26
+
27
+ Style/IfUnlessModifier:
28
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.3] - 2021-06-25
4
+
5
+ - Rubocop setup
6
+ - Add rubies 2.3, 2.4, 2.5 and 2.6 to support of gem
7
+
3
8
  ## [0.3.2] - 2021-06-24
4
9
 
5
10
  - Setup for run tests/specs locally with Docker
data/README.md CHANGED
@@ -7,6 +7,7 @@
7
7
  [![Gem](https://img.shields.io/gem/dt/qrcode_pix_ruby.svg)]()
8
8
  [![license](https://img.shields.io/github/license/pedrofurtado/qrcode_pix_ruby.svg)]()
9
9
  [![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/pedrofurtado/qrcode_pix_ruby)
10
+ [![Ruby Style Guide](https://img.shields.io/badge/code_style-rubocop-brightgreen.svg)](https://github.com/rubocop/rubocop)
10
11
 
11
12
  Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro - Banco Central do Brasil).
12
13
 
@@ -83,8 +84,8 @@ git clone https://github.com/pedrofurtado/qrcode_pix_ruby
83
84
  cd qrcode_pix_ruby/
84
85
  docker build -t qrcode_pix_ruby_specs .
85
86
 
86
- # Then, run this command how many times you want,
87
- # after editing local files, and so on, to get
87
+ # Then, run this command how many times you want,
88
+ # after editing local files, and so on, to get
88
89
  # feedback from test suite of gem.
89
90
  docker run -v $(pwd):/app/ -it qrcode_pix_ruby_specs
90
91
  ```
data/Rakefile CHANGED
@@ -2,5 +2,7 @@
2
2
 
3
3
  require 'bundler/gem_tasks'
4
4
  require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
5
6
  RSpec::Core::RakeTask.new(:spec)
6
- task default: %i[spec]
7
+ RuboCop::RakeTask.new
8
+ task default: %i[spec rubocop]
@@ -4,22 +4,22 @@ require 'rqrcode'
4
4
 
5
5
  module QrcodePixRuby
6
6
  class Payload
7
- ID_PAYLOAD_FORMAT_INDICATOR = '00'.freeze
8
- ID_POINT_OF_INITIATION_METHOD = '01'.freeze
9
- ID_MERCHANT_ACCOUNT_INFORMATION = '26'.freeze
10
- ID_MERCHANT_ACCOUNT_INFORMATION_GUI = '00'.freeze
11
- ID_MERCHANT_ACCOUNT_INFORMATION_KEY = '01'.freeze
12
- ID_MERCHANT_ACCOUNT_INFORMATION_DESCRIPTION = '02'.freeze
13
- ID_MERCHANT_CATEGORY_CODE = '52'.freeze
14
- ID_TRANSACTION_CURRENCY = '53'.freeze
15
- ID_TRANSACTION_AMOUNT = '54'.freeze
16
- ID_COUNTRY_CODE = '58'.freeze
17
- ID_MERCHANT_NAME = '59'.freeze
18
- ID_MERCHANT_CITY = '60'.freeze
19
- ID_POSTAL_CODE = '61'.freeze
20
- ID_ADDITIONAL_DATA_FIELD_TEMPLATE = '62'.freeze
21
- ID_ADDITIONAL_DATA_FIELD_TEMPLATE_TXID = '05'.freeze
22
- ID_CRC16 = '63'.freeze
7
+ ID_PAYLOAD_FORMAT_INDICATOR = '00'
8
+ ID_POINT_OF_INITIATION_METHOD = '01'
9
+ ID_MERCHANT_ACCOUNT_INFORMATION = '26'
10
+ ID_MERCHANT_ACCOUNT_INFORMATION_GUI = '00'
11
+ ID_MERCHANT_ACCOUNT_INFORMATION_KEY = '01'
12
+ ID_MERCHANT_ACCOUNT_INFORMATION_DESCRIPTION = '02'
13
+ ID_MERCHANT_CATEGORY_CODE = '52'
14
+ ID_TRANSACTION_CURRENCY = '53'
15
+ ID_TRANSACTION_AMOUNT = '54'
16
+ ID_COUNTRY_CODE = '58'
17
+ ID_MERCHANT_NAME = '59'
18
+ ID_MERCHANT_CITY = '60'
19
+ ID_POSTAL_CODE = '61'
20
+ ID_ADDITIONAL_DATA_FIELD_TEMPLATE = '62'
21
+ ID_ADDITIONAL_DATA_FIELD_TEMPLATE_TXID = '05'
22
+ ID_CRC16 = '63'
23
23
 
24
24
  attr_accessor :pix_key,
25
25
  :repeatable,
@@ -33,7 +33,7 @@ module QrcodePixRuby
33
33
  :amount
34
34
 
35
35
  def payload
36
- p = ''
36
+ p = ''
37
37
 
38
38
  p += emv(ID_PAYLOAD_FORMAT_INDICATOR, '01')
39
39
  p += emv_repeatable
@@ -51,7 +51,17 @@ module QrcodePixRuby
51
51
  end
52
52
 
53
53
  def base64
54
- ::RQRCode::QRCode.new(payload).as_png(bit_depth: 1, border_modules: 0, color_mode: 0, color: 'black', file: nil, fill: 'white', module_px_size: 6, resize_exactly_to: false, resize_gte_to: false).to_data_url
54
+ ::RQRCode::QRCode.new(payload).as_png(
55
+ bit_depth: 1,
56
+ border_modules: 0,
57
+ color_mode: 0,
58
+ color: 'black',
59
+ file: nil,
60
+ fill: 'white',
61
+ module_px_size: 6,
62
+ resize_exactly_to: false,
63
+ resize_gte_to: false
64
+ ).to_data_url
55
65
  end
56
66
 
57
67
  private
@@ -66,41 +76,34 @@ module QrcodePixRuby
66
76
  end
67
77
 
68
78
  def emv_merchant
69
- merchant_gui = emv ID_MERCHANT_ACCOUNT_INFORMATION_GUI, 'BR.GOV.BCB.PIX'
70
- merchant_pix_key = emv ID_MERCHANT_ACCOUNT_INFORMATION_KEY, pix_key
79
+ merchant_gui = emv(ID_MERCHANT_ACCOUNT_INFORMATION_GUI, 'BR.GOV.BCB.PIX')
80
+ merchant_pix_key = emv(ID_MERCHANT_ACCOUNT_INFORMATION_KEY, pix_key)
71
81
  merchant_description = emv(ID_MERCHANT_ACCOUNT_INFORMATION_DESCRIPTION, description) if description
72
-
73
- emv ID_MERCHANT_ACCOUNT_INFORMATION, "#{merchant_gui}#{merchant_pix_key}#{merchant_description}"
82
+ emv(ID_MERCHANT_ACCOUNT_INFORMATION, "#{merchant_gui}#{merchant_pix_key}#{merchant_description}")
74
83
  end
75
84
 
76
85
  def emv_additional_data
77
86
  txid = emv(ID_ADDITIONAL_DATA_FIELD_TEMPLATE_TXID, transaction_id || '***')
78
- emv ID_ADDITIONAL_DATA_FIELD_TEMPLATE, txid
87
+ emv(ID_ADDITIONAL_DATA_FIELD_TEMPLATE, txid)
79
88
  end
80
89
 
81
- def crc16(t)
82
- extended_payload = "#{t}#{ID_CRC16}04"
90
+ def crc16(text)
91
+ extended_payload = "#{text}#{ID_CRC16}04"
83
92
  extended_payload_length = extended_payload.length
84
93
  polynomial = 0x1021
85
94
  result = 0xFFFF
86
95
 
87
- if extended_payload_length > 0
96
+ if extended_payload_length.positive?
88
97
  offset = 0
89
98
 
90
99
  while offset < extended_payload_length
91
- result = result ^ (extended_payload[offset].bytes[0] << 8)
92
-
100
+ result ^= extended_payload[offset].bytes[0] << 8
93
101
  bitwise = 0
94
102
 
95
103
  while bitwise < 8
96
- result = result << 1
97
-
98
- if result & 0x10000 != 0
99
- result = result ^ polynomial
100
- end
101
-
102
- result = result & 0xFFFF
103
-
104
+ result <<= 1
105
+ result ^= polynomial if result & 0x10000 != 0
106
+ result &= 0xFFFF
104
107
  bitwise += 1
105
108
  end
106
109
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module QrcodePixRuby
4
- VERSION = '0.3.2'.freeze
4
+ VERSION = '0.3.3'
5
5
  end
@@ -5,15 +5,16 @@ require_relative 'lib/qrcode_pix_ruby/version'
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'qrcode_pix_ruby'
7
7
  spec.version = QrcodePixRuby::VERSION
8
- spec.authors = ["Pedro Furtado", "Marcio de Jesus", "William Radi", "Leonardo Comar"]
9
- spec.email = ["pedro.felipe.azevedo.furtado@gmail.com", "marciodejesusrj@gmail.com", "williamw@lbv.org.br", "lfcomar@lbv.org.br"]
10
- spec.summary = "Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro - Banco Central do Brasil)"
11
- spec.description = "Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro - Banco Central do Brasil)"
12
- spec.homepage = "https://github.com/pedrofurtado/qrcode_pix_ruby"
13
- spec.license = "MIT"
14
- spec.metadata["homepage_uri"] = spec.homepage
15
- spec.metadata["source_code_uri"] = spec.homepage
16
- spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md"
8
+ spec.authors = ['Pedro Furtado', 'Marcio de Jesus', 'William Radi', 'Leonardo Comar']
9
+ spec.email = ['pedro.felipe.azevedo.furtado@gmail.com', 'marciodejesusrj@gmail.com', 'williamw@lbv.org.br', 'lfcomar@lbv.org.br']
10
+ spec.summary = 'Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro - Banco Central do Brasil)'
11
+ spec.description = 'Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro - Banco Central do Brasil)'
12
+ spec.homepage = 'https://github.com/pedrofurtado/qrcode_pix_ruby'
13
+ spec.license = 'MIT'
14
+ spec.metadata['homepage_uri'] = spec.homepage
15
+ spec.metadata['source_code_uri'] = spec.homepage
16
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/CHANGELOG.md"
17
+ spec.required_ruby_version = '>= 2.3.0'
17
18
 
18
19
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
20
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
@@ -23,7 +24,8 @@ Gem::Specification.new do |spec|
23
24
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
24
25
  spec.require_paths = ['lib']
25
26
 
26
- spec.add_dependency 'rake', '~> 13.0'
27
- spec.add_dependency 'rspec', '~> 3.0'
28
- spec.add_dependency 'rqrcode', '~> 2.0'
27
+ spec.add_dependency 'rqrcode'
28
+ spec.add_development_dependency 'rake'
29
+ spec.add_development_dependency 'rspec'
30
+ spec.add_development_dependency 'rubocop'
29
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qrcode_pix_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Furtado
@@ -11,50 +11,64 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2021-06-25 00:00:00.000000000 Z
14
+ date: 2021-06-26 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
- name: rake
17
+ name: rqrcode
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - "~>"
20
+ - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: '13.0'
22
+ version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '13.0'
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
30
44
  - !ruby/object:Gem::Dependency
31
45
  name: rspec
32
46
  requirement: !ruby/object:Gem::Requirement
33
47
  requirements:
34
- - - "~>"
48
+ - - ">="
35
49
  - !ruby/object:Gem::Version
36
- version: '3.0'
37
- type: :runtime
50
+ version: '0'
51
+ type: :development
38
52
  prerelease: false
39
53
  version_requirements: !ruby/object:Gem::Requirement
40
54
  requirements:
41
- - - "~>"
55
+ - - ">="
42
56
  - !ruby/object:Gem::Version
43
- version: '3.0'
57
+ version: '0'
44
58
  - !ruby/object:Gem::Dependency
45
- name: rqrcode
59
+ name: rubocop
46
60
  requirement: !ruby/object:Gem::Requirement
47
61
  requirements:
48
- - - "~>"
62
+ - - ">="
49
63
  - !ruby/object:Gem::Version
50
- version: '2.0'
51
- type: :runtime
64
+ version: '0'
65
+ type: :development
52
66
  prerelease: false
53
67
  version_requirements: !ruby/object:Gem::Requirement
54
68
  requirements:
55
- - - "~>"
69
+ - - ">="
56
70
  - !ruby/object:Gem::Version
57
- version: '2.0'
71
+ version: '0'
58
72
  description: Ruby gem for Qrcode generation of Pix (Pagamento Instantâneo Brasileiro
59
73
  - Banco Central do Brasil)
60
74
  email:
@@ -70,6 +84,7 @@ files:
70
84
  - ".github/workflows/rubygems.yml"
71
85
  - ".gitignore"
72
86
  - ".rspec"
87
+ - ".rubocop.yml"
73
88
  - CHANGELOG.md
74
89
  - CODE_OF_CONDUCT.md
75
90
  - Dockerfile
@@ -99,7 +114,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
99
114
  requirements:
100
115
  - - ">="
101
116
  - !ruby/object:Gem::Version
102
- version: '0'
117
+ version: 2.3.0
103
118
  required_rubygems_version: !ruby/object:Gem::Requirement
104
119
  requirements:
105
120
  - - ">="