Skip to content
This repository has been archived by the owner on Jun 13, 2018. It is now read-only.

Commit

Permalink
Clean up documentation and metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcphillips committed Dec 5, 2016
1 parent 0f6a6bf commit 5c59e35
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 113 deletions.
52 changes: 14 additions & 38 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,45 +1,21 @@
# Contributing to ActiveShipping

We welcome fixes and additions to this project. Fork this project, make your changes and submit a pull request!
We love receiving pull requests! Anything from new carriers to documentation fixes.

### Code style
## Standards

Please use clean, concise code that follows Ruby community standards. For example:
* PR should explain what the feature does, and why the change exists.
* PR should include any carrier specific documentation explaining how it works.
* Code _must_ be tested, including both unit and remote tests where applicable.
* Be consistent. Write clean code that follows Ruby community standards.
* Code should be generic and reusable.

- Be consistent
- Don't use too much white space
- Use 2 space indent, no tabs.
- No spaces after `(`, `[` and before `]`, `)`
- Nor too little
- Use spaces around operators and after commas, colons and semicolons
- Indent when as deep as case
- Write lucid code in lieu of adding comments
If you're stuck, ask questions!

### Pull request guidelines
## How to contribute

- Add unit tests, and remote tests to make sure we won't introduce regressions to your code later on.
- Make sure CI passes for all Ruby versions and dependency versions we support.
- XML handling: use `Nokogiri.XML` for parsing XML, and `Nokogiri::XML::Builder` to generate it.
- JSON: use the JSON module that is included in Rubys standard ibrary
- HTTP: use `ActiveUtils`'s `PostsData`.
- Do not add new gem dependencies.

### Contributors

