trackerific 0.5.5 → 0.6.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 (49) hide show
  1. data/README.rdoc +62 -44
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/changelog +9 -0
  5. data/lib/trackerific/configuration.rb +2 -2
  6. data/lib/trackerific/details.rb +36 -10
  7. data/lib/trackerific/event.rb +9 -7
  8. data/lib/trackerific/service.rb +22 -6
  9. data/lib/trackerific/services/fedex.rb +11 -7
  10. data/lib/trackerific/services/mock_service.rb +23 -14
  11. data/lib/trackerific/services/ups.rb +12 -8
  12. data/lib/trackerific/services/usps.rb +114 -21
  13. data/spec/fixtures/usps_city_state_lookup_response.xml +8 -0
  14. data/spec/lib/helpers/options_helper_spec.rb +3 -3
  15. data/spec/lib/trackerific/configuration_spec.rb +35 -0
  16. data/spec/lib/trackerific/details_spec.rb +71 -11
  17. data/spec/lib/trackerific/event_spec.rb +34 -19
  18. data/spec/lib/trackerific/service_spec.rb +3 -3
  19. data/spec/lib/trackerific/services/fedex_spec.rb +16 -3
  20. data/spec/lib/trackerific/services/mock_service_spec.rb +19 -4
  21. data/spec/lib/trackerific/services/ups_spec.rb +17 -2
  22. data/spec/lib/trackerific/services/usps_spec.rb +60 -11
  23. data/spec/lib/trackerific_spec.rb +7 -5
  24. data/trackerific.gemspec +5 -27
  25. metadata +8 -30
  26. data/doc/OptionsHelper.html +0 -287
  27. data/doc/Trackerific/Configuration.html +0 -354
  28. data/doc/Trackerific/Details.html +0 -565
  29. data/doc/Trackerific/Error.html +0 -127
  30. data/doc/Trackerific/Event.html +0 -639
  31. data/doc/Trackerific/FedEx.html +0 -558
  32. data/doc/Trackerific/Service.html +0 -579
  33. data/doc/Trackerific/UPS.html +0 -532
  34. data/doc/Trackerific/USPS.html +0 -568
  35. data/doc/Trackerific.html +0 -833
  36. data/doc/_index.html +0 -226
  37. data/doc/class_list.html +0 -47
  38. data/doc/css/common.css +0 -1
  39. data/doc/css/full_list.css +0 -53
  40. data/doc/css/style.css +0 -320
  41. data/doc/file.README.html +0 -288
  42. data/doc/file_list.html +0 -49
  43. data/doc/frames.html +0 -13
  44. data/doc/index.html +0 -288
  45. data/doc/js/app.js +0 -205
  46. data/doc/js/full_list.js +0 -150
  47. data/doc/js/jquery.js +0 -16
  48. data/doc/method_list.html +0 -294
  49. data/doc/top-level-namespace.html +0 -103
