trackerific 0.3.5 → 0.4.0

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.
Files changed (42) hide show
  1. data/Gemfile +1 -1
  2. data/README.rdoc +37 -13
  3. data/VERSION +1 -1
  4. data/doc/OptionsHelper.html +287 -0
  5. data/doc/Trackerific.html +588 -35
  6. data/doc/Trackerific/Configuration.html +354 -0
  7. data/doc/Trackerific/Details.html +1 -1
  8. data/doc/Trackerific/Error.html +1 -1
  9. data/doc/Trackerific/Event.html +1 -1
  10. data/doc/Trackerific/FedEx.html +52 -35
  11. data/doc/Trackerific/{Base.html → Service.html} +54 -49
  12. data/doc/Trackerific/UPS.html +48 -31
  13. data/doc/Trackerific/USPS.html +51 -34
  14. data/doc/_index.html +35 -4
  15. data/doc/class_list.html +1 -1
  16. data/doc/file.README.html +42 -15
  17. data/doc/index.html +42 -15
  18. data/doc/method_list.html +83 -19
  19. data/doc/top-level-namespace.html +2 -2
  20. data/lib/helpers/options_helper.rb +20 -0
  21. data/lib/trackerific.rb +52 -18
  22. data/lib/trackerific/configuration.rb +49 -0
  23. data/lib/trackerific/service.rb +68 -0
  24. data/lib/trackerific/services/fedex.rb +18 -16
  25. data/lib/trackerific/services/ups.rb +16 -14
  26. data/lib/trackerific/services/usps.rb +17 -15
  27. data/spec/lib/trackerific/configuration_spec.rb +9 -0
  28. data/spec/lib/trackerific/details_spec.rb +12 -9
  29. data/spec/lib/trackerific/error_spec.rb +6 -2
  30. data/spec/lib/trackerific/event_spec.rb +21 -8
  31. data/spec/lib/trackerific/service_spec.rb +34 -0
  32. data/spec/lib/trackerific/services/fedex_spec.rb +23 -9
  33. data/spec/lib/trackerific/services/ups_spec.rb +23 -8
  34. data/spec/lib/trackerific/services/usps_spec.rb +22 -8
  35. data/spec/lib/trackerific_spec.rb +29 -7
  36. data/spec/spec_helper.rb +1 -0
  37. data/spec/support/fixtures.rb +16 -10
  38. data/spec/support/trackerific.rb +2 -2
  39. data/trackerific.gemspec +13 -8
  40. metadata +30 -25
  41. data/lib/trackerific/base.rb +0 -70
  42. data/spec/lib/trackerific/base_spec.rb +0 -34
