active_shipping 1.8.6 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +12 -7
- data/CONTRIBUTING.md +14 -38
- data/MIT-LICENSE +2 -2
- data/README.md +61 -24
- data/Rakefile +3 -0
- data/active_shipping.gemspec +25 -26
- data/{Gemfile.activesupport32 → gemfiles/activesupport32.gemfile} +2 -1
- data/{Gemfile.activesupport40 → gemfiles/activesupport40.gemfile} +2 -1
- data/{Gemfile.activesupport41 → gemfiles/activesupport41.gemfile} +2 -1
- data/{Gemfile.activesupport42 → gemfiles/activesupport42.gemfile} +2 -1
- data/{Gemfile.activesupport50 → gemfiles/activesupport50.gemfile} +2 -1
- data/gemfiles/activesupport_master.gemfile +5 -0
- data/lib/active_shipping.rb +1 -23
- data/lib/active_shipping/carrier.rb +3 -3
- data/lib/active_shipping/carriers/canada_post_pws.rb +8 -8
- data/lib/active_shipping/carriers/ups.rb +19 -0
- data/lib/active_shipping/package.rb +3 -75
- data/lib/active_shipping/package_item.rb +72 -0
- data/lib/active_shipping/version.rb +1 -1
- data/test/remote/fedex_test.rb +5 -5
- data/test/remote/ups_test.rb +2 -1
- data/test/test_helper.rb +1 -0
- data/test/unit/carriers/canada_post_pws_tracking_test.rb +2 -2
- data/test/unit/carriers/fedex_test.rb +8 -8
- data/test/unit/carriers/kunaki_test.rb +1 -1
- data/test/unit/carriers/stamps_test.rb +1 -1
- data/test/unit/carriers/usps_test.rb +2 -2
- data/test/unit/external_return_label_request_test.rb +17 -17
- data/test/unit/package_item_test.rb +237 -0
- data/test/unit/package_test.rb +393 -58
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 462841bf0a8057af2ff59f22965770b482a0007b
|
4
|
+
data.tar.gz: 8676403cf4ddf74d4841c2c3df5c25662dad8255
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 471ff19c9a74e5eb738fb560286e8af4a818d07f66b4258b0d4ec9c62879f38596b50a446de079eb286969a7e2d99fd3daa35c36acf8cc0f145c4cb3c148a70b
|
7
|
+
data.tar.gz: 99b1b6508cde41566cdc8c7b0dd89fa272856b4c1688bd380b83dcd90720a8b98e1ea6160a80a75add005ca9af04132c357f4083bedd41db34813e67d824a5f4
|
data/.travis.yml
CHANGED
@@ -9,18 +9,23 @@ rvm:
|
|
9
9
|
- "2.3.1"
|
10
10
|
|
11
11
|
gemfile:
|
12
|
-
-
|
13
|
-
-
|
14
|
-
-
|
15
|
-
-
|
16
|
-
-
|
12
|
+
- gemfiles/activesupport32.gemfile
|
13
|
+
- gemfiles/activesupport40.gemfile
|
14
|
+
- gemfiles/activesupport41.gemfile
|
15
|
+
- gemfiles/activesupport42.gemfile
|
16
|
+
- gemfiles/activesupport50.gemfile
|
17
|
+
- gemfiles/activesupport_master.gemfile
|
17
18
|
|
18
19
|
matrix:
|
19
20
|
exclude:
|
20
21
|
- rvm: "2.0"
|
21
|
-
gemfile:
|
22
|
+
gemfile: gemfiles/activesupport50.gemfile
|
23
|
+
- rvm: "2.0"
|
24
|
+
gemfile: gemfiles/activesupport_master.gemfile
|
25
|
+
- rvm: "2.1"
|
26
|
+
gemfile: gemfiles/activesupport50.gemfile
|
22
27
|
- rvm: "2.1"
|
23
|
-
gemfile:
|
28
|
+
gemfile: gemfiles/activesupport_master.gemfile
|
24
29
|
|
25
30
|
env:
|
26
31
|
global:
|
data/CONTRIBUTING.md
CHANGED
@@ -1,45 +1,21 @@
|
|
1
1
|
# Contributing to ActiveShipping
|
2
2
|
|
3
|
-
We
|
3
|
+
We love receiving pull requests! Anything from new carriers to documentation fixes.
|
4
4
|
|
5
|
-
|
5
|
+
## Standards
|
6
6
|
|
7
|
-
|
7
|
+
* PR should explain what the feature does, and why the change exists.
|
8
|
+
* PR should include any carrier specific documentation explaining how it works.
|
9
|
+
* Code _must_ be tested, including both unit and remote tests where applicable.
|
10
|
+
* Be consistent. Write clean code that follows [Ruby community standards](https://github.com/bbatsov/ruby-style-guide).
|
11
|
+
* Code should be generic and reusable.
|
8
12
|
|
9
|
-
|
10
|
-
- Don't use too much white space
|
11
|
-
- Use 2 space indent, no tabs.
|
12
|
-
- No spaces after `(`, `[` and before `]`, `)`
|
13
|
-
- Nor too little
|
14
|
-
- Use spaces around operators and after commas, colons and semicolons
|
15
|
-
- Indent when as deep as case
|
16
|
-
- Write lucid code in lieu of adding comments
|
13
|
+
If you're stuck, ask questions!
|
17
14
|
|
18
|
-
|
15
|
+
## How to contribute
|
19
16
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
- Do not add new gem dependencies.
|
26
|
-
|
27
|
-
### Contributors
|
28
|
-
|
29
|
-
- James MacAulay (<http://jmacaulay.net>)
|
30
|
-
- Tobias Luetke (<http://blog.leetsoft.com>)
|
31
|
-
- Cody Fauser (<http://codyfauser.com>)
|
32
|
-
- Jimmy Baker (<http://jimmyville.com/>)
|
33
|
-
- William Lang (<http://williamlang.net/>)
|
34
|
-
- Cameron Fowler
|
35
|
-
- Christopher Saunders (<http://christophersaunders.ca>)
|
36
|
-
- Denis Odorcic
|
37
|
-
- Dennis O'Connor
|
38
|
-
- Dennis Theisen
|
39
|
-
- Edward Ocampo-Gooding
|
40
|
-
- Isaac Kearse
|
41
|
-
- John Duff
|
42
|
-
- Nigel Ramsay
|
43
|
-
- Philip Arndt
|
44
|
-
- Vikram Oberoi
|
45
|
-
- Willem van Bergen
|
17
|
+
1. Fork it ( https://github.com/Shopify/active_shipping/fork )
|
18
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
19
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
20
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
21
|
+
5. Create a new Pull Request
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2016 Shopify
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -7,10 +7,8 @@ This library interfaces with the web services of various shipping carriers. The
|
|
7
7
|
- Tracking shipments
|
8
8
|
- Purchasing shipping labels
|
9
9
|
|
10
|
-
Active Shipping is currently being used and improved in a production environment for [Shopify]
|
10
|
+
Active Shipping is currently being used and improved in a production environment for [Shopify](http://shopify.com).
|
11
11
|
|
12
|
-
[Shopify]:http://www.shopify.com
|
13
|
-
[discuss]:http://groups.google.com/group/activemerchant
|
14
12
|
|
15
13
|
## Supported Shipping Carriers
|
16
14
|
|
@@ -25,13 +23,28 @@ Active Shipping is currently being used and improved in a production environment
|
|
25
23
|
* [Kunaki](http://www.kunaki.com)
|
26
24
|
* [Australia Post](http://auspost.com.au/)
|
27
25
|
|
26
|
+
|
27
|
+
## Versions
|
28
|
+
|
29
|
+
Development on `master` is for a pre-release of the `2.x` version of this gem. It includes a number of backwards incompatible changes and improvements. Progress can be tracked in [the milestone](https://github.com/Shopify/active_shipping/milestone/1).
|
30
|
+
|
31
|
+
We are no longer actively developing version `1.x`. We have released `1.9` and will only backport small fixes to this version, on branch `1-9-stable`, and they should be on `master` first.
|
32
|
+
|
33
|
+
|
28
34
|
## Installation
|
29
35
|
|
36
|
+
Using bundler, add to the `Gemfile`:
|
37
|
+
|
30
38
|
```ruby
|
31
|
-
gem
|
39
|
+
gem 'active_shipping'
|
40
|
+
```
|
41
|
+
|
42
|
+
Or stand alone:
|
43
|
+
|
44
|
+
```
|
45
|
+
$ gem install active_shipping
|
32
46
|
```
|
33
47
|
|
34
|
-
...or add it to your project's [Gemfile](http://bundler.io/).
|
35
48
|
|
36
49
|
## Sample Usage
|
37
50
|
|
@@ -86,6 +99,8 @@ packages = [
|
|
86
99
|
# ["USPS Global Express Guaranteed", 9400]]
|
87
100
|
```
|
88
101
|
|
102
|
+
Dimensions for packages are in `Height x Width x Length` order.
|
103
|
+
|
89
104
|
### Track a FedEx package
|
90
105
|
|
91
106
|
```ruby
|
@@ -104,40 +119,62 @@ end
|
|
104
119
|
# Delivered at Knoxville, TN on Fri Oct 24 16:45:00 UTC 2008. Signed for by: T.BAKER
|
105
120
|
```
|
106
121
|
|
107
|
-
|
122
|
+
## Carrier specific notes
|
123
|
+
|
124
|
+
### FedEx connection
|
125
|
+
|
126
|
+
The `:login` key passed to `ActiveShipping::FedEx.new()` is really the FedEx meter number, not the FedEx login.
|
127
|
+
|
128
|
+
When developing with test credentials, be sure to pass `test: true` to `ActiveShipping::FedEx.new()`.
|
129
|
+
|
130
|
+
|
131
|
+
## Tests
|
132
|
+
|
133
|
+
You can run the unit tests with:
|
134
|
+
|
135
|
+
```
|
136
|
+
bundle exec rake test:unit
|
137
|
+
```
|
138
|
+
|
139
|
+
and the remote tests with:
|
140
|
+
|
141
|
+
```
|
142
|
+
bundle exec rake test:remote
|
143
|
+
```
|
108
144
|
|
109
|
-
The
|
145
|
+
The unit tests mock out requests and responses so that everything runs locally, while the remote tests actually hit the carrier servers. For the remote tests, you'll need valid test credentials for any carriers' tests you want to run. The credentials should go in [`~/.active_shipping/credentials.yml`](https://github.com/Shopify/active_shipping/blob/master/test/credentials.yml). For some carriers, we have public credentials you can use for testing in `.travis.yml`. Remote tests missing credentials will be skipped.
|
110
146
|
|
111
|
-
When developing with test credentials, be sure to pass ```test: true``` to ```ActiveShipping::FedEx.new()``` .
|
112
147
|
|
113
|
-
##
|
148
|
+
## Contributing
|
114
149
|
|
115
|
-
|
150
|
+
See [CONTRIBUTING.md](https://github.com/Shopify/active_shipping/blob/master/CONTRIBUTING.md).
|
116
151
|
|
117
|
-
|
152
|
+
We love getting pull requests! Anything from new features to documentation clean up.
|
118
153
|
|
119
|
-
|
154
|
+
If you're building a new carrier, a good place to start is in the [`Carrier` base class](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/carrier.rb).
|
120
155
|
|
121
|
-
|
156
|
+
It would also be good to familiarize yourself with [`Location`](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/location.rb), [`Package`](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/package.rb), and [`Response`](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/response.rb).
|
122
157
|
|
123
|
-
[
|
124
|
-
[https://github.com/Shopify/active_shipping/blob/master/test/unit/carriers/usps_test.rb](https://github.com/Shopify/active_shipping/blob/master/test/unit/carriers/usps_test.rb)
|
125
|
-
[https://github.com/Shopify/active_shipping/tree/master/test/fixtures/xml/usps](https://github.com/Shopify/active_shipping/tree/master/test/fixtures/xml/usps)
|
158
|
+
You can use the [`test/console.rb`](https://github.com/Shopify/active_shipping/blob/master/test/console.rb) to do some local testing against real endpoints.
|
126
159
|
|
127
160
|
To log requests and responses, just set the `logger` on your Carrier class to some kind of `Logger` object:
|
128
161
|
|
129
162
|
```ruby
|
130
|
-
ActiveShipping::USPS.logger = Logger.new(
|
163
|
+
ActiveShipping::USPS.logger = Logger.new(STDOUT)
|
131
164
|
```
|
132
165
|
|
133
|
-
|
166
|
+
### Anatomy of a pull request
|
167
|
+
|
168
|
+
Any new features or carriers should have passing unit _and_ remote tests. Look at some existing carriers as examples.
|
169
|
+
|
170
|
+
When opening a pull request, include description of the feature, why it exists, and any supporting documentation to explain interaction with carriers.
|
134
171
|
|
135
|
-
To debug API requests and your code, you can run `rake console` to start a Pry session with `ActiveShipping` included
|
136
|
-
and instances of the various carriers set up with your test credentials.
|
137
|
-
Look at the file [`test/console.rb`](https://github.com/Shopify/active_shipping/blob/master/test/console.rb) to see the other goodies it provides.
|
138
172
|
|
139
|
-
|
173
|
+
### How to contribute
|
140
174
|
|
141
|
-
|
175
|
+
1. Fork it ( https://github.com/Shopify/active_shipping/fork )
|
176
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
177
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
178
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
179
|
+
5. Create a new Pull Request
|
142
180
|
|
143
|
-
Unless otherwise noted in specific files, all code in the ActiveShipping project is under the copyright and license described in the included MIT-LICENSE file.
|
data/Rakefile
CHANGED
@@ -6,6 +6,7 @@ Rake::TestTask.new(:test) do |t|
|
|
6
6
|
t.libs << "test"
|
7
7
|
t.pattern = 'test/**/*_test.rb'
|
8
8
|
t.verbose = true
|
9
|
+
t.warning = false
|
9
10
|
end
|
10
11
|
|
11
12
|
namespace :test do
|
@@ -14,6 +15,7 @@ namespace :test do
|
|
14
15
|
t.libs << "test"
|
15
16
|
t.pattern = 'test/unit/**/*_test.rb'
|
16
17
|
t.verbose = true
|
18
|
+
t.warning = false
|
17
19
|
end
|
18
20
|
|
19
21
|
desc "Run functional remote tests"
|
@@ -21,6 +23,7 @@ namespace :test do
|
|
21
23
|
t.libs << "test"
|
22
24
|
t.pattern = 'test/remote/*_test.rb'
|
23
25
|
t.verbose = true
|
26
|
+
t.warning = false
|
24
27
|
end
|
25
28
|
end
|
26
29
|
|
data/active_shipping.gemspec
CHANGED
@@ -1,33 +1,32 @@
|
|
1
|
-
lib = File.expand_path(
|
1
|
+
lib = File.expand_path("../lib/", __FILE__)
|
2
2
|
$:.unshift(lib) unless $:.include?(lib)
|
3
3
|
|
4
|
-
require
|
4
|
+
require "active_shipping/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
s.platform
|
10
|
-
s.authors
|
11
|
-
s.email
|
12
|
-
s.homepage
|
13
|
-
s.summary
|
14
|
-
s.description
|
15
|
-
s.license
|
7
|
+
s.name = "active_shipping"
|
8
|
+
s.version = ActiveShipping::VERSION
|
9
|
+
s.platform = Gem::Platform::RUBY
|
10
|
+
s.authors = ["Shopify"]
|
11
|
+
s.email = ["integrations-team@shopify.com"]
|
12
|
+
s.homepage = "http://github.com/shopify/active_shipping"
|
13
|
+
s.summary = "Simple shipping abstraction library"
|
14
|
+
s.description = "Get rates and tracking info from various shipping carriers. Extracted from Shopify."
|
15
|
+
s.license = "MIT"
|
16
|
+
s.files = `git ls-files`.split($/)
|
17
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
|
+
s.require_path = "lib"
|
16
20
|
|
17
|
-
s.add_dependency(
|
18
|
-
s.add_dependency(
|
19
|
-
s.add_dependency(
|
20
|
-
s.add_dependency(
|
21
|
+
s.add_dependency("quantified", "~> 1.0.1")
|
22
|
+
s.add_dependency("activesupport", ">= 3.2", "< 5.1.0")
|
23
|
+
s.add_dependency("active_utils", "~> 3.2.0")
|
24
|
+
s.add_dependency("nokogiri", ">= 1.6")
|
21
25
|
|
22
|
-
s.add_development_dependency(
|
23
|
-
s.add_development_dependency(
|
24
|
-
s.add_development_dependency(
|
25
|
-
s.add_development_dependency(
|
26
|
-
s.add_development_dependency(
|
27
|
-
s.add_development_dependency(
|
28
|
-
|
29
|
-
s.files = `git ls-files`.split($/)
|
30
|
-
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
31
|
-
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
32
|
-
s.require_path = 'lib'
|
26
|
+
s.add_development_dependency("minitest")
|
27
|
+
s.add_development_dependency("rake")
|
28
|
+
s.add_development_dependency("mocha", "~> 1")
|
29
|
+
s.add_development_dependency("timecop")
|
30
|
+
s.add_development_dependency("business_time")
|
31
|
+
s.add_development_dependency("pry")
|
33
32
|
end
|
data/lib/active_shipping.rb
CHANGED
@@ -1,26 +1,3 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2009 Jaded Pixel
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
1
|
require 'active_support/all'
|
25
2
|
require 'active_utils'
|
26
3
|
|
@@ -34,6 +11,7 @@ require 'active_shipping/delivery_date_estimates_response'
|
|
34
11
|
require 'active_shipping/shipping_response'
|
35
12
|
require 'active_shipping/label_response'
|
36
13
|
require 'active_shipping/label'
|
14
|
+
require 'active_shipping/package_item'
|
37
15
|
require 'active_shipping/package'
|
38
16
|
require 'active_shipping/location'
|
39
17
|
require 'active_shipping/rate_estimate'
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module ActiveShipping
|
2
2
|
|
3
|
-
# Carrier is abstract
|
3
|
+
# Carrier is the abstract base class for all supported carriers.
|
4
4
|
#
|
5
5
|
# To implement support for a carrier, you should subclass this class and
|
6
|
-
# implement all the methods the carrier supports.
|
6
|
+
# implement all the methods that the carrier supports.
|
7
7
|
#
|
8
8
|
# @see #find_rates
|
9
9
|
# @see #create_shipment
|
@@ -96,7 +96,7 @@ module ActiveShipping
|
|
96
96
|
|
97
97
|
# Validate credentials with a call to the API.
|
98
98
|
#
|
99
|
-
# By default this just does a `find_rates` call with the
|
99
|
+
# By default this just does a `find_rates` call with the origin and destination both as
|
100
100
|
# the carrier's default_location. Override to provide alternate functionality, such as
|
101
101
|
# checking for `test_mode` to use test servers, etc.
|
102
102
|
#
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module ActiveShipping
|
2
2
|
class CanadaPostPWS < Carrier
|
3
|
-
|
3
|
+
|
4
4
|
cattr_reader :name
|
5
5
|
@@name = "Canada Post PWS"
|
6
6
|
|
@@ -569,13 +569,13 @@ module ActiveShipping
|
|
569
569
|
|
570
570
|
def tracking_url(pin)
|
571
571
|
case pin.length
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
572
|
+
when 12, 13, 16
|
573
|
+
"#{endpoint}vis/track/pin/#{pin}/detail"
|
574
|
+
when 15
|
575
|
+
"#{endpoint}vis/track/dnc/#{pin}/detail"
|
576
|
+
else
|
577
|
+
raise InvalidPinFormatError
|
578
|
+
end
|
579
579
|
end
|
580
580
|
|
581
581
|
def create_shipment_url(options)
|