<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6647087035529895010</id><updated>2024-11-01T00:09:34.868-07:00</updated><category term="ruby"/><category term="editors"/><category term="rails"/><category term="ubuntu"/><category term="os x"/><category term="rdoc"/><title type='text'>crepuscular homunculus</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://crepuscular-homunculus.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6647087035529895010/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://crepuscular-homunculus.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>crepuscular-homunculus</name><uri>http://www.blogger.com/profile/12880267859153647874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6647087035529895010.post-278869150628448140</id><published>2008-08-08T09:19:00.000-07:00</published><updated>2008-08-08T14:27:24.574-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="editors"/><category scheme="http://www.blogger.com/atom/ns#" term="rails"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><category scheme="http://www.blogger.com/atom/ns#" term="ubuntu"/><title type='text'>jEdit for Ruby on Rails</title><content type='html'>&lt;a href=&quot;http://www.jedit.org/&quot;&gt;jEdit&lt;/a&gt; is a mature programmer&#39;s (the editor, not necessarily the programmer) text editor with hundreds (counting the time developing plugins) of person-years of development behind it.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-style:italic;&quot;&gt;Caveat: I wrote this article about one and a half years ago (before i even had this blog) and then lost the file. I just dug it up almost accidentally, and so am posting it now because jEdit development moves along fairly slowly, and the information is probably still useful. please tell me in the comments, if something wrong or no longer current. i&#39;ll try to update the blog post, but can&#39;t test anything out as i&#39;m no longer on jEdit.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;What&#39;s nice about jEdit&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Written in Java, so it runs on Mac OS X, OS/2, Unix, VMS and Windows.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Built-in macro language; extensible plugin architecture. Dozens of macros&lt;br /&gt;and plugins available.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Auto indent, and syntax highlighting for more than 130 languages.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Supports a large number of character encodings including UTF8 and Unicode.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Folding for selectively hiding regions of text.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Highly configurable and customizable.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Every other feature, both basic and advanced, you would expect to find in&lt;br /&gt;a text editor. See a &lt;a href=&quot;http://www.jedit.org/index.php?page=features&quot;&gt;full list of features&lt;/a&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Scriptable in &lt;a href=&quot;http://www.ruby-lang.org/en/&quot;&gt;Ruby&lt;/a&gt;!!&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Lighter weight than most other Java based editors.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;Installation&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;I &lt;strike&gt;am&lt;/strike&gt; was running &lt;a href=&quot;http://www.ubuntu.com/&quot;&gt;Ubuntu&lt;/a&gt; Edgy so this section details my experiences installing jEdit on that platform. This is the only platform specific section in this tutorial (and is also probably hopelessly out of date). If you are running some other system check out the &lt;a href=&quot;http://www.jedit.org/index.php?page=download&quot;&gt;jEdit download page&lt;/a&gt; for details. &lt;em&gt;Disclaimer: I am by no means an Ubuntu expert so this information may be completely off.&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;First you need Java. You need to have sun-java5-jre installed, which is in ubuntu multiverse. You also want to make sure that you have java in your path. Edgy has a symbolic link chain which goes /usr/bin/java -&gt; /etc/alternatives/java -&gt; /usr/lib/jvm/java-1.5.0-sun/jre/bin/java which you should make sure is intact. Mine got screwed up (i think) when I was experimenting with sun-java6-jre. Incidentally sun-java6-jre causes an invalid pointer exception when you try to load a project in jEdit&#39;s project viewer plugin, so avoid it.&lt;br /&gt;&lt;br /&gt;Then download the &#39;Java-based installer&#39; (jedit42install.jar) file from the jEdit download page. Make sure it is version 4.2 final, because some ruby support is broken in the latest development releases.&lt;br /&gt;&lt;br /&gt;Install it:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;$ sudo java -jar jedit42install.jar&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And run it:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;$ jedit&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;The Plugins&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;jEdit should now be running. Go to Plugins-&gt;Plugin Manager, click on the Install tab, and now click Download Options. Update the mirror list and then choose a mirror, the default one never seems to work. Now check and install the following plugins:&lt;br /&gt;&lt;dl&gt;&lt;br /&gt; &lt;dt&gt;Console&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;Allows you to interact with your rails app in a shell right in jEdit&lt;/dd&gt;&lt;br /&gt; &lt;dt&gt;IRC&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;Talk to other railers on IRC without leaving jEdit&lt;/dd&gt;&lt;br /&gt; &lt;dt&gt;Project Viwer&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;Gives you a view of your project filesytem. Required by the RubyPlugin but for some reason is not included in that plugin&#39;s dependencies so you have to manually select it&lt;/dd&gt;&lt;br /&gt; &lt;dt&gt;Ruby Plugin&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;Does a whole lot of good ruby stuff.&lt;/dd&gt;&lt;br /&gt;&lt;dt&gt;SideKick&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;Gives you a birds eye view of your file structure (classes methds etc), which also works for many other languages including html. It is also involved in parsing your ruby code, catching error, autocompletion, etc.&lt;/dd&gt;&lt;br /&gt; &lt;dt&gt;SuperAbbrevs&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;Allows TextMate like snippets&lt;/dd&gt;&lt;br /&gt; &lt;dt&gt;XML&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;XML, HTML, CSS and Javascript tools&lt;/dd&gt;&lt;br /&gt; &lt;dt&gt;SuperScript&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;Allows you to script jEdit in Ruby amongst other languages&lt;/dd&gt;&lt;br /&gt;&lt;dt&gt;Macro Manager&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;An easy way to download and manage macros&lt;/dd&gt;&lt;br /&gt;&lt;/dl&gt;&lt;br /&gt;So lets put some of these plugins to good use. Go to Plugins-&gt;Project Viewer-&gt;Show Project Viewer. Now in the window that pops up there is a triangle at the top left. Click that to dock it in jEdit&#39;s main window. Once you&#39;ve docked it, click the hard drive looking thingy (or right click the &#39;All Projects&#39; folder to add a new rails project.&lt;br /&gt;&lt;br /&gt;Now go to Plugins-&gt;Plugin Options and under Sideckick-&gt;Parsers make sure that mode ruby also has parser set to ruby. Now go to Plugins-&gt;Ruby Plugin-&gt;Structure Browser and doc the window that pops up in the main window. I usually doc it on the opposite side of the project viewer so i can see both at once. Note that the structure browser is the Sidekick structure browser and will work for other languages as well. Open a ruby file from your rails project and you can see the structure browser at work.&lt;br /&gt;&lt;br /&gt;Have a goof around later with the plugins we just downloaded. And also with the many we haven&#39;t yet because there are some real gems in there.&lt;br /&gt;&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;Setting Key Bindings&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;For the sections that follow you&#39;ll need to know how to set key bindings. jEdit calls them &#39;shortcuts&#39;.&lt;br /&gt;&lt;br /&gt;To set a shortcut go to Utilities-&gt;Global Options, and then under Shortcuts set Edit Shorcuts to Built-in Commands, Macros, or your choice of Plugin. Once you have chosen one, you will see a list of the possible commands to bind for that category. Just click on one of the primary or alternative shortcut fields to enter key  for a command. If you are over-writing another command you will be warned before it is saved.&lt;br /&gt;&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;Editing Modes&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;The ruby editing mode that comes default with jEdit aint that great so let&#39;s upgrade it. Go pick up the latest greatest (v0.6) &lt;a href=&quot;http://community.jedit.org/?q=node/view/2124&quot;&gt;jEdit ruby editing mode&lt;/a&gt;. There is a small download link, right click it and save file as ruby.xml. Don&#39;t just left click on it, it&#39;ll confuse you, it did me.&lt;br /&gt;&lt;br /&gt;Once you have it put it in ~/.jedit/modes and then edit the ~/.jedit/modes/catalog file and add the following mode entry:&lt;br /&gt;&lt;pre&gt;&amp;lt;MODE NAME=&quot;ruby&quot; FILE=&quot;ruby.xml&quot; FILE_NAME_GLOB=&quot;*.{rb,rbw}&quot;&lt;br /&gt;FIRST_LINE_GLOB=&quot;#!*/*ruby*&quot; /&amp;gt;&lt;/pre&gt;&lt;br /&gt;Your ruby editing should now be a whole lot prettier. You should see the effects immediately by the way, just close and reopen the ruby file you&#39;ve been toying with.&lt;br /&gt;&lt;br /&gt;Some other modes of interest and their catalog entries:&lt;br /&gt;&lt;dl&gt;&lt;br /&gt;&lt;dt&gt;&lt;a href=&quot;http://community.jedit.org/?q=node/view/1913&quot;&gt;yaml&lt;/a&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;&lt;pre&gt;&amp;lt;MODE NAME=&quot;yaml&quot; FILE=&quot;yaml.xml&quot; &lt;br /&gt;  FILE_NAME_GLOB=&quot;*.{yml,yaml}&quot; /&amp;gt;&lt;/pre&gt;&lt;/dd&gt;&lt;br /&gt;&lt;dt&gt;&lt;a href=&quot;http://blog.wolfman.com/articles/2006/12/01/a-haml-edit-mode-for-jedit&quot;&gt;haml&lt;/a&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;&lt;pre&gt;&amp;lt;MODE NAME=&quot;haml&quot; FILE=&quot;haml.xml&quot; &lt;br /&gt;  FILE_NAME_GLOB=&quot;*.haml&quot; /&amp;gt;&lt;/pre&gt;&lt;/dd&gt;&lt;br /&gt;&lt;dt&gt;&lt;a href=&quot;http://community.jedit.org/?q=node/view/1115&quot;&gt;rdoc&lt;/a&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;&lt;pre&gt;&amp;lt;MODE NAME=&quot;ruby&quot; FILE=&quot;ruby.xml&quot; &lt;br /&gt;  FILE_NAME_GLOB=&quot;*.{rb,rbw}&quot; FIRST_LINE_GLOB=&quot;#!*/*ruby*&quot; /&amp;gt;&lt;/pre&gt;&lt;/dd&gt;&lt;br /&gt;&lt;/dl&gt;&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;Macros&lt;/h4&gt;&lt;br /&gt;&lt;dl&gt;&lt;br /&gt;&lt;dt&gt;Open related file&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;This macro lets you easily jump between models, controllers, etc. of the same base name. I don&#39;t think it&#39;s possible to install this one via. MacroManager so you&#39;ll need to get it off the web.&lt;br /&gt;&lt;br /&gt;Download the &lt;a href=&quot;http://marioaquino.blogspot.com/&quot;&gt;open related file&lt;/a&gt;  macro and place the decompressed folder under ~/.jedit/macros. Then do Macros-&gt;Rescan Macros and there should now be a Rails entry.&lt;br /&gt;&lt;br /&gt;I like to set this binding to CS+o (Control Shift o)&lt;/dd&gt;&lt;br /&gt;&lt;dt&gt;Go To Ruby Method&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;Brings up a popup menu of Ruby methods that are in the current buffer grouped by class and ordered alphabeticaly. Selecting a class or method from the menu places the caret at that member&#39;s location in the file. I like to set this binding to CS+m (Control Shift m)&lt;/dd&gt;&lt;br /&gt;&lt;dt&gt;Redundant Macros&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;A few macros have been added to the RubyPlugin and so are now redundant, namely: &#39;Search Ruby Documentation using ri&#39;, and &#39;Auto indent and insert end&#39;&lt;/dd&gt;&lt;br /&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;SuperAbbrevs, Snippets for jEedit&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;You&#39;ve probably seen the &lt;a href=&quot;http://www.youtube.com/watch?v=dy4UhY3gdC0&quot;&gt;DHH screencasts&lt;/a&gt; where he is hardly typing anything and code is just appearing magically all over the place. The SuperAbbrevs plugin allows you to do just that using abbreviations.&lt;br /&gt;&lt;br /&gt;You can get a nice set of &#39;Snippets&#39; &lt;a href=&quot;http://synthesis.sbecker.net/articles/2006/03/20/jedit-snippets-for-ruby-on-rails&quot;&gt;here&lt;/a&gt;. There is also a reference to the same &lt;a href=&quot;http://synthesis.sbecker.net/pages/jedit-snippets-for-ruby-on-rails-docs&quot;&gt;here&lt;/a&gt;. There is a great tutorial on what they are and how to use them &lt;a href=&quot;http://ifakedit.com/log/2006/02/19/jedit-tutorial-a-how-to-on-abbreviations-superabbrevs-in-html-ruby-on-rails-and-more/&quot;&gt;here&lt;/a&gt;.&lt;br /&gt;I personally like just using Tab to expand so I didn&#39;t follow his advice on C+Enter.&lt;br /&gt;&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;Tips on writing abbrevs for ruby&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;Try to keep your abbrevs generic and rubyish. For instance the default &#39;for&#39; abbrev for ruby is of this form (from memory because i changed it, so it may not be exactly this):&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;for ${1:i} in 0..${2:to} do&lt;br /&gt;$end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Which is a fairly C way of thinking of a for loop. A more generic or polymorphic way of writing this while also keeping in mind that tab is also good for moving out of the body of a block, might be written thusly:&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;for $1 in $2&lt;br /&gt;$end&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Simpler, and more flexible.&lt;br /&gt;&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;Polishing Up&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;You are never going to have to type another &#39;end&#39; again. Set a key binding to the RubyPlugin command &#39;Auto indent and insert end&#39;. You should set the primary shortcut to &#39;Enter&#39;. Don&#39;t worry about the fact that you are overriding the built in command, it won&#39;t break anything. Now try typing up a quick class and a few method defs, and while you&#39;re at it a couple control structures too.&lt;br /&gt;&lt;br /&gt;In ruby we don&#39;t like big tabs. Go to Utilities-&gt;Global Options and in the left pane choose Editing. Here you can set your tab width and indent width, and set soft tabbing which means when you hit tab it will insert space characters instead. I usually set tab width and indent width to 2, and check soft tabbing as well. &lt;a href=&quot;http://haml.hamptoncatlin.com/&quot;&gt;Haml&lt;/a&gt; likes two space &#39;tabs&#39; as well.&lt;br /&gt;&lt;br /&gt;It would be nice if we could collapse methods classes etc in order to make the file easier to look at in certain circumstances. jEdit does indeed implement code folding, let&#39;s enable it for ruby. Go to Utilities-&gt;Global Options and then under Editing set &#39;change settings for mode&#39; to ruby, make sure that &#39;Use default settings&#39; is unchecked and then set &#39;Folding mode&#39; to Sidekick. You should now have collapsable ruby code in your edit buffer.&lt;br /&gt;&lt;br /&gt;RubyPlugin and SideKick work together to give you code completion features. If you go to Plugins-&gt;Plugin Options and then SideKick you can tweek these settings. If you are like me and you hate stuff popping up all over the place without your asking for it then uncheck &#39;Show completion popups where possible&#39;. If you want to still be able to request completions on demand set a key binding for the &#39;Complete code&#39; command of the RubyPlugin. You should leave &#39;Immediately complete if possible&#39; checked as it generally doesn&#39;t get in the way and is quite useful in some modes.&lt;br /&gt;&lt;br /&gt;One last very useful couple keybings to set are the XML plugin&#39;s &#39;Characters to Entities&#39; and &#39;Entities to Characters&#39; commands. I like to set these to CS+x CS+c  and CS+x CS+e respectively.&lt;br /&gt;&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;Conclusion&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;As you can see with all the bells and whistles installed Jedit is a powerful Ruby and Rails editor. Jedit, it should be noted, is also a great editor for many other languages including the usual web lineup. I hope that this guide has eased your entry into the Ruby on Jedit world. Thanks to the very many authors, both of software, docs, and blogs who have made this document possible.</content><link rel='replies' type='application/atom+xml' href='http://crepuscular-homunculus.blogspot.com/feeds/278869150628448140/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6647087035529895010/278869150628448140' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6647087035529895010/posts/default/278869150628448140'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6647087035529895010/posts/default/278869150628448140'/><link rel='alternate' type='text/html' href='http://crepuscular-homunculus.blogspot.com/2008/08/jedit-for-ruby-on-rails.html' title='jEdit for Ruby on Rails'/><author><name>crepuscular-homunculus</name><uri>http://www.blogger.com/profile/12880267859153647874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6647087035529895010.post-5605660167055585669</id><published>2008-08-01T11:52:00.000-07:00</published><updated>2008-08-02T11:06:16.008-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="os x"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>gem_server &amp; lingon on os x leopard</title><content type='html'>hi folks. been gone for a while, but an intercontinental house move followed by a switch of operating systems can take its toll. i hope to be posting a little bit more regularly from now on.&lt;br /&gt;&lt;br /&gt;gem_server for those not in the know is a small http server which displays which &lt;a href=&quot;http://www.rubygems.org/&quot;&gt;ruby gems&lt;/a&gt; you have installed, as well as their documentation. you may have noticed that gem_server is not installed by default on os x leopard (i&#39;m running 10.5.3). you don&#39;t need it though because you can now just write:&lt;br /&gt;&lt;br /&gt;$ gem server&lt;br /&gt;&lt;br /&gt;to get it to start up automatically when you log in, just download a great little app for writing &lt;a href=&quot;http://developer.apple.com/macosx/launchd.html&quot;&gt;launchd&lt;/a&gt; plists called &lt;a href=&quot;http://lingon.sourceforge.net/&quot;&gt;lingon&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;once you have that installed just start&#39;er up and hit the &#39;+&#39; sign at the top left. choose &#39;my agents&#39; (or one of the other options if you prefer).&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTu7gcsd-hkG4sdGB4rzKgFSUPmsVYQM_9kIi4ao4xoRrs_H5EyXeVcAVo6ysTlBs3PZUaY1CZD9dOvnvxmV9aorZOS8nOrUubjpmZcREpGwhwKRLf0613E5qyfmBh_024ui8ZCWysVXs/s1600-h/lingon_screenshot.jpg&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTu7gcsd-hkG4sdGB4rzKgFSUPmsVYQM_9kIi4ao4xoRrs_H5EyXeVcAVo6ysTlBs3PZUaY1CZD9dOvnvxmV9aorZOS8nOrUubjpmZcREpGwhwKRLf0613E5qyfmBh_024ui8ZCWysVXs/s320/lingon_screenshot.jpg&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5229628543816195874&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;then under &#39;Name&#39; write:&lt;br /&gt;&lt;br /&gt;com.yourname.gem_server&lt;br /&gt;&lt;br /&gt;and under &#39;What&#39;, write (note the space):&lt;br /&gt;&lt;br /&gt;gem server&lt;br /&gt;&lt;br /&gt;then make sure that &#39;Enabled&#39; and &#39;Run it when it is loaded by the system&#39; are both checked (if you click on the pic above you can see a more detailed screenshot). hit save, give your password, and then log off, back on, and in your browser go to:&lt;br /&gt;&lt;br /&gt;http://localhost:8808/&lt;br /&gt;&lt;br /&gt;and voila!</content><link rel='replies' type='application/atom+xml' href='http://crepuscular-homunculus.blogspot.com/feeds/5605660167055585669/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6647087035529895010/5605660167055585669' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6647087035529895010/posts/default/5605660167055585669'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6647087035529895010/posts/default/5605660167055585669'/><link rel='alternate' type='text/html' href='http://crepuscular-homunculus.blogspot.com/2008/08/gemserver-lingon-on-os-x-leopard.html' title='gem_server &amp; lingon on os x leopard'/><author><name>crepuscular-homunculus</name><uri>http://www.blogger.com/profile/12880267859153647874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTu7gcsd-hkG4sdGB4rzKgFSUPmsVYQM_9kIi4ao4xoRrs_H5EyXeVcAVo6ysTlBs3PZUaY1CZD9dOvnvxmV9aorZOS8nOrUubjpmZcREpGwhwKRLf0613E5qyfmBh_024ui8ZCWysVXs/s72-c/lingon_screenshot.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6647087035529895010.post-7756496294417452804</id><published>2007-11-19T04:50:00.000-08:00</published><updated>2008-08-02T11:04:33.745-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="rdoc"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>generating prettier rdoc</title><content type='html'>If you&#39;ve ever looked at the &lt;a href=&quot;http://api.rubyonrails.com/&quot;&gt;rails documentation&lt;/a&gt; you may have wondered how DHH and crew generated it. I find it a lot prettier to look at than vanilla rdoc. It turns out that you can quite easily change the template used by rdoc.&lt;br /&gt;&lt;br /&gt;To get the rails api look, just download the &lt;a href=&quot;http://www.jamisbuck.org/svn/rdoc-templates/jamis.rb&quot;&gt;jamis rdoc template&lt;/a&gt;, courtesy of &lt;a href=&quot;http://weblog.jamisbuck.org/&quot;&gt;Jamis Buck&lt;/a&gt;. Copy it into your rdoc html templates directory, which on my &lt;a href=&quot;http://en.wikipedia.org/wiki/Ubuntu_%28Linux_distribution%29&quot;&gt;Ubuntu&lt;/a&gt; system sits at /usr/lib/ruby/1.8/rdoc/generators/template/html/. Then pass &#39;--template=jamis&#39; to rdoc and you&#39;re good to go.&lt;br /&gt;&lt;br /&gt;Another template of note is &lt;a href=&quot;http://blog.evanweaver.com/files/doc/fauna/allison/files/README.html&quot;&gt;allison&lt;/a&gt;, which comes packaged as a gem, and is not installed directly with the other templates. It is a bit annoying when you are writing a rake file because you must spell out the entire path to the template to get it to load.&lt;br /&gt;&lt;br /&gt;Note that if you use rake&#39;s rdoc task you must use the template method of the task object to set it, you cannot add &#39;--template&#39; to the rdoc options it won&#39;t work for some reason. I wasted a good 15 minutes figuring that one out.&lt;br /&gt;&lt;br /&gt;Below are all the templates i know of. Those marked with * are &lt;em&gt;not&lt;/em&gt; included by default.  If you know of any other nice templates out there, please let me know and I&#39;ll add them to the list.&lt;br /&gt;&lt;br /&gt;&lt;dl&gt;&lt;br /&gt; &lt;dt&gt;html&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;&lt;p&gt;the default template we know and, well, just live with.&lt;/p&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7YjgSUYpOWkaYzwOnoyImCogohxY4lW6WOlxZ3cYtGwelixAwJsRKWTq8DhI6rEVpnh_tKZtE3vCxJ9aolZfw2LLhtqJI_RFOI8ZknhiXPNpimP2nMitwyoAmAV1516EmQVSd1tT9l-g/s1600-h/html.jpg&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7YjgSUYpOWkaYzwOnoyImCogohxY4lW6WOlxZ3cYtGwelixAwJsRKWTq8DhI6rEVpnh_tKZtE3vCxJ9aolZfw2LLhtqJI_RFOI8ZknhiXPNpimP2nMitwyoAmAV1516EmQVSd1tT9l-g/s320/html.jpg&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5134567877232712914&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/dd&gt;&lt;br /&gt; &lt;dt&gt;hefss&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;&lt;p&gt;similar in layout to the jamis template but using a rather unwieldy fourth frame for the main content, and (imho) nowhere near as pretty&lt;/p&gt;&lt;/dd&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg00Wfsx2McqvgcOUWu3ZOkXAhBDBBswUM1dcC4DEp1NnDGTXrjRWMwvyPbLnuh3rROZqfHaPx6cizwkhl1aS0pyRGnA0IHhuxmSh0imPTdJrC0jdxkUwKS4t6LLoIlbHnt6g5rvaHpONw/s1600-h/hefss.jpg&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg00Wfsx2McqvgcOUWu3ZOkXAhBDBBswUM1dcC4DEp1NnDGTXrjRWMwvyPbLnuh3rROZqfHaPx6cizwkhl1aS0pyRGnA0IHhuxmSh0imPTdJrC0jdxkUwKS4t6LLoIlbHnt6g5rvaHpONw/s320/hefss.jpg&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5134569706888781026&quot; /&gt;&lt;/a&gt;&lt;br /&gt; &lt;dt&gt;kilmer&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;&lt;p&gt;this one is layed out just like jamis, but is a bit lighter weight&lt;/p&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLgy55-OvRcCDRexYCq90RB7T3Xn2DqrVVcQhpn6VCoTlEoH6g643UmZSP_jNEbU2OOS6Y8ebFHuAVihxIVXL1wZMZnHNaxwTgrvKxQrcvpA8iqSxuaD95sj_bg8wvZS2yoPlMlaQsIGI/s1600-h/kilmer.jpg&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhLgy55-OvRcCDRexYCq90RB7T3Xn2DqrVVcQhpn6VCoTlEoH6g643UmZSP_jNEbU2OOS6Y8ebFHuAVihxIVXL1wZMZnHNaxwTgrvKxQrcvpA8iqSxuaD95sj_bg8wvZS2yoPlMlaQsIGI/s320/kilmer.jpg&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5134571107048119538&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/dd&gt;&lt;br /&gt; &lt;dt&gt;old_html&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;&lt;p&gt;just like regular html but with a lighter color scheme. i almost like it better than the standard html template&lt;/p&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5D1CBsm7ht4KRJ7mhxT2BUadGr4kiZ99cV2EQo1mSJL4jujWliG1olOskP-kl_GR0UcHXDyJnRo64rfXUGF_yaI-DIiQdcgeYZh50bmOW0C4wDI0fjod-Knl3AytcJRocsJHSUHf9m8E/s1600-h/old_html.jpg&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5D1CBsm7ht4KRJ7mhxT2BUadGr4kiZ99cV2EQo1mSJL4jujWliG1olOskP-kl_GR0UcHXDyJnRo64rfXUGF_yaI-DIiQdcgeYZh50bmOW0C4wDI0fjod-Knl3AytcJRocsJHSUHf9m8E/s320/old_html.jpg&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5134572593106803970&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/dd&gt;&lt;br /&gt; &lt;dt&gt;jamis*&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;&lt;p&gt;a nice template used by rails, rake, and a host of other projects online&lt;/p&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5xxh641QUQBEwL5_f3CcnFX2BCgUXANI9c372K2UWHloaHUx0Eoy2-NbtBYT0mHIoVY2O0IXPoGIry0GqJ8pQ7z2RllEZUlqaJgQbooSlvFWd6-CyNuzyo7kxsx2mxOxzdVweNh4DzGk/s1600-h/jamis.jpg&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5xxh641QUQBEwL5_f3CcnFX2BCgUXANI9c372K2UWHloaHUx0Eoy2-NbtBYT0mHIoVY2O0IXPoGIry0GqJ8pQ7z2RllEZUlqaJgQbooSlvFWd6-CyNuzyo7kxsx2mxOxzdVweNh4DzGk/s320/jamis.jpg&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5134573911661763858&quot; /&gt;&lt;/a&gt;&lt;/dd&gt;&lt;br /&gt; &lt;dt&gt;allison*&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;&lt;p&gt;another nice one which, refreshingly, has no frames&lt;/p&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglYcE3-hAzv0Xc4RbQVL4s7sFeLrLrslie94Pjg7ssLH_j5cgXX2mzzgwZ010-qN5mkPtfBJY7Ov7SoOzi9j2ROS-ILhzx2ZTityD10WoYOnL4eU2mLcbJpY_cz8fM_9RyMoEJZR_xyEQ/s1600-h/allison.jpg&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglYcE3-hAzv0Xc4RbQVL4s7sFeLrLrslie94Pjg7ssLH_j5cgXX2mzzgwZ010-qN5mkPtfBJY7Ov7SoOzi9j2ROS-ILhzx2ZTityD10WoYOnL4eU2mLcbJpY_cz8fM_9RyMoEJZR_xyEQ/s320/allison.jpg&quot; border=&quot;0&quot; alt=&quot;&quot;id=&quot;BLOGGER_PHOTO_ID_5134573915956731170&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/dd&gt;&lt;br /&gt; &lt;dt&gt;one_page_html&lt;/dt&gt;&lt;br /&gt; &lt;dd&gt;this one doesn&#39;t even work for me, i get &lt;br /&gt;&lt;pre&gt;&lt;br /&gt;  Generating HTML...&lt;br /&gt;  rake aborted!&lt;br /&gt;  uninitialized constant RDoc::Page::STYLE&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/dd&gt;&lt;br /&gt;&lt;/dl&gt;&lt;br /&gt;&lt;br /&gt;As you can see there are quite a few templates to choose from. It would be nice if there were some standardized way of packaging and distributing them though, maybe even with a web based repository that users could submit to. I&#39;d also like to be able to include the template which i want used when the rdoc for a gem is automatically generated, something which i don&#39;t think is possible at the moment? Maybe some of you out there know how to do this. Hope I&#39;ve been of some help, cheers and happy hacking.</content><link rel='replies' type='application/atom+xml' href='http://crepuscular-homunculus.blogspot.com/feeds/7756496294417452804/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6647087035529895010/7756496294417452804' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6647087035529895010/posts/default/7756496294417452804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6647087035529895010/posts/default/7756496294417452804'/><link rel='alternate' type='text/html' href='http://crepuscular-homunculus.blogspot.com/2007/11/generating-prettier-rdoc.html' title='generating prettier rdoc'/><author><name>crepuscular-homunculus</name><uri>http://www.blogger.com/profile/12880267859153647874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7YjgSUYpOWkaYzwOnoyImCogohxY4lW6WOlxZ3cYtGwelixAwJsRKWTq8DhI6rEVpnh_tKZtE3vCxJ9aolZfw2LLhtqJI_RFOI8ZknhiXPNpimP2nMitwyoAmAV1516EmQVSd1tT9l-g/s72-c/html.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6647087035529895010.post-2698390712016409720</id><published>2007-11-03T03:41:00.000-07:00</published><updated>2008-08-02T11:05:00.780-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><title type='text'>Advanced Ruby Tips And Tricks, Part 1</title><content type='html'>Welcome to this first installment of Advanced Ruby Tips and Tricks. In this little series I plan on covering anything ruby which goes beyond writing basic classes and methods; topics like &lt;a href=&quot;http://en.wikipedia.org/wiki/Meta-programming&quot;&gt;meta-programming&lt;/a&gt;, &lt;a href=&quot;http://en.wikipedia.org/wiki/Runtime_library&quot;&gt;runtime&lt;/a&gt; &lt;a href=&quot;http://en.wikipedia.org/wiki/Callback_%28computer_science%29&quot;&gt;callbacks&lt;/a&gt;, &lt;a href=&quot;http://en.wikipedia.org/wiki/Closure_%28computer_science%29&quot;&gt;closures&lt;/a&gt; and &lt;a href=&quot;http://en.wikipedia.org/wiki/Continuations&quot;&gt;continuations&lt;/a&gt;. Doubtless for some of you none of these topics will seem particularly advanced, but that&#39;s because you&#39;re already advanced :) So here goes...&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;Problem&lt;/h4&gt;&lt;br /&gt;You are designing an &lt;a href=&quot;http://en.wikipedia.org/wiki/Api&quot;&gt;API&lt;/a&gt;. You want to include some small class which has dependencies the rest of your library does not have, and whose use is only optional, but you don&#39;t want the end user to have to require the files manually.&lt;br /&gt;&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;Solution&lt;/h4&gt;&lt;pre class=&quot;ruby&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;class &lt;/span&gt;&lt;span class=&quot;class&quot;&gt;XMLTracer&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;span class=&quot;keyword&quot;&gt;def &lt;/span&gt;&lt;span class=&quot;method&quot;&gt;self.new&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;ident&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;loading...&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;ident&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;rubygems&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&#39;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;ident&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&#39;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;LoadError&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;keyword&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;LoadError&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;must have builder installed...&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;keyword&quot;&gt;else&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;keyword&quot;&gt;def &lt;/span&gt;&lt;span class=&quot;method&quot;&gt;self.new&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;ident&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;new is the new new&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;keyword&quot;&gt;super&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;ident&quot;&gt;new&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;span class=&quot;keyword&quot;&gt;def &lt;/span&gt;&lt;span class=&quot;method&quot;&gt;initialize&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;attribute&quot;&gt;@xml&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;Builder&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;constant&quot;&gt;XmlMarkup&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;(&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;symbol&quot;&gt;:target&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;STDOUT&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;br /&gt;      &lt;span class=&quot;symbol&quot;&gt;:indent&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;number&quot;&gt;2&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;punct&quot;&gt;)&lt;/span&gt; &lt;br /&gt;  &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;  &lt;span class=&quot;keyword&quot;&gt;def &lt;/span&gt;&lt;span class=&quot;method&quot;&gt;identity&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;attribute&quot;&gt;@xml&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;instruct!&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;attribute&quot;&gt;@xml&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;comment!&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;Crepuscular Homunculus :: &lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;+&lt;/span&gt;&lt;br /&gt;                   &lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;Advanced Ruby Tips and Tricks, Part 1&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&amp;quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;attribute&quot;&gt;@xml&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;class &lt;/span&gt;&lt;span class=&quot;class&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;|&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;ident&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;name&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;ident&quot;&gt;c&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;ident&quot;&gt;object_id&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;  &lt;br /&gt;  &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;&lt;br /&gt;  &lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;ident&quot;&gt;x1&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;XMLTracer&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;new&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;ident&quot;&gt;x2&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;XMLTracer&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;new&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;ident&quot;&gt;puts&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;ident&quot;&gt;x1&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;identity&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;ident&quot;&gt;x2&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;ident&quot;&gt;identity&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;h5 class=&quot;polypus_header&quot;&gt;Which Outputs&lt;/h5&gt;&lt;pre&gt;&lt;br /&gt;loading...&lt;br /&gt;new is the new new&lt;br /&gt;new is the new new&lt;br /&gt;&lt;br /&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;&amp;lt;!-- Crepuscular Homunculus :: Advanced Ruby Tips and Tricks, Part 1 --&amp;gt;&lt;br /&gt;&amp;lt;class&amp;gt;&lt;br /&gt;  &amp;lt;name&amp;gt;XMLTracer&amp;lt;/name&amp;gt;&lt;br /&gt;  &amp;lt;id&amp;gt;-607742088&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;/class&amp;gt;&lt;br /&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;br /&gt;&amp;lt;!-- Crepuscular Homunculus :: Advanced Ruby Tips and Tricks, Part 1 --&amp;gt;&lt;br /&gt;&amp;lt;class&amp;gt;&lt;br /&gt;  &amp;lt;name&amp;gt;XMLTracer&amp;lt;/name&amp;gt;&lt;br /&gt;  &amp;lt;id&amp;gt;-607742198&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;lt;/class&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;h4 class=&quot;polypus_header&quot;&gt;Walkthrough&lt;/h4&gt;&lt;br /&gt;&lt;br /&gt;The first odd thing you might notice, which you don&#39;t see in the wild that often, is that the body of our self.new method contains a rescue and else clause. This is possible because method bodies implicitly are begin end blocks.&lt;br /&gt;&lt;br /&gt;The other slightly odd thing if you&#39;re coming from more static languages is that the require statements are actually just methods and so can be called dynamically at runtime. What we are doing here is calling require only if the end-user creates a new instance of our XMLTracer class. If for some reason the requires fail, we&#39;ll catch and rethrow the load error.&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;ruby&quot;&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;def &lt;/span&gt;&lt;span class=&quot;method&quot;&gt;self.new&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;ident&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;rubygems&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&#39;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;ident&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&#39;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;builder&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&#39;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;LoadError&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;keyword&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;constant&quot;&gt;LoadError&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;must have builder installed, blah blah blah&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&quot;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Here is where it starts to get interesting. The code after the else clause is only run if no exceptions are thrown, so we know that builder has been successfully loaded. At this point we could just call super because require is smart enough not to reload previously loaded files, but that represents some unnecessary overhead every time a new XMLTracer is instantiated.&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;ruby&quot;&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;else&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;keyword&quot;&gt;def &lt;/span&gt;&lt;span class=&quot;method&quot;&gt;self.new&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;ident&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;punct&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;string&quot;&gt;new is the new new&lt;/span&gt;&lt;span class=&quot;punct&quot;&gt;&quot;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;keyword&quot;&gt;super&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;ident&quot;&gt;new&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;keyword&quot;&gt;end&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Ruby&#39;s dynamic nature means that methods can be re-bound at runtime, so we redefine the new method to just call super, and then we call it explicitly to return a new instance. But from then on calling XMLTracer.new will not attempt to require anything. Which you can see in the output, where &quot;loading...&quot; is written only once.&lt;br /&gt;&lt;br /&gt;Well, that wraps up this first installment of ARTT. Hope it has been of some use to you. If you have any suggestions/requests for future articles, please let them be known through the comments.&lt;br /&gt;&lt;br /&gt;cheers, and happy hacking!</content><link rel='replies' type='application/atom+xml' href='http://crepuscular-homunculus.blogspot.com/feeds/2698390712016409720/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6647087035529895010/2698390712016409720' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6647087035529895010/posts/default/2698390712016409720'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6647087035529895010/posts/default/2698390712016409720'/><link rel='alternate' type='text/html' href='http://crepuscular-homunculus.blogspot.com/2007/11/advanced-ruby-tips-and-tricks-part-1.html' title='Advanced Ruby Tips And Tricks, Part 1'/><author><name>crepuscular-homunculus</name><uri>http://www.blogger.com/profile/12880267859153647874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6647087035529895010.post-3542602129182591590</id><published>2007-10-23T08:32:00.000-07:00</published><updated>2008-08-08T10:33:59.988-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="editors"/><category scheme="http://www.blogger.com/atom/ns#" term="rails"/><category scheme="http://www.blogger.com/atom/ns#" term="ruby"/><category scheme="http://www.blogger.com/atom/ns#" term="ubuntu"/><title type='text'>Gedit for Ruby (and everything else) on Gutsy, or No you don&#39;t need that Mac Mini.</title><content type='html'>&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQqLcd5kH_6NdrCUwCXvtjhyphenhyphenBEpg13mhVWZrWrMULqI-aErtMz3BjdyWNZs-TaPO73coMOWrWI6sxAKf-w3Nhz-0ipRjRFml0WjL6GphNulGpx-EdztxYAEo2-BYRUoYoMowTvYPfqmno/s1600-h/gedit_4_ruby.png&quot;&gt;&lt;img style=&quot;margin: 0pt 20px 10px 0pt; float: left; cursor: pointer; width: 395px; height: 245px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQqLcd5kH_6NdrCUwCXvtjhyphenhyphenBEpg13mhVWZrWrMULqI-aErtMz3BjdyWNZs-TaPO73coMOWrWI6sxAKf-w3Nhz-0ipRjRFml0WjL6GphNulGpx-EdztxYAEo2-BYRUoYoMowTvYPfqmno/s320/gedit_4_ruby.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5124570975738499522&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;You can find many blog posts online about turning &lt;a href=&quot;http://www.gnome.org/projects/gedit/&quot;&gt;Gedit&lt;/a&gt;, Ubuntu&#39;s default text editor, into a &lt;a href=&quot;http://macromates.com/&quot;&gt;Textmate&lt;/a&gt; clone.&lt;br /&gt;&lt;br /&gt;Unfortunately most of these posts no longer apply, because Gedit is now even better than before, as Gutsy Gibbon is now shipping with a new and improved version based on the GTKSourceView2 widget, which allows for context sensitive syntax highlighting, and big speed improvements, amongst other things.&lt;br /&gt;&lt;br /&gt;The first thing you&#39;ll want to do is use your favorite package management front-end and install the gedit-plugins package, which includes a few extra plugins. Then go &lt;a href=&quot;http://robzon.aenima.pl/2007/10/ubuntu-710-rails-gedit-and.html&quot;&gt;here&lt;/a&gt;, and follow his instructions on installing the mime types and lang files. He also has a few snippets, and other tips which are quite up to date. If you are running rails 2.0 you&#39;ll also want to edit his mime types file and add a couple of glob entries to handle the new view naming scheme.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;mime-type type=&quot;text/rhtml&quot;&amp;gt;&lt;br /&gt;  &amp;lt;sub-class-of type=&quot;text/html&quot;&amp;gt;&lt;br /&gt;  &amp;lt;comment&gt;RHTML Template&amp;lt;/comment&amp;gt;&lt;br /&gt;  &amp;lt;glob pattern=&quot;*.rhtml&quot;/&amp;gt;&lt;br /&gt;  &amp;lt;glob pattern=&quot;*.erb&quot;/&amp;gt;&lt;br /&gt;&amp;lt;/mime-type&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;mime-type type=&quot;application/x-ruby&quot;&amp;gt;&lt;br /&gt;  &amp;lt;comment&gt;Ruby XML Template&amp;lt;/comment&amp;gt;&lt;br /&gt;  &amp;lt;glob pattern=&quot;*.rxml&quot;/&amp;gt;&lt;br /&gt;  &amp;lt;glob pattern=&quot;*.builder&quot;/&amp;gt;&lt;br /&gt;&amp;lt;/mime-type&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can find many more snippets &lt;a href=&quot;http://blog.nationcode.com/2007/5/30/emular-textmate-en-linux&quot;&gt;here&lt;/a&gt;, and in case you don&#39;t understand Spanish, &lt;a href=&quot;http://blog.nationcode.com/assets/2007/8/1/geditexmate.tar.gz&quot;&gt;here&lt;/a&gt; are the files. You will only want to use his snippets and discard the rest though. Place them in &#39;.gnome2/gedit/snippets&#39;. There are other snippets around the web if you just google a bit. You&#39;ll probably end up customizing them a lot, i did. Also be sure to download the &lt;a href=&quot;http://live.gnome.org/GtkSourceView/StyleSchemes&quot;&gt;textmate-like syntax highlighting style&lt;/a&gt;. Place all downloaded styles in &#39;/usr/share/gtksourceview-2.0/styles&#39;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now just open up &#39;Applications-&gt;Accessories-&gt;Text Editor&#39; and then in Gedit, &#39;Edit-&gt;Preferences&#39; and check all options under View.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipiPWnrYN0s-MgI1UPUTi16rz-7PiDIGOpoVTiKwvkztWxzOxGzhDNNKuGVa_akgkV9G-DXs_773e06qsbWLcYupLY5fXickxGRLzrX_GD5GDbxzFM1H-ozIxifRPe8oJPSQw2sbW93c0/s1600-h/gedit_prefs_view.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 300px; height: 370px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipiPWnrYN0s-MgI1UPUTi16rz-7PiDIGOpoVTiKwvkztWxzOxGzhDNNKuGVa_akgkV9G-DXs_773e06qsbWLcYupLY5fXickxGRLzrX_GD5GDbxzFM1H-ozIxifRPe8oJPSQw2sbW93c0/s320/gedit_prefs_view.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5124587902204613154&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Then under Editor set your tab prefs, I like a width of 2 and I also check insert spaces instead of tabs, and enable automatic indentation.&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjmj9u3qhBYdiJnCJnVBQlOTi6WABWYUwcufUqEy1Ry4DrlewowkePu_gf1XbD9DV5VnVmNn4_Pd3dIWxTVSsE0ALV-rjDYhVaXEzxhvLd7P0qmKvZRob6ZocpNln2fAPdAV9rSpm0roM/s1600-h/gedit_prefs_editor.png&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 300px; height: 370px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjmj9u3qhBYdiJnCJnVBQlOTi6WABWYUwcufUqEy1Ry4DrlewowkePu_gf1XbD9DV5VnVmNn4_Pd3dIWxTVSsE0ALV-rjDYhVaXEzxhvLd7P0qmKvZRob6ZocpNln2fAPdAV9rSpm0roM/s320/gedit_prefs_editor.png&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5124587631621673490&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Under &#39;Fonts and Colors&#39; you might want to enable Darkmate or Oblivion. You can also download the &lt;a href=&quot;http://rubymm.blogspot.com/2007/08/make-gedit-behave-roughly-like-textmate.html&quot;&gt;monaco font used on apple&lt;/a&gt;, but remember that much of what he says in the post no longer applies, so tread carefuly.&lt;br /&gt;&lt;br /&gt;Then under plugins be sure to activate: Bracket Completion, Embedded Terminal, External Tools, File Browser Pane, and Snippets. There is a Gemini plugin out there which does kind of what Bracket Completion does but I prefer the latter. You might also want to check out Session Saver, Class Browser, and Snap Open plugins. Check out this &lt;a href=&quot;http://live.gnome.org/Gedit/Plugins&quot;&gt;list of Gedit plugins&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;You should now be good to go! A big heads up to Joselo, and Robert from Nationcode and Insane Terminology respectively, and Luigi for the textmate theme!</content><link rel='replies' type='application/atom+xml' href='http://crepuscular-homunculus.blogspot.com/feeds/3542602129182591590/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/6647087035529895010/3542602129182591590' title='12 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6647087035529895010/posts/default/3542602129182591590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6647087035529895010/posts/default/3542602129182591590'/><link rel='alternate' type='text/html' href='http://crepuscular-homunculus.blogspot.com/2007/10/gedit-for-ruby-and-everything-else-on.html' title='Gedit for Ruby (and everything else) on Gutsy, or No you don&#39;t need that Mac Mini.'/><author><name>crepuscular-homunculus</name><uri>http://www.blogger.com/profile/12880267859153647874</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQqLcd5kH_6NdrCUwCXvtjhyphenhyphenBEpg13mhVWZrWrMULqI-aErtMz3BjdyWNZs-TaPO73coMOWrWI6sxAKf-w3Nhz-0ipRjRFml0WjL6GphNulGpx-EdztxYAEo2-BYRUoYoMowTvYPfqmno/s72-c/gedit_4_ruby.png" height="72" width="72"/><thr:total>12</thr:total></entry></feed>