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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5f2cfecba695cbe25301c9243cef963e973709a
4
- data.tar.gz: 918729e4323f336d6a8200756ddc139e1cd4e3e7
3
+ metadata.gz: 462841bf0a8057af2ff59f22965770b482a0007b
4
+ data.tar.gz: 8676403cf4ddf74d4841c2c3df5c25662dad8255
5
5
  SHA512:
6
- metadata.gz: aaf1f5071b74e714997db24d095b38cd04dd92e06fe75ce6dbda35ec36b0c854a82c261fdd8a14b5578d64b562bf93a25cdf5ddce02654fdb947dab1ae10cf1c
7
- data.tar.gz: eff96dd47c928524bd3f6d7e15617a04a6e30d10f79c684913d5a25d1e858f53cd3be81a61af8bc5a17bd53c2b8588851d3022d5317cffd8ca9c28e832369dc8
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
- - Gemfile.activesupport32
13
- - Gemfile.activesupport40
14
- - Gemfile.activesupport41
15
- - Gemfile.activesupport42
16
- - Gemfile.activesupport50
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: Gemfile.activesupport50
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: Gemfile.activesupport50
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 welcome fixes and additions to this project. Fork this project, make your changes and submit a pull request!
3
+ We love receiving pull requests! Anything from new carriers to documentation fixes.
4
4
 
5
- ### Code style
5
+ ## Standards
6
6
 
7
- Please use clean, concise code that follows Ruby community standards. For example:
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
- - Be consistent
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
- ### Pull request guidelines
15
+ ## How to contribute
19
16
 
20
- - Add unit tests, and remote tests to make sure we won't introduce regressions to your code later on.
21
- - Make sure CI passes for all Ruby versions and dependency versions we support.
22
- - XML handling: use `Nokogiri.XML` for parsing XML, and `Nokogiri::XML::Builder` to generate it.
23
- - JSON: use the JSON module that is included in Rubys standard ibrary
24
- - HTTP: use `ActiveUtils`'s `PostsData`.
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) 2008 James MacAulay
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][]. Development is being done by the Shopify integrations team (<integrations-team@shopify.com>). Discussion is welcome in the [Active Merchant Google Group][discuss].
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 install active_shipping
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
- #### FedEx connection notes
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 :login key passed to ```ActiveShipping::FedEx.new()``` is really the FedEx meter number, not the FedEx login.
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
- ## Running the tests
148
+ ## Contributing
114
149
 
115
- After installing dependencies with `bundle install`, you can run the unit tests with `rake test:unit` and the remote tests with `rake test:remote`. 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, and the format of that file can be seen in the included [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: see `.travis.yml`.
150
+ See [CONTRIBUTING.md](https://github.com/Shopify/active_shipping/blob/master/CONTRIBUTING.md).
116
151
 
117
- ## Development
152
+ We love getting pull requests! Anything from new features to documentation clean up.
118
153
 
119
- Yes, please! Take a look at the tests and the implementation of the Carrier class to see how the basics work. At some point soon there will be a carrier template generator along the lines of the gateway generator included in Active Merchant, but the [Carrier class](https://github.com/Shopify/active_shipping/blob/master/lib/active_shipping/carrier.rb) outlines most of what's necessary. The other main classes that would be good to familiarize yourself with are [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).
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
- For the features that you add, you should have both unit tests and remote tests. It's probably best to start with the remote tests, and then log those requests and responses and use them as the mocks for the unit tests. You can see how this works with the USPS tests right now:
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
- [https://github.com/Shopify/active_shipping/blob/master/test/remote/usps_test.rb](https://github.com/Shopify/active_shipping/blob/master/test/remote/usps_test.rb)
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($stdout)
163
+ ActiveShipping::USPS.logger = Logger.new(STDOUT)
131
164
  ```
132
165
 
133
- (This logging functionality is provided by the [`PostsData` module](https://github.com/Shopify/active_utils/blob/master/lib/active_utils/posts_data.rb) in the `active_utils` dependency.)
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
- After you've pushed your well-tested changes to your github fork, make a pull request, and we'll take it from there! For more information, see [CONTRIBUTING.md](https://github.com/Shopify/active_shipping/blob/master/CONTRIBUTING.md).
173
+ ### How to contribute
140
174
 
141
- ## Legal Mumbo Jumbo
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
 
@@ -1,33 +1,32 @@
1
- lib = File.expand_path('../lib/', __FILE__)
1
+ lib = File.expand_path("../lib/", __FILE__)
2
2
  $:.unshift(lib) unless $:.include?(lib)
3
3
 
4
- require 'active_shipping/version'
4
+ require "active_shipping/version"
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = "active_shipping"
8
- s.version = ActiveShipping::VERSION
9
- s.platform = Gem::Platform::RUBY
10
- s.authors = ["James MacAulay", "Tobi Lutke", "Cody Fauser", "Jimmy Baker"]
11
- s.email = ["james@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'
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('quantified', '~> 1.0.1')
18
- s.add_dependency('activesupport', '>= 3.2', '< 5.1.0')
19
- s.add_dependency('active_utils', '~> 3.2.0')
20
- s.add_dependency('nokogiri', '>= 1.6')
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('minitest')
23
- s.add_development_dependency('rake')
24
- s.add_development_dependency('mocha', '~> 1')
25
- s.add_development_dependency('timecop')
26
- s.add_development_dependency('business_time')
27
- s.add_development_dependency('pry')
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
@@ -1,5 +1,6 @@
1
1
  source "https://rubygems.org"
2
- gemspec
2
+
3
+ gemspec path: '..'
3
4
 
4
5
  gem 'activesupport', '~> 3.2.0'
5
6
  gem 'tzinfo'
@@ -1,4 +1,5 @@
1
1
  source "https://rubygems.org"
2
- gemspec
2
+
3
+ gemspec path: '..'
3
4
 
4
5
  gem 'activesupport', '~> 4.0.0'
@@ -1,4 +1,5 @@
1
1
  source "https://rubygems.org"
2
- gemspec
2
+
3
+ gemspec path: '..'
3
4
 
4
5
  gem 'activesupport', '~> 4.1.0'
@@ -1,4 +1,5 @@
1
1
  source "https://rubygems.org"
2
- gemspec
2
+
3
+ gemspec path: '..'
3
4
 
4
5
  gem 'activesupport', '~> 4.2.0'
@@ -1,5 +1,6 @@
1
1
  source "https://rubygems.org"
2
- gemspec
2
+
3
+ gemspec path: '..'
3
4
 
4
5
  gem 'activesupport', '~> 5.0.0'
5
6
  gem 'active_utils', '~> 3.2.2'
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec path: '..'
4
+
5
+ gem 'activesupport', github: 'rails/rails'
@@ -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 the base class for all supported carriers.
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 orgin and destination both as
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
- when 12, 13, 16
573
- endpoint + "vis/track/pin/%s/detail" % pin
574
- when 15
575
- endpoint + "vis/track/dnc/%s/detail" % pin
576
- else
577
- raise InvalidPinFormatError
578
- end
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)