<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>nealenssle.com &#187; tools</title>
	<atom:link href="http://nealenssle.com/blog/tag/tools/feed/" rel="self" type="application/rss+xml" />
	<link>http://nealenssle.com/blog</link>
	<description></description>
	<lastBuildDate>Tue, 27 Sep 2011 11:39:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to find the name of the current Rake task</title>
		<link>http://nealenssle.com/blog/2009/11/14/how-to-find-the-name-of-the-current-rake-task/</link>
		<comments>http://nealenssle.com/blog/2009/11/14/how-to-find-the-name-of-the-current-rake-task/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 03:15:59 +0000</pubDate>
		<dc:creator>Neal Enssle</dc:creator>
				<category><![CDATA[untagged]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://nealenssle.com/blog/?p=161</guid>
		<description><![CDATA[A few weeks ago I needed a Rake task to answer a simple question for me:
&#8220;What&#8217;s my name?&#8221;
I honestly can&#8217;t quite remember why exactly the task needed to know it&#8217;s own name, but at the time it seemed important and I spent a couple hours digging about before I found out that Rake tasks are [...]]]></description>
			<content:encoded><![CDATA[<p>A few weeks ago I needed a Rake task to answer a simple question for me:</p>
<p>&#8220;What&#8217;s my name?&#8221;</p>
<p>I honestly can&#8217;t quite remember <em>why exactly</em> the task needed to know it&#8217;s own name, but at the time it seemed important and I spent a couple hours digging about before I found out that Rake tasks are shy by nature. Or at least when implemented the way almost every tutorial tells you to implement them:</p>
<pre>
namespace :life do

  desc "The answer to life, the universe, and everything"
  task :answer do
    puts "The answer to life, the universe, and everything is 42."
  end

end
</pre>
<p>But how do I know what the name of the current task is?  Well, after making a couple of random attempts (like &#8220;puts task.name&#8221;) and digging around in the <em>very sparse</em> documentation on the <a href="http://rake.rubyforge.org/">Rake homepage</a>, I stumbled  across a bit of documentation that talked about &#8220;Tasks with Actions&#8221;:</p>
<blockquote><p>
Actions are defined by passing a block to the task method. Any Ruby code can be placed in the block. The block may reference the task object via the block parameter.</p>
<pre>
task :name => [:prereq1, :prereq2] do |t|
  # actions (may reference t)
end
</pre>
</blockquote>
<p>Ah ha! &#8220;The block may reference the task object via the block parameter.&#8221;  That&#8217;s exactly what I was looking for.  Adding the block parameter allows us to reference the task object itself. And the task object itself has a good bit of useful meta information:</p>
<pre>
namespace :life do

  desc "The answer to life, the universe, and everything"
  task :answer do |t|
    puts t.name
    puts t.comment
    puts t.scope
  end

end
</pre>
<p>The task now returns the following:</p>
<pre>
life:answer
The answer to life, the universe, and everything
life
</pre>
<p>The first line of output is nifty, and answers the &#8220;What&#8217;s my name?&#8221; question with the fully scoped name of the task. Given that much it&#8217;s probably not hard to return the task name in even the most deeply namespaced Rakefile. The second line is the &#8220;comment&#8221; &#8212; actually the description of the task.  And the third line gets us the scope (namespaces). There are more methods available, but check teh googles for &#8220;Rake::Task api&#8221;.</p>
<p>So with this meta information we can do something useful like:</p>
<pre>
namespace :life do

  desc "The answer to life, the universe, and everything"
  task :answer do |t|
    puts "#{t.comment} is 42."
  end

end
</pre>
<p>Voila. And that&#8217;s probably enough meta for one day.</p>
]]></content:encoded>
			<wfw:commentRss>http://nealenssle.com/blog/2009/11/14/how-to-find-the-name-of-the-current-rake-task/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to filter Subversion logs by date and author</title>
		<link>http://nealenssle.com/blog/2009/10/14/how-to-filter-subversion-logs-by-date-and-author/</link>
		<comments>http://nealenssle.com/blog/2009/10/14/how-to-filter-subversion-logs-by-date-and-author/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 03:43:02 +0000</pubDate>
		<dc:creator>Neal Enssle</dc:creator>
				<category><![CDATA[untagged]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scm]]></category>
		<category><![CDATA[subversion]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://nealenssle.com/blog/?p=123</guid>
		<description><![CDATA[I keep forgetting this snippet, and then spend hours re-discovering/re-inventing it. So for the record: Here&#8217;s a bit of magic to let you filter your Subversion (SVN) logs by date and author:

svn log -vr {20091014}:"HEAD" &#124; sed -n "/nealenssle/,/-----$/ p"

I use it in a bash shell script function that I&#8217;ve got in my .bash_profile script [...]]]></description>
			<content:encoded><![CDATA[<p>I keep forgetting this snippet, and then spend hours re-discovering/re-inventing it. So for the record: Here&#8217;s a bit of magic to let you filter your Subversion (SVN) logs by date and author:</p>
<pre>
svn log -vr {20091014}:"HEAD" | sed -n "/nealenssle/,/-----$/ p"
</pre>
<p>I use it in a bash shell script function that I&#8217;ve got in my .bash_profile script like so:</p>
<pre>
function svnlog {
    svn log -vr {$1}:"HEAD" | sed -n "/$2/,/-----$/ p"
}
</pre>
<p>And then call it like so:</p>
<pre>
svnlog 20091014 nealenssle
</pre>
<p>Happy spelunking!</p>
]]></content:encoded>
			<wfw:commentRss>http://nealenssle.com/blog/2009/10/14/how-to-filter-subversion-logs-by-date-and-author/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to define multiple users in a Capistrano deployment file</title>
		<link>http://nealenssle.com/blog/2007/04/11/how-to-define-multiple-users-in-a-capistrano-deployment-file/</link>
		<comments>http://nealenssle.com/blog/2007/04/11/how-to-define-multiple-users-in-a-capistrano-deployment-file/#comments</comments>
		<pubDate>Wed, 11 Apr 2007 11:36:52 +0000</pubDate>
		<dc:creator>Neal Enssle</dc:creator>
				<category><![CDATA[code]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://nealenssle.com/blog/2007/04/11/defining-multiple-users-in-a-capistrano-deployment-file/</guid>
		<description><![CDATA[We&#8217;re just starting to get into Ruby on Rails at my work, and we&#8217;re close to deploying our first application to a production server with Capistrano.  
Capistrano makes it easy for developers to deploy code to the production server from their own workstations.  But we quickly ran into two problems:

It&#8217;s often the case [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re just starting to get into <a href="http://www.rubyonrails.org">Ruby on Rails</a> at my <a href="http://foraker.com">work</a>, and we&#8217;re close to deploying our first application to a production server with <a href="http://manuals.rubyonrails.com/read/book/17">Capistrano</a>.  </p>
<p>Capistrano makes it easy for developers to deploy code to the production server from their own workstations.  But we quickly ran into two problems:</p>
<ol>
<li>It&#8217;s often the case that a developer&#8217;s username on their local workstation is different from their username on the production server.  This requires you to set the developer&#8217;s server username in the &#8220;deploy.rb&#8221; file.  Hard-coded.</li>
<li>Hard-coding a single username makes it difficult for multiple users to share a &#8220;deploy.rb&#8221; file.
</ol>
<p>Well, it turns out that Capistrano is better than all that.  With a little bit of conditional logic and the ability for Cap to read environment variables, the problem is solved like this in the &#8220;deploy.rb&#8221; file:</p>
<pre>
if ENV["USER"] == "robert"
    set :user, "bob"
elsif ENV["USER"] == "elizabeth"
    set :user, "beth"
end
</pre>
<p>Voila.</p>
]]></content:encoded>
			<wfw:commentRss>http://nealenssle.com/blog/2007/04/11/how-to-define-multiple-users-in-a-capistrano-deployment-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