@@ -0,0 +1,354 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Class: Trackerific::Configuration
8
+
9
+ &mdash; Documentation by YARD 0.7.1
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ relpath = '..';
19
+ if (relpath != '') relpath += '/';
20
+ </script>
21
+
22
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
25
+
26
+
27
+ </head>
28
+ <body>
29
+ <script type="text/javascript" charset="utf-8">
30
+ if (window.top.frames.main) document.body.className = 'frames';
31
+ </script>
32
+
33
+ <div id="header">
34
+ <div id="menu">
35
+
36
+ <a href="../_index.html">Index (C)</a> &raquo;
37
+ <span class='title'><span class='object_link'><a href="../Trackerific.html" title="Trackerific (module)">Trackerific</a></span></span>
38
+ &raquo;
39
+ <span class="title">Configuration</span>
40
+
41
+
42
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
43
+ </div>
44
+
45
+ <div id="search">
46
+
47
+ <a id="class_list_link" href="#">Class List</a>
48
+
49
+ <a id="method_list_link" href="#">Method List</a>
50
+
51
+ <a id="file_list_link" href="#">File List</a>
52
+
53
+ </div>
54
+ <div class="clear"></div>
55
+ </div>
56
+
57
+ <iframe id="search_frame"></iframe>
58
+
59
+ <div id="content"><h1>Class: Trackerific::Configuration
60
+
61
+
62
+
63
+ </h1>
64
+
65
+ <dl class="box">
66
+
67
+ <dt class="r1">Inherits:</dt>
68
+ <dd class="r1">
69
+ <span class="inheritName">Object</span>
70
+
71
+ <ul class="fullTree">
72
+ <li>Object</li>
73
+
74
+ <li class="next">Trackerific::Configuration</li>
75
+
76
+ </ul>
77
+ <a href="#" class="inheritanceTree">show all</a>
78
+
79
+ </dd>
80
+
81
+
82
+
83
+
84
+
85
+
86
+ <dt class="r2">Includes:</dt>
87
+ <dd class="r2"><span class='object_link'><a href="../OptionsHelper.html" title="OptionsHelper (module)">OptionsHelper</a></span></dd>
88
+
89
+
90
+
91
+
92
+
93
+ <dt class="r1 last">Defined in:</dt>
94
+ <dd class="r1 last">lib/trackerific/configuration.rb</dd>
95
+
96
+ </dl>
97
+ <div class="clear"></div>
98
+
99
+ <h2>Overview</h2><div class="docstring">
100
+ <div class="discussion">
101
+ <p>
102
+ Provides a dynamic configuration
103
+ </p>
104
+
105
+
106
+ </div>
107
+ </div>
108
+ <div class="tags">
109
+
110
+ </div>
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+ <h2>
124
+ Instance Method Summary
125
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
126
+ </h2>
127
+
128
+ <ul class="summary">
129
+
130
+ <li class="public ">
131
+ <span class="summary_signature">
132
+
133
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Configuration) <strong>initialize</strong> </a>
134
+
135
+
136
+
137
+ </span>
138
+
139
+ <span class="note title constructor">constructor</span>
140
+
141
+
142
+
143
+
144
+
145
+ <span class="private note title">Private</span>
146
+
147
+
148
+ <span class="summary_desc"><div class='inline'><p>
149
+ Creates a new instance of Trackerific::Configuration.
150
+ </p>
151
+ </div></span>
152
+
153
+ </li>
154
+
155
+
156
+ <li class="public ">
157
+ <span class="summary_signature">
158
+
159
+ <a href="#method_missing-instance_method" title="#method_missing (instance method)">- (Hash) <strong>method_missing</strong>(sym, *args, &amp;block) </a>
160
+
161
+
162
+
163
+ </span>
164
+
165
+
166
+
167
+
168
+
169
+ <span class="private note title">Private</span>
170
+
171
+
172
+ <span class="summary_desc"><div class='inline'><p>
173
+ Overriding the method_missing method allows dynamic methods.
174
+ </p>
175
+ </div></span>
176
+
177
+ </li>
178
+
179
+
180
+ </ul>
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="../OptionsHelper.html" title="OptionsHelper (module)">OptionsHelper</a></span></h3>
192
+ <p class="inherited"><span class='object_link'><a href="../OptionsHelper.html#validate_options-instance_method" title="OptionsHelper#validate_options (method)">#validate_options</a></span></p>
193
+ <div id="constructor_details" class="method_details_list">
194
+ <h2>Constructor Details</h2>
195
+
196
+ <div class="method_details first">
197
+ <p class="signature first" id="initialize-instance_method">
198
+
199
+ - (<tt><span class='object_link'><a href="" title="Trackerific::Configuration (class)">Configuration</a></span></tt>) <strong>initialize</strong>
200
+
201
+
202
+
203
+ </p><div class="docstring">
204
+ <div class="discussion">
205
+ <p class="note private">
206
+ <strong>This method is part of a private API.</strong>
207
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
208
+ </p>
209
+ <p>
210
+ Creates a new instance of Trackerific::Configuration
211
+ </p>
212
+
213
+
214
+ </div>
215
+ </div>
216
+ <div class="tags">
217
+
218
+ </div><table class="source_code">
219
+ <tr>
220
+ <td>
221
+ <pre class="lines">
222
+
223
+
224
+ 7
225
+ 8
226
+ 9</pre>
227
+ </td>
228
+ <td>
229
+ <pre class="code"><span class="info file"># File 'lib/trackerific/configuration.rb', line 7</span>
230
+
231
+ <span class='kw'>def</span> <span class='id initialize'>initialize</span>
232
+ <span class='ivar'>@options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
233
+ <span class='kw'>end</span></pre>
234
+ </td>
235
+ </tr>
236
+ </table>
237
+ </div>
238
+
239
+ </div>
240
+ <div id="method_missing_details" class="method_details_list">
241
+ <h2>Dynamic Method Handling</h2>
242
+ <p class="notice this">
243
+ This class handles dynamic methods through the <tt>method_missing</tt> method
244
+
245
+ </p>
246
+
247
+ <div class="method_details first">
248
+ <p class="signature first" id="method_missing-instance_method">
249
+
250
+ - (<tt>Hash</tt>) <strong>method_missing</strong>(sym, *args, &amp;block)
251
+
252
+
253
+
254
+ </p><div class="docstring">
255
+ <div class="discussion">
256
+ <p class="note private">
257
+ <strong>This method is part of a private API.</strong>
258
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
259
+ </p>
260
+ <p>
261
+ Overriding the method_missing method allows dynamic methods
262
+ </p>
263
+
264
+
265
+ </div>
266
+ </div>
267
+ <div class="tags">
268
+ <h3>Returns:</h3>
269
+ <ul class="return">
270
+
271
+ <li>
272
+
273
+
274
+ <span class='type'>(<tt>Hash</tt>)</span>
275
+
276
+
277
+
278
+ </li>
279
+
280
+ </ul>
281
+ <h3>Raises:</h3>
282
+ <ul class="raise">
283
+
284
+ <li>
285
+
286
+
287
+ <span class='type'>(<tt>NoMethodError</tt>)</span>
288
+
289
+
290
+
291
+ </li>
292
+
293
+ </ul>
294
+
295
+ </div><table class="source_code">
296
+ <tr>
297
+ <td>
298
+ <pre class="lines">
299
+
300
+
301
+ 13
302
+ 14
303
+ 15
304
+ 16
305
+ 17
306
+ 18
307
+ 19
308
+ 20
309
+ 21
310
+ 22
311
+ 23
312
+ 24
313
+ 25
314
+ 26
315
+ 27
316
+ 28</pre>
317
+ </td>
318
+ <td>
319
+ <pre class="code"><span class="info file"># File 'lib/trackerific/configuration.rb', line 13</span>
320
+
321
+ <span class='kw'>def</span> <span class='id method_missing'>method_missing</span><span class='lparen'>(</span><span class='id sym'>sym</span><span class='comma'>,</span> <span class='op'>*</span><span class='id args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id block'>block</span><span class='rparen'>)</span>
322
+ <span class='comment'># Get a list of all the services (convert symbols to lower case)
323
+ </span> <span class='id services'>services</span> <span class='op'>=</span> <span class='const'>Trackerific</span><span class='period'>.</span><span class='id services'>services</span><span class='period'>.</span><span class='id map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id service'>service</span><span class='op'>|</span> <span class='id service'>service</span><span class='period'>.</span><span class='id to_s'>to_s</span><span class='period'>.</span><span class='id downcase'>downcase</span><span class='period'>.</span><span class='id to_sym'>to_sym</span> <span class='rbrace'>}</span>
324
+ <span class='comment'># Do not accept any configuration values for anything except services
325
+ </span> <span class='id raise'>raise</span> <span class='const'>NoMethodError</span> <span class='kw'>unless</span> <span class='id services'>services</span><span class='period'>.</span><span class='id include?'>include?</span> <span class='id sym'>sym</span>
326
+ <span class='comment'># Only accept Hashes
327
+ </span> <span class='kw'>unless</span> <span class='id args'>args</span><span class='period'>.</span><span class='id empty?'>empty?</span>
328
+ <span class='id raise'>raise</span> <span class='const'>ArgumentError</span> <span class='kw'>unless</span> <span class='id args'>args</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id class'>class</span> <span class='op'>==</span> <span class='const'>Hash</span>
329
+ <span class='comment'># Validate configuration values against the required options for that service
330
+ </span> <span class='id validate_options'>validate_options</span> <span class='id args'>args</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='const'>Trackerific</span><span class='period'>.</span><span class='id service_get'>service_get</span><span class='lparen'>(</span><span class='id sym'>sym</span><span class='rparen'>)</span><span class='period'>.</span><span class='id required_options'>required_options</span>
331
+ <span class='comment'># Store the configuration options
332
+ </span> <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='id sym'>sym</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id args'>args</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span>
333
+ <span class='kw'>end</span>
334
+ <span class='comment'># return the configuration options
335
+ </span> <span class='ivar'>@options</span><span class='lbracket'>[</span><span class='id sym'>sym</span><span class='rbracket'>]</span>
336
+ <span class='kw'>end</span></pre>
337
+ </td>
338
+ </tr>
339
+ </table>
340
+ </div>
341
+
342
+ </div>
343
+
344
+
345
+ </div>
346
+
347
+ <div id="footer">
348
+ Generated on Wed Jun 15 15:30:27 2011 by
349
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
350
+ 0.7.1 (ruby-1.9.2).
351
+ </div>
352
+
353
+ </body>
354
+ </html>
@@ -556,7 +556,7 @@ a summary of the tracking status
556
556
  </div>
