active_shipping 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,4 +3,5 @@ test.xml
3
3
  sample.rb
4
4
  *.orig
5
5
  *.swp
6
- .dotest
6
+ .dotest
7
+ pkg
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -0,0 +1,136 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{active_shipping}
8
+ s.version = "0.0.2"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["James MacAulay", "Tobias Luetke", "Cody Fauser", "Jimmy Baker"]
12
+ s.date = %q{2009-11-11}
13
+ s.description = %q{Shipping API extension for Active Merchant.}
14
+ s.email = %q{jmacaulay@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.markdown"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "CHANGELOG",
21
+ "MIT-LICENSE",
22
+ "README.markdown",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "active_shipping.gemspec",
26
+ "init.rb",
27
+ "lib/active_shipping.rb",
28
+ "lib/active_shipping/lib/connection.rb",
29
+ "lib/active_shipping/lib/country.rb",
30
+ "lib/active_shipping/lib/error.rb",
31
+ "lib/active_shipping/lib/post_data.rb",
32
+ "lib/active_shipping/lib/posts_data.rb",
33
+ "lib/active_shipping/lib/requires_parameters.rb",
34
+ "lib/active_shipping/lib/utils.rb",
35
+ "lib/active_shipping/lib/validateable.rb",
36
+ "lib/active_shipping/shipping/base.rb",
37
+ "lib/active_shipping/shipping/carrier.rb",
38
+ "lib/active_shipping/shipping/carriers.rb",
39
+ "lib/active_shipping/shipping/carriers/bogus_carrier.rb",
40
+ "lib/active_shipping/shipping/carriers/fedex.rb",
41
+ "lib/active_shipping/shipping/carriers/shipwire.rb",
42
+ "lib/active_shipping/shipping/carriers/ups.rb",
43
+ "lib/active_shipping/shipping/carriers/usps.rb",
44
+ "lib/active_shipping/shipping/location.rb",
45
+ "lib/active_shipping/shipping/package.rb",
46
+ "lib/active_shipping/shipping/rate_estimate.rb",
47
+ "lib/active_shipping/shipping/rate_response.rb",
48
+ "lib/active_shipping/shipping/response.rb",
49
+ "lib/active_shipping/shipping/shipment_event.rb",
50
+ "lib/active_shipping/shipping/tracking_response.rb",
51
+ "lib/certs/cacert.pem",
52
+ "lib/vendor/quantified/MIT-LICENSE",
53
+ "lib/vendor/quantified/README.markdown",
54
+ "lib/vendor/quantified/Rakefile",
55
+ "lib/vendor/quantified/init.rb",
56
+ "lib/vendor/quantified/lib/quantified.rb",
57
+ "lib/vendor/quantified/lib/quantified/attribute.rb",
58
+ "lib/vendor/quantified/lib/quantified/length.rb",
59
+ "lib/vendor/quantified/lib/quantified/mass.rb",
60
+ "lib/vendor/quantified/test/length_test.rb",
61
+ "lib/vendor/quantified/test/mass_test.rb",
62
+ "lib/vendor/quantified/test/test_helper.rb",
63
+ "lib/vendor/test_helper.rb",
64
+ "lib/vendor/xml_node/README",
65
+ "lib/vendor/xml_node/Rakefile",
66
+ "lib/vendor/xml_node/benchmark/bench_generation.rb",
67
+ "lib/vendor/xml_node/init.rb",
68
+ "lib/vendor/xml_node/lib/xml_node.rb",
69
+ "lib/vendor/xml_node/test/test_generating.rb",
70
+ "lib/vendor/xml_node/test/test_parsing.rb",
71
+ "test/fixtures.yml",
72
+ "test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_request.xml",
73
+ "test/fixtures/xml/fedex/ottawa_to_beverly_hills_rate_response.xml",
74
+ "test/fixtures/xml/fedex/tracking_request.xml",
75
+ "test/fixtures/xml/fedex/tracking_response.xml",
76
+ "test/fixtures/xml/shipwire/international_rates_response.xml",
77
+ "test/fixtures/xml/shipwire/invalid_credentials_response.xml",
78
+ "test/fixtures/xml/shipwire/new_carrier_rate_response.xml",
79
+ "test/fixtures/xml/shipwire/no_rates_response.xml",
80
+ "test/fixtures/xml/shipwire/rates_response.xml",
81
+ "test/fixtures/xml/ups/example_tracking_response.xml",
82
+ "test/fixtures/xml/ups/shipment_from_tiger_direct.xml",
83
+ "test/fixtures/xml/ups/test_real_home_as_residential_destination_response.xml",
84
+ "test/fixtures/xml/usps/beverly_hills_to_ottawa_book_rate_response.xml",
85
+ "test/fixtures/xml/usps/beverly_hills_to_ottawa_book_wii_rate_response.xml",
86
+ "test/fixtures/xml/usps/beverly_hills_to_ottawa_wii_rate_response.xml",
87
+ "test/fixtures/xml/usps/example_tracking_response.xml",
88
+ "test/fixtures/xml/usps/multi_tracking_example.xml",
89
+ "test/remote/fedex_test.rb",
90
+ "test/remote/shipwire_test.rb",
91
+ "test/remote/ups_test.rb",
92
+ "test/remote/usps_test.rb",
93
+ "test/test_helper.rb",
94
+ "test/unit/base_test.rb",
95
+ "test/unit/carriers/fedex_test.rb",
96
+ "test/unit/carriers/shipwire_test.rb",
97
+ "test/unit/carriers/ups_test.rb",
98
+ "test/unit/carriers/usps_test.rb",
99
+ "test/unit/location_test.rb",
100
+ "test/unit/package_test.rb",
101
+ "test/unit/response_test.rb"
102
+ ]
103
+ s.homepage = %q{http://github.com/Shopify/active_shipping}
104
+ s.rdoc_options = ["--charset=UTF-8"]
105
+ s.require_paths = ["lib"]
106
+ s.rubygems_version = %q{1.3.5}
107
+ s.summary = %q{Shipping API extension for Active Merchant.}
108
+ s.test_files = [
109
+ "test/remote/fedex_test.rb",
110
+ "test/remote/shipwire_test.rb",
111
+ "test/remote/ups_test.rb",
112
+ "test/remote/usps_test.rb",
113
+ "test/test_helper.rb",
114
+ "test/unit/base_test.rb",
115
+ "test/unit/carriers/fedex_test.rb",
116
+ "test/unit/carriers/shipwire_test.rb",
117
+ "test/unit/carriers/ups_test.rb",
118
+ "test/unit/carriers/usps_test.rb",
119
+ "test/unit/location_test.rb",
120
+ "test/unit/package_test.rb",
121
+ "test/unit/response_test.rb"
122
+ ]
123
+
124
+ if s.respond_to? :specification_version then
125
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
126
+ s.specification_version = 3
127
+
128
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
129
+ s.add_runtime_dependency(%q<activesupport>, [">= 0"])
130
+ else
131
+ s.add_dependency(%q<activesupport>, [">= 0"])
132
+ end
133
+ else
134
+ s.add_dependency(%q<activesupport>, [">= 0"])
135
+ end
136
+ end
@@ -290,24 +290,15 @@ module ActiveMerchant
290
290
  track_details = i.get_elements('TrackDetail')
291
291
  unless track_details.empty?
292
292
  shipment_events = track_details.map do |track_detail|
293
- name = track_detail.get_text('Event').to_s
294
- if (time = track_detail.get_text('EventTime')) &&
295
- (date = track_detail.get_text('EventDate'))
296
-
297
- event_time = Time.parse("#{date} #{time}")
298
- end
299
-
300
- location = Location.new(
301
- :city => node_string_or_nil(track_detail.elements['EventCity']),
302
- :state => node_string_or_nil(track_detail.elements['EventState']),
303
- :postal_code => node_string_or_nil(track_detail.elements['EventZIPCode']),
304
- :country => node_string_or_nil(track_detail.elements['EventCountry'])
305
- )
306
-
307
- ShipmentEvent.new(name, event_time, location)
308
-
293
+ parse_shipment_event(track_detail)
309
294
  end
310
295
  end
296
+
297
+ track_summary = i.get_elements('TrackSummary')[0]
298
+ unless track_summary.nil?
299
+ shipment_events ||= []
300
+ shipment_events << parse_shipment_event(track_summary)
301
+ end
311
302
  TrackingResponse.new(success, response_message(xml),
312
303
  Hash.from_xml(response).values.first,
313
304
  :xml => response,
@@ -320,6 +311,24 @@ module ActiveMerchant
320
311
  end
321
312
  end
322
313
 
314
+ def parse_shipment_event(track_detail)
315
+ name = track_detail.get_text('Event').to_s
316
+ if (time = track_detail.get_text('EventTime')) &&
317
+ (date = track_detail.get_text('EventDate'))
318
+
319
+ event_time = Time.parse("#{date} #{time}")
320
+ end
321
+
322
+ location = Location.new(
323
+ :city => node_string_or_nil(track_detail.elements['EventCity']),
324
+ :state => node_string_or_nil(track_detail.elements['EventState']),
325
+ :postal_code => node_string_or_nil(track_detail.elements['EventZIPCode']),
326
+ :country => node_string_or_nil(track_detail.elements['EventCountry'])
327
+ )
328
+
329
+ ShipmentEvent.new(name, event_time, location)
330
+ end
331
+
323
332
 
324
333
 
325
334
  def response_success?(xml)
@@ -0,0 +1,104 @@
1
+ <?xml version="1.0"?>
2
+ <TrackResponse>
3
+
4
+ <TrackInfo ID="EJ958083578US">
5
+
6
+ <TrackSummary>
7
+
8
+ <EventTime>8:10 am</EventTime>
9
+
10
+ <EventDate>June 1, 2001</EventDate>
11
+
12
+ <Event>DELIVERED</Event>
13
+
14
+ <EventCity>WILMINGTON</EventCity>
15
+
16
+ <EventState>DE</EventState>
17
+
18
+ <EventZIPCode>19801</EventZIPCode>
19
+
20
+ <EventCountry/>
21
+
22
+ <FirmName></FirmName>
23
+
24
+ <Name></Name>
25
+
26
+ <AuthorizedAgent></AuthorizedAgent>
27
+
28
+ </TrackSummary>
29
+
30
+ <TrackDetail>
31
+
32
+ <EventTime>11:07 am</EventTime>
33
+
34
+ <EventDate>May 30, 2001</EventDate>
35
+
36
+ <Event>NOTICE LEFT</Event>
37
+
38
+ <EventCity>WILMINGTON</EventCity>
39
+
40
+ <EventState>DE</EventState>
41
+
42
+ <EventZIPCode>19801</EventZIPCode>
43
+
44
+ <EventCountry/>
45
+
46
+ <FirmName/>
47
+
48
+ <Name/>
49
+
50
+ <AuthorizedAgent/>
51
+
52
+ </TrackDetail>
53
+
54
+ <TrackDetail>
55
+
56
+ <EventTime>10:08 am</EventTime>
57
+
58
+ <EventDate>May 30, 2001</EventDate>
59
+
60
+ <Event>ARRIVAL AT UNIT</Event>
61
+
62
+ <EventCity>WILMINGTON</EventCity>
63
+
64
+ <EventState>DE</EventState>
65
+
66
+ <EventZIPCode>19850</EventZIPCode>
67
+
68
+ <EventCountry/>
69
+
70
+ <FirmName/>
71
+
72
+ <Name/>
73
+
74
+ <AuthorizedAgent/>
75
+
76
+ </TrackDetail>
77
+
78
+ <TrackDetail>
79
+
80
+ <EventTime>9:55 pm</EventTime>
81
+
82
+ <EventDate>May 29, 2001</EventDate>
83
+
84
+ <Event>ACCEPTANCE</Event>
85
+
86
+ <EventCity>EDGEWATER</EventCity>
87
+
88
+ <EventState>NJ</EventState>
89
+
90
+ <EventZIPCode>07020</EventZIPCode>
91
+
92
+ <EventCountry/>
93
+
94
+ <FirmName/>
95
+
96
+ <Name/>
97
+
98
+ <AuthorizedAgent/>
99
+
100
+ </TrackDetail>
101
+
102
+ </TrackInfo>
103
+
104
+ </TrackResponse>
@@ -0,0 +1,105 @@
1
+ <?xml version="1.0"?>
2
+ <TrackResponse>
3
+
4
+ <TrackInfo ID="EJ958083578US">
5
+
6
+ <TrackSummary>
7
+
8
+ <EventTime>8:10 am</EventTime>
9
+
10
+ <EventDate>June 1, 2001</EventDate>
11
+
12
+ <Event>DELIVERED</Event>
13
+
14
+ <EventCity>WILMINGTON</EventCity>
15
+
16
+ <EventState>DE</EventState>
17
+
18
+ <EventZIPCode>19801</EventZIPCode>
19
+
20
+ <EventCountry/>
21
+
22
+ <FirmName></FirmName>
23
+
24
+ <Name></Name>
25
+
26
+ <AuthorizedAgent></AuthorizedAgent>
27
+
28
+ </TrackSummary>
29
+
30
+ <TrackDetail>
31
+
32
+ <EventTime>11:07 am</EventTime>
33
+
34
+ <EventDate>May 30, 2001</EventDate>
35
+
36
+ <Event>NOTICE LEFT</Event>
37
+
38
+ <EventCity>WILMINGTON</EventCity>
39
+
40
+ <EventState>DE</EventState>
41
+
42
+ <EventZIPCode>19801</EventZIPCode>
43
+
44
+ <EventCountry/>
45
+
46
+ <FirmName/>
47
+
48
+ <Name/>
49
+
50
+ <AuthorizedAgent/>
51
+
52
+ </TrackDetail>
53
+
54
+ <TrackDetail>
55
+
56
+ <EventTime>10:08 am</EventTime>
57
+
58
+ <EventDate>May 30, 2001</EventDate>
59
+
60
+ <Event>ARRIVAL AT UNIT</Event>
61
+
62
+ <EventCity>WILMINGTON</EventCity>
63
+
64
+ <EventState>DE</EventState>
65
+
66
+ <EventZIPCode>19850</EventZIPCode>
67
+
68
+ <EventCountry/>
69
+
70
+ <FirmName/>
71
+
72
+ <Name/>
73
+
74
+ <AuthorizedAgent/>
75
+
76
+ </TrackDetail>
77
+
78
+ <TrackDetail>
79
+
80
+ <EventTime>9:55 pm</EventTime>
81
+
82
+ <EventDate>May 29, 2001</EventDate>
83
+
84
+ <Event>ACCEPTANCE</Event>
85
+
86
+ <EventCity>EDGEWATER</EventCity>
87
+
88
+ <EventState>NJ</EventState>
89
+
90
+ <EventZIPCode>07020</EventZIPCode>
91
+
92
+ <EventCountry/>
93
+
94
+ <FirmName/>
95
+
96
+ <Name/>
97
+
98
+ <AuthorizedAgent/>
99
+
100
+ </TrackDetail>
101
+
102
+ </TrackInfo>
103
+
104
+ <TrackInfo ID="EJ958088694US"><TrackSummary><EventTime>1:39 pm</EventTime><EventDate>June 1, 2001</EventDate><Event>DELIVERED</Event><EventCity>WOBURN</EventCity><EventState>MA</EventState><EventZIPCode>01815</EventZIPCode><EventCountry/><FirmName></FirmName><Name></Name><AuthorizedAgent></AuthorizedAgent></TrackSummary><TrackDetail><EventTime>7:44 am</EventTime><EventDate>May 30, 2001</EventDate><Event>NOTICE LEFT</Event><EventCity>WOBURN</EventCity><EventState>MA</EventState><EventZIPCode>01815</EventZIPCode><EventCountry/><FirmName/><Name/><AuthorizedAgent/></TrackDetail><TrackDetail><EventTime>7:36 am</EventTime><EventDate>May 30, 2001</EventDate><Event>ARRIVAL AT UNIT</Event><EventCity>NORTH READING</EventCity><EventState>MA</EventState><EventZIPCode>01889</EventZIPCode><EventCountry/><FirmName/><Name/><AuthorizedAgent/></TrackDetail><TrackDetail><EventTime>6:00 pm</EventTime><EventDate>May 29, 2001</EventDate><Event>ACCEPTANCE</Event><EventCity>PORTSMOUTH</EventCity><EventState>NH</EventState><EventZIPCode>03801</EventZIPCode><EventCountry/><FirmName/><Name/><AuthorizedAgent/></TrackDetail></TrackInfo>
105
+ </TrackResponse>
@@ -24,29 +24,29 @@ class USPSTest < Test::Unit::TestCase
24
24
  def test_find_tracking_info_should_return_a_tracking_response
25
25
  @carrier.expects(:commit).returns(xml_fixture('usps/example_tracking_response'))
26
26
  assert_instance_of ActiveMerchant::Shipping::TrackingResponse,
27
- @carrier.find_tracking_info(['EJ958083578US'], :test => true)
27
+ @carrier.find_tracking_info(['EJ958083578US'], :test => true)[0]
28
28
  end
29
29
 
30
30
  def test_find_tracking_info_should_return_a_tracking_number
31
31
  @carrier.expects(:commit).returns(xml_fixture('usps/example_tracking_response'))
32
- info = @carrier.find_tracking_info(['EJ958083578US'], :test => true)
32
+ info = @carrier.find_tracking_info(['EJ958083578US'], :test => true)[0]
33
33
 
34
34
  assert_equal 'EJ958083578US', info.tracking_number
35
35
  end
36
36
 
37
37
  def test_find_tracking_info_should_return_correct_number_of_shipment_events
38
38
  @carrier.expects(:commit).returns(xml_fixture('usps/example_tracking_response'))
39
- info = @carrier.find_tracking_info(['EJ958083578US'], :test => true)
39
+ info = @carrier.find_tracking_info(['EJ958083578US'], :test => true)[0]
40
40
 
41
- assert_equal 3, info.shipment_events.size
41
+ assert_equal 4, info.shipment_events.size
42
42
  end
43
43
 
44
44
  def test_find_tracking_info_should_return_proper_order
45
45
  @carrier.expects(:commit).returns(xml_fixture('usps/example_tracking_response'))
46
- info = @carrier.find_tracking_info(['EJ958083578US'], :test => true)
46
+ info = @carrier.find_tracking_info(['EJ958083578US'], :test => true)[0]
47
47
 
48
48
  assert_equal "NOTICE LEFT", info.shipment_events.first.name
49
- assert_equal "ACCEPTANCE", info.shipment_events.last.name
49
+ assert_equal "DELIVERED", info.shipment_events.last.name
50
50
  end
51
51
 
52
52
  def test_find_multiple_returns_two_seperate_tracking_responses
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_shipping
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James MacAulay
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2009-10-26 00:00:00 -04:00
15
+ date: 2009-11-11 00:00:00 -05:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -40,6 +40,7 @@ files:
40
40
  - README.markdown
41
41
  - Rakefile
42
42
  - VERSION
43
+ - active_shipping.gemspec
43
44
  - init.rb
44
45
  - lib/active_shipping.rb
45
46
  - lib/active_shipping/lib/connection.rb
@@ -101,6 +102,8 @@ files:
101
102
  - test/fixtures/xml/usps/beverly_hills_to_ottawa_book_rate_response.xml
102
103
  - test/fixtures/xml/usps/beverly_hills_to_ottawa_book_wii_rate_response.xml
103
104
  - test/fixtures/xml/usps/beverly_hills_to_ottawa_wii_rate_response.xml
105
+ - test/fixtures/xml/usps/example_tracking_response.xml
106
+ - test/fixtures/xml/usps/multi_tracking_example.xml
104
107
  - test/remote/fedex_test.rb
105
108
  - test/remote/shipwire_test.rb
106
109
  - test/remote/ups_test.rb