<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Virtuous Code - Latest Comments in Double-Load Guards in Ruby</title><link>http://virtuouscode.disqus.com/</link><description></description><atom:link href="https://virtuouscode.disqus.com/double_load_guards_in_ruby/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Mon, 15 Feb 2010 15:02:11 -0000</lastBuildDate><item><title>Re: Double-Load Guards in Ruby</title><link>http://devblog.avdi.org/2009/10/22/double-load-guards-in-ruby/#comment-34314327</link><description>&lt;p&gt;I found the File.expand_path two-argument trick useful for writing some code that works both in Ruby 1.8 and 1.9 (where require behavior changes)&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Subelsky</dc:creator><pubDate>Mon, 15 Feb 2010 15:02:11 -0000</pubDate></item><item><title>Re: Double-Load Guards in Ruby</title><link>http://devblog.avdi.org/2009/10/22/double-load-guards-in-ruby/#comment-25015047</link><description>&lt;p&gt;Another awesome post Avdi!  We were having some hard-to-trace double constant definitions and using this code in my Rails pre-initializer TOTALLY surfaced them.  Thanks!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mike Subelsky</dc:creator><pubDate>Mon, 07 Dec 2009 12:22:05 -0000</pubDate></item><item><title>Re: Double-Load Guards in Ruby</title><link>http://devblog.avdi.org/2009/10/22/double-load-guards-in-ruby/#comment-20897535</link><description>&lt;p&gt;Why not use Ruby 1.9, which fixed the problem by storing the expanded path in the require table?  &lt;a href="http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l25" rel="nofollow noopener" target="_blank" title="http://eigenclass.org/hiki/Changes+in+Ruby+1.9#l25"&gt;http://eigenclass.org/hiki/...&lt;/a&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">François Beausoleil</dc:creator><pubDate>Fri, 23 Oct 2009 21:19:52 -0000</pubDate></item><item><title>Re: Double-Load Guards in Ruby</title><link>http://devblog.avdi.org/2009/10/22/double-load-guards-in-ruby/#comment-20886886</link><description>&lt;p&gt;You're right. But specs/tests is about the only place I do so myself.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">The Konstantin</dc:creator><pubDate>Fri, 23 Oct 2009 17:55:18 -0000</pubDate></item><item><title>Re: Double-Load Guards in Ruby</title><link>http://devblog.avdi.org/2009/10/22/double-load-guards-in-ruby/#comment-20856571</link><description>&lt;p&gt;Konstantin, thanks for your comment. Setting up $LOAD_PATH is essential and I make sure to add the current project to the load path in all but the smallest of projects.&lt;/p&gt;&lt;p&gt;However, there are always a few files where relative requires can't be avoided. For instance, it is conventional to set up unit test/spec files so that they can be run standalone. In order for this to work each test file has to start out by requiring a test_helper.rb or a spec_helper.rb which then sets up $LOAD_PATH, requires additional libraries, etc. Because this test helper is the first thing to be loaded and can't rely on anything else to be configured, it has to be loaded with a relative path.&lt;/p&gt;&lt;p&gt;This is where I see the most double-loads occurring, because when all of the tests are run together they each require the test helper file, often with differing relative paths. Using expand_path is a way to ensure that files that must loaded relatively are required in a consistent way.&lt;/p&gt;&lt;p&gt;I may update the post to make it clear that I'm not suggesting you use relative requires throughout a project. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Avdi Grimm</dc:creator><pubDate>Fri, 23 Oct 2009 09:55:05 -0000</pubDate></item><item><title>Re: Double-Load Guards in Ruby</title><link>http://devblog.avdi.org/2009/10/22/double-load-guards-in-ruby/#comment-20845422</link><description>&lt;p&gt;I disagree. Doing require File.expand_path is way to ugly. Just setup you $LOAD_PATH correctly and you will not encounter any of such problems. Treat your code as if it was a library.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">The Konstantin</dc:creator><pubDate>Fri, 23 Oct 2009 04:05:12 -0000</pubDate></item></channel></rss>