faker_credit_card 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
data/faker_credit_card.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Vinicius Akio Higa"]
|
10
10
|
s.email = ["viniciushiga@gmail.com"]
|
11
|
-
s.homepage = ""
|
11
|
+
s.homepage = "https://github.com/viniciushiga/faker_credit_card"
|
12
12
|
s.summary = %q{}
|
13
13
|
s.description = %q{}
|
14
14
|
|
data/lib/faker_credit_card.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "faker_credit_card/generator"
|
2
2
|
require "faker_credit_card/american_express"
|
3
|
-
require "faker_credit_card/
|
3
|
+
require "faker_credit_card/diners_club"
|
4
4
|
require "faker_credit_card/discover"
|
5
5
|
require "faker_credit_card/master_card"
|
6
6
|
require "faker_credit_card/visa"
|
@@ -12,7 +12,7 @@ module Faker
|
|
12
12
|
def self.number(type, options = {})
|
13
13
|
case type
|
14
14
|
when :american_express then AmericanExpress.number(options)
|
15
|
-
when :
|
15
|
+
when :diners_club then DinersClub.number(options)
|
16
16
|
when :discover then Discover.number(options)
|
17
17
|
when :master_card then MasterCard.number(options)
|
18
18
|
when :visa then Visa.number(options)
|
@@ -16,7 +16,7 @@ module CreditCardNumberValidator
|
|
16
16
|
def valid_association?(number)
|
17
17
|
ccnum = number.to_s.gsub(/\D/, "")
|
18
18
|
|
19
|
-
return :
|
19
|
+
return :diners if ccnum.length == 14 && ccnum =~ /^3(0[0-5]|[68])/ # 300xxx-305xxx, 36xxxx, 38xxxx
|
20
20
|
return :amex if ccnum.length == 15 && ccnum =~ /^3[47]/ # 34xxxx, 37xxxx
|
21
21
|
return :visa if [13,16].include?(ccnum.length) && ccnum =~ /^4/ # 4xxxxx
|
22
22
|
return :master if ccnum.length == 16 && ccnum =~ /^5[1-5]/ # 51xxxx-55xxxx
|
@@ -10,8 +10,8 @@ class TestFakerCreditCard < Test::Unit::TestCase
|
|
10
10
|
assert valid_credit_card?(number)
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
number = Faker::CreditCard.number(:
|
13
|
+
def test_diners_club
|
14
|
+
number = Faker::CreditCard.number(:diners_club)
|
15
15
|
assert_not_nil number
|
16
16
|
assert_equal number.size, 14
|
17
17
|
assert valid_credit_card?(number)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faker_credit_card
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-12 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: ''
|
15
15
|
email:
|
@@ -24,7 +24,7 @@ files:
|
|
24
24
|
- faker_credit_card.gemspec
|
25
25
|
- lib/faker_credit_card.rb
|
26
26
|
- lib/faker_credit_card/american_express.rb
|
27
|
-
- lib/faker_credit_card/
|
27
|
+
- lib/faker_credit_card/diners_club.rb
|
28
28
|
- lib/faker_credit_card/discover.rb
|
29
29
|
- lib/faker_credit_card/generator.rb
|
30
30
|
- lib/faker_credit_card/master_card.rb
|
@@ -33,7 +33,7 @@ files:
|
|
33
33
|
- test/credit_card_number_validator.rb
|
34
34
|
- test/test_faker_credit_card.rb
|
35
35
|
- test/test_helper.rb
|
36
|
-
homepage:
|
36
|
+
homepage: https://github.com/viniciushiga/faker_credit_card
|
37
37
|
licenses: []
|
38
38
|
post_install_message:
|
39
39
|
rdoc_options: []
|