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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36b4c229dbfddaac959991ac1cfb463a551eeb17
4
- data.tar.gz: 267399613e49a562ff130331812f667a5f9344ed
3
+ metadata.gz: da0ea43ce94267431428016947a2f230ecfe304f
4
+ data.tar.gz: a61003c3bfd1715e5c4e8f8d2306f567fa64ab5f
5
5
  SHA512:
6
- metadata.gz: b1268047c9ba4b8ad7092a18351a35d04b073cd83f06e9892afb3e21dbbe8b47e74a067f90612750a2b141b49e8a3f4b4ce5a4b136597a85e96e2e4dacd3c25e
7
- data.tar.gz: c47873fc7eaf0f37c5a1c4dfb85c7887fbdc40a2b0a6b9c56fee8a402fb35b1fea37f51e7a1a920cf0b55fed284030039e2cd0d63457f00506ad172e51c4fd0c
6
+ metadata.gz: bd9ee0004797cd37a3b67e45ec4e7860c6cfde62963ab5094cdfc9b62075b387f19b7a96adf178b547122629ad86852edf1668c247cb14e87cdc8550a0753366
7
+ data.tar.gz: bf0e523a57f17413861f53c79d29b1d6b1a9192887f7210e8bf3d197fca4b0767f64210f5f766050bfacbb8b5d1ec1148b5da4c44643f470c67627db90c3a524
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tracking_number (0.9.0)
4
+ tracking_number (0.9.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.0
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
- sequence = "92#{tracking_number}".chars.to_a.map(&:to_i)
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
 
@@ -1,3 +1,3 @@
1
1
  module TrackingNumber
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
@@ -42,7 +42,7 @@ class FedExTrackingNumberTest < Minitest::Test
42
42
  end
43
43
  end
44
44
 
45
- ["61299998820821171811"].each do |valid_number|
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracking_number
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Keen