credit_card_validations 3.2.2 → 4.0.0

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
- SHA1:
3
- metadata.gz: 13bbefb17b2950ef0a22a4a3fc1210453143cfbd
4
- data.tar.gz: 1caafd3dc7e584ac059f2df3ea83713477f14a62
2
+ SHA256:
3
+ metadata.gz: c947efcf4ef54ace4e9c747430dc75dd1efe0570a260853d8c1eca1963b13ae5
4
+ data.tar.gz: a69886a9b837c4872b5bac9bed3dbc6a88757424d2b4303a2c5918f68548cd29
5
5
  SHA512:
6
- metadata.gz: 8fa7c1a358696b43e8e24cdf25e102f801e0148e4d9eaf2c6b4c3aca049bcf35e79cc8e7bffd75b0ada41cc2f8f58040f32a81c471db21ac09bf9cb69bd921a7
7
- data.tar.gz: ab43165c032cc5def62fd1f7183baa7ec690c62d60a0607373ba1fa0afb68413e2235e920f47df8ccd12a7c14a99bc26809041b215b52bde986ddb9a2625de82
6
+ metadata.gz: b5407b4b003aca97df24c20e5145cb43ab90d7fa6a62b21a953fcd53f4a97d77b1bd4b564a71767c7639ce6b1fcd5e12b51f82a3c32255eeaf87b1f66e0e6474
7
+ data.tar.gz: 6b472410891b0519878b6894222460e042afae072070a5cc22f4af0fbc7773ab01a19a2f12d61572934bbfa3107a672556c128dfe45cd89490bbd709c7f5fd85
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ /coverage
2
+ /Gemfile.lock
3
+ \.ruby-version
data/.travis.yml CHANGED
@@ -1,25 +1,32 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.9.3
4
- - 2.0.0
5
- - 2.1.9
6
- - 2.2.5
7
- - 2.3.1
8
- - jruby-19mode # JRuby in 1.9 mode
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
9
11
  gemfile:
10
12
  - gemfiles/rails1-4.gemfile
11
13
  - gemfiles/rails5.gemfile
12
14
  matrix:
13
15
  exclude:
14
16
  - gemfile: gemfiles/rails5.gemfile
15
- rvm: 1.9.3
17
+ rvm: 2.1.10
16
18
  - gemfile: gemfiles/rails5.gemfile
17
- rvm: 2.0.0
18
- - gemfile: gemfiles/rails5.gemfile
19
- rvm: 2.1.9
20
- - gemfile: gemfiles/rails5.gemfile
21
- rvm: jruby-19mode
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
+
22
29
  before_install:
23
- - gem install bundler -v '= 1.11.2'
24
- - gem update --system
25
- - gem --version
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/Changelog.md CHANGED
@@ -1,3 +1,17 @@
1
+ # 3.5.1
2
+ * Bump activemodel and activesupport versions
3
+
4
+ # 3.5.0
5
+ * Unionpay and Maestro range updates, PR #88
6
+ * Hipercard range updates , PR #79
7
+ * Visa and Discover length fix, PR #81
8
+
9
+ # 3.4.0
10
+ * Elo support enhanced, PR #75
11
+
12
+ # 3.3.0
13
+ * Added support for MIR card brand
14
+
1
15
  # 3.2.2
2
16
  * Relaxing dependency requirements to support Rails 5
3
17
 
data/README.md CHANGED
@@ -1,11 +1,9 @@
1
1
  # CreditCardValidations
2
2
 
