<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>.autotest</filename>
    </added>
    <added>
      <filename>README.rdoc</filename>
    </added>
    <added>
      <filename>spec/helper.rb</filename>
    </added>
    <added>
      <filename>spec/spec.opts</filename>
    </added>
    <added>
      <filename>spec/stateful/builders/event_spec.rb</filename>
    </added>
    <added>
      <filename>spec/stateful/builders/machine_spec.rb</filename>
    </added>
    <added>
      <filename>spec/stateful/event_spec.rb</filename>
    </added>
    <added>
      <filename>spec/stateful/listeners_spec.rb</filename>
    </added>
    <added>
      <filename>spec/stateful/machine_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,9 +1,56 @@
+require &quot;date&quot;
+require &quot;fileutils&quot;
 require &quot;rubygems&quot;
-require &quot;hoe&quot;
+require &quot;rake/gempackagetask&quot;
+require &quot;spec/rake/spectask&quot;
 
 require &quot;./lib/stateful/version.rb&quot;
 
-Hoe.new(&quot;stateful&quot;, Stateful::VERSION) do |p|
-  p.developer(&quot;John Barnette&quot;, &quot;jbarnette@rubyforge.org&quot;)
-  p.test_globs = [&quot;test/**/*_test.rb&quot;]
+stateful_gemspec = Gem::Specification.new do |s|
+  s.name             = &quot;stateful&quot;
+  s.version          = Stateful::VERSION
+  s.platform         = Gem::Platform::RUBY
+  s.has_rdoc         = true
+  s.extra_rdoc_files = [&quot;README.rdoc&quot;]
+  s.summary          = &quot;Make your Ruby objects stately.&quot;
+  s.description      = s.summary
+  s.author           = &quot;John Barnette&quot;
+  s.email            = &quot;jbarnette@rubyforge.org&quot;
+  s.homepage         = &quot;http://github.com/jbarnette/stateful&quot;
+  s.require_path     = &quot;lib&quot;
+  s.autorequire      = &quot;stateful&quot;
+  s.files            = %w(README.rdoc Rakefile) + Dir.glob(&quot;{lib,spec}/**/*&quot;)
+  
+  # Uncomment this to add a dependency
+  # s.add_dependency &quot;foo&quot;
 end