- James MacAulay (<http://jmacaulay.net>)
- Tobias Luetke (<http://blog.leetsoft.com>)
- Cody Fauser (<http://codyfauser.com>)
- Jimmy Baker (<http://jimmyville.com/>)
- William Lang (<http://williamlang.net/>)
- Cameron Fowler
- Christopher Saunders (<http://christophersaunders.ca>)
- Denis Odorcic
- Dennis O'Connor
- Dennis Theisen
- Edward Ocampo-Gooding
- Isaac Kearse
- John Duff
- Nigel Ramsay
- Philip Arndt
- Vikram Oberoi
- Willem van Bergen
1. Fork it ( https://github.com/Shopify/active_shipping/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
4 changes: 2 additions & 2 deletions MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2008 James MacAulay
Copyright (c) 2016 Shopify

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand All @@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73 changes: 49 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ This library interfaces with the web services of various shipping carriers. The
- Tracking shipments
- Purchasing shipping labels

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].
Active Shipping is currently being used and improved in a production environment for [Shopify](http://shopify.com).

[Shopify]:http://www.shopify.com
[discuss]:http://groups.google.com/group/activemerchant

## Supported Shipping Carriers

Expand All @@ -27,11 +25,18 @@ Active Shipping is currently being used and improved in a production environment

## Installation

Using bundler, add to the `Gemfile`:

```ruby
gem install active_shipping
gem 'active_shipping'
```

Or stand alone:

```
$ gem install active_shipping
```

...or add it to your project's [Gemfile](http://bundler.io/).

## Sample Usage

Expand Down Expand Up @@ -104,40 +109,60 @@ end
# Delivered at Knoxville, TN on Fri Oct 24 16:45:00 UTC 2008. Signed for by: T.BAKER
```

#### FedEx connection notes
## Carrier specific notes

The :login key passed to ```ActiveShipping::FedEx.new()``` is really the FedEx meter number, not the FedEx login.
### FedEx connection

When developing with test credentials, be sure to pass ```test: true``` to ```ActiveShipping::FedEx.new()``` .
The `:login` key passed to `ActiveShipping::FedEx.new()` is really the FedEx meter number, not the FedEx login.

## Running the tests
When developing with test credentials, be sure to pass `test: true` to `ActiveShipping::FedEx.new()`.

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`.

## Development
## Tests

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).
You can run the unit tests with:

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:
```
bundle exec rake test:unit
```

and the remote tests with:

[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)
[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)
[https://github.com/Shopify/active_shipping/tree/master/test/fixtures/xml/usps](https://github.com/Shopify/active_shipping/tree/master/test/fixtures/xml/usps)
```
bundle exec 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`](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.


## Contributing

We love getting pull requests! Anything from new features to documentation clean up. See [CONTRIBUTING.md](https://github.com/Shopify/active_shipping/blob/master/CONTRIBUTING.md).

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).

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).

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.

To log requests and responses, just set the `logger` on your Carrier class to some kind of `Logger` object:

```ruby
ActiveShipping::USPS.logger = Logger.new($stdout)
ActiveShipping::USPS.logger = Logger.new(STDOUT)
```

(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.)
### Anatomy of a pull request

Any new features or carriers should have passing unit _and_ remote tests. Look at some existing carriers as examples.

When opening a pull request, include description of the feature, why it exists, and any supporting documentation to explain interaction with carriers.

To debug API requests and your code, you can run `rake console` to start a Pry session with `ActiveShipping` included
and instances of the various carriers set up with your test credentials.
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.

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).
### How to contribute

## Legal Mumbo Jumbo
1. Fork it ( https://github.com/Shopify/active_shipping/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

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.
51 changes: 25 additions & 26 deletions active_shipping.gemspec
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
lib = File.expand_path('../lib/', __FILE__)
lib = File.expand_path("../lib/", __FILE__)
$:.unshift(lib) unless $:.include?(lib)

require 'active_shipping/version'
require "active_shipping/version"

Gem::Specification.new do |s|
s.name = "active_shipping"
s.version = ActiveShipping::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["James MacAulay", "Tobi Lutke", "Cody Fauser", "Jimmy Baker"]
s.email = ["[email protected]"]
s.homepage = "http://github.com/shopify/active_shipping"
s.summary = "Simple shipping abstraction library"
s.description = "Get rates and tracking info from various shipping carriers. Extracted from Shopify."
s.license = 'MIT'
s.name = "active_shipping"
s.version = ActiveShipping::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Shopify"]
s.email = ["[email protected]"]
s.homepage = "http://github.com/shopify/active_shipping"
s.summary = "Simple shipping abstraction library"
s.description = "Get rates and tracking info from various shipping carriers. Extracted from Shopify."
s.license = "MIT"
s.files = `git ls-files`.split($/)
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
s.test_files = s.files.grep(%r{^(test|spec|features)/})
s.require_path = "lib"

s.add_dependency('quantified', '~> 1.0.1')
s.add_dependency('activesupport', '>= 3.2', '< 5.1.0')
s.add_dependency('active_utils', '~> 3.2.0')
s.add_dependency('nokogiri', '>= 1.6')
s.add_dependency("quantified", "~> 1.0.1")
s.add_dependency("activesupport", ">= 3.2", "< 5.1.0")
s.add_dependency("active_utils", "~> 3.2.0")
s.add_dependency("nokogiri", ">= 1.6")

s.add_development_dependency('minitest')
s.add_development_dependency('rake')
s.add_development_dependency('mocha', '~> 1')
s.add_development_dependency('timecop')
s.add_development_dependency('business_time')
s.add_development_dependency('pry')

s.files = `git ls-files`.split($/)
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
s.test_files = s.files.grep(%r{^(test|spec|features)/})
s.require_path = 'lib'
s.add_development_dependency("minitest")
s.add_development_dependency("rake")
s.add_development_dependency("mocha", "~> 1")
s.add_development_dependency("timecop")
s.add_development_dependency("business_time")
s.add_development_dependency("pry")
end
23 changes: 0 additions & 23 deletions lib/active_shipping.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,3 @@
#--
# Copyright (c) 2009 Jaded Pixel
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#++

require 'active_support/all'
require 'active_utils'

Expand Down

0 comments on commit 5c59e35

Please sign in to comment.