credit_card_validator 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +4 -4
- data/lib/credit_card_validator.rb +1 -1
- data/lib/credit_card_validator/validator.rb +1 -0
- data/test/test_credit_card_validator.rb +4 -1
- metadata +40 -16
data/README.rdoc
CHANGED
@@ -20,7 +20,7 @@ Usage:
|
|
20
20
|
CreditCardValidator::Validator.valid?('1111 2222 3333 4444')
|
21
21
|
|
22
22
|
Supported card types:
|
23
|
-
:amex, :discover, :diners_club, :master_card, :visa
|
23
|
+
:amex, :discover, :diners_club, :master_card, :visa, :maestro
|
24
24
|
|
25
25
|
Whitespace is stripped from the number automatically.
|
26
26
|
|
@@ -44,11 +44,11 @@ You can also use the validator to learn about the type of the card:
|
|
44
44
|
|
45
45
|
== INSTALL:
|
46
46
|
|
47
|
-
* gem install
|
47
|
+
* gem install credit_card_validator
|
48
48
|
|
49
49
|
== LICENSE:
|
50
50
|
|
51
|
-
Copyright (c) 2009 Tobias Crawley & Bruce Hauman
|
51
|
+
Copyright (c) 2009-2011 Tobias Crawley & Bruce Hauman
|
52
52
|
|
53
53
|
Permission is hereby granted, free of charge, to any person obtaining
|
54
54
|
a copy of this software and associated documentation files (the
|
@@ -67,4 +67,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
67
67
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
68
68
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
69
69
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
70
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
70
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -2,6 +2,7 @@ module CreditCardValidator
|
|
2
2
|
CARD_TYPES = {
|
3
3
|
:visa => /^4[0-9]{12}(?:[0-9]{3})?$/,
|
4
4
|
:master_card => /^5[1-5][0-9]{14}$/,
|
5
|
+
:maestro => /(^6759[0-9]{2}([0-9]{10})$)|(^6759[0-9]{2}([0-9]{12})$)|(^6759[0-9]{2}([0-9]{13})$)/,
|
5
6
|
:diners_club => /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
|
6
7
|
:amex => /^3[47][0-9]{13}$/,
|
7
8
|
:discover => /^6(?:011|5[0-9]{2})[0-9]{12}$/
|
@@ -14,7 +14,7 @@ class TestCreditCardValidator < Test::Unit::TestCase
|
|
14
14
|
assert_equal 'diners_club', @v.card_type('30569309025904')
|
15
15
|
assert_equal 'amex', @v.card_type('371449635398431')
|
16
16
|
assert_equal 'discover', @v.card_type('6011000990139424')
|
17
|
-
|
17
|
+
assert_equal 'maestro', @v.card_type('6759671431256542')
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_detect_specific_types
|
@@ -27,6 +27,9 @@ class TestCreditCardValidator < Test::Unit::TestCase
|
|
27
27
|
assert @v.is_diners_club?('30569309025904')
|
28
28
|
assert @v.is_amex?('371449635398431')
|
29
29
|
assert @v.is_discover?('6011000990139424')
|
30
|
+
assert @v.is_maestro?('6759671431256542')
|
31
|
+
assert !@v.is_maestro?('5555555555554444')
|
32
|
+
assert !@v.is_maestro?('30569309025904')
|
30
33
|
end
|
31
34
|
|
32
35
|
def test_luhn_verification
|
metadata
CHANGED
@@ -1,37 +1,56 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: credit_card_validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- Tobias Crawley
|
14
|
+
- Bruce Hauman
|
15
|
+
- Phil McClure
|
8
16
|
autorequire:
|
9
17
|
bindir: bin
|
10
18
|
cert_chain: []
|
11
19
|
|
12
|
-
date:
|
13
|
-
default_executable:
|
20
|
+
date: 2011-06-07 00:00:00 Z
|
14
21
|
dependencies:
|
15
22
|
- !ruby/object:Gem::Dependency
|
16
23
|
name: newgem
|
17
|
-
|
18
|
-
|
19
|
-
|
24
|
+
prerelease: false
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
20
27
|
requirements:
|
21
28
|
- - ">="
|
22
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 25
|
31
|
+
segments:
|
32
|
+
- 1
|
33
|
+
- 2
|
34
|
+
- 3
|
23
35
|
version: 1.2.3
|
24
|
-
|
36
|
+
type: :development
|
37
|
+
version_requirements: *id001
|
25
38
|
- !ruby/object:Gem::Dependency
|
26
39
|
name: hoe
|
27
|
-
|
28
|
-
|
29
|
-
|
40
|
+
prerelease: false
|
41
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
30
43
|
requirements:
|
31
44
|
- - ">="
|
32
45
|
- !ruby/object:Gem::Version
|
46
|
+
hash: 55
|
47
|
+
segments:
|
48
|
+
- 1
|
49
|
+
- 8
|
50
|
+
- 0
|
33
51
|
version: 1.8.0
|
34
|
-
|
52
|
+
type: :development
|
53
|
+
version_requirements: *id002
|
35
54
|
description: A gem that provides credit card validation. It is basically a ruby port of the javascript credit card validator by Thomas Fuchs (madrobby) (http://github.com/madrobby/creditcard_js).
|
36
55
|
email:
|
37
56
|
- tcrawley@gmail.com
|
@@ -52,7 +71,6 @@ files:
|
|
52
71
|
- lib/credit_card_validator/validator.rb
|
53
72
|
- test/test_credit_card_validator.rb
|
54
73
|
- test/test_helper.rb
|
55
|
-
has_rdoc: true
|
56
74
|
homepage: http://github.com/tobias/credit_card_validator
|
57
75
|
licenses: []
|
58
76
|
|
@@ -63,23 +81,29 @@ rdoc_options:
|
|
63
81
|
require_paths:
|
64
82
|
- lib
|
65
83
|
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
66
85
|
requirements:
|
67
86
|
- - ">="
|
68
87
|
- !ruby/object:Gem::Version
|
88
|
+
hash: 3
|
89
|
+
segments:
|
90
|
+
- 0
|
69
91
|
version: "0"
|
70
|
-
version:
|
71
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
72
94
|
requirements:
|
73
95
|
- - ">="
|
74
96
|
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
98
|
+
segments:
|
99
|
+
- 0
|
75
100
|
version: "0"
|
76
|
-
version:
|
77
101
|
requirements: []
|
78
102
|
|
79
103
|
rubyforge_project: credit_card_validator
|
80
|
-
rubygems_version: 1.
|
104
|
+
rubygems_version: 1.8.4
|
81
105
|
signing_key:
|
82
|
-
specification_version:
|
106
|
+
specification_version: 2
|
83
107
|
summary: A gem that provides credit card validation
|
84
108
|
test_files:
|
85
109
|
- test/test_credit_card_validator.rb
|