557
557
 
558
558
  <div id="footer">
559
- Generated on Tue Jun 14 08:42:00 2011 by
559
+ Generated on Wed Jun 15 15:30:27 2011 by
560
560
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
561
561
  0.7.1 (ruby-1.9.2).
562
562
  </div>
@@ -118,7 +118,7 @@ Raised if something other than tracking information is returned.
118
118
  </div>
119
119
 
120
120
  <div id="footer">
121
- Generated on Tue Jun 14 08:42:00 2011 by
121
+ Generated on Wed Jun 15 15:30:26 2011 by
122
122
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
123
123
  0.7.1 (ruby-1.9.2).
124
124
  </div>
@@ -630,7 +630,7 @@ converts the event into a string
630
630
  </div>
631
631
 
632
632
  <div id="footer">
633
- Generated on Tue Jun 14 08:42:00 2011 by
633
+ Generated on Wed Jun 15 15:30:26 2011 by
634
634
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
635
635
  0.7.1 (ruby-1.9.2).
636
636
  </div>
@@ -66,12 +66,12 @@
66
66
 
67
67
  <dt class="r1">Inherits:</dt>
68
68
  <dd class="r1">
69
- <span class="inheritName"><span class='object_link'><a href="Base.html" title="Trackerific::Base (class)">Base</a></span></span>
69
+ <span class="inheritName"><span class='object_link'><a href="Service.html" title="Trackerific::Service (class)">Service</a></span></span>
70
70
 
