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 CHANGED
@@ -1 +1 @@
1
- 0.9.2
1
+ 0.9.3
@@ -39,7 +39,6 @@ class ChinaPost < Base
39
39
  rows.shift
40
40
 
41
41
  status = rows.first[2].strip.downcase
42
- puts status
43
42
  if status =~ /delivered/ then
44
43
  ret.status = DELIVERED
45
44
  elsif status =~ /arrival|departure/ then
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
- if info.status.strip.downcase == "delivered" then
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
- delivery_date = DateTime.strptime( "#{$1} -5", "%b %d, %Y %I:%M %p %z" ).to_time if html =~ /var deliveryDateTime = "(.*?)";$/
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
@@ -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
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stalkr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 61
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
- - 2
10
- version: 0.9.2
9
+ - 3
10
+ version: 0.9.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chetan Sarva