credit_card_validations 4.0.0 → 6.0.0
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 +4 -4
- data/.github/workflows/build.yml +29 -0
- data/Changelog.md +15 -0
- data/Gemfile +2 -1
- data/README.md +12 -2
- data/credit_card_validations.gemspec +3 -3
- 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 +27 -2
- data/spec/credit_card_validations_spec.rb +33 -0
- data/spec/fixtures/overrided_brands.yml +19 -0
- data/spec/fixtures/valid_cards.yml +0 -5
- data/spec/test_helper.rb +2 -3
- metadata +36 -21
- data/.travis.yml +0 -32
- data/gemfiles/rails1-4.gemfile +0 -11
- data/gemfiles/rails5.gemfile +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c955ab578ccc68fa1525166a326408c8f7ceedb16dfd197b4cee363453f4148c
|
4
|
+
data.tar.gz: f66d2c0969e1aac24c04463633e4466c997527b4d9b3a11f36914d207eea08dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96231d43a74789045abf1df806f085d649fb9400c749f2334eaa08771fcc2e369831ae65a74698484fe2b8a531241e8effa4dc6d5258f29523af33319dae435c
|
7
|
+
data.tar.gz: 4926b30dce4ca818b0ab18e7711ba96b8145a461703c3659c3eff1368fa860760febb476d1086b7f7addce5608ee501986c30a2dcb13cdab68f26a78a98e18d7
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: CI
|
2
|
+
on:
|
3
|
+
pull_request:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
name: Tests with Ruby ${{ matrix.ruby }} Rails ${{ matrix.rails }}
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
strategy:
|
12
|
+
matrix:
|
13
|
+
ruby-version:
|
14
|
+
- 2.7
|
15
|
+
- 3.0
|
16
|
+
rails:
|
17
|
+
- '6.1.5'
|
18
|
+
- '7.0.2.3'
|
19
|
+
env:
|
20
|
+
RAILS_VERSION: ${{ matrix.rails }}
|
21
|
+
steps:
|
22
|
+
- uses: actions/checkout@v3
|
23
|
+
- uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ matrix.ruby-version }}
|
26
|
+
bundler-cache: true
|
27
|
+
- name: Run tests
|
28
|
+
run: |
|
29
|
+
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/Gemfile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
group :test do
|
3
|
-
gem '
|
3
|
+
gem 'activemodel', ENV['RAILS_VERSION'], require: false
|
4
|
+
gem 'activesupport', ENV['RAILS_VERSION'], require: false
|
4
5
|
end
|
5
6
|
# Specify your gem's dependencies in credit_card_validations.gemspec
|
6
7
|
gemspec
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
# CreditCardValidations
|
2
2
|
|
3
|
-
[](https://travis-ci.org/didww/credit_card_validations)
|
4
|
-
[](https://coveralls.io/r/Fivell/credit_card_validations)
|
5
3
|
[](https://rubygems.org/gems/credit_card_validations)
|
6
4
|
[](http://didww.mit-license.org)
|
7
5
|
|
@@ -148,6 +146,18 @@ require 'credit_card_validations/plugins/laser'
|
|
148
146
|
require 'credit_card_validations/plugins/diners_us'
|
149
147
|
```
|
150
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
|
+
|
151
161
|
## Contributing
|
152
162
|
|
153
163
|
1. Fork it
|
@@ -25,12 +25,12 @@ Gem::Specification.new do |gem|
|
|
25
25
|
gem.require_paths = ["lib"]
|
26
26
|
|
27
27
|
|
28
|
-
gem.add_dependency "activemodel", ">=
|
29
|
-
gem.add_dependency "activesupport", ">=
|
28
|
+
gem.add_dependency "activemodel", ">= 5.2", "< 7.1"
|
29
|
+
gem.add_dependency "activesupport", ">= 5.2", "< 7.1"
|
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
34
|
gem.add_development_dependency 'rake', '~> 10'
|
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
@@ -197,7 +197,10 @@
|
|
197
197
|
- '637187'
|
198
198
|
- '637529'
|
199
199
|
- '639'
|
200
|
-
- '
|
200
|
+
- '640'
|
201
|
+
- '641'
|
202
|
+
- '642'
|
203
|
+
- '643'
|
201
204
|
- '670'
|
202
205
|
- '671'
|
203
206
|
- '672'
|
@@ -477,7 +480,29 @@
|
|
477
480
|
- 16
|
478
481
|
- 19
|
479
482
|
:prefixes:
|
480
|
-
- '
|
483
|
+
- '300'
|
484
|
+
- '301'
|
485
|
+
- '302'
|
486
|
+
- '303'
|
487
|
+
- '304'
|
488
|
+
- '305'
|
489
|
+
- '3095'
|
490
|
+
- '36'
|
491
|
+
- '38'
|
492
|
+
- '39'
|
493
|
+
- '60110'
|
494
|
+
- '60112'
|
495
|
+
- '60113'
|
496
|
+
- '60114'
|
497
|
+
- '601174'
|
498
|
+
- '601177'
|
499
|
+
- '601178'
|
500
|
+
- '601179'
|
501
|
+
- '601186'
|
502
|
+
- '601187'
|
503
|
+
- '601188'
|
504
|
+
- '601189'
|
505
|
+
- '60119'
|
481
506
|
- '644'
|
482
507
|
- '645'
|
483
508
|
- '646'
|
@@ -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)
|
@@ -43,14 +43,9 @@
|
|
43
43
|
- 3777 5274 9896 404
|
44
44
|
- 3782 8224 6310 005
|
45
45
|
:discover:
|
46
|
-
- 6011 1111 1111 1117
|
47
46
|
- 6011 0009 9013 9424
|
48
47
|
- 6011 0000 0000 0004
|
49
48
|
- 6011 0004 0000 0000
|
50
|
-
- 6011 1532 1637 1980
|
51
|
-
- 6011 6011 6011 6611
|
52
|
-
- 6011 6874 8256 4166
|
53
|
-
- 6011 8148 3690 5651
|
54
49
|
:maestro:
|
55
50
|
- 6759 6498 2643 8453
|
56
51
|
- 5641 8200 0000 0005
|
data/spec/test_helper.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
|
-
require 'coveralls'
|
2
|
-
Coveralls.wear!
|
3
|
-
|
4
1
|
require 'minitest/autorun'
|
5
2
|
require 'i18n'
|
6
3
|
require 'mocha/mini_test'
|
4
|
+
require 'byebug'
|
7
5
|
|
8
6
|
lib = File.expand_path("#{File.dirname(__FILE__)}/../lib")
|
9
7
|
specs = File.expand_path("#{File.dirname(__FILE__)}/../spec")
|
@@ -17,4 +15,5 @@ require 'models/credit_card'
|
|
17
15
|
|
18
16
|
VALID_NUMBERS = YAML.load_file File.join(File.dirname(__FILE__), 'fixtures/valid_cards.yml')
|
19
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')
|
20
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.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -16,40 +16,40 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
- - "
|
19
|
+
version: '5.2'
|
20
|
+
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '7.1'
|
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: '
|
30
|
-
- - "
|
29
|
+
version: '5.2'
|
30
|
+
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '7.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: activesupport
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
40
|
-
- - "
|
39
|
+
version: '5.2'
|
40
|
+
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '7.1'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: '
|
50
|
-
- - "
|
49
|
+
version: '5.2'
|
50
|
+
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '7.1'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: minitest
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,6 +92,20 @@ dependencies:
|
|
92
92
|
- - "~>"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '10'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: byebug
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
95
109
|
description: A ruby gem for validating credit card numbers
|
96
110
|
email:
|
97
111
|
- fedoronchuk@gmail.com
|
@@ -99,19 +113,18 @@ executables: []
|
|
99
113
|
extensions: []
|
100
114
|
extra_rdoc_files: []
|
101
115
|
files:
|
116
|
+
- ".github/workflows/build.yml"
|
102
117
|
- ".gitignore"
|
103
118
|
- ".hound.yml"
|
104
|
-
- ".travis.yml"
|
105
119
|
- Changelog.md
|
106
120
|
- Gemfile
|
107
121
|
- LICENSE.txt
|
108
122
|
- README.md
|
109
123
|
- Rakefile
|
110
124
|
- credit_card_validations.gemspec
|
111
|
-
- gemfiles/rails1-4.gemfile
|
112
|
-
- gemfiles/rails5.gemfile
|
113
125
|
- lib/active_model/credit_card_number_validator.rb
|
114
126
|
- lib/credit_card_validations.rb
|
127
|
+
- lib/credit_card_validations/configuration.rb
|
115
128
|
- lib/credit_card_validations/detector.rb
|
116
129
|
- lib/credit_card_validations/error.rb
|
117
130
|
- lib/credit_card_validations/factory.rb
|
@@ -127,6 +140,7 @@ files:
|
|
127
140
|
- spec/credit_card_validations_spec.rb
|
128
141
|
- spec/factory_spec.rb
|
129
142
|
- spec/fixtures/invalid_cards.yml
|
143
|
+
- spec/fixtures/overrided_brands.yml
|
130
144
|
- spec/fixtures/valid_cards.yml
|
131
145
|
- spec/models/credit_card.rb
|
132
146
|
- spec/string_spec.rb
|
@@ -138,7 +152,7 @@ metadata:
|
|
138
152
|
bug_tracker_uri: https://github.com/didww/credit_card_validations/issues
|
139
153
|
changelog_uri: https://github.com/didww/credit_card_validations/blob/master/Changelog.md
|
140
154
|
source_code_uri: https://github.com/didww/credit_card_validations
|
141
|
-
post_install_message:
|
155
|
+
post_install_message:
|
142
156
|
rdoc_options: []
|
143
157
|
require_paths:
|
144
158
|
- lib
|
@@ -153,8 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
167
|
- !ruby/object:Gem::Version
|
154
168
|
version: '0'
|
155
169
|
requirements: []
|
156
|
-
rubygems_version: 3.
|
157
|
-
signing_key:
|
170
|
+
rubygems_version: 3.1.6
|
171
|
+
signing_key:
|
158
172
|
specification_version: 4
|
159
173
|
summary: gem should be used for credit card numbers validation, card brands detections,
|
160
174
|
luhn checks
|
@@ -163,6 +177,7 @@ test_files:
|
|
163
177
|
- spec/credit_card_validations_spec.rb
|
164
178
|
- spec/factory_spec.rb
|
165
179
|
- spec/fixtures/invalid_cards.yml
|
180
|
+
- spec/fixtures/overrided_brands.yml
|
166
181
|
- spec/fixtures/valid_cards.yml
|
167
182
|
- spec/models/credit_card.rb
|
168
183
|
- spec/string_spec.rb
|
data/.travis.yml
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
rvm:
|
3
|
-
- 2.1.10
|
4
|
-
- 2.2.10
|
5
|
-
- 2.3.5
|
6
|
-
- 2.4.5
|
7
|
-
- 2.5.3
|
8
|
-
- 2.6.3
|
9
|
-
- 3.0.0
|
10
|
-
- jruby-9.1.15.0
|
11
|
-
gemfile:
|
12
|
-
- gemfiles/rails1-4.gemfile
|
13
|
-
- gemfiles/rails5.gemfile
|
14
|
-
matrix:
|
15
|
-
exclude:
|
16
|
-
- gemfile: gemfiles/rails5.gemfile
|
17
|
-
rvm: 2.1.10
|
18
|
-
- gemfile: gemfiles/rails5.gemfile
|
19
|
-
rvm: jruby-9.1.6.0
|
20
|
-
- gemfile: gemfiles/rails1-4.gemfile
|
21
|
-
rvm: 2.5.3
|
22
|
-
- gemfile: gemfiles/rails1-4.gemfile
|
23
|
-
rvm: 2.6.3
|
24
|
-
- gemfile: gemfiles/rails1-4.gemfile
|
25
|
-
rvm: 3.0.0
|
26
|
-
allow_failures:
|
27
|
-
- rvm: 2.1.10
|
28
|
-
|
29
|
-
before_install:
|
30
|
-
- gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
|
31
|
-
- gem install bundler -v '< 2'
|
32
|
-
- export BUNDLE_PATH="${TRAVIS_BUILD_DIR}/vendor/bundle"
|
data/gemfiles/rails1-4.gemfile
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gem "activemodel", ">= 3", '< 5'
|
4
|
-
gem "activesupport", ">= 3", '< 5'
|
5
|
-
group :test do
|
6
|
-
gem 'tins', '< 1.3.4', platforms: [:ruby_19, :jruby]
|
7
|
-
gem 'term-ansicolor', '~> 1.3.0', platforms: [:ruby_19, :jruby]
|
8
|
-
gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io
|
9
|
-
end
|
10
|
-
|
11
|
-
gemspec :path => "../"
|
data/gemfiles/rails5.gemfile
DELETED