data/doc/Trackerific.html DELETED
@@ -1,833 +0,0 @@
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
- Module: Trackerific
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 (T)</a> &raquo;
37
-
38
-
39
- <span class="title">Trackerific</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>Module: Trackerific
60
-
61
-
62
-
63
- </h1>
64
-
65
- <dl class="box">
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
- <dt class="r1 last">Defined in:</dt>
75
- <dd class="r1 last">lib/trackerific.rb<span class="defines">,<br />
76
- lib/trackerific/event.rb,<br /> lib/trackerific/error.rb,<br /> lib/trackerific/details.rb,<br /> lib/trackerific/service.rb,<br /> lib/trackerific/services/ups.rb,<br /> lib/trackerific/configuration.rb,<br /> lib/trackerific/services/usps.rb,<br /> lib/trackerific/services/fedex.rb</span>
77
- </dd>
78
-
79
- </dl>
80
- <div class="clear"></div>
81
-
82
- <h2>Overview</h2><div class="docstring">
83
- <div class="discussion">
84
- <p>
85
- Trackerific provides package tracking to Rails apps.
86
- </p>
87
-
88
-
89
- </div>
90
- </div>
91
- <div class="tags">
92
-
93
- </div><h2>Defined Under Namespace</h2>
94
- <p class="children">
95
-
96
-
97
-
98
-
99
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Trackerific/Configuration.html" title="Trackerific::Configuration (class)">Configuration</a></span>, <span class='object_link'><a href="Trackerific/Details.html" title="Trackerific::Details (class)">Details</a></span>, <span class='object_link'><a href="Trackerific/Error.html" title="Trackerific::Error (class)">Error</a></span>, <span class='object_link'><a href="Trackerific/Event.html" title="Trackerific::Event (class)">Event</a></span>, <span class='object_link'><a href="Trackerific/FedEx.html" title="Trackerific::FedEx (class)">FedEx</a></span>, <span class='object_link'><a href="Trackerific/Service.html" title="Trackerific::Service (class)">Service</a></span>, <span class='object_link'><a href="Trackerific/UPS.html" title="Trackerific::UPS (class)">UPS</a></span>, <span class='object_link'><a href="Trackerific/USPS.html" title="Trackerific::USPS (class)">USPS</a></span>
100
-
101
-
102
- </p>
103
-
104
-
105
-
106
-
107
-
108
-
109
- <h2>
110
- Class Method Summary
111
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
112
- </h2>
113
-
114
- <ul class="summary">
115
-
116
- <li class="public ">
117
- <span class="summary_signature">
118
-
119
- <a href="#configuration-class_method" title="configuration (class method)">+ (Trackerific::Configuration) <strong>configuration</strong> </a>
120
-
121
-
122
-
123
- </span>
124
-
125
-
126
-
127
-
128
-
129
- <span class="private note title">Private</span>
130
-
131
-
132
- <span class="summary_desc"><div class='inline'><p>
133
- Stores the configuration options for Trackerific.
134
- </p>
135
- </div></span>
136
-
137
- </li>
138
-
139
-
140
- <li class="public ">
141
- <span class="summary_signature">
142
-
143
- <a href="#configure-class_method" title="configure (class method)">+ (Trackerific::Configuration) <strong>configure</strong> {|configuration| ... }</a>
144
-
145
-
146
-
147
- </span>
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
- <span class="summary_desc"><div class='inline'><p>
157
- Configures Trackerific.
158
- </p>
159
- </div></span>
160
-
161
- </li>
162
-
163
-
164
- <li class="public ">
165
- <span class="summary_signature">
166
-
167
- <a href="#service_get-class_method" title="service_get (class method)">+ (Trackerific::Service) <strong>service_get</strong>(name) </a>
168
-
169
-
170
-
171
- </span>
172
-
173
-
174
-
175
-
176
-
177
- <span class="private note title">Private</span>
178
-
179
-
180
- <span class="summary_desc"><div class='inline'><p>
181
- Gets a Trackerific::Service class.
182
- </p>
183
- </div></span>
184
-
185
- </li>
186
-
187
-
188
- <li class="public ">
189
- <span class="summary_signature">
190
-
191
- <a href="#services-class_method" title="services (class method)">+ (Array, Symbol) <strong>services</strong> </a>
192
-
193
-
194
-
195
- </span>
196
-
197
-
198
-
199
-
200
-
201
- <span class="private note title">Private</span>
202
-
203
-
204
- <span class="summary_desc"><div class='inline'><p>
205
- Gets a list of all Trackerific services.
206
- </p>
207
- </div></span>
208
-
209
- </li>
210
-
211
-
212
- </ul>
213
-
214
- <h2>
215
- Instance Method Summary
216
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
217
- </h2>
218
-
219
- <ul class="summary">
220
-
221
- <li class="public ">
222
- <span class="summary_signature">
223
-
224
- <a href="#track_package-instance_method" title="#track_package (instance method)">- (Trackerific::Details) <strong>track_package</strong>(package_id) </a>
225
-
226
-
227
-
228
- </span>
229
-
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
- <span class="summary_desc"><div class='inline'><p>
238
- Tracks a package by determining its service from the package id.
239
- </p>
240
- </div></span>
241
-
242
- </li>
243
-
244
-
245
- <li class="public ">
246
- <span class="summary_signature">
247
-
248
- <a href="#tracking_service-instance_method" title="#tracking_service (instance method)">- (Trackerific::Base) <strong>tracking_service</strong>(package_id) </a>
249
-
250
-
251
-
252
- </span>
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
- <span class="summary_desc"><div class='inline'><p>
262
- Checks a string for a valid package tracking service.
263
- </p>
264
- </div></span>
265
-
266
- </li>
267
-
268
-
269
- </ul>
270
-
271
-
272
-
273
-
274
- <div id="class_method_details" class="method_details_list">
275
- <h2>Class Method Details</h2>
276
-
277
-
278
- <div class="method_details first">
279
- <p class="signature first" id="configuration-class_method">
280
-
281
- + (<tt><span class='object_link'><a href="Trackerific/Configuration.html" title="Trackerific::Configuration (class)">Trackerific::Configuration</a></span></tt>) <strong>configuration</strong>
282
-
283
-
284
-
285
- </p><div class="docstring">
286
- <div class="discussion">
287
- <p class="note private">
288
- <strong>This method is part of a private API.</strong>
289
- You should avoid using this method if possible, as it may be removed or be changed in the future.
290
- </p>
291
- <p>
292
- Stores the configuration options for Trackerific
293
- </p>
294
-
295
-
296
- </div>
297
- </div>
298
- <div class="tags">
299
- <h3>Returns:</h3>
300
- <ul class="return">
301
-
302
- <li>
303
-
304
-
305
- <span class='type'>(<tt><span class='object_link'><a href="Trackerific/Configuration.html" title="Trackerific::Configuration (class)">Trackerific::Configuration</a></span></tt>)</span>
306
-
307
-
308
-
309
- </li>
310
-
311
- </ul>
312
-
313
- </div><table class="source_code">
314
- <tr>
315
- <td>
316
- <pre class="lines">
317
-
318
-
319
- 34
320
- 35
321
- 36</pre>
322
- </td>
323
- <td>
324
- <pre class="code"><span class="info file"># File 'lib/trackerific/configuration.rb', line 34</span>
325
-
326
- <span class='kw'>def</span> <span class='id configuration'>configuration</span>
327
- <span class='ivar'>@configuration</span> <span class='op'>||=</span> <span class='const'>Trackerific</span><span class='op'>::</span><span class='const'>Configuration</span><span class='period'>.</span><span class='id new'>new</span>
328
- <span class='kw'>end</span></pre>
329
- </td>
330
- </tr>
331
- </table>
332
- </div>
333
-
334
- <div class="method_details ">
335
- <p class="signature " id="configure-class_method">
336
-
337
- + (<tt><span class='object_link'><a href="Trackerific/Configuration.html" title="Trackerific::Configuration (class)">Trackerific::Configuration</a></span></tt>) <strong>configure</strong> {|configuration| ... }
338
-
339
-
340
-
341
- </p><div class="docstring">
342
- <div class="discussion">
343
- <p>
344
- Configures Trackerific
345
- </p>
346
-
347
-
348
- </div>
349
- </div>
350
- <div class="tags">
351
-
352
- <div class="examples">
353
- <h3>Examples:</h3>
354
-
355
- <h4><div class='inline'><p>
356
- Defining credentials
357
- </p>
358
- </div></h4>
359
- <pre class="example code"><span class='const'>Trackerific</span><span class='period'>.</span><span class='id configure'>configure</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id config'>config</span><span class='op'>|</span>
360
- <span class='id config'>config</span><span class='period'>.</span><span class='id fedex'>fedex</span> <span class='symbol'>:meter</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>123456789</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:account</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>123456789</span><span class='tstring_end'>'</span></span>
361
- <span class='kw'>end</span></pre>
362
-
363
- </div>
364
- <h3>Yields:</h3>
365
- <ul class="yield">
366
-
367
- <li>
368
-
369
-
370
- <span class='type'>(<tt><span class='object_link'><a href="#configuration-class_method" title="Trackerific.configuration (method)">configuration</a></span></tt>)</span>
371
-
372
-
373
-
374
- </li>
375
-
376
- </ul>
377
- <h3>Returns:</h3>
378
- <ul class="return">
379
-
380
- <li>
381
-
382
-
383
- <span class='type'>(<tt><span class='object_link'><a href="Trackerific/Configuration.html" title="Trackerific::Configuration (class)">Trackerific::Configuration</a></span></tt>)</span>
384
-
385
-
386
-
387
- </li>
388
-
389
- </ul>
390
-
391
- </div><table class="source_code">
392
- <tr>
393
- <td>
394
- <pre class="lines">
395
-
396
-
397
- 44
398
- 45
399
- 46
400
- 47</pre>
401
- </td>
402
- <td>
403
- <pre class="code"><span class="info file"># File 'lib/trackerific/configuration.rb', line 44</span>
404
-
405
- <span class='kw'>def</span> <span class='id configure'>configure</span>
406
- <span class='kw'>yield</span> <span class='id configuration'>configuration</span>
407
- <span class='id configuration'>configuration</span>
408
- <span class='kw'>end</span></pre>
409
- </td>
410
- </tr>
411
- </table>
412
- </div>
413
-
414
- <div class="method_details ">
415
- <p class="signature " id="service_get-class_method">
416
-
417
- + (<tt><span class='object_link'><a href="Trackerific/Service.html" title="Trackerific::Service (class)">Trackerific::Service</a></span></tt>) <strong>service_get</strong>(name)
418
-
419
-
420
-
421
- </p><div class="docstring">
422
- <div class="discussion">
423
- <p class="note private">
424
- <strong>This method is part of a private API.</strong>
425
- You should avoid using this method if possible, as it may be removed or be changed in the future.
426
- </p>
427
- <p>
428
- Gets a Trackerific::Service class
429
- </p>
430
-
431
-
432
- </div>
433
- </div>
434
- <div class="tags">
435
- <h3>Parameters:</h3>
436
- <ul class="param">
437
-
438
- <li>
439
-
440
- <span class='name'>name</span>
441
-
442
-
443
- <span class='type'>(<tt>Symbol</tt>)</span>
444
-
445
-
446
-
447
- &mdash;
448
- <div class='inline'><p>
449
- the name of the service
450
- </p>
451
- </div>
452
-
453
- </li>
454
-
455
- </ul>
456
- <h3>Returns:</h3>
457
- <ul class="return">
458
-
459
- <li>
460
-
461
-
462
- <span class='type'>(<tt><span class='object_link'><a href="Trackerific/Service.html" title="Trackerific::Service (class)">Trackerific::Service</a></span></tt>)</span>
463
-
464
-
465
-
466
- &mdash;
467
- <div class='inline'><p>
468
- the service, or nil
469
- </p>
470
- </div>
471
-
472
- </li>
473
-
474
- </ul>
475
-
476
- </div><table class="source_code">
477
- <tr>
478
- <td>
479
- <pre class="lines">
480
-
481
-
482
- 31
483
- 32
484
- 33
485
- 34
486
- 35
487
- 36</pre>
488
- </td>
489
- <td>
490
- <pre class="code"><span class="info file"># File 'lib/trackerific.rb', line 31</span>
491
-
492
- <span class='kw'>def</span> <span class='id service_get'>service_get</span><span class='lparen'>(</span><span class='id name'>name</span><span class='rparen'>)</span>
493
- <span class='id services'>services</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id service'>service</span><span class='op'>|</span>
494
- <span class='kw'>return</span> <span class='const'>Trackerific</span><span class='period'>.</span><span class='id const_get'>const_get</span><span class='lparen'>(</span><span class='id service'>service</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id name'>name</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>
495
- <span class='kw'>end</span>
496
- <span class='kw'>return</span> <span class='kw'>nil</span>
497
- <span class='kw'>end</span></pre>
498
- </td>
499
- </tr>
500
- </table>
501
- </div>
502
-
503
- <div class="method_details ">
504
- <p class="signature " id="services-class_method">
505
-
506
- + (<tt>Array</tt>, <tt>Symbol</tt>) <strong>services</strong>
507
-
508
-
509
-
510
- </p><div class="docstring">
511
- <div class="discussion">
512
- <p class="note private">
513
- <strong>This method is part of a private API.</strong>
514
- You should avoid using this method if possible, as it may be removed or be changed in the future.
515
- </p>
516
- <p>
517
- Gets a list of all Trackerific services
518
- </p>
519
-
520
-
521
- </div>
522
- </div>
523
- <div class="tags">
524
- <h3>Returns:</h3>
525
- <ul class="return">
526
-
527
- <li>
528
-
529
-
530
- <span class='type'>(<tt>Array</tt>, <tt>Symbol</tt>)</span>
531
-
532
-
533
-
534
- &mdash;
535
- <div class='inline'><p>
536
- the services
537
- </p>
538
- </div>
539
-
540
- </li>
541
-
542
- </ul>
543
-
544
- </div><table class="source_code">
545
- <tr>
546
- <td>
547
- <pre class="lines">
548
-
549
-
550
- 20
551
- 21
552
- 22
553
- 23
554
- 24
555
- 25</pre>
556
- </td>
557
- <td>
558
- <pre class="code"><span class="info file"># File 'lib/trackerific.rb', line 20</span>
559
-
560
- <span class='kw'>def</span> <span class='id services'>services</span>
561
- <span class='comment'># a service is any Trackerific class that descends from Trackerific::Service
562
- </span> <span class='const'>Trackerific</span><span class='period'>.</span><span class='id constants'>constants</span><span class='period'>.</span><span class='id reject'>reject</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id const'>const</span><span class='op'>|</span>
563
- <span class='id const'>const</span> <span class='kw'>unless</span> <span class='const'>Trackerific</span><span class='period'>.</span><span class='id const_get'>const_get</span><span class='lparen'>(</span><span class='id const'>const</span><span class='rparen'>)</span><span class='period'>.</span><span class='id superclass'>superclass</span> <span class='op'>==</span> <span class='const'>Trackerific</span><span class='op'>::</span><span class='const'>Service</span>
564
- <span class='rbrace'>}</span>
565
- <span class='kw'>end</span></pre>
566
- </td>
567
- </tr>
568
- </table>
569
- </div>
570
-
571
- </div>
572
-
573
- <div id="instance_method_details" class="method_details_list">
574
- <h2>Instance Method Details</h2>
575
-
576
-
577
- <div class="method_details first">
578
- <p class="signature first" id="track_package-instance_method">
579
-
580
- - (<tt><span class='object_link'><a href="Trackerific/Details.html" title="Trackerific::Details (class)">Trackerific::Details</a></span></tt>) <strong>track_package</strong>(package_id)
581
-
582
-
583
-
584
- </p><div class="docstring">
585
- <div class="discussion">
586
- <p>
587
- Tracks a package by determining its service from the package id
588
- </p>
589
-
590
-
591
- </div>
592
- </div>
593
- <div class="tags">
594
-
595
- <div class="examples">
596
- <h3>Examples:</h3>
597
-
598
- <h4><div class='inline'><p>
599
- Track a package
600
- </p>
601
- </div></h4>
602
- <pre class="example code"><span class='id include'>include</span> <span class='const'>Trackerific</span>
603
- <span class='comment'># make sure to configure Trackerific before hand with the different services credentials
604
- </span><span class='const'>Trackerific</span><span class='period'>.</span><span class='id config'>config</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id config'>config</span><span class='op'>|</span>
605
- <span class='id config'>config</span><span class='period'>.</span><span class='id fedex'>fedex</span> <span class='symbol'>:meter</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>123456789</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='symbol'>:account</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>123456789</span><span class='tstring_end'>'</span></span>
606
- <span class='kw'>end</span>
607
- <span class='id details'>details</span> <span class='op'>=</span> <span class='id track_package'>track_package</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>183689015000001</span><span class='tstring_end'>&quot;</span></span></pre>
608
-
609
- </div>
610
- <h3>Parameters:</h3>
611
- <ul class="param">
612
-
613
- <li>
614
-
615
- <span class='name'>package_id</span>
616
-
617
-
618
- <span class='type'>(<tt>String</tt>)</span>
619
-
620
-
621
-
622
- &mdash;
623
- <div class='inline'><p>
624
- the package identifier
625
- </p>
626
- </div>
627
-
628
- </li>
629
-
630
- </ul>
631
- <h3>Returns:</h3>
632
- <ul class="return">
633
-
634
- <li>
635
-
636
-
637
- <span class='type'>(<tt><span class='object_link'><a href="Trackerific/Details.html" title="Trackerific::Details (class)">Trackerific::Details</a></span></tt>)</span>
638
-
639
-
640
-
641
- &mdash;
642
- <div class='inline'><p>
643
- the tracking results
644
- </p>
645
- </div>
646
-
647
- </li>
648
-
649
- </ul>
650
- <h3>Raises:</h3>
651
- <ul class="raise">
652
-
653
- <li>
654
-
655
-
656
- <span class='type'>(<tt><span class='object_link'><a href="Trackerific/Error.html" title="Trackerific::Error (class)">Trackerific::Error</a></span></tt>)</span>
657
-
658
-
659
-
660
- &mdash;
661
- <div class='inline'><p>
662
- raised when the server returns an error (invalid credentials, tracking
663
- package, etc.)
664
- </p>
665
- </div>
666
-
667
- </li>
668
-
669
- </ul>
670
-
671
- </div><table class="source_code">
672
- <tr>
673
- <td>
674
- <pre class="lines">
675
-
676
-
677
- 74
678
- 75
679
- 76
680
- 77
681
- 78
682
- 79
683
- 80
684
- 81
685
- 82
686
- 83
687
- 84</pre>
688
- </td>
689
- <td>
690
- <pre class="code"><span class="info file"># File 'lib/trackerific.rb', line 74</span>
691
-
692
- <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>
693
- <span class='comment'># find the service that will be able to track this package
694
- </span> <span class='id service'>service</span> <span class='op'>=</span> <span class='id tracking_service'>tracking_service</span> <span class='id package_id'>package_id</span>
695
- <span class='id raise'>raise</span> <span class='const'>Trackerific</span><span class='op'>::</span><span class='const'>Error</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cannot find a service to track package id </span><span class='embexpr_beg'>#{</span><span class='id package_id'>package_id</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id service'>service</span><span class='period'>.</span><span class='id nil?'>nil?</span>
696
- <span class='comment'># get the name of the service
697
- </span> <span class='id service_name'>service_name</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 split'>split</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>::</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id downcase'>downcase</span>
698
- <span class='comment'># get the default configuration for the service
699
- </span> <span class='id options'>options</span> <span class='op'>=</span> <span class='const'>Trackerific</span><span class='period'>.</span><span class='id configuration'>configuration</span><span class='period'>.</span><span class='id send'>send</span> <span class='id service_name'>service_name</span>
700
- <span class='comment'># track the package
701
- </span> <span class='id service'>service</span><span class='period'>.</span><span class='id new'>new</span><span class='lparen'>(</span><span class='id options'>options</span><span class='rparen'>)</span><span class='period'>.</span><span class='id track_package'>track_package</span> <span class='id package_id'>package_id</span>
702
- <span class='kw'>end</span></pre>
703
- </td>
704
- </tr>
705
- </table>
706
- </div>
707
-
708
- <div class="method_details ">
709
- <p class="signature " id="tracking_service-instance_method">
710
-
711
- - (<tt>Trackerific::Base</tt>) <strong>tracking_service</strong>(package_id)
712
-
713
-
714
-
715
- </p><div class="docstring">
716
- <div class="discussion">
717
- <p>
718
- Checks a string for a valid package tracking service
719
- </p>
720
-
721
-
722
- </div>
723
- </div>
724
- <div class="tags">
725
-
726
- <div class="examples">
727
- <h3>Examples:</h3>
728
-
729
- <h4><div class='inline'><p>
730
- Find out which service provider will track a valid FedEx number
731
- </p>
732
- </div></h4>
733
- <pre class="example code"><span class='id include'>include</span> <span class='const'>Trackerific</span>
734
- <span class='id tracking_service'>tracking_service</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>183689015000001</span><span class='tstring_end'>&quot;</span></span> <span class='comment'># =&gt; Trackerific::FedEx</span></pre>
735
-
736
- </div>
737
- <h3>Parameters:</h3>
738
- <ul class="param">
739
-
740
- <li>
741
-
742
- <span class='name'>package_id</span>
743
-
744
-
745
- <span class='type'>(<tt>String</tt>)</span>
746
-
747
-
748
-
749
- &mdash;
750
- <div class='inline'><p>
751
- the package identifier
752
- </p>
753
- </div>
754
-
755
- </li>
756
-
757
- </ul>
758
- <h3>Returns:</h3>
759
- <ul class="return">
760
-
761
- <li>
762
-
763
-
764
- <span class='type'>(<tt>Trackerific::Base</tt>)</span>
765
-
766
-
767
-
768
- &mdash;
769
- <div class='inline'><p>
770
- the Trackerific class that can track the given package id, or nil if none
771
- found.
772
- </p>
773
- </div>
774
-
775
- </li>
776
-
777
- </ul>
778
-
779
- </div><table class="source_code">
780
- <tr>
781
- <td>
782
- <pre class="lines">
783
-
784
-
785
- 47
786
- 48
787
- 49
788
- 50
789
- 51
790
- 52
791
- 53
792
- 54
793
- 55
794
- 56
795
- 57
796
- 58
797
- 59
798
- 60</pre>
799
- </td>
800
- <td>
801
- <pre class="code"><span class="info file"># File 'lib/trackerific.rb', line 47</span>
802
-
803
- <span class='kw'>def</span> <span class='id tracking_service'>tracking_service</span><span class='lparen'>(</span><span class='id package_id'>package_id</span><span class='rparen'>)</span>
804
- <span class='comment'># loop through all the services
805
- </span> <span class='const'>Trackerific</span><span class='period'>.</span><span class='id services'>services</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id service'>service</span><span class='op'>|</span>
806
- <span class='comment'># get the class associated with this service
807
- </span> <span class='id cls'>cls</span> <span class='op'>=</span> <span class='const'>Trackerific</span><span class='period'>.</span><span class='id const_get'>const_get</span><span class='lparen'>(</span><span class='id service'>service</span><span class='rparen'>)</span>
808
- <span class='comment'># loop through all the packge id regular expressions
809
- </span> <span class='id cls'>cls</span><span class='period'>.</span><span class='id package_id_matchers'>package_id_matchers</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id matcher'>matcher</span><span class='op'>|</span>
810
- <span class='comment'># return this class if the regular expression matches
811
- </span> <span class='kw'>return</span> <span class='id cls'>cls</span> <span class='kw'>if</span> <span class='id package_id'>package_id</span> <span class='op'>=~</span> <span class='id matcher'>matcher</span>
812
- <span class='kw'>end</span>
813
- <span class='kw'>end</span>
814
- <span class='comment'># if we've made it this far, nothing matched
815
- </span> <span class='kw'>nil</span>
816
- <span class='kw'>end</span></pre>
817
- </td>
818
- </tr>
819
- </table>
820
- </div>
821
-
822
- </div>
823
-
824
- </div>
825
-
826
- <div id="footer">
827
- Generated on Wed Jun 15 15:30:26 2011 by
828
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
829
- 0.7.1 (ruby-1.9.2).
830
- </div>
831
-
832
- </body>
833
- </html>