<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>test/app_root/db/migrate/002_migrate_has_phone_numbers_to_version_1.rb</filename>
    </added>
    <added>
      <filename>test/app_root/db/migrate/003_add_phone_number_kinds.rb</filename>
    </added>
    <added>
      <filename>test/factory.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1,9 @@
 *SVN*
 
+*0.0.3* (May 5th, 2008)
+
+* Updated documentation
+
 *0.0.2* (September 26th, 2007)
 
 * Move test fixtures out of the test application root directory</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-Copyright (c) 2006-2007 Aaron Pfeifer &amp; Neil Abraham
+Copyright (c) 2006-2008 Aaron Pfeifer
 
 Permission is hereby granted, free of charge, to any person obtaining
 a copy of this software and associated documentation files (the
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</diff>
      <filename>MIT-LICENSE</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,9 @@
 = has_phone_numbers
 
-+has_phone_numbers+ adds a base skeleton for handling phone numbers.
++has_phone_numbers+ demonstrates a reference implementation for handling phone numbers.
 
 == Resources
 
-Announcement
-
-* http://www.pluginaweek.org
-
 Wiki
 
 * http://wiki.pluginaweek.org/Has_phone_numbers
@@ -18,11 +14,11 @@ API
 
 Development
 
-* http://dev.pluginaweek.org/browser/trunk/plugins/active_record/has/has_phone_numbers
+* http://dev.pluginaweek.org/browser/trunk/has_phone_numbers
 
 Source
 
-* http://svn.pluginaweek.org/trunk/plugins/active_record/has/has_phone_numbers
+* http://svn.pluginaweek.org/trunk/has_phone_numbers
 
 == Description
 
@@ -33,34 +29,23 @@ Support for international formats may be added in the future.
 
 == Usage 
 
-=== Running migrations
-
-To migrate the tables required for this plugin, you can either run the
-migration from the command line like so:
-
-  rake db:migrate:plugins PLUGIN=has_phone_numbers
+Note that this is a reference implementation and, most likely, should be
+modified for your own usage.
 
-or (more ideally) generate a migration file that will integrate into your main
-application's migration path:
+=== Example
 
-  ruby script/generate plugin_migration has_phone_numbers
+  phone_number = Phone_number.new(
+    :country_code =&gt; '1',
+    :number =&gt; '1234567890',
+    :extension =&gt; '123'
+  )
+  phone_number.to_s # =&gt; 1- 1234567890 ext. 123
 
 == Testing
 
-Before you can run any tests, the following gems must be installed:
+Before you can run any tests, the following gem must be installed:
 * plugin_test_helper[http://wiki.pluginaweek.org/Plugin_test_helper]
-* dry_validity_assertions[http://wiki.pluginaweek.org/Dry_validity_assertions]
 
 == Dependencies
 
-This plugin is a plugin+.  That means that it contains a slice of an
-application, such as models and migrations.  To test or use a plugin+, you
-must have the following plugins/gems installed:
-* plugin_dependencies[http://wiki.pluginaweek.org/Plugin_dependencies]
-* loaded_plugins[http://wiki.pluginaweek.org/Loaded_plugins]
-* appable_plugins[http://wiki.pluginaweek.org/Appable_plugins]
-* plugin_migrations[http://wiki.pluginaweek.org/Plugin_migrations]
-
-Instead of installing each individual plugin+ feature, you can install them all
-at once using the plugins+[http://wiki.pluginaweek.org/Plugins_plus] meta package,
-which contains all additional features.
+* plugins_plus[http://wiki.pluginaweek.org/Plugins_plus]</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@ require 'rake/gempackagetask'
 require 'rake/contrib/sshpublisher'
 
 PKG_NAME           = 'has_phone_numbers'
-PKG_VERSION        = '0.0.2'
+PKG_VERSION        = '0.0.3'
 PKG_FILE_NAME      = &quot;#{PKG_NAME}-#{PKG_VERSION}&quot;
 RUBY_FORGE_PROJECT = 'pluginaweek'
 
@@ -31,7 +31,7 @@ spec = Gem::Specification.new do |s|
   s.name            = PKG_NAME
   s.version         = PKG_VERSION
   s.platform        = Gem::Platform::RUBY
-  s.summary         = 'Adds a base skeleton for handling phone numbers.'
+  s.summary         = 'Demonstrates a reference implementation for handling phone numbers.'
   
   s.files           = FileList['{app,db,lib,test}/**/*'].to_a + %w(CHANGELOG init.rb MIT-LICENSE Rakefile README)
   s.require_path    = 'lib'
@@ -39,7 +39,7 @@ spec = Gem::Specification.new do |s|
   s.has_rdoc        = true
   s.test_files      = Dir['test/**/*_test.rb']
   
-  s.author          = 'Aaron Pfeifer, Neil Abraham'
+  s.author          = 'Aaron Pfeifer'
   s.email           = 'info@pluginaweek.org'
   s.homepage        = 'http://www.pluginaweek.org'
 end</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -3,22 +3,21 @@ class PhoneNumber &lt; ActiveRecord::Base
   belongs_to  :phoneable,
                 :polymorphic =&gt; true
   
-  validates_presence_of :phoneable_id,
-                        :phoneable_type,
-                        :country_code,
-                        :number
-  
-  with_options(:allow_nil =&gt; true) do |klass|
-    klass.validates_numericality_of :country_code,
-                                    :number,
-                                    :extension
-    klass.validates_length_of       :country_code,
-                                      :in =&gt; 1..3
-    klass.validates_length_of       :number,
-                                      :is =&gt; 10
-    klass.validates_length_of       :extension,
-                                      :maximum =&gt; 10
-  end
+  validates_presence_of     :phoneable_id,
+                            :phoneable_type,
+                            :country_code,
+                            :number
+  validates_numericality_of :country_code,
+                            :number
+  validates_numericality_of :extension,
+                              :allow_nil =&gt; true
+  validates_length_of       :country_code,
+                              :in =&gt; 1..3
+  validates_length_of       :number,
+                              :is =&gt; 10
+  validates_length_of       :extension,
+                              :maximum =&gt; 10,
+                              :allow_nil =&gt; true
   
   def to_s #:nodoc
     human_number = &quot;#{country_code}- #{number}&quot;</diff>
      <filename>app/models/phone_number.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,14 +1,11 @@
 class CreatePhoneNumbers &lt; ActiveRecord::Migration
   def self.up
     create_table :phone_numbers do |t|
-      t.column :phoneable_id, :integer, :null =&gt; false, :references =&gt; nil
-      t.column :phoneable_type, :string, :null =&gt; false
-      # Default is the United States
-      t.column :country_code, :string, :null =&gt; false, :limit =&gt; 3, :default =&gt; 1
-      t.column :number, :string, :null =&gt; false, :limit =&gt; 12
-      t.column :extension, :string, :limit =&gt; 10
-      t.column :created_at, :timestamp, :null =&gt; false            
-      t.column :updated_at, :datetime, :null =&gt; false
+      t.references :phoneable, :polymorphic =&gt; true, :null =&gt; false
+      t.string :country_code, :null =&gt; false, :limit =&gt; 3, :default =&gt; 1 # Default is the United States
+      t.string :number, :null =&gt; false, :limit =&gt; 12
+      t.string :extension, :limit =&gt; 10
+      t.timestamps
     end
   end
   </diff>
      <filename>db/migrate/001_create_phone_numbers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1 +1 @@
-require 'has_phone_numbers'
\ No newline at end of file
+require 'has_phone_numbers'</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,69 +1,22 @@
 module PluginAWeek #:nodoc:
-  module Has #:nodoc:
-    # Adds base models, with minimal attribute definitions, for interacting with
-    # phone numbers.
-    module PhoneNumbers
-      def self.included(base) #:nodoc:
-        base.extend(MacroMethods)
+  # Adds a generic implementation for dealing with phone numbers
+  module HasPhoneNumbers
+    def self.included(base) #:nodoc:
+      base.class_eval do
+        extend PluginAWeek::HasPhoneNumbers::MacroMethods
       end
-      
-      module MacroMethods
-        # Creates a new association for having a single phone number.  This
-        # takes the same parameters as +has_one+.  By default, the following
-        # associations are the same:
-        # 
-        #   class Person &lt; ActiveRecord::Base
-        #     has_phone_number
-        #   end
-        # 
-        # and
-        # 
-        #   class Person &lt; ActiveRecord::Base
-        #     has_one :phone_number,
-        #               :class_name =&gt; 'PhoneNumber',
-        #               :as =&gt; :phoneable,
-        #               :dependent =&gt; :destroy
-        #   end
-        def has_phone_number(*args, &amp;extension)
-          create_phone_number_association(:one, :phone_number, *args, &amp;extension)
-        end
-        
-        # Creates a new association for having a multiple phone numbers.  This
-        # takes the same parameters as +has_many+.  By default, the following
-        # associations are the same:
-        # 
-        #   class Person &lt; ActiveRecord::Base
-        #     has_phone_numbers
-        #   end
-        # 
-        # and
-        # 
-        #   class Person &lt; ActiveRecord::Base
-        #     has_many  :phone_numbers,
-        #                 :class_name =&gt; 'PhoneNumber',
-        #                 :as =&gt; :phoneable,
-        #                 :dependent =&gt; :destroy
-        #   end
-        def has_phone_numbers(*args, &amp;extension)
-          create_phone_number_association(:many, :phone_numbers, *args, &amp;extension)
-        end
-        
-        private
-        def create_phone_number_association(cardinality, association_id, *args, &amp;extension)
-          options = extract_options_from_args!(args)
-          options.symbolize_keys!.reverse_merge!(
-            :class_name =&gt; 'PhoneNumber',
-            :as =&gt; :phoneable,
-            :dependent =&gt; :destroy
-          )
-          
-          send(&quot;has_#{cardinality}&quot;, args.first || association_id, options, &amp;extension)
-        end
+    end
+    
+    module MacroMethods
+      # Creates the following association:
+      # * +phone_number+ - All phone numbers associated with the current record.
+      def has_addresses
+        has_many  :phone_numbers
       end
     end
   end
 end
 
 ActiveRecord::Base.class_eval do
-  include PluginAWeek::Has::PhoneNumbers
+  include PluginAWeek::HasPhoneNumbers
 end</diff>
      <filename>lib/has_phone_numbers.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,9 @@
 class Person &lt; ActiveRecord::Base
-  has_phone_number  :cell_phone,
-                      :conditions =&gt; ['phone_numbers.kind = ?', 'cell']
-  has_phone_number  :work_phone,
-                      :conditions =&gt; ['phone_numbers.kind = ?', 'work']
-  has_phone_numbers :phone_numbers
-end
\ No newline at end of file
+  has_one   :cell_phone,
+              :class_name =&gt; 'PhoneNumber',
+              :conditions =&gt; {:kind =&gt; 'cell'}
+  has_one   :work_phone,
+              :class_name =&gt; 'PhoneNumber',
+              :conditions =&gt; {:kind =&gt; 'work'}
+  has_many  :phone_numbers
+end</diff>
      <filename>test/app_root/app/models/person.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,25 +1,9 @@
 require 'config/boot'
-
-$:.unshift(&quot;#{RAILS_ROOT}/../../../../../rails/plugin_dependencies/lib&quot;)
-begin
-  require 'plugin_dependencies'
-rescue Exception =&gt; e
-end
+require &quot;#{File.dirname(__FILE__)}/../../../../plugins_plus/boot&quot;
 
 Rails::Initializer.run do |config|
-  config.plugin_paths.concat([
-    &quot;#{RAILS_ROOT}/../../..&quot;,
-    &quot;#{RAILS_ROOT}/../../../../migrations&quot;,
-    &quot;#{RAILS_ROOT}/../../../../../rails&quot;,
-    &quot;#{RAILS_ROOT}/../../../../../test&quot;
-  ])
-  config.plugins = [
-    'loaded_plugins',
-    'appable_plugins',
-    'plugin_migrations',
-    File.basename(File.expand_path(&quot;#{RAILS_ROOT}/../..&quot;)),
-    'dry_validity_assertions'
-  ]
+  config.plugin_paths &lt;&lt; '..'
+  config.plugins = %w(plugins_plus has_phone_numbers)
   config.cache_classes = false
   config.whiny_nils = true
 end</diff>
      <filename>test/app_root/config/environment.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,7 @@
 class CreatePeople &lt; ActiveRecord::Migration
   def self.up
     create_table :people do |t|
-      t.column :name, :string
+      t.string :name
     end
   end
   </diff>
      <filename>test/app_root/db/migrate/001_create_people.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,13 @@
 # Load the plugin testing framework
-$:.unshift(&quot;#{File.dirname(__FILE__)}/../../../../test/plugin_test_helper/lib&quot;)
+$:.unshift(&quot;#{File.dirname(__FILE__)}/../../plugin_test_helper/lib&quot;)
 require 'rubygems'
 require 'plugin_test_helper'
 
-PluginAWeek::PluginMigrations.migrate('has_phone_numbers')
-
 # Run the migrations
 ActiveRecord::Migrator.migrate(&quot;#{RAILS_ROOT}/db/migrate&quot;)
+
+# Mixin the factory helper
+require File.expand_path(&quot;#{File.dirname(__FILE__)}/factory&quot;)
+class Test::Unit::TestCase #:nodoc:
+  include Factory
+end</diff>
      <filename>test/test_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,63 +1,149 @@
 require File.dirname(__FILE__) + '/../test_helper'
 
-class PhoneNumberTest &lt; Test::Unit::TestCase
-  fixtures :phone_numbers
+class PhoneNumberByDefaultTest &lt; Test::Unit::TestCase
+  def setup
+    @phone_number = PhoneNumber.new
+  end
+  
+  def test_should_not_have_a_phoneable_id
+    assert_nil @phone_number.phoneable_id
+  end
+  
+  def test_should_not_have_a_phoneable_type
+    assert @phone_number.phoneable_type.blank?
+  end
   
-  def test_should_be_valid
-    assert_valid phone_numbers(:cell)
+  def test_should_a_united_states_country_code
+    assert_equal '1', @phone_number.country_code
   end
   
-  def test_should_require_phoneable_id
-    assert_invalid phone_numbers(:cell), 'phoneable_id', nil
+  def test_should_not_have_a_number
+    assert @phone_number.number.blank?
+  end
+  
+  def test_should_not_have_an_extension
+    assert @phone_number.extension.blank?
+  end
+end
+
+class PhoneNumberTest &lt; Test::Unit::TestCase
+  def test_should_be_valid_with_a_set_of_valid_attributes
+    phone_number = new_phone_number
+    assert phone_number.valid?
   end
   
-  def test_should_require_phoneable_type
-    assert_invalid phone_numbers(:cell), 'phoneable_type', nil
+  def test_should_require_a_phoneable_id
+    phone_number = new_phone_number(:phoneable_id =&gt; nil)
+    assert !phone_number.valid?
+    assert_equal 1, Array(phone_number.errors.on(:phoneable_id)).size
   end
   
-  def test_should_require_country_code
-    assert_invalid phone_numbers(:cell), 'country_code', nil
+  def test_should_require_a_phoneable_type
+    phone_number = new_phone_number(:phoneable_type =&gt; nil)
+    assert !phone_number.valid?
+    assert_equal 1, Array(phone_number.errors.on(:phoneable_type)).size
   end
   
-  def test_should_require_number
-    assert_invalid phone_numbers(:cell), 'number', nil
+  def test_should_require_a_country_code
+    phone_number = new_phone_number(:country_code =&gt; nil)
+    assert !phone_number.valid?
+    assert_equal 3, Array(phone_number.errors.on(:country_code)).size
   end
   
   def test_should_require_country_code_be_a_number
-    assert_invalid phone_numbers(:cell), 'country_code', 'invalid', '123invalid'
+    phone_number = new_phone_number(:country_code =&gt; 'a')
+    assert !phone_number.valid?
+    assert_equal 1, Array(phone_number.errors.on(:country_code)).size
+  end
+  
+  def test_should_require_country_codes_be_between_1_and_3_numbers
+    phone_number = new_phone_number(:country_code =&gt; '')
+    assert !phone_number.valid?
+    assert_equal 3, Array(phone_number.errors.on(:country_code)).size
+    
+    phone_number.country_code += '1'
+    assert phone_number.valid?
+    
+    phone_number.country_code += '11'
+    assert phone_number.valid?
+    
+    phone_number.country_code += '1'
+    assert !phone_number.valid?
+    assert_equal 1, Array(phone_number.errors.on(:country_code)).size
+  end
+  
+  def test_should_require_a_number
+    phone_number = new_phone_number(:number =&gt; nil)
+    assert !phone_number.valid?
+    assert_equal 3, Array(phone_number.errors.on(:number)).size
   end
   
   def test_should_require_number_be_a_number
-    assert_invalid phone_numbers(:cell), 'number', 'invalid', '123invalid'
+    phone_number = new_phone_number(:number =&gt; 'a' * 10)
+    assert !phone_number.valid?
+    assert_equal 1, Array(phone_number.errors.on(:number)).size
   end
   
-  def test_should_require_extension_be_a_number
-    assert_invalid phone_numbers(:cell), 'extension', 'invalid', '123invalid'
+  def test_should_require_number_be_exactly_10_numbers
+    phone_number = new_phone_number(:number =&gt; '1' * 9)
+    assert !phone_number.valid?
+    assert_equal 1, Array(phone_number.errors.on(:number)).size
+    
+    phone_number.number += '1'
+    assert phone_number.valid?
+    
+    phone_number.number += '1'
+    assert !phone_number.valid?
+    assert_equal 1, Array(phone_number.errors.on(:number)).size
   end
   
-  def test_should_restrict_country_code_length
-    assert_invalid phone_numbers(:cell), 'extension', 'invalid', '123invalid'
+  def test_should_not_require_an_extension
+    phone_number = new_phone_number(:extension =&gt; nil)
+    assert phone_number.valid?
   end
   
-  def test_should_restrict_number_length
-    assert_invalid phone_numbers(:cell), 'number', '123', '12345678901'
-    assert_valid phone_numbers(:cell), 'number', '1234567890'
+  def test_should_require_extension_be_at_most_10_numbers
+    phone_number = new_phone_number(:extension =&gt; '1' * 9)
+    assert phone_number.valid?
+    
+    phone_number.extension += '1'
+    assert phone_number.valid?
+    
+    phone_number.extension += '1'
+    assert !phone_number.valid?
+    assert_equal 1, Array(phone_number.errors.on(:extension)).size
+  end
+end
+
+class PhoneNumberAfterBeingCreatedTest &lt; Test::Unit::TestCase
+  def setup
+    @person = create_person
+    @phone_number = create_phone_number(:phoneable =&gt; @person, :country_code =&gt; '1', :number =&gt; '1234567890')
   end
   
-  def test_should_restrict_extension_length
-    assert_invalid phone_numbers(:cell), 'extension', '12345678901'
-    assert_valid phone_numbers(:cell), 'extension', '1', '123', '1234567890'
+  def test_should_record_when_it_was_created
+    assert_not_nil @phone_number.created_at
   end
   
-  def test_should_allow_phoneable_to_be_of_any_type
-    assert_valid phone_numbers(:cell), 'phoneable_type', 'House', 'Person'
+  def test_should_record_when_it_was_updated
+    assert_not_nil @phone_number.updated_at
+  end
+  
+  def test_should_have_a_phoneable_association
+    assert_equal @person, @phone_number.phoneable
   end
   
   def test_should_generate_stringified_version_of_phone_number
-    assert_equal '1- 1234567890', phone_numbers(:cell).to_s
+    assert_equal '1- 1234567890', @phone_number.to_s
+  end
+end
+
+class PhoneNumberWithExtensionTest &lt; Test::Unit::TestCase
+  def setup
+    @phone_number = create_phone_number(:country_code =&gt; '1', :number =&gt; '1234567890', :extension =&gt; '123')
   end
   
-  def test_should_generate_stringified_version_of_phone_number_with_extension
-    assert_equal '1- 1234567891 ext. 123', phone_numbers(:work).to_s
+  def test_should_generate_stringified_version_of_phone_number
+    assert_equal '1- 1234567890 ext. 123', @phone_number.to_s
   end
-end
\ No newline at end of file
+end</diff>
      <filename>test/unit/phone_number_test.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>test/app_root/db/migrate/002_add_phone_number_kinds.rb</filename>
    </removed>
    <removed>
      <filename>test/fixtures/people.yml</filename>
    </removed>
    <removed>
      <filename>test/fixtures/phone_numbers.yml</filename>
    </removed>
    <removed>
      <filename>test/unit/has_phone_numbers_test.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>b54165903e1559190ac061c74fcb9664450d0883</id>
    </parent>
  </parents>
  <author>
    <name>Aaron Pfeifer</name>
    <email>aaron.pfeifer@gmail.com</email>
  </author>
  <url>http://github.com/pluginaweek/has_phone_numbers/commit/4e05f71249e4926f6bc22861a261616e27ee05cc</url>
  <id>4e05f71249e4926f6bc22861a261616e27ee05cc</id>
  <committed-date>2008-05-04T16:00:19-07:00</committed-date>
  <authored-date>2008-05-04T16:00:19-07:00</authored-date>
  <message>Updated documentation</message>
  <tree>fdeee14560f30219f6f34971f74f93ebea78dafc</tree>
  <committer>
    <name>Aaron Pfeifer</name>
    <email>aaron.pfeifer@gmail.com</email>
  </committer>
</commit>
