allpurpose 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in allpurpose.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Craig Sullivan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,48 @@
1
+ # Allpurpose
2
+
3
+ Ruby client for the [All Purpose Removals and Storage](www.allpurposeremovals.com.au) freight API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```
10
+ gem 'allpurpose'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```
16
+ $ bundle
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```
22
+ $ gem install allpurpose
23
+ ```
24
+
25
+ ## Usage
26
+
27
+ Obtaining a quote from All Purpose, you will need to pass in the destination suburb name, destination post code and volume of your items that you want shipped.
28
+
29
+ All Purpose API assumes that your items will be picked up from the Brisbane Metro area only so there is no need to define pickup destination.
30
+
31
+ Here is an example of getting a quote from All Purpose ...
32
+
33
+ ```
34
+ suburb = 'Brisbane Market'
35
+ post_code = 4106 # post code for Brisbane Market
36
+ volume = 1.58
37
+
38
+ ap = Allpurpose::Quote.quote(suburb, post_code_, volume)
39
+ puts ap.amount
40
+ ```
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create new Pull Request
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.pattern = "spec/**/*_spec.rb"
7
+ t.verbose = true
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/allpurpose/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Craig Sullivan"]
6
+ gem.email = ["craig@melbourne-systems.com"]
7
+ gem.description = %q{Get a freight cost estimate from AllPurpose Removals and Storage}
8
+ gem.summary = %q{This gem queries the AllPupose Removals and Storage web service to get a freight quote for shipping items. AllPurpose assumes shipping from Brisbane Metro area only.}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "allpurpose"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Allpurpose::VERSION
17
+
18
+ gem.add_development_dependency 'minitest'
19
+ gem.add_development_dependency 'turn'
20
+ gem.add_development_dependency 'rake'
21
+
22
+ gem.add_dependency 'httparty'
23
+
24
+ end
@@ -0,0 +1,5 @@
1
+ require "allpurpose/version"
2
+
3
+ module Allpurpose
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,40 @@
1
+ require "httparty"
2
+ require 'open-uri'
3
+
4
+ module Allpurpose
5
+
6
+ class Quote
7
+
8
+ include HTTParty
9
+ format :json
10
+ base_uri "https://www.allpurposeremovals.com.au/api/quote/json"
11
+
12
+ attr_accessor :suburb, :post_code, :volume, :amount
13
+
14
+ def initialize(suburb, post_code, volume, amount=0)
15
+ self.suburb = suburb
16
+ self.post_code = post_code
17
+ self.volume = volume
18
+ self.amount = amount
19
+ end
20
+
21
+ def self.quote(suburb, post_code, volume)
22
+
23
+ response = get("/#{URI::encode(suburb)}/#{post_code}/#{volume}")
24
+
25
+ if response.success?
26
+ if response.parsed_response.nil?
27
+ nil
28
+ else
29
+ resp = response.parsed_response["ShippingQuote"]
30
+ self.new(resp["Suburb"], resp["Postcode"].to_i, volume, resp["Quote"].to_f)
31
+ end
32
+ else
33
+ raise response.response
34
+ end
35
+
36
+ end
37
+
38
+ end
39
+
40
+ end
@@ -0,0 +1,3 @@
1
+ module Allpurpose
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,31 @@
1
+ require 'turn/autorun'
2
+
3
+ require_relative "../../lib/allpurpose/quote"
4
+
5
+ describe "AllPurpose Quote" do
6
+
7
+ describe "when a suburb exists" do
8
+ it "is must equal 75" do
9
+
10
+ suburb = 'Brisbane Market'
11
+ post_code = 4106
12
+ volume = 1.58
13
+
14
+ q = Allpurpose::Quote.quote(suburb, post_code, volume)
15
+
16
+ q.amount.must_equal 75.00
17
+ q.amount.must_be_kind_of Float
18
+ q.suburb.must_equal suburb.upcase
19
+ q.post_code.must_equal post_code
20
+
21
+ end
22
+ end
23
+
24
+ describe "when volume is zero" do
25
+ it "is must be nil" do
26
+ q = Allpurpose::Quote.quote('Brisbane Market', 4106, 0)
27
+ q.must_be_nil
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,6 @@
1
+ require 'minitest/autorun'
2
+ require 'turn/autorun'
3
+
4
+ Turn.config do |c|
5
+ c.format = :outline
6
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: allpurpose
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Craig Sullivan
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-31 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: turn
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rake
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: httparty
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Get a freight cost estimate from AllPurpose Removals and Storage
79
+ email:
80
+ - craig@melbourne-systems.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - !binary |-
86
+ LmdpdGlnbm9yZQ==
87
+ - !binary |-
88
+ R2VtZmlsZQ==
89
+ - !binary |-
90
+ TElDRU5TRQ==
91
+ - !binary |-
92
+ UkVBRE1FLm1k
93
+ - !binary |-
94
+ UmFrZWZpbGU=
95
+ - !binary |-
96
+ YWxscHVycG9zZS5nZW1zcGVj
97
+ - !binary |-
98
+ bGliL2FsbHB1cnBvc2UucmI=
99
+ - !binary |-
100
+ bGliL2FsbHB1cnBvc2UvcXVvdGUucmI=
101
+ - !binary |-
102
+ bGliL2FsbHB1cnBvc2UvdmVyc2lvbi5yYg==
103
+ - !binary |-
104
+ c3BlYy9hbGxwdXJwb3NlL3F1b3RlX3NwZWMucmI=
105
+ - !binary |-
106
+ c3BlYy9zcGVjX2hlbHBlci5yYg==
107
+ homepage: ''
108
+ licenses: []
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 1.8.24
128
+ signing_key:
129
+ specification_version: 3
130
+ summary: This gem queries the AllPupose Removals and Storage web service to get a
131
+ freight quote for shipping items. AllPurpose assumes shipping from Brisbane Metro
132
+ area only.
133
+ test_files:
134
+ - !binary |-
135
+ c3BlYy9hbGxwdXJwb3NlL3F1b3RlX3NwZWMucmI=
136
+ - !binary |-
137
+ c3BlYy9zcGVjX2hlbHBlci5yYg==