doc/Trackerific.html in trackerific-0.3.5 vs doc/Trackerific.html in trackerific-0.4.0

- old
+ new

@@ -71,11 +71,11 @@ <dt class="r1 last">Defined in:</dt> <dd class="r1 last">lib/trackerific.rb<span class="defines">,<br /> - lib/trackerific/base.rb,<br /> lib/trackerific/event.rb,<br /> lib/trackerific/error.rb,<br /> lib/trackerific/details.rb,<br /> lib/trackerific/services/ups.rb,<br /> lib/trackerific/services/usps.rb,<br /> lib/trackerific/services/fedex.rb</span> + 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> </dd> </dl> <div class="clear"></div> @@ -94,30 +94,159 @@ <p class="children"> - <strong class="classes">Classes:</strong> <span class='object_link'><a href="Trackerific/Base.html" title="Trackerific::Base (class)">Base</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/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> + <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> </p> <h2> + Class Method Summary + <small>(<a href="#" class="summary_toggle">collapse</a>)</small> + </h2> + + <ul class="summary"> + + <li class="public "> + <span class="summary_signature"> + + <a href="#configuration-class_method" title="configuration (class method)">+ (Trackerific::Configuration) <strong>configuration</strong> </a> + + + + </span> + + + + + + <span class="private note title">Private</span> + + + <span class="summary_desc"><div class='inline'><p> +Stores the configuration options for Trackerific. +</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#configure-class_method" title="configure (class method)">+ (Trackerific::Configuration) <strong>configure</strong> {|configuration| ... }</a> + + + + </span> + + + + + + + + + <span class="summary_desc"><div class='inline'><p> +Configures Trackerific. +</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#service_get-class_method" title="service_get (class method)">+ (Trackerific::Service) <strong>service_get</strong>(name) </a> + + + + </span> + + + + + + <span class="private note title">Private</span> + + + <span class="summary_desc"><div class='inline'><p> +Gets a Trackerific::Service class. +</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + + <a href="#services-class_method" title="services (class method)">+ (Array, Symbol) <strong>services</strong> </a> + + + + </span> + + + + + + <span class="private note title">Private</span> + + + <span class="summary_desc"><div class='inline'><p> +Gets a list of all Trackerific services. +</p> +</div></span> + +</li> + + + </ul> + + <h2> Instance Method Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small> </h2> <ul class="summary"> <li class="public "> <span class="summary_signature"> + <a href="#track_package-instance_method" title="#track_package (instance method)">- (Trackerific::Details) <strong>track_package</strong>(package_id) </a> + + + + </span> + + + + + + + + + <span class="summary_desc"><div class='inline'><p> +Tracks a package by determining its service from the package id. +</p> +</div></span> + +</li> + + + <li class="public "> + <span class="summary_signature"> + <a href="#tracking_service-instance_method" title="#tracking_service (instance method)">- (Trackerific::Base) <strong>tracking_service</strong>(package_id) </a> </span> @@ -140,24 +269,454 @@ </ul> + <div id="class_method_details" class="method_details_list"> + <h2>Class Method Details</h2> + + + <div class="method_details first"> + <p class="signature first" id="configuration-class_method"> + + + (<tt><span class='object_link'><a href="Trackerific/Configuration.html" title="Trackerific::Configuration (class)">Trackerific::Configuration</a></span></tt>) <strong>configuration</strong> + + + +</p><div class="docstring"> + <div class="discussion"> + <p class="note private"> + <strong>This method is part of a private API.</strong> + You should avoid using this method if possible, as it may be removed or be changed in the future. +</p> +<p> +Stores the configuration options for Trackerific +</p> + + + </div> +</div> +<div class="tags"> + <h3>Returns:</h3> +<ul class="return"> + + <li> + + + <span class='type'>(<tt><span class='object_link'><a href="Trackerific/Configuration.html" title="Trackerific::Configuration (class)">Trackerific::Configuration</a></span></tt>)</span> + + + + </li> + +</ul> + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +34 +35 +36</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/trackerific/configuration.rb', line 34</span> + +<span class='kw'>def</span> <span class='id configuration'>configuration</span> + <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> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <p class="signature " id="configure-class_method"> + + + (<tt><span class='object_link'><a href="Trackerific/Configuration.html" title="Trackerific::Configuration (class)">Trackerific::Configuration</a></span></tt>) <strong>configure</strong> {|configuration| ... } + + + +</p><div class="docstring"> + <div class="discussion"> + <p> +Configures Trackerific +</p> + + + </div> +</div> +<div class="tags"> + + <div class="examples"> + <h3>Examples:</h3> + + <h4><div class='inline'><p> +Defining credentials +</p> +</div></h4> + <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> + <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> +<span class='kw'>end</span></pre> + + </div> +<h3>Yields:</h3> +<ul class="yield"> + + <li> + + + <span class='type'>(<tt><span class='object_link'><a href="#configuration-class_method" title="Trackerific.configuration (method)">configuration</a></span></tt>)</span> + + + + </li> + +</ul> +<h3>Returns:</h3> +<ul class="return"> + + <li> + + + <span class='type'>(<tt><span class='object_link'><a href="Trackerific/Configuration.html" title="Trackerific::Configuration (class)">Trackerific::Configuration</a></span></tt>)</span> + + + + </li> + +</ul> + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +44 +45 +46 +47</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/trackerific/configuration.rb', line 44</span> + +<span class='kw'>def</span> <span class='id configure'>configure</span> + <span class='kw'>yield</span> <span class='id configuration'>configuration</span> + <span class='id configuration'>configuration</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <p class="signature " id="service_get-class_method"> + + + (<tt><span class='object_link'><a href="Trackerific/Service.html" title="Trackerific::Service (class)">Trackerific::Service</a></span></tt>) <strong>service_get</strong>(name) + + + +</p><div class="docstring"> + <div class="discussion"> + <p class="note private"> + <strong>This method is part of a private API.</strong> + You should avoid using this method if possible, as it may be removed or be changed in the future. +</p> +<p> +Gets a Trackerific::Service class +</p> + + + </div> +</div> +<div class="tags"> + <h3>Parameters:</h3> +<ul class="param"> + + <li> + + <span class='name'>name</span> + + + <span class='type'>(<tt>Symbol</tt>)</span> + + + + &mdash; + <div class='inline'><p> +the name of the service +</p> +</div> + + </li> + +</ul> +<h3>Returns:</h3> +<ul class="return"> + + <li> + + + <span class='type'>(<tt><span class='object_link'><a href="Trackerific/Service.html" title="Trackerific::Service (class)">Trackerific::Service</a></span></tt>)</span> + + + + &mdash; + <div class='inline'><p> +the service, or nil +</p> +</div> + + </li> + +</ul> + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +31 +32 +33 +34 +35 +36</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/trackerific.rb', line 31</span> + +<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> + <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> + <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> + <span class='kw'>end</span> + <span class='kw'>return</span> <span class='kw'>nil</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <p class="signature " id="services-class_method"> + + + (<tt>Array</tt>, <tt>Symbol</tt>) <strong>services</strong> + + + +</p><div class="docstring"> + <div class="discussion"> + <p class="note private"> + <strong>This method is part of a private API.</strong> + You should avoid using this method if possible, as it may be removed or be changed in the future. +</p> +<p> +Gets a list of all Trackerific services +</p> + + + </div> +</div> +<div class="tags"> + <h3>Returns:</h3> +<ul class="return"> + + <li> + + + <span class='type'>(<tt>Array</tt>, <tt>Symbol</tt>)</span> + + + + &mdash; + <div class='inline'><p> +the services +</p> +</div> + + </li> + +</ul> + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +20 +21 +22 +23 +24 +25</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/trackerific.rb', line 20</span> + +<span class='kw'>def</span> <span class='id services'>services</span> + <span class='comment'># a service is any Trackerific class that descends from Trackerific::Service +</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> + <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> + <span class='rbrace'>}</span> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + </div> + <div id="instance_method_details" class="method_details_list"> <h2>Instance Method Details</h2> <div class="method_details first"> - <p class="signature first" id="tracking_service-instance_method"> + <p class="signature first" id="track_package-instance_method"> - - (<tt><span class='object_link'><a href="Trackerific/Base.html" title="Trackerific::Base (class)">Trackerific::Base</a></span></tt>) <strong>tracking_service</strong>(package_id) + - (<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) </p><div class="docstring"> <div class="discussion"> <p> +Tracks a package by determining its service from the package id +</p> + + + </div> +</div> +<div class="tags"> + + <div class="examples"> + <h3>Examples:</h3> + + <h4><div class='inline'><p> +Track a package +</p> +</div></h4> + <pre class="example code"><span class='id include'>include</span> <span class='const'>Trackerific</span> +<span class='comment'># make sure to configure Trackerific before hand with the different services credentials +</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> + <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> +<span class='kw'>end</span> +<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> + + </div> +<h3>Parameters:</h3> +<ul class="param"> + + <li> + + <span class='name'>package_id</span> + + + <span class='type'>(<tt>String</tt>)</span> + + + + &mdash; + <div class='inline'><p> +the package identifier +</p> +</div> + + </li> + +</ul> +<h3>Returns:</h3> +<ul class="return"> + + <li> + + + <span class='type'>(<tt><span class='object_link'><a href="Trackerific/Details.html" title="Trackerific::Details (class)">Trackerific::Details</a></span></tt>)</span> + + + + &mdash; + <div class='inline'><p> +the tracking results +</p> +</div> + + </li> + +</ul> +<h3>Raises:</h3> +<ul class="raise"> + + <li> + + + <span class='type'>(<tt><span class='object_link'><a href="Trackerific/Error.html" title="Trackerific::Error (class)">Trackerific::Error</a></span></tt>)</span> + + + + &mdash; + <div class='inline'><p> +raised when the server returns an error (invalid credentials, tracking +package, etc.) +</p> +</div> + + </li> + +</ul> + +</div><table class="source_code"> + <tr> + <td> + <pre class="lines"> + + +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84</pre> + </td> + <td> + <pre class="code"><span class="info file"># File 'lib/trackerific.rb', line 74</span> + +<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> + <span class='comment'># find the service that will be able to track this package +</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> + <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> + <span class='comment'># get the name of the service +</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> + <span class='comment'># get the default configuration for the service +</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> + <span class='comment'># track the package +</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> +<span class='kw'>end</span></pre> + </td> + </tr> +</table> +</div> + + <div class="method_details "> + <p class="signature " id="tracking_service-instance_method"> + + - (<tt>Trackerific::Base</tt>) <strong>tracking_service</strong>(package_id) + + + +</p><div class="docstring"> + <div class="discussion"> + <p> Checks a string for a valid package tracking service </p> </div> @@ -200,11 +759,11 @@ <ul class="return"> <li> - <span class='type'>(<tt><span class='object_link'><a href="Trackerific/Base.html" title="Trackerific::Base (class)">Trackerific::Base</a></span></tt>)</span> + <span class='type'>(<tt>Trackerific::Base</tt>)</span> &mdash; <div class='inline'><p> @@ -221,43 +780,37 @@ <tr> <td> <pre class="lines"> -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -33 -34 -35 -36 -37</pre> +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60</pre> </td> <td> - <pre class="code"><span class="info file"># File 'lib/trackerific.rb', line 21</span> + <pre class="code"><span class="info file"># File 'lib/trackerific.rb', line 47</span> <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> - <span class='comment'># loop through each constant in Trackerific -</span> <span class='const'>Trackerific</span><span class='period'>.</span><span class='id constants'>constants</span><span class='period'>.</span><span class='id each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id const'>const</span><span class='op'>|</span> - <span class='comment'># get the constant's class -</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 const'>const</span><span class='rparen'>)</span> - <span class='comment'># check if it descends from Trackerific::Base -</span> <span class='kw'>if</span> <span class='id cls'>cls</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'>Base</span> - <span class='comment'># loop through each package id matcher -</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> - <span class='comment'># return the class if it matches -</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> - <span class='kw'>end</span> + <span class='comment'># loop through all the services +</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> + <span class='comment'># get the class associated with this service +</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> + <span class='comment'># loop through all the packge id regular expressions +</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> + <span class='comment'># return this class if the regular expression matches +</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> <span class='kw'>end</span> <span class='kw'>end</span> <span class='comment'># if we've made it this far, nothing matched </span> <span class='kw'>nil</span> <span class='kw'>end</span></pre> @@ -269,10 +822,10 @@ </div> </div> <div id="footer"> - Generated on Tue Jun 14 08:41:59 2011 by + Generated on Wed Jun 15 15:30:26 2011 by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a> 0.7.1 (ruby-1.9.2). </div> </body> \ No newline at end of file