credit_card_validations 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -38,9 +38,17 @@ The following issuing institutes are accepted:
38
38
  MasterCard | :mastercard
39
39
  Solo | :solo
40
40
  Visa | :visa
41
+ Laser | :laser
41
42
 
43
+ Examples using string monkey patch
42
44
 
43
- Examples
45
+ require 'credit_card_validations/string'
46
+ '5274 5763 9425 9961'.credit_card_brand
47
+ '5274 5763 9425 9961'.valid_credit_card_brand?(:mastercard, :visa)
48
+ '5274 5763 9425 9961'.valid_credit_card_brand?(:amex)
49
+
50
+
51
+ Examples using CreditCardValidations::Detector class
44
52
 
45
53
  number = "41111111111111111"
46
54
  CreditCardValidations::Detector.new(number).brand #:visa
@@ -8,7 +8,7 @@ Gem::Specification.new do |gem|
8
8
  gem.version = CreditCardValidations::VERSION
9
9
  gem.authors = ["Igor"]
10
10
  gem.email = ["fedoronchuk@gmail.com"]
11
- gem.description = %q{A ruby gem for validating credit card numbers (a port of ZF2 Zend\Validator\CreditCard)}
11
+ gem.description = %q{A ruby gem for validating credit card numbers (a port of ZF2 Zend\Validator\CreditCard)}
12
12
  gem.summary = "gem for credit card numbers validation, card brands detections"
13
13
  gem.homepage = "https://github.com/Fivell/credit_card_validations"
14
14
 
@@ -19,6 +19,8 @@ Gem::Specification.new do |gem|
19
19
 
20
20
  gem.add_dependency('activemodel', '~> 3.0')
21
21
  gem.add_dependency('activesupport', '~> 3.0')
22
+
22
23
  gem.add_development_dependency "test-unit"
23
24
  gem.add_development_dependency 'rake'
25
+
24
26
  end
@@ -42,7 +42,7 @@ module CreditCardValidations
42
42
  ]
43
43
 
44
44
  MAESTRO = [
45
- {length: [12, 13, 14, 15, 16, 17, 18, 19], prefixes: ['5018', '5020', '5038', '6304', '6759', '6761', '6763']}
45
+ {length: [12, 13, 14, 15, 16, 17, 18, 19], prefixes: ['5018', '5020', '5038', '6304', '6759', '6761', '6762','6763', '6764', '6765', '6766']}
46
46
  ]
47
47
 
48
48
  SOLO = [
@@ -55,4 +55,4 @@ module CreditCardValidations
55
55
 
56
56
 
57
57
  end
58
- end
58
+ end
@@ -0,0 +1,9 @@
1
+ class String
2
+ def credit_card_brand
3
+ CreditCardValidations::Detector.new(self).brand
4
+ end
5
+
6
+ def valid_credit_card_brand?(*brands)
7
+ CreditCardValidations::Detector.new(self).valid?(*brands)
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module CreditCardValidations
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -82,6 +82,13 @@ class CreditCardValidationsTest < Test::Unit::TestCase
82
82
  assert cc.valid?
83
83
  end
84
84
 
85
+ def test_string_extension
86
+ require 'credit_card_validations/string'
87
+ assert_equal @test_numbers[:mastercard].credit_card_brand, :mastercard
88
+ assert @test_numbers[:mastercard].valid_credit_card_brand?(:mastercard)
89
+ assert !@test_numbers[:mastercard].valid_credit_card_brand?(:visa, :amex)
90
+ end
91
+
85
92
  protected
86
93
 
87
94
  def detector(number)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: credit_card_validations
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-19 00:00:00.000000000 Z
12
+ date: 2013-04-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
16
- requirement: &70284411124720 !ruby/object:Gem::Requirement
16
+ requirement: &70312995369880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70284411124720
24
+ version_requirements: *70312995369880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70284411123600 !ruby/object:Gem::Requirement
27
+ requirement: &70312995369380 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70284411123600
35
+ version_requirements: *70312995369380
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: test-unit
38
- requirement: &70284411122800 !ruby/object:Gem::Requirement
38
+ requirement: &70312995369000 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70284411122800
46
+ version_requirements: *70312995369000
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rake
49
- requirement: &70284411138640 !ruby/object:Gem::Requirement
49
+ requirement: &70312995384900 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,9 +54,8 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70284411138640
57
+ version_requirements: *70312995384900
58
58
  description: A ruby gem for validating credit card numbers (a port of ZF2 Zend\Validator\CreditCard)
59
-
60
59
  email:
61
60
  - fedoronchuk@gmail.com
62
61
  executables: []
@@ -73,6 +72,7 @@ files:
73
72
  - lib/credit_card_validations/card_rules.rb
74
73
  - lib/credit_card_validations/detector.rb
75
74
  - lib/credit_card_validations/luhn.rb
75
+ - lib/credit_card_validations/string.rb
76
76
  - lib/credit_card_validations/version.rb
77
77
  - test/credit_card_validations_test.rb
78
78
  homepage: https://github.com/Fivell/credit_card_validations