3
- [![Build Status](http://img.shields.io/travis/Fivell/credit_card_validations.svg)](https://travis-ci.org/Fivell/credit_card_validations)
4
- [![Dependency Status](http://img.shields.io/gemnasium/Fivell/credit_card_validations.svg)](https://gemnasium.com/Fivell/credit_card_validations)
3
+ [![Build Status](http://img.shields.io/travis/didww/credit_card_validations.svg)](https://travis-ci.org/didww/credit_card_validations)
5
4
  [![Coverage Status](http://img.shields.io/coveralls/Fivell/credit_card_validations.svg)](https://coveralls.io/r/Fivell/credit_card_validations)
6
- [![Code Climate](http://img.shields.io/codeclimate/github/Fivell/credit_card_validations.svg)](https://codeclimate.com/github/Fivell/credit_card_validations)
7
5
  [![Gem Version](http://img.shields.io/gem/v/credit_card_validations.svg)](https://rubygems.org/gems/credit_card_validations)
8
- [![License](http://img.shields.io/:license-mit-blue.svg)](http://Fivell.mit-license.org)
6
+ [![License](http://img.shields.io/:license-mit-blue.svg)](http://didww.mit-license.org)
9
7
 
10
8
 
11
9
  Gem adds validator to check whether or not a given number actually falls within the ranges of possible numbers prior to performing such verification, and, as such, CreditCardValidations simply verifies that the credit card number provided is well-formed.
@@ -16,22 +14,28 @@ More info about card BIN numbers http://en.wikipedia.org/wiki/Bank_card_number
16
14
 
17
15
  Add this line to your application's Gemfile:
18
16
 
19
- gem 'credit_card_validations'
17
+ ```sh
18
+ $ gem 'credit_card_validations'
19
+ ```
20
20
 
21
21
  And then execute:
22
22
 
23
- $ bundle
23
+ ```sh
24
+ $ bundle
25
+ ```
24
26
 
25
27
  Or install it yourself as:
26
28
 
27
- $ gem install credit_card_validations
29
+ ```sh
30
+ $ gem install credit_card_validations
31
+ ```
28
32
 
29
33
  ## Usage
30
34
 
31
35
 
32
36
  The following issuing institutes are accepted:
33
37
 
34
- Name | Key |
38
+ | Name | Key |
35
39
  --------------------- | ------------|
36
40
  [American Express](http://en.wikipedia.org/wiki/American_Express) | :amex
37
41
  [China UnionPay](http://en.wikipedia.org/wiki/China_UnionPay) | :unionpay
@@ -43,6 +47,7 @@ The following issuing institutes are accepted:
43
47
  [JCB](http://en.wikipedia.org/wiki/Japan_Credit_Bureau) | :jcb
44
48
  [Maestro](http://en.wikipedia.org/wiki/Maestro_%28debit_card%29) | :maestro
45
49
  [MasterCard](http://en.wikipedia.org/wiki/MasterCard) | :mastercard
50
+ [MIR](http://www.nspk.ru/en/cards-mir/) | :mir
46
51
  [Rupay](http://en.wikipedia.org/wiki/RuPay) | :rupay
47
52
  [Solo](http://en.wikipedia.org/wiki/Solo_(debit_card)) | :solo
48
53
  [Switch](http://en.wikipedia.org/wiki/Switch_(debit_card)) | :switch
@@ -50,9 +55,9 @@ The following issuing institutes are accepted:
50
55
 
51
56
 
52
57
 
53
- The following are supported with with plugins
58
+ The following are supported with plugins
54
59
 
55
- Name | Key |
60
+ | Name | Key |
56
61
  --------------------- | ------------|
57
62
  [Diners Club US](http://en.wikipedia.org/wiki/Diners_Club_International#MasterCard_alliance) | :diners_us
58
63
  [EnRoute](https://en.wikipedia.org/wiki/EnRoute_(credit_card)) | :en_route
@@ -63,12 +68,12 @@ The following are supported with with plugins
63
68
  ### Examples using string monkey patch
64
69
 
65
70
  ```ruby
66
- require 'credit_card_validations/string'
67
- '5274 5763 9425 9961'.credit_card_brand #=> :mastercard
68
- '5274 5763 9425 9961'.credit_card_brand_name #=> "MasterCard"
69
- '5274 5763 9425 9961'.valid_credit_card_brand?(:mastercard, :visa) #=> true
70
- '5274 5763 9425 9961'.valid_credit_card_brand?(:amex) #=> false
71
- '5274 5763 9425 9961'.valid_credit_card_brand?('MasterCard') #=> true
71
+ require 'credit_card_validations/string'
72
+ '5274 5763 9425 9961'.credit_card_brand #=> :mastercard
73
+ '5274 5763 9425 9961'.credit_card_brand_name #=> "MasterCard"
74
+ '5274 5763 9425 9961'.valid_credit_card_brand?(:mastercard, :visa) #=> true
75
+ '5274 5763 9425 9961'.valid_credit_card_brand?(:amex) #=> false
76
+ '5274 5763 9425 9961'.valid_credit_card_brand?('MasterCard') #=> true
72
77
  ```
73
78
 
74
79
  ### ActiveModel support
@@ -76,73 +81,72 @@ The following are supported with with plugins
76
81
  only for certain brands
77
82
 
78
83
  ```ruby
79
- class CreditCardModel
80
- attr_accessor :number
81
- include ActiveModel::Validations
82
- validates :number, credit_card_number: {brands: [:amex, :maestro]}
83
- end
84
+ class CreditCardModel
85
+ attr_accessor :number
86
+ include ActiveModel::Validations
87
+ validates :number, credit_card_number: {brands: [:amex, :maestro]}
88
+ end
84
89
  ```
85
90
 
86
91
  for all known brands
87
92
 
88
- ```ruby
89
- validates :number, presence: true, credit_card_number: true
93
+ ```ruby
94
+ validates :number, presence: true, credit_card_number: true
90
95
  ```
91
96
 
92
97
  ### Examples using CreditCardValidations::Detector class
93
98
 
94
- ```ruby
95
- number = "4111111111111111"
96
- detector = CreditCardValidations::Detector.new(number)
97
- detector.brand #:visa
98
- detector.visa? #true
99
- detector.valid?(:mastercard,:maestro) #false
100
- detector.valid?(:visa, :mastercard) #true
101
- detector.issuer_category #"Banking and financial"
99
+ ```ruby
100
+ number = "4111111111111111"
101
+ detector = CreditCardValidations::Detector.new(number)
102
+ detector.brand #:visa
103
+ detector.visa? #true
104
+ detector.valid?(:mastercard,:maestro) #false
105
+ detector.valid?(:visa, :mastercard) #true
106
+ detector.issuer_category #"Banking and financial"
102
107
  ```
103
108
 
104
109
  ### Also You can add your own brand rules to detect other credit card brands/types
105
110
  passing name,length(integer/array of integers) and prefix(string/array of strings)
106
111
  Example
107
112
 
108
- ```ruby
109
- CreditCardValidations.add_brand(:voyager, {length: 15, prefixes: '86'})
110
- voyager_test_card_number = '869926275400212'
111
- CreditCardValidations::Detector.new(voyager_test_card_number).brand #:voyager
112
- CreditCardValidations::Detector.new(voyager_test_card_number).voyager? #true
113
+ ```ruby
114
+ CreditCardValidations.add_brand(:voyager, {length: 15, prefixes: '86'})
115
+ voyager_test_card_number = '869926275400212'
116
+ CreditCardValidations::Detector.new(voyager_test_card_number).brand #:voyager
117
+ CreditCardValidations::Detector.new(voyager_test_card_number).voyager? #true
113
118
  ```
114
119
 
115
120
  ### Remove brands also supported
116
121
 
117
122
  ```ruby
118
- CreditCardValidations.delete_brand(:maestro)
123
+ CreditCardValidations::Detector.delete_brand(:maestro)
119
124
  ```
120
125
 
121
126
  ### Check luhn
122
127
 
123
- ```ruby
124
- CreditCardValidations::Detector.new(@credit_card_number).valid_luhn?
125
- #or
126
- CreditCardValidations::Luhn.valid?(@credit_card_number)
127
- ```
128
+ ```ruby
129
+ CreditCardValidations::Detector.new(@credit_card_number).valid_luhn?
130
+ #or
131
+ CreditCardValidations::Luhn.valid?(@credit_card_number)
132
+ ```
128
133
 
129
134
  ### Generate credit card numbers that pass validation
130
135
 
131
136
  ```ruby
132
- CreditCardValidations::Factory.random(:amex)
133
- # => "348051773827666"
134
- CreditCardValidations::Factory.random(:maestro)
135
- # => "6010430241237266856"
137
+ CreditCardValidations::Factory.random(:amex)
138
+ # => "348051773827666"
139
+ CreditCardValidations::Factory.random(:maestro)
140
+ # => "6010430241237266856"
136
141
  ```
137
142
 
138
- ### Plugins
139
-
140
- ```ruby
141
- require 'credit_card_validations/plugins/en_route'
142
- require 'credit_card_validations/plugins/laser'
143
- require 'credit_card_validations/plugins/diners_us'
143
+ ### Plugins
144
144
 
145
- ```
145
+ ```ruby
146
+ require 'credit_card_validations/plugins/en_route'
147
+ require 'credit_card_validations/plugins/laser'
148
+ require 'credit_card_validations/plugins/diners_us'
149
+ ```
146
150
 
147
151
  ## Contributing
148
152
 
@@ -10,8 +10,14 @@ Gem::Specification.new do |gem|
10
10
  gem.email = ["fedoronchuk@gmail.com"]
11
11
  gem.description = %q{A ruby gem for validating credit card numbers}
12
12
  gem.summary = "gem should be used for credit card numbers validation, card brands detections, luhn checks"
13
- gem.homepage = "http://fivell.github.io/credit_card_validations/"
14
- gem.license = 'MIT'
13
+ gem.homepage = "http://didww.github.io/credit_card_validations/"
14
+ gem.license = "MIT"
15
+
16
+ gem.metadata = {
17
+ 'bug_tracker_uri' => 'https://github.com/didww/credit_card_validations/issues',
18
+ 'changelog_uri' => 'https://github.com/didww/credit_card_validations/blob/master/Changelog.md',
19
+ 'source_code_uri' => 'https://github.com/didww/credit_card_validations'
20
+ }
15
21
 
16
22
  gem.files = `git ls-files`.split($/)
17
23
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -19,10 +25,11 @@ Gem::Specification.new do |gem|
19
25
  gem.require_paths = ["lib"]
20
26
 
21
27
 
22
- gem.add_dependency "activemodel", ">= 3"
23
- gem.add_dependency "activesupport", ">= 3"
28
+ gem.add_dependency "activemodel", ">= 3", "<= 6.2"
29
+ gem.add_dependency "activesupport", ">= 3", "<= 6.2"
24
30
 
25
31
 
32
+ gem.add_development_dependency "minitest", '~> 5.14.3'
26
33
  gem.add_development_dependency "mocha", '1.1.0'
27
34
  gem.add_development_dependency 'rake', '~> 10'
28
35
 
@@ -2,8 +2,9 @@ source "https://rubygems.org"
2
2
 
3
3
  gem "activemodel", ">= 3", '< 5'
4
4
  gem "activesupport", ">= 3", '< 5'
5
-
6
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]
7
8
  gem 'coveralls', require: false # Test coverage website. Go to https://coveralls.io
8
9
  end
9
10
 
@@ -142,6 +142,7 @@ module CreditCardValidations
142
142
  def compile_regexp(prefixes)
143
143
  Regexp.new("^((#{prefixes.join(")|(")}))")
144
144
  end
145
+
145
146
  end
146
147
  end
147
148
  end
@@ -1,3 +1,3 @@
1
1
  module CreditCardValidations
2
- VERSION = '3.2.2'
2
+ VERSION = '4.0.0'
3
3
  end
data/lib/data/brands.yaml CHANGED
@@ -4,8 +4,11 @@
4
4
  - :length:
5
5
  - 13
6
6
  - 16
7
+ - 19
7
8
  :prefixes:
8
9
  - '4'
10
+ :options:
11
+ :brand_name: Visa
9
12
  :mastercard:
10
13
  :rules:
11
14
  - :length:
@@ -64,21 +67,8 @@
64
67
  - '38'
65
68
  :options:
66
69
  :brand_name: Diners Club
67
- :discover:
68
- :rules:
69
- - :length:
70
- - 16
71
- :prefixes:
72
- - '6011'
73
- - '644'
74
- - '645'
75
- - '646'
76
- - '647'
77
- - '648'
78
- - '649'
79
- - '65'
80
70
  :jcb:
81
- :rules:
71
+ :rules:
82
72
  - :length:
83
73
  - 15
84
74
  - 16
@@ -99,7 +89,7 @@
99
89
  - :length:
100
90
  - 19
101
91
  :prefixes:
102
- - '357266'
92
+ - '357266'
103
93
  :options:
104
94
  :brand_name: JCB
105
95
  :solo:
@@ -172,11 +162,42 @@
172
162
  - '604'
173
163
  - '605'
174
164
  - '6060'
175
- - '621'
176
- - '627'
177
- - '629'
178
- - '6304'
179
- - '6390'
165
+ - '616788'
166
+ - '62183'
167
+ - '62186'
168
+ - '62188'
169
+ - '62198'
170
+ - '62199'
171
+ - '6220'
172
+ - '622110'
173
+ - '627089'
174
+ - '62709601'
175
+ - '6271'
176
+ - '6272'
177
+ - '6273'
178
+ - '6274'
179
+ - '6275'
180
+ - '6276'
181
+ - '6277'
182
+ - '6278'
183
+ - '6279'
184
+ - '6280'
185
+ - '6281'
186
+ - '6294'
187
+ - '6301'
188
+ - '630490'
189
+ - '633857'
190
+ - '63609'
191
+ - '6361'
192
+ - '636392'
193
+ - '636708'
194
+ - '637043'
195
+ - '637102'
196
+ - '637118'
197
+ - '637187'
198
+ - '637529'
199
+ - '639'
200
+ - '64'
180
201
  - '670'
181
202
  - '671'
182
203
  - '672'
@@ -203,11 +224,58 @@
203
224
  - 18
204
225
  - 19
205
226
  :prefixes:
206
- - '622'
227
+ - '620'
228
+ - '6210'
229
+ - '6212'
230
+ - '6213'
231
+ - '6214'
232
+ - '6215'
233
+ - '6216'
234
+ - '6217'
235
+ - '621977'
236
+ - '622126'
237
+ - '622127'
238
+ - '622128'
239
+ - '622129'
240
+ - '62213'
241
+ - '62214'
242
+ - '62215'
243
+ - '62216'
244
+ - '62217'
245
+ - '62218'
246
+ - '62220'
247
+ - '62221'
248
+ - '62222'
249
+ - '62223'
250
+ - '62224'
251
+ - '62225'
252
+ - '62226'
253
+ - '62227'
254
+ - '62228'
255
+ - '62229'
256
+ - '6223'
257
+ - '6224'
258
+ - '6225'
259
+ - '6226'
260
+ - '6227'
261
+ - '6228'
262
+ - '6229'
263
+ - '623'
207
264
  - '624'
208
265
  - '625'
209
266
  - '626'
210
- - '628'
267
+ - '62702'
268
+ - '62704'
269
+ - '62706'
270
+ - '62707'
271
+ - '6282'
272
+ - '6283'
273
+ - '6284'
274
+ - '6291'
275
+ - '6292'
276
+ - '632062'
277
+ - '685800'
278
+ - '69075'
211
279
  :options:
212
280
  :skip_luhn: true
213
281
  :brand_name: China UnionPay
@@ -241,37 +309,181 @@
241
309
  - 19
242
310
  :prefixes:
243
311
  - '384'
312
+ - '606282'
313
+ - '637095'
314
+ - '637568'
315
+ - '637599'
316
+ - '637609'
317
+ - '637612'
244
318
  :elo:
245
319
  :rules:
246
320
  - :length:
247
321
  - 16
248
322
  :prefixes:
249
- - '4011'
323
+ - '401178'
324
+ - '401179'
325
+ - '431274'
250
326
  - '438935'
251
327
  - '451416'
252
- - '4576'
328
+ - '457393'
329
+ - '457631'
330
+ - '457632'
253
331
  - '504175'
254
332
  - '506699'
255
- - '5067'
256
- - '509040'
257
- - '509042'
258
- - '509043'
259
- - '509045'
260
- - '509046'
261
- - '509047'
262
- - '509048'
263
- - '509049'
333
+ - '50670'
334
+ - '50671'
335
+ - '506717'
336
+ - '506718'
337
+ - '50672'
338
+ - '506720'
339
+ - '506721'
340
+ - '506724'
341
+ - '506725'
342
+ - '506726'
343
+ - '506727'
344
+ - '506728'
345
+ - '506729'
346
+ - '50673'
347
+ - '50674'
348
+ - '50675'
349
+ - '50676'
350
+ - '506770'
351
+ - '506771'
352
+ - '506772'
353
+ - '506773'
354
+ - '506774'
355
+ - '506775'
356
+ - '506776'
357
+ - '506777'
358
+ - '506778'
359
+ - '50900'
360
+ - '509013'
361
+ - '50902'
362
+ - '509031'
363
+ - '509033'
364
+ - '509035'
365
+ - '509036'
366
+ - '509037'
367
+ - '509038'
368
+ - '509039'
369
+ - '50904'
264
370
  - '509050'
265
371
  - '509051'
266
372
  - '509052'
373
+ - '509053'
267
374
  - '509064'
268
375
  - '509066'
269
376
  - '509067'
270
377
  - '509068'
271
378
  - '509069'
379
+ - '509072'
272
380
  - '509074'
381
+ - '509076'
382
+ - '509077'
383
+ - '509078'
384
+ - '509079'
385
+ - '509080'
386
+ - '509081'
387
+ - '509082'
388
+ - '509083'
389
+ - '509085'
273
390
  - '636297'
274
- - '63636'
391
+ - '636368'
392
+ - '650031'
393
+ - '650032'
394
+ - '650033'
395
+ - '650035'
396
+ - '650036'
397
+ - '650037'
398
+ - '650038'
399
+ - '650039'
400
+ - '65004'
401
+ - '650050'
402
+ - '650051'
403
+ - '650405'
404
+ - '650406'
405
+ - '650407'
406
+ - '650408'
407
+ - '650409'
408
+ - '65041'
409
+ - '65042'
410
+ - '65043'
411
+ - '650485'
412
+ - '650486'
413
+ - '650487'
414
+ - '650488'
415
+ - '650489'
416
+ - '65049'
417
+ - '65050'
418
+ - '65051'
419
+ - '65052'
420
+ - '650530'
421
+ - '650531'
422
+ - '650532'
423
+ - '650533'
424
+ - '650534'
425
+ - '650535'
426
+ - '650536'
427
+ - '650537'
428
+ - '650538'
429
+ - '650541'
430
+ - '650700'
431
+ - '650720'
432
+ - '650901'
433
+ - '650921'
434
+ - '650922'
435
+ - '650923'
436
+ - '650924'
437
+ - '650925'
438
+ - '650926'
439
+ - '650927'
440
+ - '650928'
441
+ - '650929'
442
+ - '65093'
443
+ - '65094'
444
+ - '65095'
445
+ - '65096'
446
+ - '650970'
447
+ - '650971'
448
+ - '650972'
449
+ - '650973'
450
+ - '650974'
451
+ - '650975'
452
+ - '650976'
453
+ - '650977'
454
+ - '650978'
455
+ - '651652'
456
+ - '65500'
457
+ - '65501'
458
+ - '655021'
459
+ - '65503'
460
+ - '65504'
275
461
  :options:
276
462
  :skip_luhn: true
277
463
  :brand_name: Elo
464
+ :mir:
465
+ :rules:
466
+ - :length:
467
+ - 16
468
+ :prefixes:
469
+ - '2200'
470
+ - '2201'
471
+ - '2202'
472
+ - '2203'
473
+ - '2204'
474
+ :discover:
475
+ :rules:
476
+ - :length:
477
+ - 16
478
+ - 19
479
+ :prefixes:
480
+ - '6011'
481
+ - '644'
482
+ - '645'
483
+ - '646'
484
+ - '647'
485
+ - '648'
486
+ - '649'
487
+ - '65'
488
+ :options:
489
+ :brand_name: Discover
@@ -9,9 +9,9 @@ describe 'ActiveModel Validator' do
9
9
  card = model.dup
10
10
  card.card_type = 'Master Card'
11
11
  card.number6 = CreditCardValidations::Factory.random(:visa)
12
- card.valid?.must_equal false
12
+ expect(card.valid?).must_equal false
13
13
  card.number6 = CreditCardValidations::Factory.random(:mastercard)
14
- card.valid?.must_equal true
14
+ expect(card.valid?).must_equal true
15
15
  end
16
16
  end
17
17
 
@@ -22,7 +22,7 @@ describe 'ActiveModel Validator' do
22
22
  card = model
23
23
  card.number4 = number
24
24
  card.number5 = number
25
- card.valid?.must_equal true
25
+ expect(card.valid?).must_equal true
26
26
  end
27
27
  end
28
28
  end
@@ -33,8 +33,8 @@ describe 'ActiveModel Validator' do
33
33
  VALID_NUMBERS.except(:amex, :maestro).each do |_, numbers|
34
34
  card = model
35
35
  card.number = numbers.first
36
- card.valid?.must_equal false
37
- card.errors[:number].include?(card.errors.generate_message(:number, :invalid)).must_equal true
36
+ expect(card.valid?).must_equal false
37
+ expect(card.errors[:number].include?(card.errors.generate_message(:number, :invalid))).must_equal true
38
38
  end
39
39
  end
40
40
 
@@ -42,7 +42,7 @@ describe 'ActiveModel Validator' do
42
42
  VALID_NUMBERS.except(:amex, :maestro).each do |_, numbers|
43
43
  card = model
44
44
  card.number3 = numbers.first
45
- card.valid?.must_equal true
45
+ expect(card.valid?).must_equal true
46
46
  end
47
47
  end
48
48
  end
@@ -53,7 +53,7 @@ describe 'ActiveModel Validator' do
53
53
  card = model
54
54
  card.number = numbers.first
55
55
  card.number2 = numbers.first
56
- card.valid?.must_equal true
56
+ expect(card.valid?).must_equal true
57
57
  end
58
58
  end
59
59
  end
@@ -62,8 +62,8 @@ describe 'ActiveModel Validator' do
62
62
  it 'should allow custom message' do
63
63
  card = model
64
64
  card.number7 = 'wrong'
65
- card.valid?.must_equal false
66
- card.errors[:number7].must_equal ['Custom message']
65
+ expect(card.valid?).must_equal false
66
+ expect(card.errors[:number7]).must_equal ['Custom message']
67
67
  end
68
68
  end
69
69
 
@@ -10,7 +10,7 @@ describe CreditCardValidations do
10
10
  describe 'MMI' do
11
11
  it 'should detect issuer category' do
12
12
  d = detector(VALID_NUMBERS[:visa].first)
13
- d.issuer_category.must_equal CreditCardValidations::Mmi::ISSUER_CATEGORIES[d.number[0]]
13
+ expect(d.issuer_category).must_equal CreditCardValidations::Mmi::ISSUER_CATEGORIES[d.number[0]]
14
14
  end
15
15
  end
16
16
 
@@ -20,17 +20,17 @@ describe CreditCardValidations do
20
20
  }
21
21
  it 'should call Luhn.valid? once' do
22
22
  CreditCardValidations::Luhn.expects(:valid?).with(card_detector.number).once
23
- card_detector.valid?(:visa, :unionpay).must_equal true
23
+ expect(card_detector.valid?(:visa, :unionpay)).must_equal true
24
24
  end
25
25
 
26
26
  it 'should call Luhn.valid? twice' do
27
27
  CreditCardValidations::Luhn.expects(:valid?).with(card_detector.number).twice
28
- card_detector.valid?(:visa, :mastercard).must_equal false
28
+ expect(card_detector.valid?(:visa, :mastercard)).must_equal false
29
29
  end
30
30
 
31
31
  it 'should not call Luhn.valid?' do
32
32
  CreditCardValidations::Luhn.expects(:valid?).never
33
- card_detector.valid?(:unionpay).must_equal true
33
+ expect(card_detector.valid?(:unionpay)).must_equal true
34
34
  end
35
35
 
36
36
  end
@@ -40,7 +40,7 @@ describe CreditCardValidations do
40
40
  VALID_NUMBERS.each do |brand, card_numbers|
41
41
  if has_luhn_check_rule?(brand)
42
42
  card_numbers.each do |number|
43
- luhn_valid?(detector(number).number).must_equal true
43
+ expect(luhn_valid?(detector(number).number)).must_equal true
44
44
  end
45
45
  end
46
46
  end
@@ -49,56 +49,56 @@ describe CreditCardValidations do
49
49
  it 'should check valid brand' do
50
50
  VALID_NUMBERS.each do |brand, card_numbers|
51
51
  card_numbers.each do |card_number|
52
- detector(card_number).send("#{brand}?").must_equal true
53
- detector(card_number).brand.must_equal brand
52
+ expect(detector(card_number).send("#{brand}?")).must_equal true
53
+ expect(detector(card_number).brand).must_equal brand
54
54
  end
55
55
  end
56
56
  end
57
57
 
58
58
  it 'should check if card invalid' do
59
59
  INVALID_NUMBERS.each do |card_number|
60
- detector(card_number).valid?.must_equal false
61
- detector(card_number).brand.must_be_nil
60
+ expect(detector(card_number).valid?).must_equal false
61
+ expect(detector(card_number).brand).must_be_nil
62
62
  VALID_NUMBERS.keys.each do |brand|
63
- detector(card_number).send("#{brand}?").must_equal false
63
+ expect(detector(card_number).send("#{brand}?")).must_equal false
64
64
  end
65
65
  end
66
66
  end
67
67
 
68
68
  it 'should detect by full brand name' do
69
69
  amex = CreditCardValidations::Factory.random(:amex)
70
- detector(amex).valid?('American Express').must_equal true
70
+ expect(detector(amex).valid?('American Express')).must_equal true
71
71
  visa = CreditCardValidations::Factory.random(:visa)
72
- detector(visa).valid?('American Express').must_equal false
72
+ expect(detector(visa).valid?('American Express')).must_equal false
73
73
  end
74
74
 
75
75
  it 'should support multiple brands for single check' do
76
76
  VALID_NUMBERS.slice(:visa, :mastercard).each do |key, value|
77
- detector(value.first).brand(:visa, :mastercard).must_equal key
77
+ expect(detector(value.first).brand(:visa, :mastercard)).must_equal key
78
78
  end
79
79
 
80
80
  VALID_NUMBERS.except(:visa, :mastercard).each do |_, value|
81
- detector(value.first).brand(:visa, :mastercard).must_be_nil
81
+ expect(detector(value.first).brand(:visa, :mastercard)).must_be_nil
82
82
  end
83
83
  end
84
84
 
85
85
  it 'should check if valid brand without arguments' do
86
86
  VALID_NUMBERS.each do |key, value|
87
87
  value.each do |card_number|
88
- detector(card_number).valid?(key).must_equal true
89
- assert detector(card_number).valid?.must_equal true
88
+ expect(detector(card_number).valid?(key)).must_equal true
89
+ expect(assert detector(card_number).valid?).must_equal true
90
90
  end
91
91
  end
92
92
  end
93
93
 
94
94
  it 'should not be valid? if wrong brand' do
95
- detector(VALID_NUMBERS[:visa].first).valid?(:mastercard).must_equal false
96
- detector(VALID_NUMBERS[:mastercard].first).valid?(:visa).must_equal false
95
+ expect(detector(VALID_NUMBERS[:visa].first).valid?(:mastercard)).must_equal false
96
+ expect(detector(VALID_NUMBERS[:mastercard].first).valid?(:visa)).must_equal false
97
97
  end
98
98
 
99
99
  it 'should be valid? if right brand' do
100
- detector(VALID_NUMBERS[:visa].first).valid?(:mastercard, :visa).must_equal true
101
- detector(VALID_NUMBERS[:visa].first).valid?(:mastercard, :amex).must_equal false
100
+ expect(detector(VALID_NUMBERS[:visa].first).valid?(:mastercard, :visa)).must_equal true
101
+ expect(detector(VALID_NUMBERS[:visa].first).valid?(:mastercard, :amex)).must_equal false
102
102
  end
103
103
 
104
104
 
@@ -110,9 +110,9 @@ describe CreditCardValidations do
110
110
 
111
111
  it 'should validate number as voyager' do
112
112
  CreditCardValidations::Detector.add_brand(:voyager, length: 15, prefixes: '86')
113
- detector(voyager_number).valid?(:voyager).must_equal true
114
- detector(voyager_number).voyager?.must_equal true
115
- detector(voyager_number).brand.must_equal :voyager
113
+ expect(detector(voyager_number).valid?(:voyager)).must_equal true
114
+ expect(detector(voyager_number).voyager?).must_equal true
115
+ expect(detector(voyager_number).brand).must_equal :voyager
116
116
  end
117
117
 
118
118
  describe 'Add voyager rule' do
@@ -121,9 +121,9 @@ describe CreditCardValidations do
121
121
  end
122
122
 
123
123
  it 'should validate number as voyager' do
124
- detector(voyager_number).valid?(:voyager).must_equal true
125
- detector(voyager_number).voyager?.must_equal true
126
- detector(voyager_number).brand.must_equal :voyager
124
+ expect(detector(voyager_number).valid?(:voyager)).must_equal true
125
+ expect(detector(voyager_number).voyager?).must_equal true
126
+ expect(detector(voyager_number).brand).must_equal :voyager
127
127
  end
128
128
 
129
129
  describe 'Remove voyager rule' do
@@ -132,8 +132,8 @@ describe CreditCardValidations do
132
132
  end
133
133
 
134
134
  it 'should not validate number as voyager' do
135
- detector(voyager_number).respond_to?(:voyager?).must_equal false
136
- detector(voyager_number).brand.must_be_nil
135
+ expect(detector(voyager_number).respond_to?(:voyager?)).must_equal false
136
+ expect(detector(voyager_number).brand).must_be_nil
137
137
  end
138
138
  end
139
139
  end
@@ -142,20 +142,20 @@ describe CreditCardValidations do
142
142
  describe 'plugins' do
143
143
  [:diners_us, :en_route, :laser].each do |brand|
144
144
  it "should support #{brand}" do
145
- -> { CreditCardValidations::Factory.random(brand) }.
145
+ expect(-> { CreditCardValidations::Factory.random(brand) }).
146
146
  must_raise(CreditCardValidations::Error)
147
147
  custom_number = 'some_number'
148
- detector(custom_number).respond_to?("#{brand}?").must_equal false
148
+ expect(detector(custom_number).respond_to?("#{brand}?")).must_equal false
149
149
  require "credit_card_validations/plugins/#{brand}"
150
150
  number = CreditCardValidations::Factory.random(brand)
151
- detector(number).valid?("#{brand}".to_sym).must_equal true
152
- detector(custom_number).respond_to?("#{brand}?").must_equal true
151
+ expect(detector(number).valid?("#{brand}".to_sym)).must_equal true
152
+ expect(detector(custom_number).respond_to?("#{brand}?")).must_equal true
153
153
  end
154
154
  end
155
155
  end
156
156
 
157
157
  it 'should raise Error if no brand added before' do
158
- -> { CreditCardValidations::Detector::add_rule(:undefined_brand, 20, [20]) }.
158
+ expect(-> { CreditCardValidations::Detector::add_rule(:undefined_brand, 20, [20]) }).
159
159
  must_raise(CreditCardValidations::Error)
160
160
  end
161
161
  end
data/spec/factory_spec.rb CHANGED
@@ -4,14 +4,14 @@ describe CreditCardValidations::Factory do
4
4
 
5
5
  it 'should generate random brand' do
6
6
  number = CreditCardValidations::Factory.random
7
- CreditCardValidations::Detector.new(number).valid?.must_equal true
7
+ expect(CreditCardValidations::Detector.new(number).valid?).must_equal true
8
8
  end
9
9
 
10
10
  CreditCardValidations::Detector.brands.keys.sort.each do |key|
11
11
  describe "#{key}" do
12
12
  it "should generate valid #{key}" do
13
13
  number = CreditCardValidations::Factory.random(key)
14
- CreditCardValidations::Detector.new(number).valid?(key).must_equal true
14
+ expect(CreditCardValidations::Detector.new(number).valid?(key)).must_equal true
15
15
  end
16
16
  end
17
17
  end
@@ -56,9 +56,44 @@
56
56
  - 5641 8200 0000 0005
57
57
  - 5033 9619 8909 17
58
58
  - 5868 2416 0825 5333 38
59
+ - 6167 8856 4660 5238
60
+ - 6218 3782 7162 0705
61
+ - 6218 6064 1843 1366
62
+ - 6218 8455 3580 6171
63
+ - 6219 8470 1538 3118
64
+ - 6219 9203 6534 5837
65
+ - 6220 1885 7707 6726
66
+ - 6221 1083 1803 2381
67
+ - 6270 8984 1174 5752
68
+ - 6270 9601 6484 7142
69
+ - 6271 0126 3275 2014
70
+ - 6272 5470 0241 5113
71
+ - 6273 5523 8170 6073
72
+ - 6274 4145 1171 2555
73
+ - 6275 3486 8618 0058
74
+ - 6276 0982 4454 3458
75
+ - 6277 6702 4773 1576
76
+ - 6278 1636 1660 6511
77
+ - 6279 7366 4387 5768
78
+ - 6280 4737 1307 4604
79
+ - 6281 5524 1682 8637
80
+ - 6294 4318 2601 2816
81
+ - 6301 1412 8720 7778
82
+ - 6304 9003 0332 3654
83
+ - 6304 9086 6523 0248 21
84
+ - 6338 5705 2835 6175
85
+ - 6360 9440 0747 0123
86
+ - 6361 4178 1150 8502
87
+ - 6363 9214 5556 2632
88
+ - 6367 0803 6033 4748
89
+ - 6370 4379 0022 2632
90
+ - 6371 0283 5125 2860
91
+ - 6371 1802 0780 5415
92
+ - 6371 8718 1864 7655
93
+ - 6375 2978 8623 4844
94
+ - 6400 0578 8840 6561
59
95
  - 6799 9901 0000 0000 019
60
96
  - 6390 0200 0000 000003
61
- - 6304 9506 0000 0000 00
62
97
  - 6304 9000 1774 0292 441
63
98
  :jcb:
64
99
  - 3575 7591 5225 4876
@@ -74,9 +109,61 @@
74
109
  - 6334 7306 0000 0000 00
75
110
  - 6767 6767 6767 6767 671
76
111
  :unionpay:
112
+ - 6205 4687 6758 6422
113
+ - 6210 0345 5222 3424
114
+ - 6212 2545 6614 8478
115
+ - 6213 0005 0723 4136
116
+ - 6214 0114 0514 5414
117
+ - 6215 4794 3842 9213
118
+ - 6216 2080 3647 3680
119
+ - 6217 3228 8155 9136
120
+ - 6219 7704 6772 7014
121
+ - 6221 2610 6056 0875
122
+ - 6221 2703 3387 7511
123
+ - 6221 2860 4501 8723
124
+ - 6221 2940 0187 5508
125
+ - 6221 3008 0432 3735
126
+ - 6221 4035 2650 5041
127
+ - 6221 5050 3211 0387
128
+ - 6221 6206 2057 6335
129
+ - 6221 7084 6822 1773
130
+ - 6221 8075 5266 5356
131
+ - 6222 0036 3722 7888
132
+ - 6222 1058 8000 7162
133
+ - 6222 2061 3672 5803
134
+ - 6222 3068 2276 5616
135
+ - 6222 4053 4600 2835
136
+ - 6222 5203 3381 7225
137
+ - 6222 6080 1686 1014
138
+ - 6222 7088 5121 8153
139
+ - 6222 8035 1083 2211
140
+ - 6222 9175 6828 0444
141
+ - 6223 7906 8294 4834
142
+ - 6224 0617 0122 1813
143
+ - 6225 2033 2312 4467
144
+ - 6226 0315 6271 3412
145
+ - 6227 5171 6866 2101
146
+ - 6228 3658 3631 6034
147
+ - 6229 9701 3846 6087
148
+ - 6230 0388 8477 1162
149
+ - 6234 6051 1836 1717
150
+ - 6244 1608 1703 3165
151
+ - 6251 7173 7983 2118
152
+ - 6262 1704 1722 3287
77
153
  - 6264 1852 1292 2132 067
78
- - 6288 9977 1545 2584
79
154
  - 6269 9920 5813 4322
155
+ - 6270 2754 6260 5740
156
+ - 6270 4000 5254 5060
157
+ - 6270 6014 6481 7266
158
+ - 6270 7647 4746 0500
159
+ - 6282 7754 7900 5608
160
+ - 6283 5632 6428 3062
161
+ - 6284 6110 6682 6452
162
+ - 6291 8025 7481 1158
163
+ - 6292 6014 3461 6826
164
+ - 6320 6205 2613 4288
165
+ - 6858 0012 5116 6441
166
+ - 6907 5577 4227 8443
80
167
  :dankort:
81
168
  - 5019 7170 1010 3742
82
169
  :switch:
@@ -87,10 +174,10 @@
87
174
  :hipercard:
88
175
  - 3841 0058 9908 8180 330
89
176
  :elo:
90
- - '4011 4141 3850 9070'
177
+ - '4011 7841 3850 9070'
91
178
  - '4389 3555 4728 7502'
92
- - '4514 1620 5642 0699'
93
- - '4576 5598 7564 9522'
179
+ - '4573 9320 5642 0699'
180
+ - '4576 3198 7564 9522'
94
181
  - '5041 7572 2687 1008'
95
182
  - '5066 9917 1703 9876'
96
183
  - '5067 5391 6526 0388'
@@ -113,3 +200,7 @@
113
200
  - '5090 7463 8779 6948'
114
201
  - '6362 9745 2190 7765'
115
202
  - '6363 6850 2897 2643'
203
+ - '6504 9799 9991 0279'
204
+ - '6516 5299 9991 0328'
205
+ :mir:
206
+ - 2202 1234 1234 1234
data/spec/string_spec.rb CHANGED
@@ -8,25 +8,25 @@ describe 'String ext' do
8
8
  let(:invalid) { INVALID_NUMBERS.sample }
9
9
 
10
10
  it 'should allow detect brand for mastercard' do
11
- mastercard.credit_card_brand.must_equal :mastercard
12
- mastercard.credit_card_brand_name.must_equal 'MasterCard'
13
- mastercard.valid_credit_card_brand?(:mastercard).must_equal true
14
- mastercard.valid_credit_card_brand?('MasterCard').must_equal true
15
- mastercard.valid_credit_card_brand?(:visa, :amex).must_equal false
11
+ expect(mastercard.credit_card_brand).must_equal :mastercard
12
+ expect(mastercard.credit_card_brand_name).must_equal 'MasterCard'
13
+ expect(mastercard.valid_credit_card_brand?(:mastercard)).must_equal true
14
+ expect(mastercard.valid_credit_card_brand?('MasterCard')).must_equal true
15
+ expect(mastercard.valid_credit_card_brand?(:visa, :amex)).must_equal false
16
16
  end
17
17
 
18
18
  it 'should allow detect brand for visa' do
19
- visa.credit_card_brand.must_equal :visa
20
- visa.credit_card_brand_name.must_equal 'Visa'
21
- visa.valid_credit_card_brand?(:mastercard).must_equal false
22
- visa.valid_credit_card_brand?(:visa, :amex).must_equal true
19
+ expect(visa.credit_card_brand).must_equal :visa
20
+ expect(visa.credit_card_brand_name).must_equal 'Visa'
21
+ expect(visa.valid_credit_card_brand?(:mastercard)).must_equal false
22
+ expect(visa.valid_credit_card_brand?(:visa, :amex)).must_equal true
23
23
  end
24
24
 
25
25
  it 'should not allow detect brand for invalid card' do
26
- invalid.credit_card_brand.must_be_nil
27
- invalid.credit_card_brand_name.must_be_nil
28
- invalid.valid_credit_card_brand?(:mastercard).must_equal false
29
- invalid.valid_credit_card_brand?(:visa, :amex).must_equal false
26
+ expect(invalid.credit_card_brand).must_be_nil
27
+ expect(invalid.credit_card_brand_name).must_be_nil
28
+ expect(invalid.valid_credit_card_brand?(:mastercard)).must_equal false
29
+ expect(invalid.valid_credit_card_brand?(:visa, :amex)).must_equal false
30
30
  end
31
31
 
32
32
  end
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: 3.2.2
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-04 00:00:00.000000000 Z
11
+ date: 2021-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3'
20
+ - - "<="
21
+ - !ruby/object:Gem::Version
22
+ version: '6.2'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,6 +27,9 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '3'
30
+ - - "<="
31
+ - !ruby/object:Gem::Version
32
+ version: '6.2'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: activesupport
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -31,6 +37,9 @@ dependencies:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
39
  version: '3'
40
+ - - "<="
41
+ - !ruby/object:Gem::Version
42
+ version: '6.2'
34
43
  type: :runtime
35
44
  prerelease: false
36
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,6 +47,23 @@ dependencies:
38
47
  - - ">="
39
48
  - !ruby/object:Gem::Version
40
49
  version: '3'
50
+ - - "<="
51
+ - !ruby/object:Gem::Version
52
+ version: '6.2'
53
+ - !ruby/object:Gem::Dependency
54
+ name: minitest
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: 5.14.3
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: 5.14.3
41
67
  - !ruby/object:Gem::Dependency
42
68
  name: mocha
43
69
  requirement: !ruby/object:Gem::Requirement
@@ -73,6 +99,7 @@ executables: []
73
99
  extensions: []
74
100
  extra_rdoc_files: []
75
101
  files:
102
+ - ".gitignore"
76
103
  - ".hound.yml"
77
104
  - ".travis.yml"
78
105
  - Changelog.md
@@ -104,10 +131,13 @@ files:
104
131
  - spec/models/credit_card.rb
105
132
  - spec/string_spec.rb
106
133
  - spec/test_helper.rb
107
- homepage: http://fivell.github.io/credit_card_validations/
134
+ homepage: http://didww.github.io/credit_card_validations/
108
135
  licenses:
109
136
  - MIT
110
- metadata: {}
137
+ metadata:
138
+ bug_tracker_uri: https://github.com/didww/credit_card_validations/issues
139
+ changelog_uri: https://github.com/didww/credit_card_validations/blob/master/Changelog.md
140
+ source_code_uri: https://github.com/didww/credit_card_validations
111
141
  post_install_message:
112
142
  rdoc_options: []
113
143
  require_paths:
@@ -123,8 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
153
  - !ruby/object:Gem::Version
124
154
  version: '0'
125
155
  requirements: []
126
- rubyforge_project:
127
- rubygems_version: 2.4.6
156
+ rubygems_version: 3.0.3
128
157
  signing_key:
129
158
  specification_version: 4
130
159
  summary: gem should be used for credit card numbers validation, card brands detections,