trackerific 0.3.5 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.rdoc +37 -13
- data/VERSION +1 -1
- data/doc/OptionsHelper.html +287 -0
- data/doc/Trackerific.html +588 -35
- data/doc/Trackerific/Configuration.html +354 -0
- data/doc/Trackerific/Details.html +1 -1
- data/doc/Trackerific/Error.html +1 -1
- data/doc/Trackerific/Event.html +1 -1
- data/doc/Trackerific/FedEx.html +52 -35
- data/doc/Trackerific/{Base.html → Service.html} +54 -49
- data/doc/Trackerific/UPS.html +48 -31
- data/doc/Trackerific/USPS.html +51 -34
- data/doc/_index.html +35 -4
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +42 -15
- data/doc/index.html +42 -15
- data/doc/method_list.html +83 -19
- data/doc/top-level-namespace.html +2 -2
- data/lib/helpers/options_helper.rb +20 -0
- data/lib/trackerific.rb +52 -18
- data/lib/trackerific/configuration.rb +49 -0
- data/lib/trackerific/service.rb +68 -0
- data/lib/trackerific/services/fedex.rb +18 -16
- data/lib/trackerific/services/ups.rb +16 -14
- data/lib/trackerific/services/usps.rb +17 -15
- data/spec/lib/trackerific/configuration_spec.rb +9 -0
- data/spec/lib/trackerific/details_spec.rb +12 -9
- data/spec/lib/trackerific/error_spec.rb +6 -2
- data/spec/lib/trackerific/event_spec.rb +21 -8
- data/spec/lib/trackerific/service_spec.rb +34 -0
- data/spec/lib/trackerific/services/fedex_spec.rb +23 -9
- data/spec/lib/trackerific/services/ups_spec.rb +23 -8
- data/spec/lib/trackerific/services/usps_spec.rb +22 -8
- data/spec/lib/trackerific_spec.rb +29 -7
- data/spec/spec_helper.rb +1 -0
- data/spec/support/fixtures.rb +16 -10
- data/spec/support/trackerific.rb +2 -2
- data/trackerific.gemspec +13 -8
- metadata +30 -25
- data/lib/trackerific/base.rb +0 -70
- data/spec/lib/trackerific/base_spec.rb +0 -34
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
version: 0.4.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Travis Haynes
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-06-
|
17
|
+
date: 2011-06-15 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -93,52 +93,52 @@ dependencies:
|
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: *id005
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
96
|
+
name: yardstick
|
97
97
|
requirement: &id006 !ruby/object:Gem::Requirement
|
98
98
|
none: false
|
99
99
|
requirements:
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
segments:
|
103
|
-
-
|
104
|
-
-
|
105
|
-
-
|
106
|
-
version:
|
103
|
+
- 0
|
104
|
+
- 4
|
105
|
+
- 0
|
106
|
+
version: 0.4.0
|
107
107
|
type: :development
|
108
108
|
prerelease: false
|
109
109
|
version_requirements: *id006
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
111
|
+
name: rspec-rails
|
112
112
|
requirement: &id007 !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
segments:
|
118
|
+
- 2
|
119
|
+
- 6
|
118
120
|
- 1
|
119
|
-
|
120
|
-
- 0
|
121
|
-
version: 1.1.0
|
121
|
+
version: 2.6.1
|
122
122
|
type: :development
|
123
123
|
prerelease: false
|
124
124
|
version_requirements: *id007
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: rspec_multi_matchers
|
127
127
|
requirement: &id008 !ruby/object:Gem::Requirement
|
128
128
|
none: false
|
129
129
|
requirements:
|
130
130
|
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
segments:
|
133
|
+
- 1
|
134
|
+
- 1
|
133
135
|
- 0
|
134
|
-
|
135
|
-
- 6
|
136
|
-
version: 0.11.6
|
136
|
+
version: 1.1.0
|
137
137
|
type: :development
|
138
138
|
prerelease: false
|
139
139
|
version_requirements: *id008
|
140
140
|
- !ruby/object:Gem::Dependency
|
141
|
-
name:
|
141
|
+
name: ruby-debug19
|
142
142
|
requirement: &id009 !ruby/object:Gem::Requirement
|
143
143
|
none: false
|
144
144
|
requirements:
|
@@ -146,9 +146,9 @@ dependencies:
|
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
segments:
|
148
148
|
- 0
|
149
|
-
-
|
150
|
-
-
|
151
|
-
version: 0.
|
149
|
+
- 11
|
150
|
+
- 6
|
151
|
+
version: 0.11.6
|
152
152
|
type: :development
|
153
153
|
prerelease: false
|
154
154
|
version_requirements: *id009
|
@@ -169,12 +169,14 @@ files:
|
|
169
169
|
- README.rdoc
|
170
170
|
- Rakefile
|
171
171
|
- VERSION
|
172
|
+
- doc/OptionsHelper.html
|
172
173
|
- doc/Trackerific.html
|
173
|
-
- doc/Trackerific/
|
174
|
+
- doc/Trackerific/Configuration.html
|
174
175
|
- doc/Trackerific/Details.html
|
175
176
|
- doc/Trackerific/Error.html
|
176
177
|
- doc/Trackerific/Event.html
|
177
178
|
- doc/Trackerific/FedEx.html
|
179
|
+
- doc/Trackerific/Service.html
|
178
180
|
- doc/Trackerific/UPS.html
|
179
181
|
- doc/Trackerific/USPS.html
|
180
182
|
- doc/_index.html
|
@@ -191,11 +193,13 @@ files:
|
|
191
193
|
- doc/js/jquery.js
|
192
194
|
- doc/method_list.html
|
193
195
|
- doc/top-level-namespace.html
|
196
|
+
- lib/helpers/options_helper.rb
|
194
197
|
- lib/trackerific.rb
|
195
|
-
- lib/trackerific/
|
198
|
+
- lib/trackerific/configuration.rb
|
196
199
|
- lib/trackerific/details.rb
|
197
200
|
- lib/trackerific/error.rb
|
198
201
|
- lib/trackerific/event.rb
|
202
|
+
- lib/trackerific/service.rb
|
199
203
|
- lib/trackerific/services/fedex.rb
|
200
204
|
- lib/trackerific/services/ups.rb
|
201
205
|
- lib/trackerific/services/usps.rb
|
@@ -205,10 +209,11 @@ files:
|
|
205
209
|
- spec/fixtures/ups_success_response.xml
|
206
210
|
- spec/fixtures/usps_error_response.xml
|
207
211
|
- spec/fixtures/usps_success_response.xml
|
208
|
-
- spec/lib/trackerific/
|
212
|
+
- spec/lib/trackerific/configuration_spec.rb
|
209
213
|
- spec/lib/trackerific/details_spec.rb
|
210
214
|
- spec/lib/trackerific/error_spec.rb
|
211
215
|
- spec/lib/trackerific/event_spec.rb
|
216
|
+
- spec/lib/trackerific/service_spec.rb
|
212
217
|
- spec/lib/trackerific/services/fedex_spec.rb
|
213
218
|
- spec/lib/trackerific/services/ups_spec.rb
|
214
219
|
- spec/lib/trackerific/services/usps_spec.rb
|
@@ -231,7 +236,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
231
236
|
requirements:
|
232
237
|
- - ">="
|
233
238
|
- !ruby/object:Gem::Version
|
234
|
-
hash: -
|
239
|
+
hash: -318977101
|
235
240
|
segments:
|
236
241
|
- 0
|
237
242
|
version: "0"
|
data/lib/trackerific/base.rb
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
module Trackerific
|
2
|
-
# Base class for Trackerific package tracking services.
|
3
|
-
class Base
|
4
|
-
# Creates a new instance of Trackerific::Base with required options
|
5
|
-
# @api private
|
6
|
-
def initialize(options = {})
|
7
|
-
required = self.class.required_options
|
8
|
-
# make sure all the required options exist
|
9
|
-
required.each do |k|
|
10
|
-
raise ArgumentError.new("Missing required parameter: #{k}") unless options.has_key?(k)
|
11
|
-
end
|
12
|
-
# make sure no invalid options exist
|
13
|
-
options.each do |k, v|
|
14
|
-
raise ArgumentError.new("Invalid parameter: #{k}") unless required.include?(k)
|
15
|
-
end
|
16
|
-
@options = options
|
17
|
-
end
|
18
|
-
|
19
|
-
# Gets the tracking information for the package from the server
|
20
|
-
# @param [String] package_id the package identifier
|
21
|
-
# @return [Trackerific::Details] the tracking details
|
22
|
-
# @example Override this method in your custom tracking service to implement tracking
|
23
|
-
# module Trackerific
|
24
|
-
# class MyTrackingService < Base
|
25
|
-
# def track_package
|
26
|
-
# # your tracking code here
|
27
|
-
# Trackerific::Details.new(
|
28
|
-
# "summary of tracking events",
|
29
|
-
# [Trackerific::Event.new(Time.now, "summary", "location")]
|
30
|
-
# )
|
31
|
-
# end
|
32
|
-
# end
|
33
|
-
# end
|
34
|
-
# @api semipublic
|
35
|
-
def track_package(package_id)
|
36
|
-
@package_id = package_id
|
37
|
-
end
|
38
|
-
|
39
|
-
# An Array of Regexp that matches valid package identifiers for your service
|
40
|
-
# @example Override this method in your custom tracking service
|
41
|
-
# module Trackerific
|
42
|
-
# class MyTrackingService < Base
|
43
|
-
# def self.package_id_matchers
|
44
|
-
# [ /^.Z/, /^[HK].{10}$/ ] # matchers for UPS package identifiers
|
45
|
-
# end
|
46
|
-
# end
|
47
|
-
# end
|
48
|
-
# @return [Array, Regexp] an array of regular expressions
|
49
|
-
# @api semipublic
|
50
|
-
def self.package_id_matchers
|
51
|
-
nil
|
52
|
-
end
|
53
|
-
|
54
|
-
# An array of options that are required to create a new instance of this class
|
55
|
-
# @return [Array] the required options
|
56
|
-
# @example Override this method in your custom tracking service to enforce some options
|
57
|
-
# module Trackerific
|
58
|
-
# class MyTrackingService < Base
|
59
|
-
# def self.required_options
|
60
|
-
# [:all, :these, :are, :required]
|
61
|
-
# end
|
62
|
-
# end
|
63
|
-
# end
|
64
|
-
# @api semipublic
|
65
|
-
def self.required_options
|
66
|
-
[]
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
class TestBaseClass < Trackerific::Base
|
4
|
-
def self.required_options
|
5
|
-
[:required, :also_required]
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe 'Trackerific::Base' do
|
10
|
-
|
11
|
-
before(:all) do
|
12
|
-
@base = Trackerific::Base.new
|
13
|
-
end
|
14
|
-
|
15
|
-
context "with a new Trackerific::Base class that has required options" do
|
16
|
-
context "has all the required options" do
|
17
|
-
it "should be able to create a new instance" do
|
18
|
-
t = TestBaseClass.new(:required => true, :also_required => :yup)
|
19
|
-
t.should be_a TestBaseClass
|
20
|
-
end
|
21
|
-
end
|
22
|
-
context "is missing some required options" do
|
23
|
-
it "should raise an ArgumentError" do
|
24
|
-
lambda { TestBaseClass.new() }.should raise_error(ArgumentError)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
context "has an invalid option" do
|
28
|
-
it "should raise an ArgumentError" do
|
29
|
-
lambda { TestBaseClass.new(:unknown => :argument ) }.should raise_error(ArgumentError)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|