tracking_number 0.9.0 → 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/tracking_number/fedex.rb +6 -4
- data/lib/tracking_number/version.rb +1 -1
- data/test/fedex_tracking_number_test.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da0ea43ce94267431428016947a2f230ecfe304f
|
4
|
+
data.tar.gz: a61003c3bfd1715e5c4e8f8d2306f567fa64ab5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd9ee0004797cd37a3b67e45ec4e7860c6cfde62963ab5094cdfc9b62075b387f19b7a96adf178b547122629ad86852edf1668c247cb14e87cdc8550a0753366
|
7
|
+
data.tar.gz: bf0e523a57f17413861f53c79d29b1d6b1a9192887f7210e8bf3d197fca4b0767f64210f5f766050bfacbb8b5d1ec1148b5da4c44643f470c67627db90c3a524
|
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.1
|
@@ -25,9 +25,8 @@ module TrackingNumber
|
|
25
25
|
end
|
26
26
|
|
27
27
|
class FedExSmartPost < FedEx
|
28
|
-
SEARCH_PATTERN = /(\b([0-9]\s*){20}\b)/
|
29
|
-
VERIFY_PATTERN = /^([0-9]{5}[0-9]{14})([0-9])$/
|
30
|
-
LENGTH = 20
|
28
|
+
SEARCH_PATTERN = /(\b(?:9\s*2\s*)?([0-9]\s*){20}\b)/
|
29
|
+
VERIFY_PATTERN = /^((?:92)?[0-9]{5}[0-9]{14})([0-9])$/
|
31
30
|
|
32
31
|
def matches
|
33
32
|
self.tracking_number.scan(VERIFY_PATTERN).flatten
|
@@ -36,7 +35,9 @@ module TrackingNumber
|
|
36
35
|
def valid_checksum?
|
37
36
|
# http://stackoverflow.com/questions/15744704/how-to-calculate-a-fedex-smartpost-tracking-number-check-digit
|
38
37
|
|
39
|
-
|
38
|
+
@tracking_number = "92#{tracking_number}" unless tracking_number =~ /^92/
|
39
|
+
|
40
|
+
sequence = @tracking_number.chars.map(&:to_i)
|
40
41
|
check_digit = sequence.pop
|
41
42
|
total = 0
|
42
43
|
|
@@ -44,6 +45,7 @@ module TrackingNumber
|
|
44
45
|
x *= 3 if i.even?
|
45
46
|
total += x
|
46
47
|
end
|
48
|
+
|
47
49
|
check = total % 10
|
48
50
|
check = (10 - check) unless (check.zero?)
|
49
51
|
|
@@ -42,7 +42,7 @@ class FedExTrackingNumberTest < Minitest::Test
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
[
|
45
|
+
['61299998820821171811', '9261292700768711948021'].each do |valid_number|
|
46
46
|
should "return fedex smart post for #{valid_number}" do
|
47
47
|
should_be_valid_number(valid_number, TrackingNumber::FedExSmartPost, :fedex)
|
48
48
|
end
|