+
+Rake::GemPackageTask.new(stateful_gemspec) do |pkg|
+  pkg.gem_spec = stateful_gemspec
+end
+
+namespace :gem do
+  task :install =&gt; :package do
+    sh %{sudo gem install --local pkg/stateful-#{Stateful::VERSION}}
+  end
+  
+  namespace :spec do
+    desc &quot;Update stateful.gemspec&quot;
+    task :generate do
+      File.open(&quot;stateful.gemspec&quot;, &quot;w&quot;) do |f|
+        f.puts(stateful_gemspec.to_ruby)
+      end
+    end
+  end
+end
+
+desc &quot;Run all specs&quot;
+Spec::Rake::SpecTask.new do |t|
+  t.spec_files = FileList[&quot;spec/**/*_spec.rb&quot;]
+  t.spec_opts = [&quot;--options&quot;, &quot;spec/spec.opts&quot;]
+end
+
+task :default =&gt; :spec
+
+desc &quot;Remove all generated artifacts&quot;
+task :clean =&gt; :clobber_package</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -9,18 +9,18 @@ require &quot;stateful/persisters/default&quot;
 class Class
   def statefully(options={}, &amp;block)
     unless stateful?
-      @stateful = Stateful::Machine.new
+      @machine = Stateful::Machine.new
       include Stateful::Persisters::Default
     end
 
-    return @stateful if options.empty? &amp;&amp; !block_given?    
+    return @machine if options.empty? &amp;&amp; !block_given?
 
-    @stateful.apply(options, &amp;block)
-    @stateful.accessorize(self)
-    @stateful
+    @machine.apply(options, &amp;block)
+    @machine.accessorize(self)
+    @machine
   end
-  
+
   def stateful?
-    defined?(@stateful)
+    defined?(@machine)
   end
 end</diff>
      <filename>lib/stateful.rb</filename>
    </modified>
    <modified>
      <diff>@@ -3,6 +3,8 @@ require &quot;stateful/builders/event&quot;
 module Stateful #:nodoc:
   module Builders #:nodoc:
     class Event #:nodoc:
+      attr_accessor :parent, :event
+      
       def initialize(parent, event)
         @parent = parent
         @event = event
@@ -18,7 +20,7 @@ module Stateful #:nodoc:
         end
         
         # ensure all referenced states exist
-        pair.to_a.flatten.each { |n| @parent.state(n) }
+        pair.to_a.flatten.uniq.each { |n| @parent.state(n) }
         
         froms, to = pair.keys.first, pair.values.first
         Array(froms).each { |from| @event.transitions[from] = to }</diff>
      <filename>lib/stateful/builders/event.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,12 @@
 require &quot;stateful/builders/event&quot;
+require &quot;stateful/event&quot;
+require &quot;stateful/state&quot;
 
 module Stateful #:nodoc:
   module Builders #:nodoc:
     class Machine #:nodoc:
+      attr_reader :machine
+      
       def initialize(machine)
         @machine = machine
       end
@@ -38,8 +42,8 @@ module Stateful #:nodoc:
         kinds.each do |kind|
           class_eval &lt;&lt;-END, __FILE__, __LINE__
             def #{kind}(*names, &amp;block)
-              @machine.listeners(#{kind.inspect}) &lt;&lt; block if names.empty?
-              names.each { |n| #{source}(n).listeners(#{kind.inspect}) &lt;&lt; block }
+              @machine.listeners[#{kind.inspect}] &lt;&lt; block if names.empty?
+              names.each { |n| #{source}(n).listeners[#{kind.inspect}] &lt;&lt; block }
             end
           END
         end</diff>
      <filename>lib/stateful/builders/machine.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,12 +1,11 @@
 module Stateful #:nodoc:
   module Listeners #:nodoc:
-    def listeners(kind)
+    def listeners
       @listeners ||= Hash.new { |h,k| h[k] = [] }
-      @listeners[kind]
     end
     
     def fire(kind, *args)
-      listeners(kind).each { |l| l.call(*args) }
+      listeners[kind].each { |l| l[*args] }
     end
   end
 end</diff>
      <filename>lib/stateful/listeners.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,21 +22,21 @@ module Stateful
     def accessorize(target)
       @states.keys.each do |name|
         unless target.method_defined?(&quot;#{name}?&quot;)
-          target.class_eval &lt;&lt;-END, __FILE__, __LINE__
+          target.class_eval &lt;&lt;-RUBY
             def #{name}?
               current_state == #{name.inspect}
             end
-          END
+          RUBY
         end
       end
       
       @events.keys.each do |name|
         unless target.method_defined?(&quot;#{name}!&quot;)
-          target.class_eval &lt;&lt;-END, __FILE__, __LINE__
+          target.class_eval &lt;&lt;-RUBY
             def #{name}!
               self.class.statefully.execute(self, #{name.inspect})
             end
-          END
+          RUBY
         end
       end
     end
@@ -51,20 +51,20 @@ module Stateful
       to    = states[dest] or raise StateNotFound.new(dest)
       args  = model, event.name, to.name, from.name
       
-      multifire(event, :firing, args)
-      multifire(from, :exiting, args)
-      multifire(to, :entering, args)
+      fire(event, :firing, args)
+      fire(from, :exiting, args)
+      fire(to, :entering, args)
       
       model.current_state = to.name
       
-      multifire(to, :entered, args)
-      multifire(event, :fired, args)
+      fire(to, :entered, args)
+      fire(event, :fired, args)
     end
     
     private
     
-    def multifire(target, event_name, args)
-      fire(event_name, *args) # first fire the global listeners,
+    def fire(target, event_name, args)
+      super(event_name, *args) # first fire the global listeners,
       target.fire(event_name, *args) # then the ones for a specific state/event
     end
   end</diff>
      <filename>lib/stateful/machine.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,18 +2,18 @@ module Stateful
   module Persisters
     module Default
       def self.included(target)
-        unless target.method_defined?(:current_state)
-          target.class_eval &lt;&lt;-END, __FILE__, __LINE__
+        unless target.respond_to?(:current_state)
+          target.class_eval &lt;&lt;-RUBY
             def current_state
               @current_state ||= self.class.statefully.start
             end
-          END
+          RUBY
         end
         
-        unless target.method_defined?(:current_state=)
-          target.class_eval &lt;&lt;-END, __FILE__, __LINE__
+        unless target.respond_to?(:current_state=)
+          target.class_eval &lt;&lt;-RUBY
             attr_writer :current_state
-          END
+          RUBY
         end
       end
     end</diff>
      <filename>lib/stateful/persisters/default.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>History.txt</filename>
    </removed>
    <removed>
      <filename>Manifest.txt</filename>
    </removed>
    <removed>
      <filename>README.txt</filename>
    </removed>
    <removed>
      <filename>test/helper.rb</filename>
    </removed>
    <removed>
      <filename>test/stateful/machine_test.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>91e16b164957bd818bf1b3d8e56128060b498111</id>
    </parent>
  </parents>
  <author>
    <name>John Barnette</name>
    <email>jbarnette@gmail.com</email>
  </author>
  <url>http://github.com/jbarnette/stateful/commit/b5203b2321942b3c4f592d6b22e3b814e6db5bb3</url>
  <id>b5203b2321942b3c4f592d6b22e3b814e6db5bb3</id>
  <committed-date>2008-07-03T13:31:55-07:00</committed-date>
  <authored-date>2008-07-03T13:31:55-07:00</authored-date>
  <message>Autotestify, RSpecify, and unhoe.</message>
  <tree>e30f66c69af20afdeb1c4d208e29b1342c28fd5d</tree>
  <committer>
    <name>John Barnette</name>
    <email>jbarnette@gmail.com</email>
  </committer>
</commit>
