issuer_response_codes 0.2.5 → 0.3.1

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: 37ba4c8ea618ac92cad2812d33718b65dc667a9cd33c74f9022682490c6c262a
4
- data.tar.gz: ce06e7107a1138c0c681a78bf03e8336eaa5ef9745c58c9781dedf221e1b9c14
3
+ metadata.gz: 839c0044ecc25de1dc98ccf239876473f0330bdfb4366f7ea0f58bc56782f6d4
4
+ data.tar.gz: de71594e7157bc85257bbe19356f4c7f4b44493524498725da34c9ba3dd2ebf0
5
5
  SHA512:
6
- metadata.gz: fc4cc8e087f2c0b4d44a14de3cb4ba06b171880fe0a77ed65677fea7d8b26ebbb4a6ec3e53e55ca41ff3c71e131cc59c4f00a3f66356a97f24fd995bc098c5fd
7
- data.tar.gz: dde8649dc04e1243d070774403c28697b4e0cdd33ebbc8f8b37f8ed6cafbe16b134fdb9c38cc54c96863bcdc7b33c94357360d4b846ea8eae30973e8cee62454
6
+ metadata.gz: 58f2791696723f19735d73618d477003ae2eebfc253a62118432754c6c12ef4d12bd9ac5ad0ad1616ee8c44b4cddac3fbcdce2c5516c3d6f9309b377a522cb9e
7
+ data.tar.gz: 4df9f02699234b177ce31e412c6763d7bb574cb4920897bd06aedaa373655151980a66007388f1da12667c72982c4b44eeb942a2c73740e31a514241d1ff8993
@@ -0,0 +1,38 @@
1
+ name: CI Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ 'main' ]
6
+ pull_request:
7
+ branches: [ 'main' ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ env:
13
+ CI: true
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ['3.0', '3.1', '3.2']
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v3
20
+ - name: Install Ruby and gems
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
25
+ - name: Run unit tests
26
+ run: bundle exec rake test
27
+
28
+ lint:
29
+ runs-on: ubuntu-latest
30
+ steps:
31
+ - name: Checkout code
32
+ uses: actions/checkout@v3
33
+ - name: Install Ruby and gems
34
+ uses: ruby/setup-ruby@v1
35
+ with:
36
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
37
+ - name: Lint
38
+ run: bundle exec rubocop --parallel --color
data/.rubocop.yml CHANGED
@@ -1,78 +1,5 @@
1
- Style/StringLiterals:
2
- Enabled: false
3
-
4
- Style/SingleArgumentDig:
5
- Enabled: false
6
-
7
- Layout/LineLength:
8
- Enabled: false
9
-
10
- Style/Documentation:
11
- Enabled: false
12
-
13
- Style/ClassAndModuleChildren:
14
- Enabled: false
15
-
16
- Style/MethodCallWithArgsParentheses:
17
- Enabled: false
18
-
19
- Style/ModuleFunction:
20
- EnforcedStyle: 'extend_self'
21
-
22
- Style/MissingElse:
23
- Enabled: false
24
-
25
- Lint/NumberConversion:
26
- Enabled: false
27
-
28
- Lint/ConstantResolution:
29
- Enabled: false
30
-
31
- Style/RescueStandardError:
32
- Enabled: false
33
-
34
- Style/FormatStringToken:
35
- Enabled: false
36
-
37
- Style/FormatString:
38
- Enabled: false
39
-
40
- Style/DocumentationMethod:
41
- Enabled: false
42
-
43
- Style/Copyright:
44
- Enabled: false
45
-
46
- Style/StringHashKeys:
47
- Enabled: false
48
-
49
- Style/InlineComment:
50
- Enabled: false
51
-
52
- Layout/FirstHashElementLineBreak:
53
- Enabled: false
54
-
55
- Layout/FirstMethodArgumentLineBreak:
56
- Enabled: false
57
-
58
- Style/ConstantVisibility:
59
- Enabled: false
60
-
61
- Layout/FirstArrayElementLineBreak:
62
- Enabled: false
63
-
64
- Layout/MultilineMethodArgumentLineBreaks:
65
- Enabled: false
66
-
67
- Layout/MultilineAssignmentLayout:
68
- Enabled: false
69
-
70
- Bundler/GemComment:
71
- Enabled: false
1
+ inherit_gem:
2
+ rubocop-espago: rubocop.yml
72
3
 
73
4
  AllCops:
74
- EnabledByDefault: true
75
- Exclude:
76
- - 'bin/*'
77
- - 'spec/**/*'
78
- - 'test/**/*'
5
+ TargetRubyVersion: 3.0
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.2
1
+ 3.1.4
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+
9
+ ## [0.3.0]
10
+
11
+ [Diff](https://github.com/espago/issuer_response_codes/compare/v0.3.0...espago:issuer_response_codes:v0.2.5)
12
+
13
+ This release adds support for Ruby 3.1 and 3.2 and full translations for brand new languages: `:es, :fi, :fr, :hr, :it, :nl, :pt`.
data/Gemfile CHANGED
@@ -1,6 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in issuer_response_codes.gemspec
6
6
  gemspec
7
+
8
+ gem 'bundler', '~> 2.0' # library manager
9
+ gem 'debug', '~> 1.6.3' # debugger
10
+ gem 'minitest', '~> 5.0' # test framework
11
+ gem 'rake', '~> 12.0' # automation
12
+ gem 'rubocop', '~> 1.54' # linter
13
+ gem 'rubocop-espago', '~> 1.0' # linter config
14
+ gem 'solargraph', '~> 0.49' # language server
data/Gemfile.lock CHANGED
@@ -1,84 +1,97 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- issuer_response_codes (0.2.5)
4
+ issuer_response_codes (0.3.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  ast (2.4.2)
10
10
  backport (1.2.0)
11
- benchmark (0.1.1)
12
- bundler-audit (0.8.0)
13
- bundler (>= 1.2.0, < 3)
14
- thor (~> 1.0)
15
- byebug (11.1.3)
16
- diff-lcs (1.4.4)
11
+ benchmark (0.2.1)
12
+ debug (1.6.3)
13
+ irb (>= 1.3.6)
14
+ reline (>= 0.3.1)
15
+ diff-lcs (1.5.0)
17
16
  e2mmap (0.1.0)
18
- jaro_winkler (1.5.4)
19
- kramdown (2.3.1)
17
+ io-console (0.5.11)
18
+ irb (1.4.1)
19
+ reline (>= 0.3.0)
20
+ jaro_winkler (1.5.6)
21
+ json (2.6.3)
22
+ kramdown (2.4.0)
20
23
  rexml
21
24
  kramdown-parser-gfm (1.1.0)
22
25
  kramdown (~> 2.0)
23
- mini_portile2 (2.5.3)
24
- minitest (5.14.4)
25
- nokogiri (1.11.7)
26
- mini_portile2 (~> 2.5.0)
26
+ language_server-protocol (3.17.0.3)
27
+ mini_portile2 (2.8.4)
28
+ minitest (5.18.1)
29
+ nokogiri (1.15.3)
30
+ mini_portile2 (~> 2.8.2)
27
31
  racc (~> 1.4)
28
- parallel (1.20.1)
29
- parser (3.0.1.1)
32
+ parallel (1.23.0)
33
+ parser (3.2.2.3)
30
34
  ast (~> 2.4.1)
31
- racc (1.5.2)
32
- rainbow (3.0.0)
35
+ racc
36
+ racc (1.7.1)
37
+ rainbow (3.1.1)
33
38
  rake (12.3.3)
34
- regexp_parser (2.1.1)
35
- reverse_markdown (2.0.0)
39
+ rbs (2.8.4)
40
+ regexp_parser (2.8.1)
41
+ reline (0.3.1)
42
+ io-console (~> 0.5)
43
+ reverse_markdown (2.1.1)
36
44
  nokogiri
37
45
  rexml (3.2.5)
38
- rubocop (1.18.2)
46
+ rubocop (1.54.2)
47
+ json (~> 2.3)
48
+ language_server-protocol (>= 3.17.0)
39
49
  parallel (~> 1.10)
40
- parser (>= 3.0.0.0)
50
+ parser (>= 3.2.2.3)
41
51
  rainbow (>= 2.2.2, < 4.0)
42
52
  regexp_parser (>= 1.8, < 3.0)
43
- rexml
44
- rubocop-ast (>= 1.7.0, < 2.0)
53
+ rexml (>= 3.2.5, < 4.0)
54
+ rubocop-ast (>= 1.28.0, < 2.0)
45
55
  ruby-progressbar (~> 1.7)
46
- unicode-display_width (>= 1.4.0, < 3.0)
47
- rubocop-ast (1.7.0)
48
- parser (>= 3.0.1.1)
49
- ruby-progressbar (1.11.0)
50
- solargraph (0.42.3)
56
+ unicode-display_width (>= 2.4.0, < 3.0)
57
+ rubocop-ast (1.29.0)
58
+ parser (>= 3.2.1.0)
59
+ rubocop-espago (1.0.3)
60
+ rubocop
61
+ ruby-progressbar (1.13.0)
62
+ solargraph (0.49.0)
51
63
  backport (~> 1.2)
52
64
  benchmark
53
- bundler (>= 1.17.2)
65
+ bundler (~> 2.0)
54
66
  diff-lcs (~> 1.4)
55
67
  e2mmap
56
68
  jaro_winkler (~> 1.5)
57
69
  kramdown (~> 2.3)
58
70
  kramdown-parser-gfm (~> 1.1)
59
71
  parser (~> 3.0)
60
- reverse_markdown (>= 1.0.5, < 3)
61
- rubocop (>= 0.52)
72
+ rbs (~> 2.0)
73
+ reverse_markdown (~> 2.0)
74
+ rubocop (~> 1.38)
62
75
  thor (~> 1.0)
63
76
  tilt (~> 2.0)
64
77
  yard (~> 0.9, >= 0.9.24)
65
- thor (1.1.0)
66
- tilt (2.0.10)
67
- unicode-display_width (2.0.0)
68
- yard (0.9.26)
78
+ thor (1.2.2)
79
+ tilt (2.2.0)
80
+ unicode-display_width (2.4.2)
81
+ yard (0.9.34)
69
82
 
70
83
  PLATFORMS
71
84
  ruby
72
85
 
73
86
  DEPENDENCIES
74
- bundler
75
- bundler-audit
76
- byebug
87
+ bundler (~> 2.0)
88
+ debug (~> 1.6.3)
77
89
  issuer_response_codes!
78
90
  minitest (~> 5.0)
79
91
  rake (~> 12.0)
80
- rubocop
81
- solargraph
92
+ rubocop (~> 1.54)
93
+ rubocop-espago (~> 1.0)
94
+ solargraph (~> 0.49)
82
95
 
83
96
  BUNDLED WITH
84
- 2.1.4
97
+ 2.4.17
data/README.md CHANGED
@@ -1,15 +1,22 @@
1
1
  # IssuerResponseCodes
2
2
 
3
- This gem provides a quite comprehensive library of Issuer Response Code and 3D-Secure Status Code descriptions (for both cardholders and merchants) with suggested actions in 9 languages:
3
+ This gem provides a quite comprehensive library of Issuer Response Code and 3D-Secure Status Code descriptions (for both cardholders and merchants) with suggested actions in many languages:
4
+
4
5
  - Complete locales:
5
6
  - en
6
7
  - pl
8
+ - es
9
+ - fi
10
+ - fr
11
+ - hr
12
+ - it
13
+ - nl
14
+ - pt
7
15
 
8
16
  - Incomplete locales:
9
17
  - da
10
18
  - de
11
19
  - ee
12
- - it
13
20
  - lt
14
21
  - lv
15
22
  - sv
@@ -133,7 +140,7 @@ code.behaviour #=> "Please contact your card issuer to get more details and try
133
140
 
134
141
  ##### Locale
135
142
 
136
- The default locale is `:en`. There are 7 in total: `%i[en pl da ee lt lv sv]`. Only the first two are complete, the rest are partially in English.
143
+ The default locale is `:en`. Only the first two are complete, the rest are partially in English.
137
144
 
138
145
  ```ruby
139
146
  code = ::IssuerResponseCodes::Code.new(id: '54')
@@ -146,6 +153,8 @@ code = ::IssuerResponseCodes::Code.new(id: '54', locale: :pl)
146
153
  code.reason #=> "Karta utraciła ważność."
147
154
  ```
148
155
 
156
+ A full list of available locales is stored in `IssuerResponseCodes::AVAILABLE_LOCALES`.
157
+
149
158
  #### Methods
150
159
 
151
160
  ##### reason
@@ -260,7 +269,7 @@ code.behaviour #=> "Please use a different card or contact issuer. Transactions
260
269
 
261
270
  ##### Locale
262
271
 
263
- The default locale is `:en`. There are 7 in total: `%i[en pl da ee lt lv sv]`. Only the first two are complete, the rest are partially in English.
272
+ The default locale is `:en`. Only the first two are complete, the rest are partially in English.
264
273
 
265
274
  ```ruby
266
275
  code = ::IssuerResponseCodes::TdsCode.new(id: '11', target: :cardholder)
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
3
5
 
4
6
  Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
8
10
  end
9
11
 
10
- task :default => :test
12
+ task default: :test
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "issuer_response_codes"
3
+ require 'bundler/setup'
4
+ require 'issuer_response_codes'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,7 @@ require "issuer_response_codes"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
14
- IRB.start(__FILE__)
13
+ include ::IssuerResponseCodes
14
+
15
+ require 'irb'
16
+ ::IRB.start(__FILE__)
@@ -3,34 +3,28 @@
3
3
  require_relative 'lib/issuer_response_codes/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "issuer_response_codes"
6
+ spec.name = 'issuer_response_codes'
7
7
  spec.version = IssuerResponseCodes::VERSION
8
- spec.authors = ["Espago", "Mateusz Drewniak"]
9
- spec.email = ["m.drewniak@espago.com"]
8
+ spec.authors = ['Espago', 'Mateusz Drewniak']
9
+ spec.email = ['m.drewniak@espago.com']
10
10
 
11
- spec.summary = "Issuer Response Code descriptions for cardholders and merchants"
12
- spec.description = "A simple Ruby gem which provides Issuer Response Code descriptions and suggestions for cardholders and merchants"
13
- spec.homepage = "https://github.com/espago/issuer_response_codes"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 2.5")
11
+ spec.summary = 'Issuer Response Code descriptions for cardholders and merchants'
12
+ spec.description =
13
+ 'A simple Ruby gem which provides Issuer Response Code descriptions and suggestions for cardholders and merchants'
14
+ spec.homepage = 'https://github.com/espago/issuer_response_codes'
15
+ spec.license = 'MIT'
16
+ spec.required_ruby_version = Gem::Requirement.new('>= 3.0')
16
17
 
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = "https://github.com/espago/issuer_response_codes"
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = 'https://github.com/espago/issuer_response_codes'
19
20
 
20
21
  # Specify which files should be added to the gem when it is released.
21
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
23
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
24
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
25
  end
25
- spec.bindir = "exe"
26
+ spec.bindir = 'exe'
26
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
- spec.require_paths = ["lib"]
28
-
29
- spec.add_development_dependency 'bundler'
30
- spec.add_development_dependency 'bundler-audit'
31
- spec.add_development_dependency 'byebug'
32
- spec.add_development_dependency 'minitest', '~> 5.0'
33
- spec.add_development_dependency 'rake', '~> 12.0'
34
- spec.add_development_dependency 'rubocop'
35
- spec.add_development_dependency 'solargraph'
28
+ spec.require_paths = ['lib']
29
+ spec.metadata['rubygems_mfa_required'] = 'true'
36
30
  end
@@ -1,11 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IssuerResponseCodes
4
+ # ISO-8583 Response code.
4
5
  class Code
5
6
  attr_reader :id, :target, :locale, :fraud_notice
6
7
 
7
8
  NOT_PROVIDED = ::Object.new
8
9
 
10
+ # @param id [String]
11
+ # @param target [Symbol]
12
+ # @param locale [Symbol]
13
+ # @param fraud_notice [Boolean, Object]
9
14
  def initialize(id:, target: :merchant, locale: :en, fraud_notice: NOT_PROVIDED)
10
15
  @id = id
11
16
  @target = target
@@ -22,25 +27,35 @@ module IssuerResponseCodes
22
27
  @fraud_notice = target == :merchant
23
28
  end
24
29
 
30
+ # @return [String]
25
31
  def humanize
26
32
  "#{reason} #{behaviour}"
27
33
  end
28
-
29
34
  alias description humanize
30
35
 
36
+ # @return [String]
31
37
  def reason
32
- LOCALE_LIBRARY.dig(path: id, scope: "issuer_response_codes.targeted.#{target}", locale: locale, default: :unknown)
38
+ LOCALE_LIBRARY[path: id,
39
+ scope: "issuer_response_codes.targeted.#{target}",
40
+ locale: locale,
41
+ default: :unknown]
33
42
  end
34
43
 
44
+ # @return [String]
35
45
  def behaviour
36
- behaviour_str = LOCALE_LIBRARY.dig(path: id, scope: "issuer_response_codes.behaviour", locale: locale, default: :unknown)
46
+ behaviour_str = LOCALE_LIBRARY[path: id,
47
+ scope: 'issuer_response_codes.behaviour',
48
+ locale: locale,
49
+ default: :unknown]
37
50
  return behaviour_str unless fraud_notice && fraudulent_code?
38
51
 
39
- "#{behaviour_str} #{LOCALE_LIBRARY.dig(path: 'issuer_response_codes.fraud_notice')}"
52
+ "#{behaviour_str} #{LOCALE_LIBRARY[path: 'issuer_response_codes.fraud_notice']}"
40
53
  end
41
54
 
55
+ # @return [Boolean]
42
56
  def fraudulent_code?
43
- @fraudulent_code ||= LOCALE_LIBRARY.dig(path: id, scope: "issuer_response_codes.fraudulent_codes", locale: locale)
57
+ @fraudulent_code ||= LOCALE_LIBRARY[path: id, scope: 'issuer_response_codes.fraudulent_codes', locale: locale]
44
58
  end
59
+
45
60
  end
46
61
  end
@@ -1,11 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IssuerResponseCodes
4
+ # Context stores default settings for retrieving codes.
4
5
  class Context
5
6
  attr_reader :default_target, :default_locale, :fraud_notice_by_default
6
7
 
7
8
  NOT_PROVIDED = ::Object.new
8
9
 
10
+ # @param default_target [Symbol]
11
+ # @param default_locale [Symbol]
12
+ # @param fraud_notice_by_default [Boolean, Object]
13
+ # @raise [IllegalLocale]
14
+ # @raise [IllegalTarget]
9
15
  def initialize(default_target: :merchant, default_locale: :en, fraud_notice_by_default: NOT_PROVIDED)
10
16
  @default_target = default_target
11
17
  @default_locale = default_locale
@@ -21,10 +27,20 @@ module IssuerResponseCodes
21
27
  @fraud_notice_by_default = default_target == :merchant
22
28
  end
23
29
 
30
+ # @param id [String, Symbol]
31
+ # @param target [Symbol]
32
+ # @param locale [Symbol]
33
+ # @param fraud_notice [Boolean, Object]
34
+ # @return [Code]
24
35
  def code(id:, target: default_target, locale: default_locale, fraud_notice: fraud_notice_by_default)
25
36
  Code.new(id: id, target: target, locale: locale, fraud_notice: fraud_notice)
26
37
  end
27
38
 
39
+ # @param id [String, Symbol]
40
+ # @param target [Symbol]
41
+ # @param locale [Symbol]
42
+ # @param fraud_notice [Boolean, Object]
43
+ # @return [TdsCode]
28
44
  def tds_code(id:, target: default_target, locale: default_locale, fraud_notice: fraud_notice_by_default)
29
45
  TdsCode.new(id: id, target: target, locale: locale, fraud_notice: fraud_notice)
30
46
  end