credit_card_generator 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 790455eb00a3a79ca79a51d213e9b1c47fdc309b0b2eb19fc0aa68c32f5c13f7
4
+ data.tar.gz: d83a42d6564a2723e0a3f1ae8e720e83dce640b188d4a23daacc780168158c46
5
+ SHA512:
6
+ metadata.gz: 9ccb68a118112f071c13ccd776c5510df18a5cd62e26dced8edafc275095cf727fca7bc1cc1dea766a8b2b15648209e1924bcc535265a3695bd251bbc2e053bb
7
+ data.tar.gz: d72a435d55da5b0390b22f8a1e03d65b2a5de7e2ce75d79ff291aa85d7f6e7bc79f6f6a09daa251977f43358e37a3f7e985bdde65a5d4881b1ad381726466bbc
data/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # CreditCard-Generator
2
+ CreditCardGenerator is a Ruby library designed to generate valid credit card numbers for testing purposes. Using the Luhn algorithm, this library creates credit card numbers that conform to the standard validation rules used by most payment processors.
3
+
4
+ ## Purpose
5
+ The primary goal of CreditCardGenerator is to assist developers and testers in generating valid credit card numbers for use in test environments. These numbers are syntactically correct but cannot be used for real transactions, making them ideal for testing payment processing systems, form validations, and other use cases where valid card numbers are required.
6
+
7
+ ## Features
8
+ Supports Multiple Card Types: Generate numbers for Visa, MasterCard, American Express, and other major card providers.
9
+ Customizable Lengths and Prefixes: Generate card numbers with specific lengths and prefixes to simulate different card types.
10
+ Batch Generation: Easily generate multiple card numbers in one go.
11
+
12
+ ## Use Cases
13
+ Payment Gateway Testing: Simulate transactions with valid card numbers.
14
+ Form Validation: Ensure your forms correctly validate and accept credit card numbers.
15
+ Load Testing: Generate large quantities of card numbers to stress-test payment systems.
16
+
@@ -0,0 +1,6 @@
1
+ # lib/credit_card_generator/version.rb
2
+
3
+ module CreditCardGenerator
4
+ VERSION = "0.1.0"
5
+ end
6
+
@@ -0,0 +1,31 @@
1
+ module CreditCardGenerator
2
+ def self.luhn_checksum(card_number)
3
+ digits = card_number.chars.map(&:to_i)
4
+ checksum = 0
5
+
6
+ digits.reverse.each_with_index do |digit, index|
7
+ if index.odd?
8
+ digit *= 2
9
+ digit -= 9 if digit > 9
10
+ end
11
+ checksum += digit
12
+ end
13
+
14
+ checksum % 10
15
+ end
16
+
17
+ def self.generate_card_number(prefix, length)
18
+ card_number = prefix.dup
19
+
20
+ while card_number.length < (length - 1)
21
+ card_number += rand(0..9).to_s
22
+ end
23
+
24
+ checksum_digit = (10 - luhn_checksum(card_number + '0')) % 10
25
+ card_number + checksum_digit.to_s
26
+ end
27
+
28
+ def self.generate(prefix, length, quantity)
29
+ (1..quantity).map { generate_card_number(prefix, length) }
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: credit_card_generator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Victor Oliveira
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-08-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: httparty
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: This library generates credit card numbers using the Luhn algorithm,
42
+ suitable for testing payment systems and form validations.
43
+ email:
44
+ - victorhugodias2001@gmail.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - README.md
50
+ - lib/credit_card_generator.rb
51
+ - lib/credit_card_generator/version.rb
52
+ homepage: https://github.com/VictorHugoDiasOliveira/CreditCard-Generator
53
+ licenses:
54
+ - MIT
55
+ metadata:
56
+ homepage_uri: https://github.com/VictorHugoDiasOliveira/CreditCard-Generator
57
+ source_code_uri: https://github.com/VictorHugoDiasOliveira/CreditCard-Generator
58
+ changelog_uri: https://github.com/VictorHugoDiasOliveira/CreditCard-Generator/CHANGELOG.md
59
+ post_install_message: Thank you for installing CreditCardGenerator!
60
+ rdoc_options: []
61
+ require_paths:
62
+ - lib
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirements: []
74
+ rubygems_version: 3.5.11
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: A simple library for generating valid credit card numbers for testing purposes.
78
+ test_files: []