trackerific 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -44
- data/VERSION +1 -1
- data/examples/custom_service_spec.rb +44 -0
- data/lib/trackerific/configuration.rb +2 -1
- data/lib/trackerific/services/usps.rb +1 -1
- data/trackerific.gemspec +2 -1
- metadata +4 -3
data/README.rdoc
CHANGED
@@ -125,50 +125,7 @@ or for a Rails application:
|
|
125
125
|
|
126
126
|
== Writing a Custom Service
|
127
127
|
|
128
|
-
|
129
|
-
|
130
|
-
describe Trackerific::CustomService do
|
131
|
-
specify("it should descend from Trackerific::Service") {
|
132
|
-
Trackerific::CustomService.superclass.should be Trackerific::Service
|
133
|
-
}
|
134
|
-
describe :track_package do
|
135
|
-
before do
|
136
|
-
@valid_package_id = 'valid package id'
|
137
|
-
@invalid_package_id = 'invalid package id'
|
138
|
-
@service = Trackerific::CustomService.new :required => 'option'
|
139
|
-
end
|
140
|
-
context "with a successful response from the server" do
|
141
|
-
before(:each) do
|
142
|
-
@tracking = @service.track_package(@valid_package_id)
|
143
|
-
end
|
144
|
-
subject { @tracking }
|
145
|
-
it("should return a Trackerific::Details") { should be_a Trackerific::Details }
|
146
|
-
describe :summary do
|
147
|
-
subject { @tracking.summary }
|
148
|
-
it { should_not be_empty }
|
149
|
-
end
|
150
|
-
end
|
151
|
-
context "with an error response from the server" do
|
152
|
-
specify { lambda { @service.track_package(@invalid_package_id) }.should raise_error(Trackerific::Error) }
|
153
|
-
end
|
154
|
-
end
|
155
|
-
describe :required_options do
|
156
|
-
subject { Trackerific::CustomService.required_options }
|
157
|
-
it { should include(:required) }
|
158
|
-
end
|
159
|
-
describe :valid_options do
|
160
|
-
it "should include required_options" do
|
161
|
-
valid = Trackerific::CustomService.valid_options
|
162
|
-
Trackerific::CustomService.required_options.each do |opt|
|
163
|
-
valid.should include opt
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
describe :package_id_matchers do
|
168
|
-
subject { Trackerific::CustomService.package_id_matchers }
|
169
|
-
it("should be an Array of Regexp") { should each { |m| m.should be_a Regexp } }
|
170
|
-
end
|
171
|
-
end
|
128
|
+
See the examples folder for an example of a custom service.
|
172
129
|
|
173
130
|
=== Testing with Trackerific
|
174
131
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.1
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Trackerific::CustomService do
|
4
|
+
specify("it should descend from Trackerific::Service") {
|
5
|
+
Trackerific::CustomService.superclass.should be Trackerific::Service
|
6
|
+
}
|
7
|
+
describe :track_package do
|
8
|
+
before do
|
9
|
+
@valid_package_id = 'valid package id'
|
10
|
+
@invalid_package_id = 'invalid package id'
|
11
|
+
@service = Trackerific::CustomService.new :required => 'option'
|
12
|
+
end
|
13
|
+
context "with a successful response from the server" do
|
14
|
+
before(:each) do
|
15
|
+
@tracking = @service.track_package(@valid_package_id)
|
16
|
+
end
|
17
|
+
subject { @tracking }
|
18
|
+
it("should return a Trackerific::Details") { should be_a Trackerific::Details }
|
19
|
+
describe :summary do
|
20
|
+
subject { @tracking.summary }
|
21
|
+
it { should_not be_empty }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
context "with an error response from the server" do
|
25
|
+
specify { lambda { @service.track_package(@invalid_package_id) }.should raise_error(Trackerific::Error) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
describe :required_options do
|
29
|
+
subject { Trackerific::CustomService.required_options }
|
30
|
+
it { should include(:required) }
|
31
|
+
end
|
32
|
+
describe :valid_options do
|
33
|
+
it "should include required_options" do
|
34
|
+
valid = Trackerific::CustomService.valid_options
|
35
|
+
Trackerific::CustomService.required_options.each do |opt|
|
36
|
+
valid.should include opt
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
describe :package_id_matchers do
|
41
|
+
subject { Trackerific::CustomService.package_id_matchers }
|
42
|
+
it("should be an Array of Regexp") { should each { |m| m.should be_a Regexp } }
|
43
|
+
end
|
44
|
+
end
|
@@ -19,7 +19,8 @@ module Trackerific
|
|
19
19
|
# Only accept Hashes
|
20
20
|
raise ArgumentError unless args[0].class == Hash
|
21
21
|
# Validate configuration values against the required parameters for that service
|
22
|
-
|
22
|
+
service = Trackerific.service_get(sym)
|
23
|
+
validate_options args[0], service.required_parameters, service.valid_options
|
23
24
|
# Store the configuration options
|
24
25
|
@options[sym] = args[0]
|
25
26
|
end
|
@@ -104,7 +104,7 @@ module Trackerific
|
|
104
104
|
)
|
105
105
|
end
|
106
106
|
|
107
|
-
# Gets the city/state of a zipcode
|
107
|
+
# Gets the city/state of a zipcode - requires access to USPS address APIs
|
108
108
|
# @param [String] zipcode The zipcode to find the city/state for
|
109
109
|
# @return [Hash] { zip: 'the zipcode, 'city: "the city", state: "the state" }
|
110
110
|
# @example Lookup zipcode for Beverly Hills, CA
|
data/trackerific.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{trackerific}
|
8
|
-
s.version = "0.6.
|
8
|
+
s.version = "0.6.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Travis Haynes"]
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"Rakefile",
|
26
26
|
"VERSION",
|
27
27
|
"changelog",
|
28
|
+
"examples/custom_service_spec.rb",
|
28
29
|
"lib/helpers/options_helper.rb",
|
29
30
|
"lib/trackerific.rb",
|
30
31
|
"lib/trackerific/configuration.rb",
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 1
|
9
|
+
version: 0.6.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Travis Haynes
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- Rakefile
|
171
171
|
- VERSION
|
172
172
|
- changelog
|
173
|
+
- examples/custom_service_spec.rb
|
173
174
|
- lib/helpers/options_helper.rb
|
174
175
|
- lib/trackerific.rb
|
175
176
|
- lib/trackerific/configuration.rb
|
@@ -217,7 +218,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
217
218
|
requirements:
|
218
219
|
- - ">="
|
219
220
|
- !ruby/object:Gem::Version
|
220
|
-
hash: -
|
221
|
+
hash: -56606041559702296
|
221
222
|
segments:
|
222
223
|
- 0
|
223
224
|
version: "0"
|