pan_masker 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 04d909368e342698a21c417f9d0c1a6bd3194cee
4
+ data.tar.gz: b47629dbaa6fcf9aeab59d8fcca31f06d795f71b
5
+ SHA512:
6
+ metadata.gz: 12b7c096cc840bb597c368d00e22eeee63c871172d0cc657b40d776d7b550610f230c6e43b239a6fa7c34e97807bf5032242f5d0ef765b3e6f1be181ea5d32e1
7
+ data.tar.gz: 8cdd01ab6f4da39c7e1433d8c07cdbdea875168845e4dd6c9e29ef6102d91588fcfd4ea587a6ac1020cacad31dc84bef620deeabdda6d2f02ff6602e36092d00
@@ -3,7 +3,7 @@ class Pan_masker::Finder
3
3
  cardType = cardType.capitalize
4
4
  case cardType
5
5
  when 'DEFAULT'
6
- extractedPans = data.scan(/[\d][0-9]{18}$|[\d][0-9]{15}$|[\d][0-9]{11}$/)
6
+ extractedPans = data.scan(/[\d][0-9]{11,18}/)
7
7
  when 'VERVE'
8
8
  extractedPans = data.scan(/[\d][0-9]{18}$/)
9
9
  when 'MASTERCARD'
@@ -15,7 +15,7 @@ class Pan_masker::Finder
15
15
  when 'CHINAUNIONPAY'
16
16
  extractedPans = data.scan(/[\d][0-9]{18}$|[\d][0-9]{15}$/)
17
17
  else
18
- extractedPans = data.scan(/[\d][0-9]{18}$|[\d][0-9]{15}$|[\d][0-9]{11}$/)
18
+ extractedPans = data.scan(/[\d][0-9]{11,18}/)
19
19
  end
20
20
 
21
21
  if extractedPans.any?
@@ -1,18 +1,18 @@
1
- class Pan_masker::Finder::Masker
2
- def self.mask_pan(pan)
3
- panLenght = pan.length
4
- firstSix = pan[0..5]
5
- lastFour = pan[panLenght-4..panLenght]
6
-
7
- panLenghtToBeMasked = panLenght - 10
8
- count = 1
9
- mask = '*'
10
- begin
11
- mask = mask + '*'
12
- count += 1
13
- end while count < panLenghtToBeMasked
14
- maskedPan = firstSix + mask + lastFour
15
- maskedPan
16
- end
17
- end
18
-
1
+ class Pan_masker::Finder::Masker
2
+ def self.mask_pan(pan)
3
+ panLenght = pan.length
4
+ firstSix = pan[0..5]
5
+ lastFour = pan[panLenght-4..panLenght]
6
+
7
+ panLenghtToBeMasked = panLenght - 10
8
+ count = 1
9
+ mask = '*'
10
+ begin
11
+ mask = mask + '*'
12
+ count += 1
13
+ end while count < panLenghtToBeMasked
14
+ maskedPan = firstSix + mask + lastFour
15
+ maskedPan
16
+ end
17
+ end
18
+
@@ -1,36 +1,40 @@
1
- require 'test/unit'
2
- require 'pan_masker'
3
-
4
- class PanMaskerTest < Test::Unit::TestCase
5
- def test_no_pan
6
- assert_equal "the is no pan in this string", Pan_masker.mask("the is no pan in this string")
7
- end
8
-
9
- def test_verve_pans
10
- assert_equal "verve 19 111111*********1111", Pan_masker.mask("verve 19 1111111111111111111")
11
- end
12
-
13
- def test_no_pan_master
14
- assert_equal "the is no pan in this string", Pan_masker.mask("the is no pan in this string",'mastercard')
15
- end
16
-
17
- def test_default_pans
18
- assert_equal "verve 19 111111*********1111", Pan_masker.mask("verve 19 1111111111111111111")
19
- end
20
-
21
- def test_default_pans_two
22
- assert_equal "mastercard and visa 16 111111******1111", Pan_masker.mask("mastercard and visa 16 1111111111111111")
23
- end
24
-
25
- def test_visa_pans
26
- assert_equal "visa 16 111111******1111", Pan_masker.mask("visa 16 1111111111111111",'visa')
27
- end
28
-
29
- def test_verve_pans
30
- assert_equal "verve 19 111111*********1111", Pan_masker.mask("verve 19 1111111111111111111",'verve')
31
- end
32
-
33
- def test_mastercard_pan
34
- assert_equal "master 16 111111******1111", Pan_masker.mask("master 16 1111111111111111",'mastercard')
35
- end
36
- end
1
+ require 'test/unit'
2
+ require 'pan_masker'
3
+
4
+ class PanMaskerTest < Test::Unit::TestCase
5
+ def test_no_pan
6
+ assert_equal "the is no pan in this string", Pan_masker.mask("the is no pan in this string")
7
+ end
8
+
9
+ def test_verve_pans
10
+ assert_equal "verve 19 111111*********1111", Pan_masker.mask("verve 19 1111111111111111111")
11
+ end
12
+
13
+ def test_no_pan_master
14
+ assert_equal "the is no pan in this string", Pan_masker.mask("the is no pan in this string",'mastercard')
15
+ end
16
+
17
+ def test_default_pans
18
+ assert_equal "verve 19 111111*********1111", Pan_masker.mask("verve 19 1111111111111111111")
19
+ end
20
+
21
+ def test_default_pans_two
22
+ assert_equal "mastercard and visa 16 111111******1111", Pan_masker.mask("mastercard and visa 16 1111111111111111")
23
+ end
24
+
25
+ def test_visa_pans
26
+ assert_equal "visa 16 111111******1111", Pan_masker.mask("visa 16 1111111111111111",'visa')
27
+ end
28
+
29
+ def test_verve_pans
30
+ assert_equal "verve 19 111111*********1111", Pan_masker.mask("verve 19 1111111111111111111",'verve')
31
+ end
32
+
33
+ def test_mastercard_pan
34
+ assert_equal "master 16 111111******1111", Pan_masker.mask("master 16 1111111111111111",'mastercard')
35
+ end
36
+
37
+ def test_large_text_default
38
+ assert_equal masked, Pan_masker.mask(text)
39
+ end
40
+ end
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pan_masker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
5
- prerelease:
4
+ version: 0.2.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Mayowa Anibaba
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-12 00:00:00.000000000 Z
11
+ date: 2014-05-06 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: A simple gem to scan a string, find and mask mastercard, visa, discover and verve credit/debit card pans to comply with PCIDSS standards
15
14
  email: me@codegidi.com
@@ -26,6 +25,7 @@ files:
26
25
  homepage: http://rubygems.org/gems/pan_masker
27
26
  licenses:
28
27
  - MIT
28
+ metadata: {}
29
29
  post_install_message:
30
30
  rdoc_options: []
31
31
  require_paths:
@@ -35,18 +35,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
35
35
  - - '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
- none: false
39
38
  required_rubygems_version: !ruby/object:Gem::Requirement
40
39
  requirements:
41
40
  - - '>='
42
41
  - !ruby/object:Gem::Version
43
42
  version: '0'
44
- none: false
45
43
  requirements: []
46
44
  rubyforge_project:
47
- rubygems_version: 1.8.24
45
+ rubygems_version: 2.1.9
48
46
  signing_key:
49
- specification_version: 3
47
+ specification_version: 4
50
48
  summary: Pan masker
51
49
  test_files:
52
50
  - test/test_pan_masker.rb