71
71
  <ul class="fullTree">
72
72
  <li>Object</li>
73
73
 
74
- <li class="next"><span class='object_link'><a href="Base.html" title="Trackerific::Base (class)">Base</a></span></li>
74
+ <li class="next"><span class='object_link'><a href="Service.html" title="Trackerific::Service (class)">Service</a></span></li>
75
75
 
76
76
  <li class="next">Trackerific::FedEx</li>
77
77
 
@@ -116,12 +116,19 @@ Provides package tracking support for FedEx
116
116
 
117
117
 
118
118
 
119
+
120
+
121
+
122
+
119
123
 
120
124
 
121
125
 
122
126
 
123
127
 
124
128
 
129
+
130
+
131
+
125
132
 
126
133
 
127
134
  <h2>
@@ -224,12 +231,22 @@ Tracks a FedEx package.
224
231
 
225
232
 
226
233
 
227
- <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Base.html" title="Trackerific::Base (class)">Base</a></span></h3>
228
- <p class="inherited"><span class='object_link'><a href="Base.html#initialize-instance_method" title="Trackerific::Base#initialize (method)">#initialize</a></span></p>
234
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Service.html" title="Trackerific::Service (class)">Service</a></span></h3>
235
+ <p class="inherited"><span class='object_link'><a href="Service.html#initialize-instance_method" title="Trackerific::Service#initialize (method)">#initialize</a></span></p>
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+ <h3 class="inherited">Methods included from <span class='object_link'><a href="../OptionsHelper.html" title="OptionsHelper (module)">OptionsHelper</a></span></h3>
245
+ <p class="inherited"><span class='object_link'><a href="../OptionsHelper.html#validate_options-instance_method" title="OptionsHelper#validate_options (method)">#validate_options</a></span></p>
229
246
  <div id="constructor_details" class="method_details_list">
