credit_card_validations 5.0.0 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build.yml +9 -7
- data/Changelog.md +15 -0
- data/README.md +12 -0
- data/credit_card_validations.gemspec +4 -4
- data/lib/credit_card_validations/configuration.rb +9 -0
- data/lib/credit_card_validations/version.rb +1 -1
- data/lib/credit_card_validations.rb +23 -2
- data/lib/data/brands.yaml +3 -5
- data/spec/credit_card_validations_spec.rb +33 -0
- data/spec/fixtures/overrided_brands.yml +19 -0
- data/spec/test_helper.rb +1 -0
- metadata +14 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b8d3e090e222ece5a4532b931d8bfedf9a4ac73e2c924e09c6c2d465364c3ca
|
4
|
+
data.tar.gz: 10f9892d010c271806dcbce9c26178a3318873ae3b925c719e6e496a529bc89b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4bc9ea274ed6cf155c6185b36bca6a99c28fcf7f73634b4679c0ffe2103b953fad46f8595dc82a76ba559358554d968faccdfe511c4666395c718e4296abfe8
|
7
|
+
data.tar.gz: 9c7dd57ab21943def16202b67a50494713cfc46c30c6b2cf6f11208d81c9ee721edf48e3ada864a7abdb081c2f14990ec905504b4db9920b209bdb3fdbb665a7
|
data/.github/workflows/build.yml
CHANGED
@@ -6,25 +6,27 @@ on:
|
|
6
6
|
- master
|
7
7
|
jobs:
|
8
8
|
test:
|
9
|
-
name: Tests with Ruby ${{ matrix.ruby }} Rails ${{ matrix.rails }}
|
9
|
+
name: Tests with Ruby ${{ matrix.ruby-version }} Rails ${{ matrix.rails }}
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
strategy:
|
12
12
|
matrix:
|
13
13
|
ruby-version:
|
14
14
|
- 2.7
|
15
|
-
- 3.0
|
15
|
+
- '3.0'
|
16
|
+
- 3.1
|
17
|
+
- 3.2
|
16
18
|
rails:
|
17
19
|
- '6.1.5'
|
18
20
|
- '7.0.2.3'
|
21
|
+
- '7.1.0'
|
19
22
|
env:
|
20
23
|
RAILS_VERSION: ${{ matrix.rails }}
|
21
24
|
steps:
|
22
|
-
- uses: actions/checkout@
|
23
|
-
- uses:
|
25
|
+
- uses: actions/checkout@v3
|
26
|
+
- uses: ruby/setup-ruby@v1
|
24
27
|
with:
|
25
28
|
ruby-version: ${{ matrix.ruby-version }}
|
29
|
+
bundler-cache: true
|
26
30
|
- name: Run tests
|
27
31
|
run: |
|
28
|
-
|
29
|
-
bundle install
|
30
|
-
bundle exec rake
|
32
|
+
bundle exec rake
|
data/Changelog.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
# 6.0.0
|
2
|
+
* changes to discover branch
|
3
|
+
* allows to configure usage of own yaml brands file
|
4
|
+
|
5
|
+
# 5.0.0
|
6
|
+
* rails 7 support
|
7
|
+
* drop rails support < 5.2
|
8
|
+
|
9
|
+
# 4.1.0
|
10
|
+
* changes to disover and maesto rules
|
11
|
+
|
12
|
+
# 4.0.0
|
13
|
+
* support rails 6
|
14
|
+
* test against ruby 3.0, drop ruby 2.1 support
|
15
|
+
|
1
16
|
# 3.5.1
|
2
17
|
* Bump activemodel and activesupport versions
|
3
18
|
|
data/README.md
CHANGED
@@ -146,6 +146,18 @@ require 'credit_card_validations/plugins/laser'
|
|
146
146
|
require 'credit_card_validations/plugins/diners_us'
|
147
147
|
```
|
148
148
|
|
149
|
+
|
150
|
+
### Configuration
|
151
|
+
|
152
|
+
In order to override default data source you can copy [original one](https://github.com/didww/credit_card_validations/blob/master/lib/data/brands.yaml) , change it and configure during rails initializer
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
CreditCardValidations.configure do |config|
|
156
|
+
config.source = '/path/to/my_brands.yml'
|
157
|
+
end
|
158
|
+
```
|
159
|
+
|
160
|
+
|
149
161
|
## Contributing
|
150
162
|
|
151
163
|
1. Fork it
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.summary = "gem should be used for credit card numbers validation, card brands detections, luhn checks"
|
13
13
|
gem.homepage = "http://didww.github.io/credit_card_validations/"
|
14
14
|
gem.license = "MIT"
|
15
|
-
|
15
|
+
|
16
16
|
gem.metadata = {
|
17
17
|
'bug_tracker_uri' => 'https://github.com/didww/credit_card_validations/issues',
|
18
18
|
'changelog_uri' => 'https://github.com/didww/credit_card_validations/blob/master/Changelog.md',
|
@@ -25,12 +25,12 @@ Gem::Specification.new do |gem|
|
|
25
25
|
gem.require_paths = ["lib"]
|
26
26
|
|
27
27
|
|
28
|
-
gem.add_dependency "activemodel", ">= 5.2", "< 7.
|
29
|
-
gem.add_dependency "activesupport", ">= 5.2", "< 7.
|
28
|
+
gem.add_dependency "activemodel", ">= 5.2", "< 7.2"
|
29
|
+
gem.add_dependency "activesupport", ">= 5.2", "< 7.2"
|
30
30
|
|
31
31
|
|
32
32
|
gem.add_development_dependency "minitest", '~> 5.14.3'
|
33
33
|
gem.add_development_dependency "mocha", '1.1.0'
|
34
|
-
gem.add_development_dependency 'rake'
|
34
|
+
gem.add_development_dependency 'rake'
|
35
35
|
gem.add_development_dependency 'byebug'
|
36
36
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'credit_card_validations/version'
|
2
|
+
require 'credit_card_validations/configuration'
|
2
3
|
require 'credit_card_validations/error'
|
3
4
|
require 'active_model'
|
4
5
|
require 'active_support/core_ext'
|
@@ -14,16 +15,36 @@ module CreditCardValidations
|
|
14
15
|
autoload :Factory, 'credit_card_validations/factory'
|
15
16
|
autoload :Mmi, 'credit_card_validations/mmi'
|
16
17
|
|
18
|
+
attr_accessor :configuration
|
19
|
+
|
20
|
+
def self.configuration
|
21
|
+
@configuration ||= Configuration.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.reset
|
25
|
+
@configuration = Configuration.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.configure
|
29
|
+
yield(configuration)
|
30
|
+
reload!
|
31
|
+
end
|
17
32
|
|
18
33
|
def self.add_brand(key, rules, options = {})
|
19
34
|
Detector.add_brand(key, rules, options)
|
20
35
|
end
|
21
36
|
|
22
|
-
|
37
|
+
def self.source
|
38
|
+
configuration.source || File.join(File.join(File.dirname(__FILE__)), 'data', 'brands.yaml')
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.data
|
42
|
+
YAML.load_file(source) || {}
|
43
|
+
end
|
23
44
|
|
24
45
|
def self.reload!
|
25
46
|
Detector.brands = {}
|
26
|
-
|
47
|
+
data.each do |key, data|
|
27
48
|
add_brand(key, data.fetch(:rules), data.fetch(:options, {}))
|
28
49
|
end
|
29
50
|
end
|
data/lib/data/brands.yaml
CHANGED
@@ -486,16 +486,14 @@
|
|
486
486
|
- '303'
|
487
487
|
- '304'
|
488
488
|
- '305'
|
489
|
+
- '3095'
|
490
|
+
- '36'
|
489
491
|
- '38'
|
490
492
|
- '39'
|
491
493
|
- '60110'
|
492
494
|
- '60112'
|
493
495
|
- '60113'
|
494
|
-
- '
|
495
|
-
- '601141'
|
496
|
-
- '601142'
|
497
|
-
- '601143'
|
498
|
-
- '601144'
|
496
|
+
- '60114'
|
499
497
|
- '601174'
|
500
498
|
- '601177'
|
501
499
|
- '601178'
|
@@ -7,6 +7,39 @@ describe CreditCardValidations do
|
|
7
7
|
CreditCardValidations.reload!
|
8
8
|
end
|
9
9
|
|
10
|
+
|
11
|
+
describe 'configure' do
|
12
|
+
|
13
|
+
let(:number) { '6111111180456137' }
|
14
|
+
|
15
|
+
before do
|
16
|
+
expect(card_detector.valid?(:discover)).must_equal false
|
17
|
+
CreditCardValidations.configure do |config|
|
18
|
+
config.source = OVERRIDED_BRANDS_FILE
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:card_detector) {
|
23
|
+
detector(number)
|
24
|
+
}
|
25
|
+
|
26
|
+
it 'should generate overrided discover' do
|
27
|
+
discover = CreditCardValidations::Factory.random(:discover)
|
28
|
+
expect(detector(discover).valid?('DiscoverBrand')).must_equal true
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should detect patched discover' do
|
32
|
+
expect(card_detector.valid?(:discover)).must_equal true
|
33
|
+
expect(card_detector.valid?(:visa)).must_equal false
|
34
|
+
end
|
35
|
+
|
36
|
+
after do
|
37
|
+
CreditCardValidations.reset
|
38
|
+
CreditCardValidations.reload!
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
10
43
|
describe 'MMI' do
|
11
44
|
it 'should detect issuer category' do
|
12
45
|
d = detector(VALID_NUMBERS[:visa].first)
|
data/spec/test_helper.rb
CHANGED
@@ -15,4 +15,5 @@ require 'models/credit_card'
|
|
15
15
|
|
16
16
|
VALID_NUMBERS = YAML.load_file File.join(File.dirname(__FILE__), 'fixtures/valid_cards.yml')
|
17
17
|
INVALID_NUMBERS = YAML.load_file File.join(File.dirname(__FILE__), 'fixtures/invalid_cards.yml')
|
18
|
+
OVERRIDED_BRANDS_FILE = File.join(File.dirname(__FILE__), 'fixtures/overrided_brands.yml')
|
18
19
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: credit_card_validations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '5.2'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '7.
|
22
|
+
version: '7.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '5.2'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '7.
|
32
|
+
version: '7.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: '5.2'
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '7.
|
42
|
+
version: '7.2'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: '5.2'
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '7.
|
52
|
+
version: '7.2'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: minitest
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,16 +82,16 @@ dependencies:
|
|
82
82
|
name: rake
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
-
- - "
|
85
|
+
- - ">="
|
86
86
|
- !ruby/object:Gem::Version
|
87
|
-
version: '
|
87
|
+
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
90
|
version_requirements: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
|
-
- - "
|
92
|
+
- - ">="
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: '
|
94
|
+
version: '0'
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
96
|
name: byebug
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- credit_card_validations.gemspec
|
125
125
|
- lib/active_model/credit_card_number_validator.rb
|
126
126
|
- lib/credit_card_validations.rb
|
127
|
+
- lib/credit_card_validations/configuration.rb
|
127
128
|
- lib/credit_card_validations/detector.rb
|
128
129
|
- lib/credit_card_validations/error.rb
|
129
130
|
- lib/credit_card_validations/factory.rb
|
@@ -139,6 +140,7 @@ files:
|
|
139
140
|
- spec/credit_card_validations_spec.rb
|
140
141
|
- spec/factory_spec.rb
|
141
142
|
- spec/fixtures/invalid_cards.yml
|
143
|
+
- spec/fixtures/overrided_brands.yml
|
142
144
|
- spec/fixtures/valid_cards.yml
|
143
145
|
- spec/models/credit_card.rb
|
144
146
|
- spec/string_spec.rb
|
@@ -165,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
167
|
- !ruby/object:Gem::Version
|
166
168
|
version: '0'
|
167
169
|
requirements: []
|
168
|
-
rubygems_version: 3.
|
170
|
+
rubygems_version: 3.3.7
|
169
171
|
signing_key:
|
170
172
|
specification_version: 4
|
171
173
|
summary: gem should be used for credit card numbers validation, card brands detections,
|
@@ -175,6 +177,7 @@ test_files:
|
|
175
177
|
- spec/credit_card_validations_spec.rb
|
176
178
|
- spec/factory_spec.rb
|
177
179
|
- spec/fixtures/invalid_cards.yml
|
180
|
+
- spec/fixtures/overrided_brands.yml
|
178
181
|
- spec/fixtures/valid_cards.yml
|
179
182
|
- spec/models/credit_card.rb
|
180
183
|
- spec/string_spec.rb
|