Skip to content

Commit

Permalink
Release v1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
binarylogic committed May 14, 2009
1 parent 3e14eff commit b672e27
Show file tree
Hide file tree
Showing 23 changed files with 5,542 additions and 28 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
== 1.0.1

* Changed inclusion method to use apply_addresslogic instead of include Addresslogic. This allows you to pass options and specify alternate fields.

== 1.0.0

* Initial release
12 changes: 6 additions & 6 deletions Manifest → Manifest.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
init.rb
lib/addresslogic/version.rb
lib/addresslogic.rb
MIT-LICENSE
Rakefile
Manifest.txt
README.rdoc
test/addresslogic_tests.rb
Rakefile
init.rb
lib/addresslogic.rb
lib/addresslogic/version.rb
test/test_addresslogic.rb
test/test_helper.rb
Manifest
10 changes: 8 additions & 2 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,16 @@ Or as a plugin

$ sudo script/plugin install url

Then ust include the AddressLogic module into any class of your choice. All that it assumes is that you have the street1, street2, city, state, zip, country (optional) methods.
Then just include the AddressLogic module into any class of your choice. All that it assumes is that you have the street1, street2, city, state, zip, country (optional) methods.

class Address
include Addresslogic
apply_addresslogic
end

You can specify the fields too:

class Address
apply_addresslogic :fields => [:street1, :street2, :city, [:state, :zip], :country]
end

== Helpful links
Expand Down
21 changes: 14 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
require 'rubygems'
ENV['RDOCOPT'] = "-S -f html -T hanna"

require "rubygems"
require "hoe"
require File.dirname(__FILE__) << "/lib/addresslogic/version"
require 'echoe'

Echoe.new 'addresslogic' do |p|
p.version = Addresslogic::Version::STRING
Hoe.new("Addresslogic", Addresslogic::Version::STRING) do |p|
p.name = "addresslogic"
p.rubyforge_name = "addresslogic"
p.author = "Ben Johnson of Binary Logic"
p.email = 'bjohnson@binarylogic.com'
p.project = 'addresslogic'
p.summary = "Tools for displaying addresses"
p.summary = "Easily display addresses."
p.description = "Easily display addresses."
p.url = "http://github.com/binarylogic/addresslogic"
p.dependencies = %w(echoe)
p.history_file = "CHANGELOG.rdoc"
p.readme_file = "README.rdoc"
p.extra_rdoc_files = ["CHANGELOG.rdoc", "README.rdoc"]
p.remote_rdoc_dir = ''
p.test_globs = ["test/*/test_*.rb", "test/*_test.rb", "test/*/*_test.rb"]
end
114 changes: 114 additions & 0 deletions doc/classes/Addresslogic.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang='en'>
<head>
<title>: Addresslogic [addresslogic-1.0.0 Documentation]</title>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<link href='../rdoc-style.css' media='screen' rel='stylesheet' type='text/css'>
<script type='text/javascript'>
//<![CDATA[
function popupCode(url) {
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
}

function toggleCode(id) {
var code = document.getElementById(id)

code.style.display = code.style.display != 'block' ? 'block' : 'none'
return true
}

// Make codeblocks hidden by default
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
//]]>
</script>
</head>
<body class='page'>
<div class='class' id='wrapper'>
<div class='header'>
<div class='name'>
<span class='type'>Module</span>
Addresslogic
</div>
<ol class='paths'>
<li>
<a href="../files/lib/addresslogic/version_rb.html">lib/addresslogic/version.rb</a>
</li>
<li class='other'>
<a href="../files/lib/addresslogic_rb.html">lib/addresslogic.rb</a>
</li>
<li>
<a class='show' href='#' onclick='this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false'>show all</a>
</li>
</ol>
</div>
<div id='content'>
<div id='text'>
<div id='description'>
<h1>Address Logic</h1>
<p>
This is a simple module that you can include into any classm as long as it
has a street1, street2, city, state, zip, and country (optional) methods.
Just include it into your class like so:
</p>
<pre>class Address&#x000A; include AddressLogic&#x000A;end</pre>
<p>
This adds a sigle method: address_parts. More on this method below...
</p>
</div>
<div id='method-list'>
<h2>Methods</h2>
<h3>public instance</h3>
<ol>
<li><a href="#M000001">address_parts</a></li>
</ol>
</div>
<div id='section'>
<div id='class-list'>
<h2>Classes and Modules</h2>
Class <a href="Addresslogic/Version.html" class="link">Addresslogic::Version</a><br />
</div>
<div id='methods'>
<h2>Public instance methods</h2>
<div class='public-instance method' id='method-M000001'>
<a name='M000001'> </a>
<div class='synopsis'>
<span class='name'>address_parts</span>
<span class='arguments'>(options = {})</span>
</div>
<div class='description'>
<p>
Returns the parts of an address in an array. Example:
</p>
<pre>[&quot;Street1&quot;, &quot;Street2&quot;, &quot;City, State, Zip&quot;, &quot;Country&quot;]</pre>
<p>
This makes displaying addresses on your view pretty simple:
</p>
<pre>address.address_parts.join(&quot;&lt;br /&gt;&quot;)</pre>
<h3>Options</h3>
<ul>
<li><tt>only:</tt> fields you want included in the result

