<?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>SmartLogic Solutions Blog &#187; Rake</title>
	<atom:link href="http://blog.smartlogicsolutions.com/category/rake/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smartlogicsolutions.com</link>
	<description>News and updates from the people at SmartLogic Solutions</description>
	<lastBuildDate>Tue, 30 Nov 2010 21:39:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Including external .rake files in your project&#8217;s Rakefile &#8212; keep your rake tasks organized!</title>
		<link>http://blog.smartlogicsolutions.com/2009/05/26/including-external-rake-files-in-your-projects-rakefile-keep-your-rake-tasks-organized/</link>
		<comments>http://blog.smartlogicsolutions.com/2009/05/26/including-external-rake-files-in-your-projects-rakefile-keep-your-rake-tasks-organized/#comments</comments>
		<pubDate>Tue, 26 May 2009 14:58:07 +0000</pubDate>
		<dc:creator>Glenn Gentzke</dc:creator>
				<category><![CDATA[Glenn Gentzke]]></category>
		<category><![CDATA[Rake]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rake task]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=649</guid>
		<description><![CDATA[Perhaps you have a non-Rails project (let&#8217;s say it&#8217;s in ruby and maybe some other languages, too) and you use Rake tasks to automate some of the dirty work. So you&#8217;ve got a bunch of methods that you wish to keep neatly sorted into .rake files in some dir&#8217;s (probably a sub folder of lib [...]]]></description>
			<content:encoded><![CDATA[<p>Perhaps you have a non-Rails project (let&#8217;s say it&#8217;s in ruby and maybe some other languages, too) and you use Rake tasks to automate some of the dirty work.  So you&#8217;ve got a bunch of methods that you wish to keep neatly sorted into .rake files in some dir&#8217;s (probably a sub folder of lib like lib/tasks) and a single Rakefile in your project&#8217;s root directory.  Including those external .rake files in your project&#8217;s Rakefile via <strong>require</strong> statements won&#8217;t work :</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'lib/some_rake_file'</span> <span style="color:#008000; font-style:italic;"># or require 'lib/some_rake_file.rake'</span></pre></div></div>

<p><em>=> rake aborted!<br />
no such file to load &#8212; /home/your_project/lib/some_rake_file</em></p>
<p>Rake assumes the &#8216;require&#8217;d files end in .rb, so it won&#8217;t find your .rake files.  You need to <strong>import</strong> rake files:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">import <span style="color:#996600;">'lib/some_rake_file'</span></pre></div></div>

<p>  This is fine for individual files, but I wanted to include all files that end in .rake in my tasks dir:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">glob</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'tasks/*.rake'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">each</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>r<span style="color:#006600; font-weight:bold;">|</span> import r <span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>&#8230;and there you go.  While dead simple, this exemplifies an important distinction between require and import that I found to be poorly documented.  Keep your rake tasks organized and remember that Rake isn&#8217;t just for rails apps!</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2009/04/04/environmentalist-023-released-supports-rails-232/" rel="bookmark" class="crp_title">environmentalist 0.2.3 released &#8212; supports rails 2.3.2</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/06/15/automating-flex-compilation-using-ant/" rel="bookmark" class="crp_title">Automating Flex Compilation Using ANT</a></li><li><a href="http://blog.smartlogicsolutions.com/2009/04/26/integrity-ci-on-passenger-222-with-ruby-enterprise-edition-on-ubuntu-804/" rel="bookmark" class="crp_title">Integrity CI on Passenger 2.2.2 with Ruby Enterprise Edition on Ubuntu 8.04</a></li><li><a href="http://blog.smartlogicsolutions.com/2010/05/13/directory-conventions-for-rack-middleware-rubygems/" rel="bookmark" class="crp_title">Directory Conventions for Rack Middleware RubyGems</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/06/02/better-setup-for-environments-in-rails/" rel="bookmark" class="crp_title">Better setup for environments in Rails</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2009/05/26/including-external-rake-files-in-your-projects-rakefile-keep-your-rake-tasks-organized/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

