stalkr 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/stalkr/china_post.rb +0 -1
- data/lib/stalkr/fedex.rb +9 -2
- data/test/stalkr/fedex_test.rb +7 -0
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.3
|
data/lib/stalkr/china_post.rb
CHANGED
data/lib/stalkr/fedex.rb
CHANGED
@@ -40,8 +40,13 @@ class FEDEX < Base
|
|
40
40
|
|
41
41
|
info = info_scraper.scrape(html)
|
42
42
|
|
43
|
-
|
43
|
+
status = info.status.strip.downcase
|
44
|
+
if status == "delivered" then
|
44
45
|
ret.status = DELIVERED
|
46
|
+
elsif status == "on schedule" then
|
47
|
+
ret.status = IN_TRANSIT
|
48
|
+
else
|
49
|
+
ret.status = UNKNOWN
|
45
50
|
end
|
46
51
|
ret.location = info.destination.strip
|
47
52
|
|
@@ -52,7 +57,9 @@ class FEDEX < Base
|
|
52
57
|
delivery_date = info.dates[1].strip if info.dates.length == 2
|
53
58
|
if shipped_date.empty? then
|
54
59
|
shipped_date = DateTime.strptime( $1, "%b %d, %Y" ).to_time if html =~ /var shipDate = "(.*?);$"/
|
55
|
-
|
60
|
+
if html =~ /var deliveryDateTime = "(.*?)";$/ and not ($1.nil? or $1.strip.empty?) then
|
61
|
+
delivery_date = DateTime.strptime( "#{$1} -5", "%b %d, %Y %I:%M %p %z" ).to_time
|
62
|
+
end
|
56
63
|
end
|
57
64
|
ret.delivered_at = delivery_date
|
58
65
|
ret.updated_at = delivery_date
|
data/test/stalkr/fedex_test.rb
CHANGED
@@ -10,6 +10,13 @@ class FEDEX_Test < Test::Unit::TestCase
|
|
10
10
|
assert(info.delivered_at.kind_of? Time)
|
11
11
|
end
|
12
12
|
|
13
|
+
def test_track_in_transit
|
14
|
+
id = "005794539515313"
|
15
|
+
info = Stalkr::FEDEX.new.track(id)
|
16
|
+
assert(info.shipper == :FEDEX)
|
17
|
+
assert(info.status == Stalkr::IN_TRANSIT)
|
18
|
+
end
|
19
|
+
|
13
20
|
def test_track_bad_code
|
14
21
|
|
15
22
|
id = "foobar"
|
metadata
CHANGED