</li>
<li><tt>except:</tt> any fields you want excluded from the result

</li>
</ul>
</div>
<div class='source'>
<a class='source-toggle' href='#' onclick="toggleCode('M000001-source'); return false">
[show source]
</a>
<pre id='M000001-source'><span class="ruby-comment cmt"># File lib/addresslogic.rb, line 24</span>&#x000A; <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">address_parts</span>(<span class="ruby-identifier">options</span> = {})&#x000A; <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only</span>] = [<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only</span>]] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)&#x000A; <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>] = [<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>]] <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>].<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)&#x000A; &#x000A; <span class="ruby-identifier">parts</span> = {}&#x000A; [<span class="ruby-identifier">:street1</span>, <span class="ruby-identifier">:street2</span>, <span class="ruby-identifier">:city</span>, <span class="ruby-identifier">:state</span>, <span class="ruby-identifier">:zip</span>, <span class="ruby-identifier">:country</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">part</span><span class="ruby-operator">|</span>&#x000A; <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">respond_to?</span>(<span class="ruby-identifier">part</span>)&#x000A; <span class="ruby-identifier">value</span> = <span class="ruby-identifier">send</span>(<span class="ruby-identifier">part</span>)&#x000A; <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">value</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">strip</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-operator">||</span> (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">options</span>[<span class="ruby-identifier">:only</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">part</span>)) <span class="ruby-operator">||</span> (<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>] <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:except</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">part</span>))&#x000A; <span class="ruby-identifier">parts</span>[<span class="ruby-identifier">part</span>] = <span class="ruby-identifier">value</span>&#x000A; <span class="ruby-keyword kw">end</span>&#x000A; &#x000A; <span class="ruby-identifier">state_parts</span> = [<span class="ruby-identifier">parts</span>[<span class="ruby-identifier">:state</span>], <span class="ruby-identifier">parts</span>[<span class="ruby-identifier">:zip</span>]].<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot; &quot;</span>)&#x000A; <span class="ruby-identifier">state_parts</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">state_parts</span>.<span class="ruby-identifier">strip</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>&#x000A; <span class="ruby-identifier">city_parts</span> = [<span class="ruby-identifier">parts</span>[<span class="ruby-identifier">:city</span>], <span class="ruby-identifier">state_parts</span>].<span class="ruby-identifier">compact</span>.<span class="ruby-identifier">join</span>(<span class="ruby-value str">&quot;, &quot;</span>)&#x000A; <span class="ruby-identifier">city_parts</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">city_parts</span>.<span class="ruby-identifier">strip</span> <span class="ruby-operator">==</span> <span class="ruby-value str">&quot;&quot;</span>&#x000A; [<span class="ruby-identifier">parts</span>[<span class="ruby-identifier">:street1</span>], <span class="ruby-identifier">parts</span>[<span class="ruby-identifier">:street2</span>], <span class="ruby-identifier">city_parts</span>, <span class="ruby-identifier">parts</span>[<span class="ruby-identifier">:country</span>]].<span class="ruby-identifier">compact</span>&#x000A; <span class="ruby-keyword kw">end</span></pre>
</div>
</div>
</div>
</div>
</div>
</div>
<div id='footer-push'></div>
</div>
<div id='footer'>
<a href="http://github.com/mislav/hanna/tree/master"><strong>Hanna</strong> RDoc template</a>
</div>
</body>
</html>
Loading

0 comments on commit b672e27

Please sign in to comment.