<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.aaronpfeifer.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>PluginAWeek</title>
	
	<link>http://www.pluginaweek.org</link>
	<description>Plugins worth their weight in rubies.</description>
	<lastBuildDate>Mon, 19 Apr 2010 11:00:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.aaronpfeifer.com/PluginAWeek" /><feedburner:info uri="pluginaweek" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>state_machine 0.9.0: Locked and loaded</title>
		<link>http://feeds.aaronpfeifer.com/~r/PluginAWeek/~3/zdNarq6jFFw/</link>
		<comments>http://www.pluginaweek.org/2010/04/19/state_machine-0-9-0-locked-and-loaded/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 11:00:06 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[arewethereyet]]></category>
		<category><![CDATA[iknowkungfu]]></category>
		<category><![CDATA[state machine]]></category>
		<category><![CDATA[whoa]]></category>

		<guid isPermaLink="false">http://www.pluginaweek.org/?p=309</guid>
		<description><![CDATA[I&#8216;ve decided the only way to go viral is to get a cat to use state_machine. I&#8217;m just having a hard time getting past that whole &#8220;cats can&#8217;t program&#8221; thing&#8230; so blogging it is! Last week, state_machine 0.9.0 was tagged after a month&#8217;s worth of active development. This is a major milestone that I&#8217;m really [...]]]></description>
			<content:encoded><![CDATA[<img class="left" src="http://www.pluginaweek.org/wp-content/uploads/2010/04/trinity.jpg" title="Trinity" style="display: inline; float: left; margin: 0; padding: 4px 10px 10px 0;" /><p><span class="first_letter">I</span>&#8216;ve decided the only way to go viral is to get <a href="http://www.youtube.com/watch?v=Q9NP-AeKX40">a cat</a> to use state_machine.  I&#8217;m just having a hard time getting past that whole &#8220;cats can&#8217;t program&#8221; thing&#8230; so blogging it is!  Last week, state_machine 0.9.0 was <a href="http://github.com/pluginaweek/state_machine/tree/v0.9.0">tagged</a> after a month&#8217;s worth of active development.  This is a major milestone that I&#8217;m really excited to share with all of you.</p>
<p><strong>If you can dodge a bullet, you can dodge a ball.  Wait, what?</strong></p>
<p>If you&#8217;ve been following the project for a while, you&#8217;ll know that I only bump major versions when there are significant changes in either the public API or the feature set.  Fortunately, this release comes loaded with a bunch of new features (and some fixes) that I hope you&#8217;ll all enjoy:</p>
<ul>
<li>MongoMapper 0.5.5+ integration support</li>
<li>ActiveModel 3.0.0+ integration support (extracted from ActiveRecord)</li>
<li>DataMapper 0.10.3+ support</li>
<li>around_transition callbacks (supplements before/after callbacks)</li>
<li>Rails 3 railtie integration</li>
<li>Consolidated rake tasks</li>
<li>Unified API for event / attribute transitions</li>
<li>&#8230;and 7 bug fixes</li>
</ul>
<p>To me, the most interesting part of this release has been building support for around_transition callbacks.  Here&#8217;s a basic example of its usage:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span class="kw1">class</span> Vehicle <span class="sy0">&lt;</span> <span class="re2">ActiveRecord::Base</span>
  state_machine <span class="re3">:initial</span> <span class="sy0">=&gt;</span> <span class="re3">:parked</span> <span class="kw1">do</span>
    around_transition <span class="re3">:on</span> <span class="sy0">=&gt;</span> <span class="re3">:ignite</span>, <span class="re3">:do</span> <span class="sy0">=&gt;</span> <span class="re3">:benchmark</span>
    event <span class="re3">:ignite</span> <span class="kw1">do</span>
      transition <span class="re3">:parked</span> <span class="sy0">=&gt;</span> <span class="re3">:first_gear</span>
    <span class="kw1">end</span>
  <span class="kw1">end</span>
&nbsp;
  <span class="kw1">def</span> benchmark
    <span class="kw3">puts</span> <span class="st0">&quot;...starting benchmark&quot;</span>
    time = <span class="kw4">Benchmark</span>.<span class="me1">measure</span> <span class="br0">&#123;</span> <span class="kw1">yield</span> <span class="br0">&#125;</span>
    <span class="kw3">puts</span> <span class="st0">&quot;...completed in: #{time.real}&quot;</span>
  <span class="kw1">end</span>
<span class="kw1">end</span>
&nbsp;
v = Vehicle.<span class="me1">new</span>
v.<span class="me1">ignite</span>
<span class="co1"># ...starting benchmark</span>
<span class="co1"># ...completed in: 0.0642118453979492</span>
v.<span class="me1">state</span> <span class="co1"># =&gt; &quot;idling&quot;</span>
&nbsp;
v = Vehicle.<span class="me1">new</span><span class="br0">&#40;</span><span class="re3">:state_event</span> <span class="sy0">=&gt;</span> <span class="st0">'ignite'</span><span class="br0">&#41;</span>
v.<span class="me1">valid</span>?
<span class="co1"># ...starting benchmark</span>
v.<span class="me1">state</span> <span class="co1"># =&gt; &quot;idling&quot;</span>
<span class="kw3">sleep</span> <span class="nu0">1</span>
v.<span class="me1">save</span>
<span class="co1"># ...completed in: 1.00799298286438</span></pre></div></div>

<p>See the full list of changes <a href="http://github.com/pluginaweek/state_machine/blob/v0.9.0/CHANGELOG.rdoc">here</a>.</p>
<p><strong>I can only show you the door&#8230; unfortunately, it&#8217;s locked.</strong></p>
<p>Besides addition of the above features, 0.9.0 is also a significant milestone as it marks the beginning of feature lockdown on state_machine.  All future changes will be primarily for maintenance means (fixing bugs, compatibility with releases of integrated ORMs, etc.).  This is the final push to get to an official 1.0.0 release.</p>
<p>However, <strong>I need your help</strong> to get to 1.0.0.  If you encounter bugs in any part of the code or see any issues with the documentation, <em>now</em> is the time to <a href="http://pluginaweek.lighthouseapp.com/projects/13288-state_machine/tickets/new">report them</a>.</p>
<p>Otherwise, enjoy this release <img src='http://www.pluginaweek.org/wp-content/plugins/smilies-themer/adiumicons/happy.png' alt=':)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/PluginAWeek/~4/zdNarq6jFFw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.pluginaweek.org/2010/04/19/state_machine-0-9-0-locked-and-loaded/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.pluginaweek.org/2010/04/19/state_machine-0-9-0-locked-and-loaded/</feedburner:origLink></item>
		<item>
		<title>state_machine 0.8.1: The Ocho</title>
		<link>http://feeds.aaronpfeifer.com/~r/PluginAWeek/~3/wqM3IZTWLbY/</link>
		<comments>http://www.pluginaweek.org/2010/03/15/state_machine-0-8-1-the-ocho/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 04:00:16 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[eye of the tiger]]></category>
		<category><![CDATA[ocho]]></category>
		<category><![CDATA[pi]]></category>
		<category><![CDATA[state machine]]></category>

		<guid isPermaLink="false">http://www.pluginaweek.org/?p=264</guid>
		<description><![CDATA[If you had asked me 6 months ago when the next release of state_machine was going to be, Pi Day 2010 would probably not have been my first guess. If it had been, I probably would have asked you to admit me into a hospital so I could be treated for delirium. Then again, what [...]]]></description>
			<content:encoded><![CDATA[<img class="left" src="http://www.pluginaweek.org/wp-content/uploads/2010/03/rocky.png" title="Rocky" style="display: inline; float: left; margin: 0; padding: 4px 10px 10px 0;" /><p><span class="first_letter">I</span>f you had asked me 6 months ago when the next release of <a href="http://github.com/pluginaweek/state_machine">state_machine</a> was going to be, Pi Day 2010 would probably not have been my first guess.  If it had been, I probably would have asked you to admit me into a hospital so I could be treated for delirium.  Then again, what better way to celebrate such an important holiday?</p>
<p><strong>Be a thinker, not a stinker. Or at least take a shower. Seriously.</strong></p>
<p>Without further ado, I am excited to announce the release of <a href="http://github.com/pluginaweek/state_machine/tree/v0.8.1">state_machine 0.8.1</a>.  This is the most stable, feature-rich release yet.  Given that I never officially announced the 0.8.0 release 6 months ago, below is a brief overview of everything that comes with the Ocho package:</p>
<ul>
<li>ActiveRecord 2.0 and 3.0 support (Rails 3 users, rejoice!)</li>
<li>DataMapper 0.10 support</li>
<li>ruby-graphviz 0.9 support</li>
<li>Full compatibility with ORM dirty attribute tracking</li>
<li>Default state-driven behaviors</li>
<li>More control over whether after_transition callbacks get run after failed actions</li>
<li>Define multiple callbacks in a single before/after_transition call</li>
<li>ActiveRecord i18n support for state / event names</li>
<li>Query available state transitions with :from / :to / :on requirements</li>
<li>Earlier access to initial states during the initialization of an object</li>
<li>&#8230;and 20 bug fixes!</li>
</ul>
<p>Here&#8217;s a very small bit of code demonstrating some of the visibily new features:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span class="kw1">class</span> Vehicle
  <span class="kw1">include</span> <span class="re2">DataMapper::Resource</span>
&nbsp;
  property <span class="re3">:id</span>, Serial
  property <span class="re3">:state</span>, <span class="re3">:String</span>
&nbsp;
  state_machine <span class="kw1">do</span>
    before_transition all <span class="sy0">=&gt;</span> <span class="re3">:parked</span>, <span class="re3">:do</span> <span class="sy0">=&gt;</span> <span class="br0">&#91;</span><span class="re3">:set_alarm</span>, <span class="re3">:lock_doors</span><span class="br0">&#93;</span>
    after_transition <span class="re3">:do</span> <span class="sy0">=&gt;</span> <span class="re3">:log_transition</span>, <span class="re3">:include_failures</span> <span class="sy0">=&gt;</span> <span class="kw2">true</span>
&nbsp;
    event <span class="re3">:ignite</span> <span class="br0">&#123;</span> transition <span class="re3">:parked</span> <span class="sy0">=&gt;</span> <span class="re3">:first_gear</span> <span class="br0">&#125;</span>
    event <span class="re3">:park</span> <span class="br0">&#123;</span> transition <span class="re3">:first_gear</span> <span class="sy0">=&gt;</span> <span class="re3">:parked</span> <span class="br0">&#125;</span>
&nbsp;
    state <span class="re3">:first_gear</span> <span class="kw1">do</span>
      <span class="kw1">def</span> speed
        <span class="nu0">10</span>
      <span class="kw1">end</span>
    <span class="kw1">end</span>
  <span class="kw1">end</span>
&nbsp;
  <span class="kw1">def</span> speed
    <span class="nu0">0</span>
  <span class="kw1">end</span>
<span class="kw1">end</span>
&nbsp;
vehicle = Vehicle.<span class="me1">new</span>
vehicle.<span class="me1">state_transitions</span>
vehicle.<span class="me1">state_transitions</span><span class="br0">&#40;</span><span class="re3">:to</span> <span class="sy0">=&gt;</span> <span class="re3">:parked</span><span class="br0">&#41;</span></pre></div></div>

<p>See the full list of changes (and follow the project!) <a href="http://github.com/pluginaweek/state_machine/blob/v0.8.1/CHANGELOG.rdoc">here</a>.  If you are on any other version, I <strong>strongly</strong> suggest (using &lt;strong&gt; tags, too) that you upgrade to 0.8.1.  You&#8217;ll thank me later.  Or you&#8217;ll yell at me for not releasing this earlier <img src='http://www.pluginaweek.org/wp-content/plugins/smilies-themer/adiumicons/happy.png' alt=':)' class='wp-smiley' /> </p>
<p><strong>I&#8217;d like to thank everyone at the academy who I paid off to vote for me.</strong></p>
<p>As with every release, none of this would have been possible without the help of every person who filed a bug, sent me an e-mail, made a pull request, or tried to stalk me.  The following Rubyists were particularly instrumental in putting this release together:</p>
<ul>
<li>Jeremy Wells</li>
<li>Joe Lind</li>
<li>Jon Evans</li>
<li>Sandro Turriate</li>
<li>Tim Pope</li>
</ul>
<p><strong>I didn&#8217;t hear no bell. My hearing aid must be broken.</strong></p>
<p>So where do we go from here?  The road to 1.0 has been simple for me from the get-go.  Over the past year or so, we&#8217;ve seen many Rubyists work together to standardize commonly-needed features through libraries like rack, i18n, activemodel, etc.  That was exactly the goal for state_machine 1.0&#8230; to build a standardized implementation for state machines and become the recommended implementation for at least 1 of the 3 major Ruby ORMs.  And that&#8217;s not something I can do without your help.</p>
<p>Either way, I&#8217;d love to hear feedback from the community.  What do you think the 1.0 release should be (or should include)?</p>
<p><strong>Hope you enjoyed some Pi.  Delicious, delicious 3.14159&#8230;&#8230;..</strong></p>
<img src="http://feeds.feedburner.com/~r/PluginAWeek/~4/wqM3IZTWLbY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.pluginaweek.org/2010/03/15/state_machine-0-8-1-the-ocho/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		<feedburner:origLink>http://www.pluginaweek.org/2010/03/15/state_machine-0-8-1-the-ocho/</feedburner:origLink></item>
		<item>
		<title>Visualizing Thoughtbot’s OSS Ruby Inkling markets</title>
		<link>http://feeds.aaronpfeifer.com/~r/PluginAWeek/~3/bq3dhk4PI2A/</link>
		<comments>http://www.pluginaweek.org/2009/04/11/visualizing-thoughtbots-oss-ruby-inkling-markets/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 02:06:50 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[ooo shiny!]]></category>
		<category><![CDATA[thoughtbot]]></category>

		<guid isPermaLink="false">http://www.pluginaweek.org/?p=207</guid>
		<description><![CDATA[Last month, Thoughtbot decided to enable my gambling addiction by opening up an open-source prediction market to answer all the questions that keep you up at night like: Who will win a Ruby Heroes Award at RailsConf 2009? Which RESTful controller project should I use? Which state machine project should I use? What am I [...]]]></description>
			<content:encoded><![CDATA[<img class="left" src="http://www.pluginaweek.org/wp-content/uploads/2009/04/graph.jpg" title="Graph" style="display: inline; float: left; margin: 0; padding: 4px 10px 10px 0;" /><p><span class="first_letter">L</span>ast month, <a href="http://www.thoughtbot.com">Thoughtbot</a> decided to enable my gambling addiction by <a href="http://giantrobots.thoughtbot.com/2009/3/4/win-a-1295-dollar-prize">opening up</a> an open-source prediction market to answer all the questions that keep you up at night like:</p>
<ul style="list-style-position: inside;">
<li>Who will win a Ruby Heroes Award at RailsConf 2009?</li>
<li>Which RESTful controller project should I use?</li>
<li>Which state machine project should I use?</li>
<li>What am I going to wear tomorrow?</li>
</ul>
<p><strong>What gambling addiction? You play poker by betting &#8220;pretty&#8221; colors.</strong></p>
<p>To help visualize how these markets are playing out and for the obsessive compulsive, I wrote a little <a href="http://www.pluginaweek.org/wp-content/themes/pluginaweek/jquery.rubymarkets.js">jQuery plugin</a> which pulls the real-time follower data down from <a href="http://github.com">GitHub</a> and generates a Google Chart with it (it&#8217;s a hack, I&#8217;ll admit it).  Now you can see who&#8217;s the market leader faster than it takes for a flame war to start involving the words Twitter and Ruby.</p>
<p>Check it out (may take a second to load):</p>
<div id="market-examples" style="margin-bottom: 18px;">
<script>jQuery(function() { jQuery.rubyMarkets('#market-examples', ['RESTful controller', 'state machine', 'gem creation']); });</script>
</div>
<p>And all of that can be accomplished through just a little snippet of javascript:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span class="sy0">&lt;</span>script type<span class="sy0">=</span><span class="st0">'text/javascript'</span> src<span class="sy0">=</span><span class="st0">&quot;http://www.pluginaweek.org/wp-content/themes/pluginaweek/jquery.rubymarkets.js&quot;</span><span class="sy0">&gt;&lt;/</span>script<span class="sy0">&gt;</span>
jQuery<span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
  jQuery.<span class="me1">rubyMarkets</span><span class="br0">&#40;</span><span class="st0">'#market-examples'</span><span class="sy0">,</span> <span class="br0">&#91;</span>
    <span class="st0">'RESTful controller'</span><span class="sy0">,</span>
    <span class="st0">'state machine'</span><span class="sy0">,</span>
    <span class="st0">'gem creation'</span>
  <span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre></div></div>

<p><strong>I&#8217;m most intimidating if I leave my cards face up in poker. No one else thinks so.</strong></p>
<p><del datetime="2009-04-12T11:56:33+00:00">Unfortunately, it would appear as of today that Thoughtbot&#8217;s <a href="https://opensource.inklingmarkets.com">Inkling markets account</a> expired and you can no longer participate.  Fear not, I&#8217;m sure they&#8217;re aware of it.</del>  <strong>Update:</strong> <a href="https://opensource.inklingmarkets.com">The markets are back</a>.  Don&#8217;t forget, there&#8217;s a $1,295 value prize on the line for those of you making good bets.  In the meantime, you can see a full visualization of the markets (using the above plugin) and their respective leaders here:</p>
<p><a href="http://www.pluginaweek.org/oss-ruby-markets/">Open-source Ruby Prediction Markets</a></p>
<p>Feel free to embed these graphs on your own website using the plugin.  Wear your market badge proud.  Show those wall street brokers who&#8217;s boss.</p>
<img src="http://feeds.feedburner.com/~r/PluginAWeek/~4/bq3dhk4PI2A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.pluginaweek.org/2009/04/11/visualizing-thoughtbots-oss-ruby-inkling-markets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.pluginaweek.org/2009/04/11/visualizing-thoughtbots-oss-ruby-inkling-markets/</feedburner:origLink></item>
		<item>
		<title>state_machine 0.7: Better integrations, more access</title>
		<link>http://feeds.aaronpfeifer.com/~r/PluginAWeek/~3/-a-oRVhqbNU/</link>
		<comments>http://www.pluginaweek.org/2009/04/05/state_machine-07-better-integrations-more-access/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 20:30:01 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[billy mays]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[state machine]]></category>

		<guid isPermaLink="false">http://www.pluginaweek.org/?p=113</guid>
		<description><![CDATA[Fast and furious. That&#8217;s how development&#8217;s been on state_machine over the last month (and is also what happens to sequels when you run out of bad ideas). Yesterday, 0.7 was officially added to the state_machine family of releases. With this release comes better integrations, easier access to more state information, and the all new and [...]]]></description>
			<content:encoded><![CDATA[<img class="left" src="http://www.pluginaweek.org/wp-content/uploads/2009/04/pitchman.jpg" title="Pitchman" style="display: inline; float: left; margin: 0; padding: 4px 10px 10px 0;" /><p><span class="first_letter">F</span>ast and furious.  That&#8217;s how development&#8217;s been on <a href="http://github.com/pluginaweek/state_machine">state_machine</a> over the last month (and is also what happens to <a href="http://www.imdb.com/title/tt1013752/">sequels</a> when you run out of bad ideas).  Yesterday, 0.7 was officially added to the state_machine family of <a href="http://github.com/pluginaweek/state_machine/downloads">releases</a>.  With this release comes better integrations, easier access to more state information, and the all new and improved Done Right™.  Check out the <a href="http://github.com/pluginaweek/state_machine/blob/v0.7.0/CHANGELOG.rdoc">changelog</a> for a detailed list of changes.</p>
<p><strong>REST and events</strong> &#8211; Events are auto-fired when a machine&#8217;s action is called (or when validations run) based on the value of #{attribute}_event:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">purchase = Purchase.<span class="me1">create</span>  <span class="co1"># =&gt; #&lt;Purchase id: 1, state: &quot;pending&quot;&gt;</span>
purchase.<span class="me1">state_event</span>        <span class="co1"># =&gt; nil</span>
&nbsp;
purchase.<span class="me1">update_attributes</span><span class="br0">&#40;</span><span class="re3">:state_event</span> <span class="sy0">=&gt;</span> <span class="st0">'authorize'</span><span class="br0">&#41;</span>
purchase.<span class="me1">state</span>              <span class="co1"># =&gt; &quot;authorized&quot;</span>
purchase.<span class="me1">state_event</span>        <span class="co1"># =&gt; nil</span>
&nbsp;
purchase.<span class="me1">state_event</span> = <span class="st0">'capture'</span>
purchase.<span class="me1">valid</span>?             <span class="co1"># =&gt; true</span>
purchase.<span class="me1">state</span>              <span class="co1"># =&gt; &quot;captured&quot;</span>
purchase.<span class="me1">save</span>               <span class="co1"># =&gt; true</span></pre></div></div>

<p>This means that your create/update controller actions don&#8217;t change at all.  For an example of the full Rails/Merb vertical slice, see the <a href="http://github.com/pluginaweek/state_machine/tree/master/examples">RESTful examples</a>. </p>
<p><strong>State rollbacks</strong> &#8211; If an action fails when firing an event, the transition is <a href="http://api.pluginaweek.org/state_machine/classes/StateMachine/Machine.html">rolled back</a>:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">purchase = Purchase.<span class="me1">find</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span>
purchase.<span class="me1">state</span>              <span class="co1"># =&gt; &quot;pending&quot;</span>
purchase.<span class="me1">amount</span> = <span class="kw2">nil</span>
purchase.<span class="me1">valid</span>?             <span class="co1"># =&gt; false # validates_presence_of :amount</span>
purchase.<span class="me1">authorize</span>          <span class="co1"># =&gt; false</span>
purchase.<span class="me1">state</span>              <span class="co1"># =&gt; &quot;pending&quot; # Returned &quot;authorized&quot; pre-0.7</span></pre></div></div>

<p><strong>ActiveRecord Observers</strong> &#8211; The <a href="http://api.pluginaweek.org/state_machine/classes/StateMachine/Integrations/ActiveRecord.html">ActiveRecord integration</a> kicked it up a notch (<strong>bam!</strong>) with new Observer hooks:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span class="kw1">class</span> PurchaseObserver <span class="sy0">&lt;</span> <span class="re2">ActiveRecord::Observer</span>
  <span class="kw1">def</span> before_capture_from_pending_to_captured<span class="br0">&#40;</span><span class="kw3">p</span>, transition<span class="br0">&#41;</span>; <span class="kw1">end</span>
  <span class="kw1">def</span> before_capture_from_pending<span class="br0">&#40;</span><span class="kw3">p</span>, transition<span class="br0">&#41;</span>; <span class="kw1">end</span>
  <span class="kw1">def</span> before_capture_to_captured<span class="br0">&#40;</span><span class="kw3">p</span>, transition<span class="br0">&#41;</span>; <span class="kw1">end</span>
  <span class="kw1">def</span> before_capture<span class="br0">&#40;</span><span class="kw3">p</span>, transition<span class="br0">&#41;</span>; <span class="kw1">end</span>
  <span class="kw1">def</span> before_transition_state_from_pending_to_captured<span class="br0">&#40;</span><span class="kw3">p</span>, transition<span class="br0">&#41;</span>; <span class="kw1">end</span>
  <span class="kw1">def</span> before_transition_state_to_captured<span class="br0">&#40;</span><span class="kw3">p</span>, transition<span class="br0">&#41;</span>; <span class="kw1">end</span>
  <span class="kw1">def</span> before_transition_state_from_pending<span class="br0">&#40;</span><span class="kw3">p</span>, transition<span class="br0">&#41;</span>; <span class="kw1">end</span>
  <span class="kw1">def</span> before_transition_state<span class="br0">&#40;</span><span class="kw3">p</span>, transition<span class="br0">&#41;</span>; <span class="kw1">end</span>
  <span class="kw1">def</span> before_transition<span class="br0">&#40;</span><span class="kw3">p</span>, transition<span class="br0">&#41;</span>; <span class="kw1">end</span>
<span class="kw1">end</span></pre></div></div>

<p>You can define the same types of hooks for after_* as well.</p>
<p><strong>DataMapper Defaults</strong> &#8211; The <a href="http://api.pluginaweek.org/state_machine/classes/StateMachine/Integrations/DataMapper.html">DataMapper integration</a> no longer uses transactions by default and properties are now auto-defined if they don&#8217;t already exist:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span class="kw1">class</span> Purchase
  <span class="kw1">include</span> <span class="re2">DataMapper::Resource</span>
  property <span class="re3">:id</span>, <span class="kw3">Integer</span>, <span class="re3">:serial</span> <span class="sy0">=&gt;</span> <span class="kw2">true</span>
  <span class="co1"># property :state, String # Automatically done by state_machine</span>
&nbsp;
  state_machine <span class="re3">:use_transactions</span> <span class="sy0">=&gt;</span> <span class="kw2">true</span> <span class="kw1">do</span>
    ...
  <span class="kw1">end</span>
<span class="kw1">end</span></pre></div></div>

<p><strong>Available events / transitions</strong> &#8211; The full list of available events / transitions for a state machine can be accessed via two new helpers:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">purchase = Purchase.<span class="me1">find</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span> <span class="co1"># =&gt; #&lt;Purchase id: 1, state: &quot;pending&quot;&gt;</span>
purchase.<span class="me1">state_events</span>       <span class="co1"># =&gt; [:authorize, :capture]</span>
purchase.<span class="me1">state_transitions</span>  <span class="co1"># =&gt; [#&lt;StateMachine::Transition ...&gt;, ...]</span>
&nbsp;
purchase.<span class="me1">authorize</span>
purchase.<span class="me1">state_events</span>       <span class="co1"># =&gt; [:capture]</span>
purchase.<span class="me1">state_transitions</span>  <span class="co1"># =&gt; [#&lt;StateMachine::Transition ...&gt;]</span></pre></div></div>

<p>This becomes particularly useful when presenting these in a view as a dropdown for users to select from.</p>
<p><strong style="color: #680000;">Backwards Incompatible!</strong> Accessing a specific event&#8217;s transition has been renamed from next_#{event}_transition to #{event}_transition:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">purchase.<span class="me1">authorize_transition</span>       <span class="co1"># =&gt; #&lt;StateMachine::Transition ...&gt;</span>
purchase.<span class="me1">next_authorize_transition</span>  <span class="co1"># =&gt; NoMethodError: undefined method...</span></pre></div></div>

<p><strong>Event arguments</strong> &#8211; Arguments to event methods can be accessed from transition callbacks:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">before_transition <span class="re3">:on</span> <span class="sy0">=&gt;</span> <span class="re3">:authorize</span> <span class="kw1">do</span> <span class="sy0">|</span>purchase, transition<span class="sy0">|</span>
  amount = transition.<span class="me1">args</span>.<span class="me1">first</span>
  ...
<span class="kw1">end</span></pre></div></div>

<p><strong>after_transition callbacks</strong> &#8211; <strong style="color: #680000;">Backwards incompatible!</strong> The result of the action is no longer passed to after_transition callbacks.  It can be accessed from the transition instead:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">after_transition <span class="re3">:on</span> <span class="sy0">=&gt;</span> <span class="re3">:authorize</span> <span class="kw1">do</span> <span class="sy0">|</span>purchase, transition<span class="sy0">|</span>
  saved = transition.<span class="me1">result</span>
  ...
<span class="kw1">end</span></pre></div></div>

<p>This affects all integrations as well.</p>
<p><strong>Parallel events</strong> &#8211; For classes that use multiple state machines, you can fire events off in parallel on an object.  This means their before/after callbacks get run at the same time and actions only get called once if they&#8217;re the same:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">purchase = Purchase.<span class="me1">find</span><span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span>
purchase.<span class="me1">state</span>                                    <span class="co1"># =&gt; &quot;pending&quot;</span>
purchase.<span class="me1">shipped_at</span>                               <span class="co1"># =&gt; nil</span>
purchase.<span class="me1">fire_events</span><span class="br0">&#40;</span><span class="re3">:capture</span>, <span class="re3">:deliver_shipment</span><span class="br0">&#41;</span> <span class="co1"># =&gt; true</span>
purchase.<span class="me1">state</span>                                    <span class="co1"># =&gt; &quot;captured&quot;</span>
purchase.<span class="me1">shipped_at</span>                               <span class="co1"># =&gt; Sun Apr 05 ...</span>
&nbsp;
<span class="co1"># Bang method is similar to events</span>
purchase.<span class="me1">fire_events</span>!<span class="br0">&#40;</span><span class="re3">:capture</span><span class="br0">&#41;</span> <span class="co1"># =&gt; StateMachine::InvalidTransition: ...</span></pre></div></div>

<p><strong>And the rest of the gang&#8230;</strong></p>
<p>In addition to the above major changes / additions, there were 6 new minor features and 4 bug fixes in this release.</p>
<p>A special Billy Mays shout-out goes to the folks who helped make this release happen, including:</p>
<ul>
<li>Aaron Gibralter</li>
<li>Paweł Kondzior</li>
<li>Mikhail Shirkov</li>
</ul>
<p><strong>Stalk me, but not in a creepy way</strong></p>
<p>As always, be sure to <a href="http://github.com/pluginaweek/state_machine">follow the project</a> on GitHub!  Happy coding!</p>
<img src="http://feeds.feedburner.com/~r/PluginAWeek/~4/-a-oRVhqbNU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.pluginaweek.org/2009/04/05/state_machine-07-better-integrations-more-access/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		<feedburner:origLink>http://www.pluginaweek.org/2009/04/05/state_machine-07-better-integrations-more-access/</feedburner:origLink></item>
		<item>
		<title>state_machine: One machine to rule them all?</title>
		<link>http://feeds.aaronpfeifer.com/~r/PluginAWeek/~3/g2dm3NrHjDM/</link>
		<comments>http://www.pluginaweek.org/2009/03/08/state_machine-one-machine-to-rule-them-all/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 22:07:24 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[agent smith]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[state machine]]></category>

		<guid isPermaLink="false">http://www.pluginaweek.org/?p=35</guid>
		<description><![CDATA[After 2 1/2 years of blood, sweat, tears, and the occasional Jägermeister, I&#8217;m finally officially announcing a project I&#8217;ve been quietly working on: state_machine. Well, quietly until some people started mentioning it This is a project which has undergone many rounds of rewrites, but which has finally met its goal, in my opinion, to become [...]]]></description>
			<content:encoded><![CDATA[<img class="left" src="http://www.pluginaweek.org/wp-content/uploads/2009/03/ring.jpg" title="Ring" style="display: inline; float: left; margin: 0; padding: 4px 10px 10px 0;" /><p><span class="first_letter">A</span>fter 2 1/2 years of blood, sweat, tears, and the occasional Jägermeister, I&#8217;m finally officially announcing a project I&#8217;ve been quietly working on: <a href="http://github.com/pluginaweek/state_machine">state_machine</a>.  Well, quietly until <a href="http://giantrobots.thoughtbot.com/2009/3/4/win-a-1295-dollar-prize"><em>some</em> people</a> started mentioning it <img src='http://www.pluginaweek.org/wp-content/plugins/smilies-themer/adiumicons/wink.png' alt=';)' class='wp-smiley' />  This is a project which has undergone many rounds of rewrites, but which has finally met its goal, in my opinion, to become the easiest, sexiest, yet most powerful state machine library for the Ruby language.</p>
<p><strong>LOTR reference?  Really?  What&#8217;s next, The Matrix?</strong></p>
<p>Rather than sit here and beat about the bush, here&#8217;s a rundown of state_machine&#8217;s features (in no particular order):</p>
<ul>
<li>Define multiple state machines on any Ruby class</li>
<li>Namespaced state machines</li>
<li>before/after transition hooks with explicit transition requirements</li>
<li>Integration with ActiveRecord / DataMapper / Sequel</li>
<li>State-driven instance / class behavior</li>
<li>State values of any data type</li>
<li>Dynamically-generated state values</li>
<li>Inheritance support</li>
<li>Simple instance/class method overrides</li>
<li>Internationalization</li>
<li>GraphViz visualization creator</li>
</ul>
<p>Now if that list doesn&#8217;t get you up on the dance floor, we need to have a talk.</p>
<p><strong>Never send a human to do a state machine&#8217;s job.</strong></p>
<p>What&#8217;s a blog post about code without&#8230; well, code?  Rather than bore you with words, here&#8217;s an example using state_machine with a Purchase DataMapper resource, written just for this blog <img src='http://www.pluginaweek.org/wp-content/plugins/smilies-themer/adiumicons/happy.png' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span class="kw1">class</span> Purchase
  <span class="kw1">include</span> <span class="re2">DataMapper::Resource</span>
&nbsp;
  property <span class="re3">:id</span>, Serial
  property <span class="re3">:amount</span>, <span class="kw3">Float</span>
  property <span class="re3">:state</span>, <span class="kw3">String</span>
  property <span class="re3">:shipped_at</span>, <span class="kw4">DateTime</span>
  property <span class="re3">:receipt</span>, <span class="kw3">String</span>
&nbsp;
  state_machine <span class="re3">:initial</span> <span class="sy0">=&gt;</span> <span class="re3">:pending</span> <span class="kw1">do</span>
    before_transition <span class="re3">:log_state_change</span>
    after_transition  <span class="re3">:pending</span> <span class="sy0">=&gt;</span> <span class="re3">:authorized</span>, <span class="re3">:authorized</span> <span class="sy0">=&gt;</span> <span class="re3">:captured</span> <span class="kw1">do</span>
      <span class="co1"># Update RSS feed...</span>
    <span class="kw1">end</span>
&nbsp;
    event <span class="re3">:authorize</span> <span class="kw1">do</span>
      transition <span class="re3">:pending</span> <span class="sy0">=&gt;</span> <span class="re3">:authorized</span>
    <span class="kw1">end</span>
&nbsp;
    event <span class="re3">:reauthorize</span> <span class="kw1">do</span>
      transition <span class="re3">:authorized</span> <span class="sy0">=&gt;</span> same, <span class="re3">:if</span> <span class="sy0">=&gt;</span> <span class="kw3">lambda</span> <span class="br0">&#123;</span><span class="sy0">|</span>p<span class="sy0">|</span> <span class="kw3">p</span>.<span class="me1">amount_diff</span> <span class="sy0">&lt;</span> <span class="nu0">15</span><span class="br0">&#125;</span>
    <span class="kw1">end</span>
&nbsp;
    event <span class="re3">:capture</span> <span class="kw1">do</span>
      transition <span class="br0">&#91;</span><span class="re3">:pending</span>, <span class="re3">:authorized</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="re3">:captured</span>
    <span class="kw1">end</span>
&nbsp;
    event <span class="re3">:void</span> <span class="kw1">do</span>
      transition all <span class="sy0">-</span> <span class="br0">&#91;</span><span class="re3">:captured</span>, <span class="re3">:voided</span><span class="br0">&#93;</span> <span class="sy0">=&gt;</span> <span class="re3">:voided</span>
    <span class="kw1">end</span>
&nbsp;
    state <span class="re3">:pending</span> <span class="kw1">do</span>
      <span class="kw1">def</span> transaction_id
        <span class="kw2">nil</span>
      <span class="kw1">end</span>
    <span class="kw1">end</span>
&nbsp;
    state <span class="re3">:authorized</span>, <span class="re3">:captured</span>, <span class="re3">:voided</span> <span class="kw1">do</span>
      validates_present <span class="re3">:receipt</span>
&nbsp;
      <span class="kw1">def</span> transaction_id
        id.<span class="me1">to_s</span>
      <span class="kw1">end</span>
    <span class="kw1">end</span>
  <span class="kw1">end</span>
&nbsp;
  state_machine <span class="re3">:shipped_at</span>, <span class="re3">:initial</span> <span class="sy0">=&gt;</span> <span class="re3">:pending</span>, <span class="re3">:namespace</span> <span class="sy0">=&gt;</span> <span class="st0">'shipment'</span> <span class="kw1">do</span>
    event <span class="re3">:deliver</span> <span class="kw1">do</span>
      transition <span class="re3">:pending</span> <span class="sy0">=&gt;</span> <span class="re3">:delivered</span>
    <span class="kw1">end</span>
&nbsp;
    state <span class="re3">:pending</span>, <span class="re3">:value</span> <span class="sy0">=&gt;</span> <span class="kw2">nil</span>
    state <span class="re3">:delivered</span>, <span class="re3">:if</span> <span class="sy0">=&gt;</span> <span class="kw3">lambda</span> <span class="br0">&#123;</span><span class="sy0">|</span>value<span class="sy0">|</span> value<span class="br0">&#125;</span>, <span class="re3">:value</span> <span class="sy0">=&gt;</span> <span class="kw3">lambda</span> <span class="br0">&#123;</span><span class="kw4">Time</span>.<span class="me1">now</span><span class="br0">&#125;</span>
  <span class="kw1">end</span>
&nbsp;
  <span class="kw1">def</span> amount_diff
    amount <span class="sy0">-</span> original_values<span class="br0">&#91;</span><span class="re3">:amount</span><span class="br0">&#93;</span>
  <span class="kw1">end</span>
&nbsp;
  <span class="kw1">def</span> log_state_change<span class="br0">&#40;</span>transition<span class="br0">&#41;</span>
    event, from, to = transition.<span class="me1">event</span>, transition.<span class="me1">from_name</span>, transition.<span class="me1">to_name</span>
    DataMapper.<span class="me1">logger</span>.<span class="me1">info</span><span class="br0">&#40;</span><span class="st0">&quot;#{id}: #{from} =&gt; #{to} on #{event}&quot;</span><span class="br0">&#41;</span>
  <span class="kw1">end</span>
<span class="kw1">end</span></pre></div></div>

<p>And now some fun actually interacting with the state machine:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">purchase = Purchase.<span class="me1">new</span>         <span class="co1"># =&gt; #&lt;Purchase id=nil amount=nil state=&quot;pending&quot;</span>
                                <span class="co1">#               shipping_status=nil receipt=nil&gt;</span>
purchase.<span class="me1">amount</span> = <span class="nu0">5.0</span>
purchase.<span class="me1">state</span>                  <span class="co1"># =&gt; &quot;pending&quot;</span>
purchase.<span class="me1">state_name</span>             <span class="co1"># =&gt; :pending</span>
purchase.<span class="me1">pending</span>?               <span class="co1"># =&gt; true</span>
purchase.<span class="me1">can_authorize</span>?         <span class="co1"># =&gt; true</span>
purchase.<span class="me1">transaction_id</span>         <span class="co1"># =&gt; nil</span>
purchase.<span class="me1">save</span>                   <span class="co1"># =&gt; true</span>
&nbsp;
purchase.<span class="me1">authorize</span>              <span class="co1"># =&gt; false</span>
purchase.<span class="me1">errors</span>.<span class="me1">full_messages</span>   <span class="co1"># =&gt; [&quot;Receipt must not be blank&quot;]</span>
purchase.<span class="me1">reload</span>                 <span class="co1"># =&gt; #&lt;Purchase id=1 amount=5.0 state=&quot;pending&quot;</span>
                                <span class="co1">#               shipped_at=nil receipt=nil&gt;</span>
purchase.<span class="me1">receipt</span> = <span class="st0">'abc123'</span>
purchase.<span class="me1">authorize</span>              <span class="co1"># =&gt; true</span>
purchase.<span class="me1">authorized</span>?            <span class="co1"># =&gt; true</span>
purchase.<span class="me1">captured</span>?              <span class="co1"># =&gt; false</span>
purchase.<span class="me1">transaction_id</span>         <span class="co1"># =&gt; &quot;1&quot;</span>
&nbsp;
purchase.<span class="me1">authorize</span>!             <span class="co1"># =&gt; StateMachine::InvalidTransition: ...</span>
&nbsp;
purchase.<span class="me1">shipped_at</span>             <span class="co1"># =&gt; nil</span>
purchase.<span class="me1">shipped_at_name</span>        <span class="co1"># =&gt; :pending</span>
&nbsp;
purchase.<span class="me1">can_deliver_shipment</span>?  <span class="co1"># =&gt; true</span>
purchase.<span class="me1">deliver_shipment</span>       <span class="co1"># =&gt; true</span>
purchase.<span class="me1">shipped_at</span>             <span class="co1"># =&gt; #&lt;DateTime: 106051652881/43200,-1/6,2299161&gt;</span>
purchase.<span class="me1">shipped_at_name</span>        <span class="co1"># =&gt; :delivered</span>
&nbsp;
purchase.<span class="me1">shipment_pending</span>?      <span class="co1"># =&gt; false</span>
purchase.<span class="me1">shipment_delivered</span>?    <span class="co1"># =&gt; true</span>
&nbsp;
Purchase.<span class="me1">with_state</span><span class="br0">&#40;</span><span class="re3">:authorized</span><span class="br0">&#41;</span>.<span class="me1">count</span>        <span class="co1"># =&gt; 1</span>
Purchase.<span class="me1">without_shipped_at</span><span class="br0">&#40;</span><span class="re3">:pending</span><span class="br0">&#41;</span>.<span class="me1">count</span>   <span class="co1"># =&gt; 1</span>
&nbsp;
Purchase.<span class="me1">state_machines</span>.<span class="me1">each</span> <span class="br0">&#123;</span><span class="sy0">|</span>name, machine<span class="sy0">|</span> machine.<span class="me1">draw</span><span class="br0">&#125;</span></pre></div></div>

<p>Boom shakalak!  That covers the basics, but notice that little nugget at the end?  That draws a visual representation of the graph for those PowerPoint presentations you&#8217;ll be giving.  Here they are (click for the full image):</p>
<div class="clearfix" style="margin-bottom: 10px;">
  <a href="http://www.pluginaweek.org/wp-content/uploads/2009/03/purchase_state.png" style="float: left;"><img src="http://www.pluginaweek.org/wp-content/uploads/2009/03/purchase_state-116x150.png" title="Purchase: state" width="116" height="150" /></a></p>
<p>  <a href="http://www.pluginaweek.org/wp-content/uploads/2009/03/purchase_shipment_status.png" style="float: left; margin-left: 15px;"><img src="http://www.pluginaweek.org/wp-content/uploads/2009/03/purchase_shipment_status-55x150.png" alt="purchase_shipment_status" title="Purchase: shipment_status" width="55" height="150" /></a>
</div>
<p><strong>What are we going to do tonight, Brain?</strong></p>
<p>So that&#8217;s a taste of state_machine.  Take a gander over to <a href="http://github.com/pluginaweek/state_machine">GitHub</a> and <a href="http://api.pluginaweek.org/state_machine">read the docs</a>.  There&#8217;s lots more there.</p>
<p>Before I close out this post, I want to recognize a few people who asked the hard questions, contributed back, or provided inspiration for this library:</p>
<ul>
<li>Scott Barron</li>
<li>S. Brent Faulkner</li>
<li>Pete Forde</li>
<li>Aaron Gibralter</li>
<li>Avdi Grimm</li>
<li>Michael Grosser</li>
<li>Tse-Ching Ho</li>
<li>Nate Murray</li>
<li>Sean O&#8217;Brien</li>
<li>Mike Perham</li>
<li>Brian Terlson</li>
<li>Dennis Theisen</li>
<li>Richard Titze</li>
<li>&#8230;and anyone else I missed!</li>
</ul>
<p>While you&#8217;re here, don&#8217;t forget to <a href="http://github.com/pluginaweek/state_machine">follow the project</a> on GitHub and help make state_machine a <a href="https://opensource.inklingmarkets.com/markets/18368">market leader</a>!</p>
<img src="http://feeds.feedburner.com/~r/PluginAWeek/~4/g2dm3NrHjDM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.pluginaweek.org/2009/03/08/state_machine-one-machine-to-rule-them-all/feed/</wfw:commentRss>
		<slash:comments>49</slash:comments>
		<feedburner:origLink>http://www.pluginaweek.org/2009/03/08/state_machine-one-machine-to-rule-them-all/</feedburner:origLink></item>
		<item>
		<title>Viximo: We want you. We need you.</title>
		<link>http://feeds.aaronpfeifer.com/~r/PluginAWeek/~3/23wYvzjuCLg/</link>
		<comments>http://www.pluginaweek.org/2008/07/14/viximo-we-want-you-we-need-you/#comments</comments>
		<pubDate>Mon, 14 Jul 2008 21:48:04 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[chuck norris]]></category>
		<category><![CDATA[digital goods]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[viximo]]></category>

		<guid isPermaLink="false">http://www.pluginaweek.org/?p=32</guid>
		<description><![CDATA[Not happy with your current job? Stuck in a code formatting war with your coworker? Can&#8217;t seem to convince your boss that Chuck Norris was written in Ruby? We can help with that. You take the blue pill &#8211; the story ends, you wake up at your company and believe whatever you want to believe [...]]]></description>
			<content:encoded><![CDATA[<img class="left" src="http://www.pluginaweek.org/wp-content/uploads/2008/07/viximo.gif" title="Viximo" style="display: inline; float: left; margin: 0; padding: 4px 10px 10px 0;" /><p><span class="first_letter">N</span>ot happy with your current job? Stuck in a code formatting war with your coworker? Can&#8217;t seem to convince your boss that Chuck Norris was written in Ruby? We can help with that.</p>
<p><strong>You take the blue pill &#8211; the story ends, you wake up at your company and believe whatever you want to believe</strong></p>
<p>Welcome to <a href="http://viximo.com">Viximo</a>. Viximo is a venture-funded startup, based in Boston, building a digital goods platform that will help creators, developers, and online communities monetize social interactions. At least, that&#8217;s what the biz folks say <img src='http://www.pluginaweek.org/wp-content/plugins/smilies-themer/adiumicons/wink.png' alt=';)' class='wp-smiley' /> We&#8217;re currently working on a pilot program on Facebook with the folks over at <a href="http://apps.facebook.com/birthday_calendar">Birthday Calendar</a> using a gifting platform that&#8217;s been under development over the past 9 months.  Want to send your friend a cupcake for his birthday? A beer? Maybe a pair of handcuffs? This is where the magic happens <img src='http://www.pluginaweek.org/wp-content/plugins/smilies-themer/adiumicons/wink.png' alt=';)' class='wp-smiley' /> </p>
<p><strong>You take the red pill &#8211; you come to Viximo and I show you how deep the rabbit-hole goes</strong></p>
<p>I joined the company when we were a small group of 5.  Nine months later we&#8217;re up to a whopping 15, but we&#8217;re still a small company with an amazing group of individuals who know their stuff and know how to have fun. We use Ruby on Rails. We&#8217;re built on EC2. We test using RSpec. And we occasionally play Hannah Montana over the office sound system.</p>
<p>Viximo wants you. Viximo needs you. So if you&#8217;re interested in meeting us in person, check out our <strong><a href="http://viximo.com/jobs">Jobs page</a></strong>.</p>
<p><strong>Is that pill chewable? Like Flintstones vitamins? I really like those.</strong></p>
<p>If you&#8217;re not quite ready for a new job or are unsure, <a href="mailto:aaron.pfeifer@gmail.com">e-mail me</a> anyway. If or when you&#8217;re in the Boston area, drop me a note and we&#8217;ll chat.</p>
<img src="http://feeds.feedburner.com/~r/PluginAWeek/~4/23wYvzjuCLg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.pluginaweek.org/2008/07/14/viximo-we-want-you-we-need-you/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.pluginaweek.org/2008/07/14/viximo-we-want-you-we-need-you/</feedburner:origLink></item>
		<item>
		<title>acts_as_what?</title>
		<link>http://feeds.aaronpfeifer.com/~r/PluginAWeek/~3/eeKIRJYujdc/</link>
		<comments>http://www.pluginaweek.org/2008/07/06/acts_as_what/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 12:00:10 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[acts_as]]></category>
		<category><![CDATA[chuck norris]]></category>
		<category><![CDATA[naming]]></category>

		<guid isPermaLink="false">http://www.pluginaweek.org/?p=13</guid>
		<description><![CDATA[This guy&#8217;s expression pretty much sums up my reaction whenever a new acts_as_* shows up in my RSS feed for AgileWebDevelopment plugins. As of today, there are 1,115 plugins listed there, 129 of which start with acts_as. That&#8217;s about 11.5% and I&#8217;m not even including ones like acts_as_hasselholf or acts_as_rickroll acts_as_chuck_norris is impossible &#8211; the [...]]]></description>
			<content:encoded><![CDATA[<img class="left" src="http://www.pluginaweek.org/wp-content/uploads/2008/07/confused.jpg" title="Confused" style="display: inline; float: left; margin: 0; padding: 4px 10px 10px 0;" /><p><span class="first_letter">T</span>his guy&#8217;s expression pretty much sums up my reaction whenever a new acts_as_* shows up in my <a href="http://feeds.feedburner.com/RubyOnRailsPlugins">RSS feed</a> for <a href="http://agilewebdevelopment.com/plugins">AgileWebDevelopment plugins</a>.  As of today, there are 1,115 plugins listed there, <strong>129</strong> of which start with acts_as.  That&#8217;s about 11.5% and I&#8217;m not even including ones like <a href="http://svn.lazyatom.com/public/plugins/acts_as_hasselhoff">acts_as_hasselholf</a> or <a href="http://procnew.com/acts_as_rickroll.html">acts_as_rickroll</a> <img src='http://www.pluginaweek.org/wp-content/plugins/smilies-themer/adiumicons/wink.png' alt=';)' class='wp-smiley' /> </p>
<p><strong>acts_as_chuck_norris is impossible &#8211; the only thing that can act like Chuck Norris is Chuck Norris</strong></p>
<p>acts_as_* has sort of become the joke of the Rails community. Everything is acts_as whether it makes sense or not.  Something simple like auto_validations becomes acts_as_auto_validated.  And, in all honesty, I was sucked right into it like everyone else until I realized how ridiculous it had become.  The majority of these plugins have names that are just terrible at describing what it is they do.</p>
<p><strong>chuck_norris_fu consists of one move: the roundhouse kick</strong></p>
<p>*_fu isn&#8217;t exactly much better. It seemed like once people started realizing that acts_as_* was becoming old, worn, and <em>so</em> last year, they resorted to suffixing every plugin with _fu. So instead of calling it auto_validations, it would be called validation_fu. The names changed, but the problems remained the same.</p>
<p><strong>Where&#8217;s my acts_as_soviet_russia plugin?</strong></p>
<p>Coming up with a name isn&#8217;t easy and isn&#8217;t always going to be witty and unique.  Try to create something that&#8217;s, first and foremost, descriptive of what it is that your plugin provides&#8230; or you can just get lost in the acts_as_shuffle <img src='http://www.pluginaweek.org/wp-content/plugins/smilies-themer/adiumicons/tongue.png' alt=':-p' class='wp-smiley' />  Either way, I can at least say I warned you!</p>
<p><em>Disclaimer: I know I have a plugin that starts with acts_as&#8230; but I swear it actually makes sense in its context! <img src='http://www.pluginaweek.org/wp-content/plugins/smilies-themer/adiumicons/biggrin.png' alt=':D' class='wp-smiley' /> </em></p>
<img src="http://feeds.feedburner.com/~r/PluginAWeek/~4/eeKIRJYujdc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.pluginaweek.org/2008/07/06/acts_as_what/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		<feedburner:origLink>http://www.pluginaweek.org/2008/07/06/acts_as_what/</feedburner:origLink></item>
		<item>
		<title>Git up, Git on up</title>
		<link>http://feeds.aaronpfeifer.com/~r/PluginAWeek/~3/02DVPGKoWH4/</link>
		<comments>http://www.pluginaweek.org/2008/06/27/git-up-git-on-up/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 02:06:49 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[lighthouse]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[trac]]></category>

		<guid isPermaLink="false">http://www.pluginaweek.org/?p=24</guid>
		<description><![CDATA[Well what do ya know&#8230; Pandora, Twitter, Lost, and GitHub have something in common after all! Yeah, so I sort of avoided jumping on the bandwagon for a while, but each time I keep caving under pressure &#8230; although I&#8217;m still reluctant to admit that I&#8217;ve ever watched an episode of Lost. So that&#8217;s big [...]]]></description>
			<content:encoded><![CDATA[<img class="left" src="http://www.pluginaweek.org/wp-content/uploads/2008/06/github.png" title="github" style="display: inline; float: left; margin: 0; padding: 4px 10px 10px 0;" /><p><span class="first_letter">W</span>ell what do ya know&#8230; <a href="http://www.pandora.com">Pandora</a>, <a href="http://twitter.com">Twitter</a>, <a href="http://en.wikipedia.org/wiki/Lost_(TV_series)">Lost</a>, and <a href="http://www.github.com">GitHub</a> have something in common after all! Yeah, so I sort of avoided jumping on the bandwagon for a while, but each time I keep caving under pressure <img src='http://www.pluginaweek.org/wp-content/plugins/smilies-themer/adiumicons/happy.png' alt=':)' class='wp-smiley' /> &#8230; although I&#8217;m still reluctant to admit that I&#8217;ve ever watched an episode of Lost.</p>
<p>So that&#8217;s <strong>big</strong> news for this project. I&#8217;ve spent the last few weeks tidying up some of the plugins and making the transition from <a href="http://subversion.tigris.org">Subversion</a> to <a href="http://github.com">GitHub</a> and <a href="http://trac.edgewall.org">Trac</a> to <a href="http://lighthouseapp.com">Lighthouse</a>. I&#8217;m really hoping that this change will help encourage more contributions to this project and give it a better spotlight to shine in.</p>
<p><strong>Check out the goodies</strong></p>
<p>Github: <a href="http://github.com/pluginaweek">http://github.com/pluginaweek</a><br />
Lighthouse: <a href="http://pluginaweek.lighthouseapp.com">http://pluginaweek.lighthouseapp.com</a></p>
<p>If you need to access the old Subversion repository, I still have it up at <a href="http://svn.pluginaweek.org/trunk">svn.pluginaweek.org</a> and it&#8217;ll remain there for a while, albeit deprecated, until most people have moved over to GitHub.</p>
<p>I really hope you&#8217;re as excited about these changes as I am <img src='http://www.pluginaweek.org/wp-content/plugins/smilies-themer/adiumicons/happy.png' alt=':)' class='wp-smiley' />  And I look forward to a more social interaction with other developers such as yourself!</p>
<img src="http://feeds.feedburner.com/~r/PluginAWeek/~4/02DVPGKoWH4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.pluginaweek.org/2008/06/27/git-up-git-on-up/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.pluginaweek.org/2008/06/27/git-up-git-on-up/</feedburner:origLink></item>
		<item>
		<title>Rails 2.1 Certified</title>
		<link>http://feeds.aaronpfeifer.com/~r/PluginAWeek/~3/S3BiqkCwGkM/</link>
		<comments>http://www.pluginaweek.org/2008/05/26/rails-21-certified/#comments</comments>
		<pubDate>Mon, 26 May 2008 13:00:26 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[gravy train]]></category>
		<category><![CDATA[ice cream]]></category>
		<category><![CDATA[rails 2.1]]></category>
		<category><![CDATA[spaghetti]]></category>

		<guid isPermaLink="false">http://www.pluginaweek.org/?p=11</guid>
		<description><![CDATA[Toot toot! Rails 2.1 is almost out and the gravy train has set sail, full speed ahead! Are you excited? I know the girl to the left here is. She&#8217;s totally psyched about the upcoming release. Screw barbie dolls, you&#8217;ve got some upgrading to do! You&#8217;ll be happy to know that all the plugins here [...]]]></description>
			<content:encoded><![CDATA[<img class="left" src="http://www.pluginaweek.org/wp-content/uploads/2008/05/excited.jpg" title="Excited" style="display: inline; float: left; margin: 0; padding: 4px 10px 10px 0;" /><p><span class="first_letter">T</span>oot toot!  Rails 2.1 is almost out and the gravy train has set sail, full speed ahead!  Are you excited?  I know the girl to the left here is.  She&#8217;s totally psyched about the upcoming release.  Screw barbie dolls, you&#8217;ve got some upgrading to do!</p>
<p>You&#8217;ll be happy to know that all the plugins here are Rails 2.1 ready.  That&#8217;s been my testbed for a while now.</p>
<p><strong>I&#8217;m sorry, son.  You must be 2.1 or over to enter.</strong></p>
<p>The downside of being Rails 2.1 ready is, well&#8230; <strong>Rails 2.1 certified means NOT < Rails 2.1 certified</strong>.  I don&#8217;t like code strictly meant for backwards compatibility.  This project is maintained against the latest version of Rails and is meant to be implemented with the latest and greatest in mind.</p>
<p>Hopefully, for most people, that decision won&#8217;t have much of an effect on your project.  If you&#8217;re lagging a bit behind and want to update a plugin, you should feel free to just make the appropriate patches needed.  Sure, it&#8217;s a little extra work, but I think you&#8217;ll be happier with code that&#8217;s not just a bowl of spaghetti.</p>
<p><strong>You wanted a bowl of ice cream anyway.  Screw spaghetti.</strong></p>
<p><a href="http://dev.pluginaweek.org">Let me know</a> if you run into any issues with the 2.1 release.  I&#8217;ll be happy to take a look!</p>
<img src="http://feeds.feedburner.com/~r/PluginAWeek/~4/S3BiqkCwGkM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.pluginaweek.org/2008/05/26/rails-21-certified/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.pluginaweek.org/2008/05/26/rails-21-certified/</feedburner:origLink></item>
		<item>
		<title>Go green with 5 lines of Ruby</title>
		<link>http://feeds.aaronpfeifer.com/~r/PluginAWeek/~3/JXzY2V1IiZA/</link>
		<comments>http://www.pluginaweek.org/2008/05/21/go-green-with-5-lines-of-ruby/#comments</comments>
		<pubDate>Wed, 21 May 2008 13:00:06 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[energy]]></category>
		<category><![CDATA[green]]></category>
		<category><![CDATA[hack]]></category>

		<guid isPermaLink="false">http://www.pluginaweek.org/?p=20</guid>
		<description><![CDATA[I decided to go &#8220;green&#8221; last weekend and spend a little time reducing the energy consumption of my computer. See, I&#8217;ve always left my desktop computer on at home while I&#8217;ve been at work or asleep. I&#8217;m sort of lazy and suspend never really worked that well in Ubuntu. After upgrading to 8.04 and finding [...]]]></description>
			<content:encoded><![CDATA[<img class="left" src="http://www.pluginaweek.org/wp-content/uploads/2008/05/green_tree.jpg" title="Green Tree" style="display: inline; float: left; margin: 0; padding: 4px 10px 10px 0;" /><p><span class="first_letter">I</span> decided to go &#8220;green&#8221; last weekend and spend a little time reducing the energy consumption of my computer.  See, I&#8217;ve always left my desktop computer on at home while I&#8217;ve been at work or asleep.  I&#8217;m sort of lazy and suspend never really worked that well in <a href="http://www.ubuntu.com">Ubuntu</a>.</p>
<p>After upgrading to 8.04 and finding suspend working, I decided to overcome the &#8220;lazy&#8221; excuse and write a script that automagically suspends my computer after I&#8217;ve left and turns it back on before I come back.  Now I never have to think about it (if I&#8217;m in a rush) and I can still significantly reduce energy consumption.</p>
<p>Here&#8217;s the meat:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span class="co1">#!/usr/bin/ruby</span>
<span class="kw3">require</span> <span class="st0">'time'</span>
wake_time = <span class="kw4">Time</span>.<span class="me1">parse</span><span class="br0">&#40;</span>ARGV<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span>
wake_time <span class="sy0">+</span>= <span class="nu0">24</span> <span class="sy0">*</span> <span class="nu0">60</span> <span class="sy0">*</span> <span class="nu0">60</span> <span class="kw1">if</span> wake_time <span class="sy0">&lt;</span> <span class="kw4">Time</span>.<span class="me1">now</span>
<span class="kw4">File</span>.<span class="kw3">open</span><span class="br0">&#40;</span><span class="st0">'/proc/acpi/alarm'</span>, <span class="st0">'w'</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><span class="sy0">|</span>f<span class="sy0">|</span> f <span class="sy0">&lt;&lt;</span> wake_time.<span class="me1">utc</span>.<span class="me1">strftime</span><span class="br0">&#40;</span><span class="st0">'%Y-%m-%d %H:%M:%S'</span><span class="br0">&#41;</span><span class="br0">&#125;</span>
<span class="kw3">system</span><span class="br0">&#40;</span><span class="st0">'/etc/acpi/sleep.sh force'</span><span class="br0">&#41;</span></pre></div></div>

<p>This just takes a single argument representing the next time the computer should start up, sets up the ACPI to wake up at that time, and then suspends the computer.</p>
<p>I have 2 cron jobs set up to use this script:</p>
<pre lang="">
45 09 * * 1,2,3,4,5 /home/aaron/Projects/Personal/green/sleep.rb 19:00:00
00 02 * * * /home/aaron/Projects/Personal/green/sleep.rb 07:45:00
</pre>
<p>This means the computer will always be off between 9:45am and 7:00pm on weekdays and between 2:00am and 7:45am every day.  Now, sometimes I work late, so if you&#8217;re on Ubuntu and use Gnome, here&#8217;s a little extension of the script that will display a dialog and give you a chance to cancel the automatic shutdown:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span class="co1">#!/usr/bin/ruby</span>
<span class="kw3">require</span> <span class="st0">'time'</span>
<span class="kw3">require</span> <span class="st0">'timeout'</span>
<span class="kw3">require</span> <span class="st0">'gtk2'</span>
&nbsp;
<span class="kw1">begin</span>
  <span class="co1"># Wait a few minutes before going on in case we're working late</span>
  Timeout::timeout<span class="br0">&#40;</span><span class="nu0">5</span> <span class="sy0">*</span> <span class="nu0">60</span><span class="br0">&#41;</span> <span class="kw1">do</span>
    dialog = <span class="re2">Gtk::Dialog</span>.<span class="kw5">new</span><span class="br0">&#40;</span><span class="st0">'Still awake?'</span>, <span class="kw2">nil</span>, <span class="kw2">nil</span>, <span class="br0">&#91;</span><span class="re2">Gtk::Stock::OK</span>, <span class="re2">Gtk::Dialog::RESPONSE_NONE</span><span class="br0">&#93;</span><span class="br0">&#41;</span>
    dialog.<span class="me1">signal_connect</span><span class="br0">&#40;</span><span class="st0">'response'</span><span class="br0">&#41;</span> <span class="kw1">do</span>
      <span class="co1"># User is still around</span>
      dialog.<span class="kw5">destroy</span>
      Gtk.<span class="me1">main_quit</span>
    <span class="kw1">end</span>
    dialog.<span class="me1">resize</span><span class="br0">&#40;</span><span class="nu0">200</span>, <span class="nu0">51</span><span class="br0">&#41;</span>
    dialog.<span class="me1">show_all</span>
    Gtk.<span class="me1">main</span>
  <span class="kw1">end</span>
<span class="kw1">rescue</span> <span class="re2">Timeout::Error</span>
  <span class="co1"># Time to go to sleep</span>
&nbsp;
  <span class="co1"># Write the time that we're going to wake up next</span>
  wake_time = <span class="kw4">Time</span>.<span class="me1">parse</span><span class="br0">&#40;</span>ARGV<span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#41;</span>
  wake_time <span class="sy0">+</span>= <span class="nu0">24</span> <span class="sy0">*</span> <span class="nu0">60</span> <span class="sy0">*</span> <span class="nu0">60</span> <span class="kw1">if</span> wake_time <span class="sy0">&lt;</span> <span class="kw4">Time</span>.<span class="me1">now</span>
  <span class="kw4">File</span>.<span class="kw3">open</span><span class="br0">&#40;</span><span class="st0">'/proc/acpi/alarm'</span>, <span class="st0">'w'</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><span class="sy0">|</span>f<span class="sy0">|</span> f <span class="sy0">&lt;&lt;</span> wake_time.<span class="me1">utc</span>.<span class="me1">strftime</span><span class="br0">&#40;</span><span class="st0">'%Y-%m-%d %H:%M:%S'</span><span class="br0">&#41;</span><span class="br0">&#125;</span>
&nbsp;
  <span class="co1"># Suspend the computer</span>
  <span class="kw3">system</span><span class="br0">&#40;</span><span class="st0">'/etc/acpi/sleep.sh force'</span><span class="br0">&#41;</span>
<span class="kw1">end</span></pre></div></div>

<p>Every little bit counts <img src='http://www.pluginaweek.org/wp-content/plugins/smilies-themer/adiumicons/wink.png' alt=';)' class='wp-smiley' /> </p>
<p>P.S. The dialog extension needs a windowing environment, so I set up <a href="http://www.astrojar.org.uk/kalarm">KAlarm</a> to replace the cron jobs.</p>
<p>P.P.S. Disclaimer, be careful, blah blah .. you know the story.</p>
<img src="http://feeds.feedburner.com/~r/PluginAWeek/~4/JXzY2V1IiZA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.pluginaweek.org/2008/05/21/go-green-with-5-lines-of-ruby/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.pluginaweek.org/2008/05/21/go-green-with-5-lines-of-ruby/</feedburner:origLink></item>
	</channel>
</rss>