230
247
  <h2>Constructor Details</h2>
231
248
 
232
- <p class="notice">This class inherits a constructor from <span class='object_link'><a href="Base.html#initialize-instance_method" title="Trackerific::Base#initialize (method)">Trackerific::Base</a></span></p>
249
+ <p class="notice">This class inherits a constructor from <span class='object_link'><a href="Service.html#initialize-instance_method" title="Trackerific::Service#initialize (method)">Trackerific::Service</a></span></p>
233
250
 
234
251
  </div>
235
252
 
@@ -285,14 +302,14 @@ the regular expression
285
302
  <pre class="lines">
286
303
 
287
304
 
288
- 51
289
- 52
290
- 53</pre>
305
+ 16
306
+ 17
307
+ 18</pre>
291
308
  </td>
292
309
  <td>
293
- <pre class="code"><span class="info file"># File 'lib/trackerific/services/fedex.rb', line 51</span>
310
+ <pre class="code"><span class="info file"># File 'lib/trackerific/services/fedex.rb', line 16</span>
294
311
 
295
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id package_id_matchers'>package_id_matchers</span>
312
+ <span class='kw'>def</span> <span class='id package_id_matchers'>package_id_matchers</span>
296
313
  <span class='lbracket'>[</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>^[0-9]{15}$</span><span class='regexp_end'>/</span></span> <span class='rbracket'>]</span>
297
314
  <span class='kw'>end</span></pre>
298
315
  </td>
@@ -347,14 +364,14 @@ required options for tracking a FedEx package are :account and :meter
347
364
  <pre class="lines">
348
365
 
349
366
 
350
- 59
351
- 60
352
- 61</pre>
367
+ 24
368
+ 25
369
+ 26</pre>
353
370
  </td>
354
371
  <td>
355
- <pre class="code"><span class="info file"># File 'lib/trackerific/services/fedex.rb', line 59</span>
372
+ <pre class="code"><span class="info file"># File 'lib/trackerific/services/fedex.rb', line 24</span>
356
373
 
357
- <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id required_options'>required_options</span>
374
+ <span class='kw'>def</span> <span class='id required_options'>required_options</span>
358
375
  <span class='lbracket'>[</span><span class='symbol'>:account</span><span class='comma'>,</span> <span class='symbol'>:meter</span><span class='rbracket'>]</span>
359
376
  <span class='kw'>end</span></pre>
360
377
  </td>
@@ -464,23 +481,6 @@ package, etc.)
464
481
  <pre class="lines">
465
482
 
466
483
 
467
- 20
468
- 21
469
- 22
470
- 23
471
- 24
472
- 25
473
- 26
474
- 27
475
- 28
476
- 29
477
- 30
478
- 31
479
- 32
480
- 33
481
- 34
482
- 35
483
- 36
484
484
  37
485
485
  38
486
486
  39
@@ -490,10 +490,27 @@ package, etc.)
490
490
  43
491
491
  44
492
492
  45
493
- 46</pre>
493
+ 46
494
+ 47
495
+ 48
496
+ 49
497
+ 50
498
+ 51
499
+ 52
500
+ 53
501
+ 54
502
+ 55
503
+ 56
504
+ 57
505
+ 58
506
+ 59
507
+ 60
508
+ 61
509
+ 62
510
+ 63</pre>
494
511
  </td>
495
512
  <td>
496
- <pre class="code"><span class="info file"># File 'lib/trackerific/services/fedex.rb', line 20</span>
513
+ <pre class="code"><span class="info file"># File 'lib/trackerific/services/fedex.rb', line 37</span>
497
514
 
498
515
  <span class='kw'>def</span> <span class='id track_package'>track_package</span><span class='lparen'>(</span><span class='id package_id'>package_id</span><span class='rparen'>)</span>
499
516
  <span class='kw'>super</span>
@@ -532,7 +549,7 @@ package, etc.)
532
549
  </div>
533
550
 
534
551
  <div id="footer">
535
- Generated on Tue Jun 14 08:42:00 2011 by
552
+ Generated on Wed Jun 15 15:30:27 2011 by
536
553
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
537
554
  0.7.1 (ruby-1.9.2).
538
555
  </div>