creditcard-identifier 2.1.0 → 2.2.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 +4 -4
- data/lib/creditcard_identifier/brands.rb +207 -25
- data/lib/creditcard_identifier/brands_detailed.rb +25117 -321
- data/lib/creditcard_identifier.rb +16 -2
- metadata +2 -2
|
@@ -58,11 +58,25 @@ module CreditcardIdentifier
|
|
|
58
58
|
def find_brand(card_number, detailed: false)
|
|
59
59
|
return nil if card_number.nil? || card_number.empty?
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
# Collect all matching brands
|
|
62
|
+
matching_brands = @brands.select do |b|
|
|
62
63
|
b[:regexp_full].match?(card_number)
|
|
63
64
|
end
|
|
64
65
|
|
|
65
|
-
return nil
|
|
66
|
+
return nil if matching_brands.empty?
|
|
67
|
+
|
|
68
|
+
# Resolve priority: a brand with priority_over takes precedence
|
|
69
|
+
brand = matching_brands.first
|
|
70
|
+
if matching_brands.length > 1
|
|
71
|
+
matching_names = matching_brands.map { |b| b[:name] }
|
|
72
|
+
matching_brands.each do |candidate|
|
|
73
|
+
priority_over = candidate[:priority_over] || []
|
|
74
|
+
if priority_over.any? { |p| matching_names.include?(p) }
|
|
75
|
+
brand = candidate
|
|
76
|
+
break
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
66
80
|
|
|
67
81
|
if detailed
|
|
68
82
|
detailed_brand = @brands_detailed.find { |b| b[:scheme] == brand[:name] }
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: creditcard-identifier
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Renato Viço
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-01-
|
|
11
|
+
date: 2026-01-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: minitest
|