<?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>Dr Nic &#187; NewGem</title>
	<atom:link href="http://drnicwilliams.com/category/ruby/gems/newgem/feed/" rel="self" type="application/rss+xml" />
	<link>http://drnicwilliams.com</link>
	<description>Ruby makes Rails, Javascript makes Ajax, Dr Nic makes Magic</description>
	<lastBuildDate>Tue, 01 Jun 2010 12:54:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>newgem 1.0.0 all thanks to Cucumber</title>
		<link>http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/</link>
		<comments>http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 16:51:14 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Gems]]></category>
		<category><![CDATA[NewGem]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=316</guid>
		<description><![CDATA[The New Gem Generator (newgem) was exciting, moderately revolutionary, and definitely helpful two years ago when I created it. Of late it seems to attract a chunk of criticism: making a new gem, but newgem seems broken&#8230; hoe hoe NewGem has the &#8220;hoe&#8221; virus. Much prefer Mr. Bones. the newgem site is begging for someone [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2009/11/03/first-look-at-rails-3-0-pre/' rel='bookmark' title='Permanent Link: First look at rails 3.0.pre'>First look at rails 3.0.pre</a> <small> This article is out of date in some aspects....</small></li><li><a href='http://drnicwilliams.com/2009/04/15/cucumber-building-a-better-world-object/' rel='bookmark' title='Permanent Link: Cucumber: building a better World (object)'>Cucumber: building a better World (object)</a> <small>How to write helper libraries for your Cucumber step definitions...</small></li><li><a href='http://drnicwilliams.com/2009/03/26/testing-outbound-emails-with-cucumber/' rel='bookmark' title='Permanent Link: Testing outbound emails with Cucumber'>Testing outbound emails with Cucumber</a> <small> My testimonial for Cucumber still stands even in 2009....</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>The New Gem Generator (<a href="http://newgem.rubyforge.org">newgem</a>) was exciting, moderately revolutionary, and definitely helpful two years ago when I created it. Of late it seems to attract a chunk of criticism:</p>
<ul>
<li>making a new gem, but newgem seems broken&#8230; hoe hoe</li>
<li>NewGem has the &#8220;hoe&#8221; virus. Much prefer Mr. Bones.</li>
<li>the newgem site is begging for someone to put the word fuck on its front page</li>
<li>Almost two days fighting with newgem, but today i won! The secret is hoe 1.7.0 and rubygem 1.2.0.</li>
<li>unfortunately for the one project I went with newgem, will give Mr. Bones a try on the next gem I throw out there.</li>
<li>sow or newgem, neither, Mr. Bones</li>
<li>egads, the website newgem sets up for you looks awful</li>
<li>newgem seems to be failed to generate package if AUTHOR is an array of authors.</li>
</ul>
<p>On the positive side of the spectrum is the following list:</p>
<ul>
<li>newgem? really? you rock drnic!</li>
</ul>
<p>Comparatively, the two lists are awfully different in length. And not in a good way. No, not at all.</p>
<p>I know about these criticisms and platitude(s) because they appear publicly on <a href="http://newgem.rubyforge.org">newgem&#8217;s website</a> within a live Twitter search of &#8216;<a href="http://search.twitter.com/search?q=newgem">newgem</a>&#8217;. So that the twitter messages on the project&#8217;s own homepage are more positive, it was time for a new direction. A new beginning. It was time for a change.</p>
<p>So I fixed it. All of it. As of release 1.0.3 it is perfect [1]. </p>
<p>To help you realise how wonderful newgem now is, I shall use the time-proven medium for proving awesomeness: a list. The bullet points are for free.</p>
<ul>
<li>newgem now finally gone 1.0.0. It made it all the way to 0.29.0, but I think 1.0.0 was needed to transfer the message of a new beginning. This is the Obama of Gem Generators.</li>
<li>Generated gems are 50% smaller. No more config/hoe.rb. No more website folder (by default). No more tasks folder. No more license file. No more version.rb file.</li>
<li>Very little config required before releasing your gem. Just a few fields in the <code>Rakefile</code>.</li>
<li>You can use rspec or test/unit for unit testing (option: <code>-T rspec</code>)</li>
<li>You can use cucumber for functional testing (option: <code>-i cucumber</code> or run <code>script/generate install_cucumber</code>)</li>
<li>Generated gems are future-proofed. They will automatically benefit from future newgem releases.</li>
<li>Executable apps within gems now have a <code>lib/appname/cli.rb</code> file for the code base, and a lightweight <code>bin/appname</code> (option: <code>-b appname</code> or run <code>script/generate executable appname</code>)</li>
<li>Your README file can be called <code>README.rdoc</code> so it appears nicely formatted on github. No more hoe warning messages about &#8220;README.txt is missing&#8221; (see <a href="http://github.com/drnic/newgem/tree/master/features/rubygem_tasks.feature#L15-19">feature</a>)</li>
<li><a href="http://github.com/">GitHub</a> RubyGem support. <code>rake gemspec</code> generates a clean <code>my_project.gemspec</code> file that will work with GitHub</li>
<li>RubyForge support. As before, <code>rake release VERSION=X.Y.Z</code> releases your project to RubyForge (see &#8216;<a href="http://newgem.rubyforge.org/rubyforge.html">preparing for releases to rubyforge</a>&#8217; help page)</li>
<li>newgem&#8217;s website is a different colour. Its a nice peppermint green colour. The default website template is now this theme too.</li>
<li>You can raise bugs or suggest improvements via <a href="http://drnic.lighthouseapp.com/projects/18881-newgem">Lighthouse tracker</a></li>
</ul>
<h3 id="installation">Installation</h3>
<pre>sudo gem install newgem
</pre>
<h3 id="usage">Usage</h3>
<p>To create your RubyGem scaffold:</p>
<pre>newgem mygem
newgem mygem -b myapp              # create a CLI executable
newgem mygem -T rspec -i cucumber  # use rspec and cucumber for gem tests
newgem mygem -w                    # create a simple website
newgem -h                          # get help
</pre>
<p>Now your code goes in <code>lib</code> folder, and your tests go in <code>test</code>, <code>spec</code>, and/or <code>features</code> as appropriate.</p>
<p>There are a bunch of rails-esque generators (like <code>model</code> or <code>migration</code>) that you can use to help your development:</p>
<pre>script/generate executable myapp                       # create your own command-line interface (CLI)
script/generate extconf mylib                          # starting point for C-extensions, plus TDD framework
script/generate component_generator mygenerator scope  # create your own generators for Rails, Merb, RubyGems
script/generate application_generator myapp            # create a CLI that is a generator for something
script/generate -h                                     # get help
</pre>
<h3 id="bugs_and_suggestions">Bugs and suggestions</h3>
<p>You can raise bugs or suggest improvements via <a href="http://drnic.lighthouseapp.com/projects/18881-newgem">Lighthouse tracker</a></p>
<h3 id="thanks_goes_to8230_cucumber">Thanks goes to&#8230; Cucumber</h3>
<p>Aside from several days of my time refactoring it, reducing it, and doubling the amount of awesomeness within it, all its wondefulness is thanks to Cucumber. </p>
<p><a href="http://github.com/aslakhellesoy/cucumber">Cucumber</a> is the successor to Rspec Story Runner. I never found time to play with Story Runner, but Cucumber is blowing my mind with awesomeness. My attention-span is short so I may be forgetting something but I think Cucumber could be the most important piece of software released in 2008 for Ruby-based developers.</p>
<p>Cucumber gave me a framework to specify newgem&#8217;s expected behaviour; its features. First I wrote feature descriptions for known, expected behaviour. Then I refactored the crap out of newgem until it was in tip-top shape.</p>
<p>There are over 90 feature steps defining newgem&#8217;s current features. To run them:</p>
<pre>gem unpack newgem
cd newgem-*
sudo gem install cucumber
cucumber features
</pre>
<p>And watch the awesomeness of Cucumber unfold before your eyes. What you are seeing isn&#8217;t just newgem&#8217;s generators being executed, but also the generated code is being executed, rake tasks executed, and generated test files tested.</p>
<p>I can now setup continuous integration for newgem. I have a framework to know that newgem, or any other RubyGem, is doing what it should do. </p>
<p>UPDATE: I want to thank <a href="http://blog.davidchelimsky.net">David Chelimsky</a> for our time hanging out in Brazil during RailsSummit. I saw him using Cucumber, and talking about it on stage and then help helped me whilst I integrated it into newgem as a generator and then using it internally itself. For a day and a half we hung out in the hotel foyer. He&#8217;s so wonderful.</p>
<p>Cucumber makes me so happy.</p>
<h3 id="summary">Summary</h3>
<p>Use <a href="http://newgem.rubyforge.org/">newgem</a>. Write gems.</p>
<p>Use <a href="http://github.com/TwP/bones/tree/master">mrbones</a>. Write gems.</p>
<p>Use <a href="http://seattlerb.rubyforge.org/hoe/">sow</a>. Write gems.</p>
<p><o>Use <a href="http://github.com/dcrec1/gemhub/tree/master">gemhub</a>. Write gems.</p>
<p>And write cucumber feature descriptions first. Then unit tests. Then code. Then release. Then profit.</p>
<p>[1] All claims of perfection are for the express purpose of making you try the product enough to use it, share it with your friends, and wrap it up and give it as a gift to family on Xmas day. Gift boxes are available upon request.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2009/11/03/first-look-at-rails-3-0-pre/' rel='bookmark' title='Permanent Link: First look at rails 3.0.pre'>First look at rails 3.0.pre</a> <small> This article is out of date in some aspects....</small></li><li><a href='http://drnicwilliams.com/2009/04/15/cucumber-building-a-better-world-object/' rel='bookmark' title='Permanent Link: Cucumber: building a better World (object)'>Cucumber: building a better World (object)</a> <small>How to write helper libraries for your Cucumber step definitions...</small></li><li><a href='http://drnicwilliams.com/2009/03/26/testing-outbound-emails-with-cucumber/' rel='bookmark' title='Permanent Link: Testing outbound emails with Cucumber'>Testing outbound emails with Cucumber</a> <small> My testimonial for Cucumber still stands even in 2009....</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Writing C extensions in RubyGems using newgem generators (plus a free TextMate bundle)</title>
		<link>http://drnicwilliams.com/2008/04/01/writing-c-extensions-in-rubygems/</link>
		<comments>http://drnicwilliams.com/2008/04/01/writing-c-extensions-in-rubygems/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 11:51:07 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[NewGem]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/?p=269</guid>
		<description><![CDATA[Already know C extensions in RubyGems? Cool &#8211; then just run the following cmds and see what can be generated for you; plus check out the TextMate bundle at the bottom. sudo gem install newgem newgem pickaxe cd pickaxe script/generate extconf my_test rake test For everyone else&#8230; Its 15000km from Brisbane AU to Prague CZ [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/' rel='bookmark' title='Permanent Link: newgem 1.0.0 all thanks to Cucumber'>newgem 1.0.0 all thanks to Cucumber</a> <small>The New Gem Generator (newgem) was exciting, moderately revolutionary, and...</small></li><li><a href='http://drnicwilliams.com/2008/05/12/textmate-bundles-for-merb/' rel='bookmark' title='Permanent Link: TextMate bundles for Merb'>TextMate bundles for Merb</a> <small>If you are using TextMate (OS X) or E Text...</small></li><li><a href='http://drnicwilliams.com/2007/08/20/newgem-using-rubigen-for-generator-support/' rel='bookmark' title='Permanent Link: NewGem Generator &#8211; now with script/generate'>NewGem Generator &#8211; now with script/generate</a> <small>The New Gem Generator (0.13.0)&#8217;s newgem command now behaves like...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Already know C extensions in RubyGems? Cool &#8211; then just run the following cmds and see what can be generated for you; plus check out the TextMate bundle at the bottom.</p>
<pre>sudo gem install newgem
newgem pickaxe
cd pickaxe
script/generate extconf my_test
rake test
</pre>
<p>For everyone else&#8230;</p>
<p>Its <a href="http://www.timeanddate.com/worldclock/distanceresult.html?p1=47&amp;p2=204">15000km</a> from Brisbane AU to Prague CZ where <a href="http://www.euruko2008.org/">Euruko2008</a> &#8211; the European Ruby Conf &#8211; was held. I came ready to <a href="http://...">talk</a>, to met lots of cool multi-lingual Rubyists, and to learn. Ooh, I learnt something alright.</p>
<p>Tim Becker was introducing <a href="http://blog.kuriositaet.de/?p=220">Native C Extensions for Ruby</a>, and fortunately he said &#8220;now, everyone, follow along with this example&#8221;. I&#8217;d never done native C extensions, but I&#8217;d received lots of requests from RubyGem developers on how to do it. I had no idea.</p>
<p>So I was typing in everything Tim told me to type in. When Tim changed slides too quickly, I may have yelled at him to slow down. Perhaps I was the only one doing his tutorial out of 300 people, but I didn&#8217;t care. This was gold.</p>
<p>After he finished his session, I dragged him off into the corridor with Jonas Pfenniger (zimbatm), and the three of us mapped out a generic layout for how native C extensions work within RubyGems. I didn&#8217;t know any of this, but Tim and Jonas did, and we probably looked silly sitting at a small table in the middle of the narrow corridor. </p>
<p><em>But at the end, we had a working RubyGem with native C extensions that were built: when the tests were executed via rake, and when the gem was installed. The next day I figured out how to get the C extension built via autotest.</em></p>
<p>Thanks to Tim and Jonas I was able to then write a <code>extconf</code> generator for RubyGems so that its super-super easy to get started writing native C extensions within RubyGems. </p>
<h3 id="tutorial">Tutorial</h3>
<p>This tutorial is for *nix, as I&#8217;m still investigating <a href="http://blog.mmediasys.com/2008/03/29/progress-of-one-click-installer-rubyinstaller/">win32 extensions</a>, and jruby + .net/ironruby extensions. So when I figure that out &#8211; hopefully with the help of other people currently at RubyFools conferences, I&#8217;ll get back to you.</p>
<p>The code comes from the <a href="http://www.rubycentral.com/pickaxe/ext_ruby.html">Pickaxe book &#8211; p264</a>, and we&#8217;ll insert it into a new RubyGem using <code>newgem</code> (version 0.20.1+):</p>
<pre>sudo gem install newgem
newgem pickaxe
cd pickaxe
script/generate extconf my_test
</pre>
<p>Create a test for a class <code>MyTest</code> that doesn&#8217;t exist yet:</p>
<pre># test/test_my_test_extn.rb
require "test/unit"
require 'pickaxe'

class TestMyTestExtn &lt; Test::Unit::TestCase
  def test_working
    t = MyTest.new
    assert_equal(Object, MyTest.superclass)
    assert_equal(MyTest, t.class)
    t.add(1)
    t.add(2)
    assert_equal([1,2], t.instance_eval("@arr"))
  end
end
</pre>
<p>Run <code>rake</code> to build the C extension and run the tests. You can also run <code>autottest</code> and it will automatically build the C extension before running the tests.</p>
<p>To create the <code>MyTest</code> class, using the code from p262 of the Pickaxe book:</p>
<pre>#include "ruby.h"
static int id_push;

static VALUE t_init(VALUE self)
{
  VALUE arr;
  arr = rb_ary_new();
  rb_iv_set(self, "@arr", arr);
  return self;
}

static VALUE t_add(VALUE self, VALUE obj)
{
  VALUE arr;
  arr = rb_iv_get(self, "@arr");
  rb_funcall(arr, id_push, 1, obj);
  return arr;
}

VALUE cTest;
void Init_my_test() {
  cTest = rb_define_class("MyTest", rb_cObject);
  rb_define_method(cTest, "initialize", t_init, 0);
  rb_define_method(cTest, "add", t_add, 1);
  id_push = rb_intern("push");
}
</pre>
<p>To <code>lib/pickaxe.rb</code>:</p>
<pre>require "my_test.so"
# or require 'my_test' if its unique
</pre>
<p>The last line will import the generated shared library. If the RubyGem is tested or installed on Windows, then the .dll file will be automatically loaded instead. The &#8220;.so&#8221; notation is merely a placeholder to explicitly specify the shared C-extension, rather than any Ruby library of the same name.</p>
<p>Now run tests (<code>rake</code>), the C extension will be rebuilt and the tests will pass.</p>
<h3 id="build_and_install_rubygem">Build and install RubyGem</h3>
<pre>rake manifest:refresh
rake install_gem
irb -rubygems -rpickaxe
&gt; a = MyTest.new
&gt; a.add 3
</pre>
<p>You have successfully created a C-extension within RubyGems, using TDD.</p>
<h3 id="textmate_bundle_for_ruby_c_extensions">TextMate bundle for Ruby C extensions</h3>
<p>I&#8217;ve started a TextMate bundle to give syntax highlighting + some simple snippets for developing the C files for Ruby extensions.</p>
<p>To install:</p>
<pre>cd ~/Library/Application Support/TextMate/Bundles
git clone git://github.com/drnic/ruby-c-extensions-tmbundle.git "Ruby C Extensions.tmbundle"

or 

wget http://github.com/drnic/ruby-c-extensions-tmbundle/tarball/master
tar xfv drnic-ruby-c-extensions-tmbundle-master.tar.gz
mv drnic-ruby-c-extensions-tmbundle-master "Ruby C Extensions.tmbundle"
</pre>
<p>Then restart TextMate or &#8220;Reload Bundles&#8221;.</p>
<p>You can clone/fork the source via  <a href="http://github.com/drnic/ruby-c-extensions-tmbundle/tree/master">http://github.com/drnic/ruby-c-extensions-tmbundle/tree/master</a></p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/' rel='bookmark' title='Permanent Link: newgem 1.0.0 all thanks to Cucumber'>newgem 1.0.0 all thanks to Cucumber</a> <small>The New Gem Generator (newgem) was exciting, moderately revolutionary, and...</small></li><li><a href='http://drnicwilliams.com/2008/05/12/textmate-bundles-for-merb/' rel='bookmark' title='Permanent Link: TextMate bundles for Merb'>TextMate bundles for Merb</a> <small>If you are using TextMate (OS X) or E Text...</small></li><li><a href='http://drnicwilliams.com/2007/08/20/newgem-using-rubigen-for-generator-support/' rel='bookmark' title='Permanent Link: NewGem Generator &#8211; now with script/generate'>NewGem Generator &#8211; now with script/generate</a> <small>The New Gem Generator (0.13.0)&#8217;s newgem command now behaves like...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2008/04/01/writing-c-extensions-in-rubygems/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>RubiGen video from RejectConf Berlin</title>
		<link>http://drnicwilliams.com/2007/09/22/rubigen-video-from-rejectconf-berlin/</link>
		<comments>http://drnicwilliams.com/2007/09/22/rubigen-video-from-rejectconf-berlin/#comments</comments>
		<pubDate>Sat, 22 Sep 2007 19:06:37 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[NewGem]]></category>
		<category><![CDATA[RubiGen]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/09/22/rubigen-video-from-rejectconf-berlin/</guid>
		<description><![CDATA[Go straight to video below I took a video recorder to the RejectConf, like I did in Portland. Unfortunately, there were two reasons I didn&#8217;t record any of them. Firstly, there didn&#8217;t seem to be any obvious place to position the camera. Secondly, it was deemed critical that everyone does their talks in the dark. [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2007/10/25/dr-nic-at-rubyconf-2007-rubigen-teaser/' rel='bookmark' title='Permanent Link: Dr Nic at RubyConf 2007 &#8211; RubiGen &#8211; Teaser'>Dr Nic at RubyConf 2007 &#8211; RubiGen &#8211; Teaser</a> <small>4th of November 2007 &#8211; 9am &#8211; main conference room...</small></li><li><a href='http://drnicwilliams.com/2007/06/02/ze-frank-at-railsconf-like-ted/' rel='bookmark' title='Permanent Link: Missed Ze Frank at Railsconf? [video]'>Missed Ze Frank at Railsconf? [video]</a> <small>Neat. Here is Ze Frank at TED 20062004 [thx Erik...</small></li><li><a href='http://drnicwilliams.com/2007/05/27/new-gem-generates-gets-rspec-video/' rel='bookmark' title='Permanent Link: New Gem Generator gets RSpec [video]'>New Gem Generator gets RSpec [video]</a> <small> One day you will be able to write a...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p><a href="#rubigen-rejectconf-video">Go straight to video below</a></p>
<p>I took a video recorder to the RejectConf, like I did in Portland. Unfortunately, there were two reasons I didn&#8217;t record any of them.</p>
<p>Firstly, there didn&#8217;t seem to be any obvious place to position the camera.</p>
<p>Secondly, it was deemed critical that everyone does their talks in the dark. The conference isn&#8217;t run in the dark, local Ruby groups don&#8217;t run meetings in the dark but consecutive RejectConfs have been run by adminstrators with a dark fetish. Great for drinking beer and heckling presenters. Bad for video recording.</p>
<p>The makers of the <a href="http://www.jvc.com/presentations/everio_g/">JVC HDD camcorder</a> &#8211; a nifty device with a 20G HDD in it &#8211; don&#8217;t make it possible to record in the dark. Not because it doesn&#8217;t have a &#8220;night time mode&#8221; &#8211; apparently it does &#8211; but when you are already in the dark, you can&#8217;t figure out how to turn it on.</p>
<p>Ok, fine, if I&#8217;d made an effort I could have figured it out. So, let&#8217;s use excuse #1 as the reason for not recording the presentations.</p>
<p>Its a valid excuse, the Pirate Cove was chock-a-block full of people. The local Berlin Ruby Group did an awesome job of finding a great &#8220;underground&#8221;-esque venue. </p>
<p>Fortunately a fellow Australian &#8211; <a href="http://redartisan.com/blog">Marcus Crafter</a> &#8211; had a front row position, and a MacBook Pro. With said device, he captured my talk on RubiGen (<a href="http://redartisan.com/2007/9/22/rejectconf-europe-2007">and John Barton&#8217;s</a>). </p>
<h3 id="rubigen-rejectconf-video">RejectConf video of RubiGen</h3>
<p>In 5 minutes, I make a Merb generator, using <a href="http://rubigen.rubyforge.org">RubiGen</a> and <a href="http://newgem.rubyforge.org">NewGem</a>. Nifty stuff indeed. </p>
<p><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="437" height="370" id="viddler"><param name="movie" value="http://www.viddler.com/player/b8b13c86/" /><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><embed src="http://www.viddler.com/player/b8b13c86/" width="437" height="370" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" name="viddler" ></embed></object></p>
<caption>Recorded and published by <a href="http://redartisan.com/2007/9/22/rejectconf-europe-2007">Marcus Crafter</a></caption>
<p>There were lots of other awesome presentations (that is perhaps a dubious inference that mine was awesome), but it was dark, I had beer in both hands, and I was too busy yelling &#8220;AUSTRALIA!!!&#8221; to write notes.</p>
<p>What a great night <img src='http://drnicwilliams.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2007/10/25/dr-nic-at-rubyconf-2007-rubigen-teaser/' rel='bookmark' title='Permanent Link: Dr Nic at RubyConf 2007 &#8211; RubiGen &#8211; Teaser'>Dr Nic at RubyConf 2007 &#8211; RubiGen &#8211; Teaser</a> <small>4th of November 2007 &#8211; 9am &#8211; main conference room...</small></li><li><a href='http://drnicwilliams.com/2007/06/02/ze-frank-at-railsconf-like-ted/' rel='bookmark' title='Permanent Link: Missed Ze Frank at Railsconf? [video]'>Missed Ze Frank at Railsconf? [video]</a> <small>Neat. Here is Ze Frank at TED 20062004 [thx Erik...</small></li><li><a href='http://drnicwilliams.com/2007/05/27/new-gem-generates-gets-rspec-video/' rel='bookmark' title='Permanent Link: New Gem Generator gets RSpec [video]'>New Gem Generator gets RSpec [video]</a> <small> One day you will be able to write a...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/09/22/rubigen-video-from-rejectconf-berlin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>NewGem Generator &#8211; now with script/generate</title>
		<link>http://drnicwilliams.com/2007/08/20/newgem-using-rubigen-for-generator-support/</link>
		<comments>http://drnicwilliams.com/2007/08/20/newgem-using-rubigen-for-generator-support/#comments</comments>
		<pubDate>Mon, 20 Aug 2007 10:00:33 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[NewGem]]></category>
		<category><![CDATA[RubiGen]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/08/20/newgem-using-rubigen-for-generator-support/</guid>
		<description><![CDATA[The New Gem Generator (0.13.0)&#8217;s newgem command now behaves like the rails command thanks to RubiGen &#8211; a new project that is an extraction of the rails_generator. Developing a RubyGem? You can now have a script/generate command, just like Rails. Other projects, say like Merb, can do this too. Awesomeness with a Gold Star. (disclosure: [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/' rel='bookmark' title='Permanent Link: newgem 1.0.0 all thanks to Cucumber'>newgem 1.0.0 all thanks to Cucumber</a> <small>The New Gem Generator (newgem) was exciting, moderately revolutionary, and...</small></li><li><a href='http://drnicwilliams.com/2008/04/01/writing-c-extensions-in-rubygems/' rel='bookmark' title='Permanent Link: Writing C extensions in RubyGems using newgem generators (plus a free TextMate bundle)'>Writing C extensions in RubyGems using newgem generators (plus a free TextMate bundle)</a> <small>Already know C extensions in RubyGems? Cool &#8211; then just...</small></li><li><a href='http://drnicwilliams.com/2008/02/19/one-stop-javascript-unit-testing-for-rails2/' rel='bookmark' title='Permanent Link: One-stop JavaScript Unit Testing for Rails 2.0'>One-stop JavaScript Unit Testing for Rails 2.0</a> <small>Previously, I mentioned a multi-step/multi-project solution to doing JavaScript Unit...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://newgem.rubyforge.org/" title="New Gem Generator">New Gem Generator</a> (0.13.0)&#8217;s <code>newgem</code> command now behaves like the <code>rails</code> command thanks to <a href="http://rubigen.rubyforge.org" title="rubigen - Ruby Generator Framework">RubiGen</a> &#8211; a new project that is an extraction of the <code>rails_generator</code>.</p>
<p>Developing a RubyGem? You can now have a <code>script/generate</code> command, just like Rails. Other projects, say like Merb, can do this too.</p>
<p>Awesomeness with a Gold Star. (disclosure: Dr Nic awarded this Gold Star to himself)</p>
<h3>Warning</h3>
<p>This article can get confusing.</p>
<p>Especially around the heading &#8220;Generating Generators&#8221;. </p>
<p>Plus, this article talks about two projects &#8211; an update to <a href="http://newgem.rubyforge.org">New Gem Generator</a> (0.13.0) and the new <a href="http://rubigen.rubyforge.org">RubiGen</a> project.</p>
<p>So, give yourself time to digest it all, and then perhaps come back and read it again. </p>
<p>And then perhaps re-write the article for me. </p>
<p><strong>&#8220;A generator that can provide generators to your projects, so that you can write generators for your other projects.&#8221;</strong></p>
<p>Re-write it &#8211; I dare you.</p>
<h2 id="background">Background</h2>
<p>One of the killer features of Rails is the Rails Generator. </p>
<p>It does three things: </p>
<ul>
<li>generates an entire scaffold for your application, thus sharing with you its conventions (over configuration) methodology; and </li>
<li>it then allows you to generate <em>more</em> stuff, like models, controllers, plugins etc. Things that are relevant to a Rails app. Finally, </li>
<li>it allows you to write your own generators for Rails apps.</li>
</ul>
<p>Now you can do all this with New Gem.</p>
<h2 id="killer_feature_1_upgrade_path">Killer Feature #1 &#8211; upgrade path</h2>
<p>Never before have you been able to run &#8216;newgem&#8217; on top of an existing RubyGem. Why? It used to blow away the entire folder, and then start writing new files&#8230; not very friendly.</p>
<p>Now, just like the <code>rails</code> command, you can go into your RubyGem development directory, and run <code>newgem .</code> and you will be asked which files to override.</p>
<p>NOTE: Copy your Rakefile to Rakefile.old, and after running <code>newgem .</code> copy the configuration information into the new file <code>config/hoe.rb</code>.</p>
<p>If you&#8217;re using newgem already, I dare you to upgrade as above. (Ok, perhaps make a backup copy of your work first&#8230;)</p>
<h2 id="killer_feature_2_script_generate">Killer Feature #2 &#8211; script/generate</h2>
<p>Once you&#8217;ve upgraded, or create a new RubyGem (using <code>newgem gemname</code>), you&#8217;ll now have two scripts: <code>script/generate</code> and <code>script/destroy</code>, just like Rails has. (and matching generate.cmd and destroy.cmd for Windows users)</p>
<p>Try them out:</p>
<pre>
script/generate
...
Installed Generators
  Rubygems: application_generator, component_generator, executable, install_jruby, install_rspec, install_website
  Builtin: test_unit
</pre>
<p>Oh yeah, I&#8217;ve had some fun extracting things into generators.</p>
<ul>
<li>Install the dubious-looking NewGem website &#8211; <code>script/generate install_website</code>.</li>
<li>Install RSpec support &#8211; <code>script/generate install_rspec</code>.</li>
<li>Make the RubyGem a JRuby gem &#8211; <code>script/generate install_jruby</code> (the generated gem will have <code>-jruby.gem</code> in its name)</li>
<li>Create an executable Ruby app &#8211; <code>script/generate executable appname</code></li>
</ul>
<p>These generators are also reused via the newgem commands various options (Run <code>newgem</code> to see them.)</p>
<h2 id="killer_feature_3_generate_generators">Killer Feature #3 &#8211; generate generators</h2>
<p>I&#8217;ll post more about RubiGen later, but you can create a new <code>rails</code>-like command-line app that generates a whole stack load of directories and files using <code>script/generate application_generator appname</code>. </p>
<p>There is a large USAGE rundown if you run <code>script/generate application_generator</code>.</p>
<p>Want to create your own generators for developing RubyGems? (similar to creating a generator for a Rails app, but for RubyGems)</p>
<pre>
script/generate component_generator foobar rubygems
    create  rubygems_generators/foobar/templates
    exists  test
    create  rubygems_generators/foobar/foobar_generator.rb
    create  test/test_foobar_generator.rb
    create  test/test_generator_helper.rb
    create  rubygems_generators/foobar/USAGE
    readme  readme
</pre>
<p>Firstly, note <code>test/test_generatorname_generator.rb</code> &#8211; that&#8217;s right, you get a test stub for your new generator. Start there, write tests, then write your generator. There&#8217;s inline help for useful assertions.</p>
<p>Secondly, note <code>rubygems_generators</code> folder. This folder is the &#8220;scope&#8221; of the generator. As it starts with &#8220;rubygems&#8221; the generator will only be available when you are developing rubygems. It will not show up in Rails, nor Merb or Camping or any other place that may support RubiGen one day.</p>
<p>Similarly, if you want to write a Rails generator using the <code>component_generator</code> then specify the scope as <code>rails</code>.</p>
<pre>
script/generate component_generator booya rails
     create  rails_generators/booya/templates
     exists  test
     create  rails_generators/booya/booya_generator.rb
     create  test/test_booya_generator.rb
  identical  test/test_generator_helper.rb
     create  rails_generators/booya/USAGE
     readme  readme
</pre>
<p>In Edge Rails (and any Rails version <em>after</em> 1.2.3), the <code>script/generate</code> command in Rails will search all RubyGems for /rails_generator/* folders in addition to the existing search paths (<a href="http://dev.rubyonrails.org/ticket/8730" title="#8730 ([patch] rails_generator finds generators within RubyGems) - Rails Trac - Trac">ticket</a>).</p>
<h2 id="thanks_goes_to_rails_generator">Thanks goes to Rails Generator</h2>
<p>I&#8217;ve long been in love with the Rails Generator for what it does, the beautiful syntax for specifying a generator, etc. <strike>I don&#8217;t know who wrote what bit, e.g. if DHH wrote all of it, or others wrote nice chunks, but its awesome. Thanks DHH and co.</strike> Thanks to <a href="http://bitsweat.net/">Jeremy Kemper</a></p>
<p>RubiGen is 95% Rails Generator code, with extensions to support scoping. Setting Rails Generator free of its Rails constraints is a tribute to it.</p>
<p>Now RubyGems can use generators, and any other frameworks can integrate generators and their developers can write and distribute additional generators for those frameworks.</p>
<p>I award myself 2 gold stars, and a scratch-n-sniff</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/' rel='bookmark' title='Permanent Link: newgem 1.0.0 all thanks to Cucumber'>newgem 1.0.0 all thanks to Cucumber</a> <small>The New Gem Generator (newgem) was exciting, moderately revolutionary, and...</small></li><li><a href='http://drnicwilliams.com/2008/04/01/writing-c-extensions-in-rubygems/' rel='bookmark' title='Permanent Link: Writing C extensions in RubyGems using newgem generators (plus a free TextMate bundle)'>Writing C extensions in RubyGems using newgem generators (plus a free TextMate bundle)</a> <small>Already know C extensions in RubyGems? Cool &#8211; then just...</small></li><li><a href='http://drnicwilliams.com/2008/02/19/one-stop-javascript-unit-testing-for-rails2/' rel='bookmark' title='Permanent Link: One-stop JavaScript Unit Testing for Rails 2.0'>One-stop JavaScript Unit Testing for Rails 2.0</a> <small>Previously, I mentioned a multi-step/multi-project solution to doing JavaScript Unit...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/08/20/newgem-using-rubigen-for-generator-support/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Smart people doing smart things in Netherlands &#8211; RubyEnRails 2007</title>
		<link>http://drnicwilliams.com/2007/06/09/smart-people-doing-smart-things-in-netherlands-rubyenrails-2007/</link>
		<comments>http://drnicwilliams.com/2007/06/09/smart-people-doing-smart-things-in-netherlands-rubyenrails-2007/#comments</comments>
		<pubDate>Sat, 09 Jun 2007 07:35:45 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Magic Model Generator]]></category>
		<category><![CDATA[NewGem]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/06/09/smart-people-doing-smart-things-in-netherlands-rubyenrails-2007/</guid>
		<description><![CDATA[Summary: click to select Photo by Thijs van der Vossen,Fingertips For one million people in Amsterdam, time stood still as a parade of Rails gurus in Netherlands/ Belgium talked up a storm at RubyEnRails 2007. Only 240 were allow inside to the free, one day conference, so riots ensued at the doorsteps of the building. [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2009/04/06/easy-scheduling-by-location-tasks-and-people-a-case-study-of-a-client-application-from-mocra/' rel='bookmark' title='Permanent Link: Easy scheduling by location, tasks and people &#8211; a case study of a client application from Mocra'>Easy scheduling by location, tasks and people &#8211; a case study of a client application from Mocra</a> <small> UPDATE: Orchestrate was reported in TechCrunch Several years ago...</small></li><li><a href='http://drnicwilliams.com/2007/03/22/meta-magic-in-ruby-presentation/' rel='bookmark' title='Permanent Link: Meta-Magic in Ruby: Dr Nic Unplugged in Stockholm'>Meta-Magic in Ruby: Dr Nic Unplugged in Stockholm</a> <small>Last nights&#8217; Ruby meeting in Stockholm had a great turn...</small></li><li><a href='http://drnicwilliams.com/2006/10/06/amsterdam-rails-catchup-summary/' rel='bookmark' title='Permanent Link: Amsterdam Rails Catchup summary'>Amsterdam Rails Catchup summary</a> <small>It was brilliant to meet up with a dozen or...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p id="bk_summary_192" name="bk_summary_192" class="bk_summary"><strong>Summary: </strong> <span class="help">click to select</span></p>
<input id="bk_summary_input_192" value="Slides of Dr Nic's keynote and 'DIY Syntax' sessions at RubyEnRails 2007" style="width:100%"  onClick="javascript:var summary = document.getElementById('bk_summary_input_192'); summary.focus();summary.select();" readonly="true" /></span></p>
<div>
<div style="float: right">
<p><a class="imagelink" href="http://www.fngtps.com/2007/06/rubyenrails-2007" title="rubyenrails2007-me-presenting-by-fngtps.jpg"><img width="200" id="image191" src="http://drnicwilliams.com/wp-content/uploads/2007/06/rubyenrails2007-me-presenting-by-fngtps.jpg" alt="rubyenrails2007-me-presenting-by-fngtps.jpg" /></a></p>
<p>
<caption>Photo by Thijs van der Vossen,<br/><a href="http://www.fngtps.com">Fingertips</a></caption>
</p>
</div>
<p>For one million people in Amsterdam, time stood still as a parade of Rails gurus in Netherlands/ Belgium talked up a storm at <a href="http://2007.rubyenrails.nl">RubyEnRails 2007</a>. Only 240 were allow inside to the free, one day conference, so riots ensued at the doorsteps of the building. Police were called in. Helicopters. Tanks.</p>
<p>Or so I&#8217;m told. I was too busy inside meeting many very clever developers and sharp business people. The buzz of excitement for Rails in the foyer during the breaks was tremendous. The conference organisers recorded the audio of all presentations which will be great to listen to.
</p>
<p>I was flown in my private jet, helicoptered to the conference building and shepherded in by 24 Dutch Special Forces men, all of equal height and build, identical in every fashion. Before my keynote, I was interviewed by all the major TV networks. I have no idea what drives me to make this all up.</p>
<p>But I was given a free RubyEnRails conference t-shirt. I was also able to give a couple of presentations:</p>
</div>
<h3>Keynote</h3>
<div>
<object style="float:right" type="application/x-shockwave-flash" data="https://s3.amazonaws.com:443/slideshare/ssplayer.swf?id=61632&#038;doc=rubyenrails2007-dr-nic-williams-keynote4975" width="312" height="220"><param name="movie" value="https://s3.amazonaws.com:443/slideshare/ssplayer.swf?id=61632&#038;doc=rubyenrails2007-dr-nic-williams-keynote4975" /></object></p>
<p>It was a wonderful opportunity to start the day, and I shared &#8220;What&#8217;s cool with Rails?&#8221; focusing on some hot potatoes like scaling and deployment, as well as RESTfulness. <a href="http://www.slideshare.net/drnic/rubyenrails2007-dr-nic-williams-keynote/">Slides here</a>.</p>
<p>Ultimately the basic theme of the keynote was &#8220;Its all just text&#8221;, and choosing between Rails, Merb, Camping, Mongrel handlers, becomes a design/architectural decision to be made for each portion of each application you build.</p>
<p>I included a live demo of the Magic Model Generator, and encouraged people to write RubyGems instead of Rails plugins, as they provide better support for: dependencies, versioning, and reuse outside of Rails.</p>
</div>
<h3>DIY syntax</h3>
<div>
<object style="float: right" type="application/x-shockwave-flash" data="https://s3.amazonaws.com:443/slideshare/ssplayer.swf?id=61633&#038;doc=rubyenrails2007-dr-nic-williams-diy-syntax820" width="312" height="220"><param name="movie" value="https://s3.amazonaws.com:443/slideshare/ssplayer.swf?id=61633&#038;doc=rubyenrails2007-dr-nic-williams-diy-syntax820" /></object></p>
<p>The ability to extend my programming language tickles me pink. Often you write a block of code and you just think &#8220;That should be prettier and simpler&#8221;.</p>
<p>With Ruby meta-programming, blocks, method_missing, const_missing and optional parentheses you can craft nearly any syntactic sugar you like to replace lengthy, complicated code.</p>
<p><a href="http://www.slideshare.net/drnic/rubyenrails2007-dr-nic-williams-diy-syntax/">Slides here.</a></p>
</div>
<h3>Dr Nic Academy</h3>
<p>I also took the opportunity to introduce Dr Nic Academy &#8211; training courses in Ruby on Rails by me. The first course will be <a href="http://drnicacademy.eventwax.com/beginning-ruby-on-rails">7th and 8th of July in Amsterdam</a>. If you are thinking of attending, hold off buying tickets!! The new website and a special bonus discount price will be coming soon. I&#8217;d hate you to miss out.</p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2009/04/06/easy-scheduling-by-location-tasks-and-people-a-case-study-of-a-client-application-from-mocra/' rel='bookmark' title='Permanent Link: Easy scheduling by location, tasks and people &#8211; a case study of a client application from Mocra'>Easy scheduling by location, tasks and people &#8211; a case study of a client application from Mocra</a> <small> UPDATE: Orchestrate was reported in TechCrunch Several years ago...</small></li><li><a href='http://drnicwilliams.com/2007/03/22/meta-magic-in-ruby-presentation/' rel='bookmark' title='Permanent Link: Meta-Magic in Ruby: Dr Nic Unplugged in Stockholm'>Meta-Magic in Ruby: Dr Nic Unplugged in Stockholm</a> <small>Last nights&#8217; Ruby meeting in Stockholm had a great turn...</small></li><li><a href='http://drnicwilliams.com/2006/10/06/amsterdam-rails-catchup-summary/' rel='bookmark' title='Permanent Link: Amsterdam Rails Catchup summary'>Amsterdam Rails Catchup summary</a> <small>It was brilliant to meet up with a dozen or...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/06/09/smart-people-doing-smart-things-in-netherlands-rubyenrails-2007/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>8 steps for fixing other people&#8217;s code</title>
		<link>http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/</link>
		<comments>http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#comments</comments>
		<pubDate>Fri, 01 Jun 2007 11:34:04 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Gems]]></category>
		<category><![CDATA[NewGem]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/</guid>
		<description><![CDATA[Before or after you&#8217;re sharing your own code as open-source, you might find yourself itching to fix someone else&#8217;s code. Twelve months ago I made my first contribution to someone else&#8217;s project &#8211; I added some auto-generated tests to the AjaxScaffold project (now ActiveScaffold and no longer a rails generator). It was the first RubyGem [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2009/11/04/hacking-someones-gem-with-github-and-gemcutter/' rel='bookmark' title='Permanent Link: Hacking someone&#8217;s gem with github and gemcutter'>Hacking someone&#8217;s gem with github and gemcutter</a> <small> Ever used a rubygem, found a bug, and just...</small></li><li><a href='http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/' rel='bookmark' title='Permanent Link: Future proofing your Ruby code. Ruby 1.9.1 is coming.'>Future proofing your Ruby code. Ruby 1.9.1 is coming.</a> <small> Bugger. I&#8217;m a Ruby monogamist. I use the Ruby...</small></li><li><a href='http://drnicwilliams.com/2007/06/25/rails-generators-in-rubygems/' rel='bookmark' title='Permanent Link: Where art thou generator?'>Where art thou generator?</a> <small>Summary: click to select UPDATE: Rails Generators within RubyGems support...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<p>Before or after you&#8217;re sharing your own code as open-source, you might find yourself itching to fix someone else&#8217;s code.</p>
<p>Twelve months ago I made my first contribution to someone else&#8217;s project &#8211; I added some auto-generated tests to the AjaxScaffold project (now ActiveScaffold and no longer a rails generator). It was the first RubyGem I really investigated. It was the first Rails Generator I investigated. It was the first <span class="caps">OSS</span> project I think I&#8217;ve ever submitted a patch to. It took days.</p>
<h2>Its always the same process</h2>
<p>Yesterday I created a patch for <a href="http://merb.rubyforge.org">Merb</a>: an update to their <span class="caps">README</span> file so it converted to RDoc nicely. The whole patching process: spotting the ugly <span class="caps">README</span>, checking out merb trunk, changing its <span class="caps">README</span>, testing, creating a patch, and submitting it to Merb&#8217;s trac, took about 30 minutes whilst also doing other things.</p>
<p>The process was the same, I&#8217;m just better at it.</p>
<h2>Step-by-step</h2>
<p>So here&#8217;s how to fix other people&#8217;s code. It has Ruby-specific examples, but I&#8217;m sure the process is the same in all OSS communities. Its also worth checking out the slides from Josh Susser&#8217;s Railsconf talk on <a href="http://blog.hasmanythrough.com/2007/5/24/laying-tracks-slides">contributing to Rails Core</a>.</p>
<h3>1. Get annoyed by a defect or missing feature</h3>
<p>Open source software isn&#8217;t written by an army of coders, with a back up army of testers, documenters, and &#8220;Dummies Guide&#8221; book authors. Rather, its code that fixed the author&#8217;s problem; and they were nice enough to flesh it out generically so you could use it. Or they were seeking fame and glory.</p>
<p>So you find problems. The project owner and all its users will be super grateful if you fix it for them.</p>
<h3>2. Finding the source</h3>
<p>The modern Ruby community uses <a href="http://subversion.tigris.org/">subversion/svn</a> for their source repositories. So now is your excuse to install it and start to learn how to use it.</p>
<p>The tricky part is &#8220;where is the repository?&#8221;</p>
<p>If the project has a RubyForge project go to  (if its <span class="caps">URL</span> is <code>http://XYZ.rubyforge.org</code>, then its project page is <code>http://rubyforge.org/projects/XYZ</code>) then try the &#8220;SCM&#8221; tab on the project page. If the project isn&#8217;t hosting on RubyForge <span class="caps">SVN</span>, hopefully they have disabled this menu tab. If not, you&#8217;ll get version 0 when you do the checkout to tell you the project&#8217;s not hosted here.</p>
<p>Alternately, the project&#8217;s homepage/README file should tell you where the repository is.</p>
<p>Finally, email the project owner. And tell them to get their act together and publicise their <span class="caps">SVN</span> repos.</p>
<h3>3. Checkout the source</h3>
<p>Hopefully you&#8217;re told the complete <span class="caps">URL</span> to the trunk of the project. For anonymous access to the <code>newgem</code> RubyForge project the <span class="caps">URL</span> is <a href="svn://rubyforge.org/var/svn/newgem/trunk">svn://rubyforge.org/var/svn/newgem/trunk</a></p>
<p>A project <span class="caps">SVN</span> repository might contain multiple projects, and may or may not use the common trunk/branches/tags root folders. So you may need to navigate around the repository and til you find the trunk of the project&#8217;s code.</p>
<p>So for a generic RubyForge project, the root <span class="caps">URL</span> for anonymous access is <code>svn://rubyforge.org/var/svn/XYZ</code>.</p>
<pre>$ svn list svn://rubyforge.org/var/svn/newgem
branches/
tags/
trunk/
$ svn list svn://rubyforge.org/var/svn/newgem<strong>/trunk</strong>
History.txt
...
</pre>
<p>[Thx to Seth - originally I suggested doing a checkout; but <code>list</code> is cleaner.]</p>
<p>If there is a <strong>trunk</strong> root folder, then do the following:</p>
<pre>rm -rf XYZ
svn co svn://rubyforge.org/var/svn/XYZ/trunk XYZ
cd XYZ
</pre>
<p>And now you&#8217;ve checked out the trunk or &#8220;edge&#8221; of the project. The latest and greatest.</p>
<h3>4. Snoop around</h3>
<p>Load up the project into your editor and poke around.</p>
<p>If it has test cases (!) try running them. You may need to create some databases and/or modify the Rakefile/connection details to work with your database. Hopefully the project comes with rake tasks to create/drop the databases. <code>rake -T</code> should find them.</p>
<p>If its a RubyGem, try installing the gem locally (on top of the existing defective gem that you&#8217;re about to fix). Again, run <code>rake -T</code> and hopefully there is a task <code>install_gem</code> or similar to build and install the gem from source. If not, send hate mail to the author. And then fix the Rakefile to use the Hoe gem. And then send a patch to the author with the fixed Rakefile.</p>
<p><code>rake install_gem</code></p>
<h3>5. Make changes</h3>
<p>Finally, you get to change their code.</p>
<p>If the project has a suite of test cases, please make an effort to add &#8220;failing test cases&#8221;. That is, add test cases that demonstrate the defect by failing (unless the project includes your fix).</p>
<p>Run the tests to ensure they are working.</p>
<h3>6. Refresh the code from the repository (svn up)</h3>
<p>The original repository may have changed since you did the checkout, so update your version.</p>
<pre>svn up</pre>
<p>If there are any conflicts, go fix them and delete any helper files created by <span class="caps">SVN</span>.</p>
<h3>7. Create the patch</h3>
<p>First, you need to tell subversion about any folders/files you&#8217;ve added (<code>svn add</code>) or deleted (<code>svn remove</code>).</p>
<p>Then, from the root folder of the trunk:</p>
<pre>svn diff &gt; i_fixed_a_bug.patch</pre>
<p>Give the patch file a useful, readable name. Like <code>readme_updated_for_rdoc_syntax.patch</code>.</p>
<p><a name="8a-trac"></p>
<h3>8a. Submit patch to trac</h3>
<p>[<a href="#8a-trac">link to 8a</a>]</p>
<p>Each project may have a different preferred way to submit patches.</p>
<p>If the project uses <a href="http://trac.edgewall.org/">trac</a> then:</p>
<ol>
<li>Register an account (normally a link at the top right of the page) if available. Some trac installations require an account (e.g. <a href="http://dev.rubyonrails.org">Rails</a>) and others allow anonymous tickets.</li>
<li>Click &#8220;<strong>New Ticket</strong>&#8221; </li>
<li>Fill in details (note, there is nowhere initially to add your patch). Prefix the subject with [PATCH]</li>
<li>Save the ticket (check the box &#8220;Attach files&#8221;)</li>
<li>Attach the patch file and save</li>
</ol>
<p><a name="8b-google-groups"><a name="8b-fixing"></p>
<h3>8b. Submit patch to Google Groups</h3>
<p>[<a href="#8b-google-groups">link to 8b</a>]</p>
<p>Projects hosted on rubyforge <span class="caps">SVN</span> cannot use trac. I personally use Google Groups for my projects &#8211; the project communities are all small enough such that its manageable.</p>
<ol>
<li>Join the Group (using Google Account)</li>
<li>Add a picture to your Google Groups account; I cannot communicate how relatively unnecessary this step truly is</li>
<li>Go to Files section (link on right hand side)</li>
<li>Attach your patch file to the group</li>
<li>Get the <span class="caps">URL</span> for the uploaded file</li>
<li>Post a note/write an email to the group describing your patch, and include the <span class="caps">URL</span> for the patch file</li>
</ol>
<p><a name="8c-rubyforge"></p>
<h3>8c. Submit patch to RubyForge Tracker</h3>
<p>[<a href="#8c-rubyforge">link to 8c</a>] [Thx <a href="http://chriscodes.com/">Chris Martin</a>]</p>
<p>RubyForge offers a bug/patch/feature request tracker for each Project. It is enabled by default for new projects:</p>
<ol>
<li><a href="http://rubyforge.org/account/login.php">Login</a> or <a href="http://rubyforge.org/account/register.php">Create new</a> Rubyforge account</li>
<li>Go to project page and click &#8220;<strong>Tracker</strong>&#8220; from sub-menu</li>
<li>Click &#8220;<strong>Submit New</strong>&#8221; </li>
<li>Fill in details (each RubyForge Project can contain many sub-projects/gems &#8211; pick from Category drop-down)</li>
<li>Check the box &#8220;Check to Upload &#038; Attach File&#8221;</li>
<li>Browse and select your patch file; put file name in File Description field as you&#8217;ve already made it human readable, because you&#8217;re a champion.</li>
<li>Save the ticket</li>
</ol>
<p><a name="8d-launchpad"></p>
<h3>8d. Submit patch to <a href="https://bugs.launchpad.net/">LaunchPad Tracker</a></h3>
<p>[<a href="#8d-launchpad">link to 8d</a>]</p>
<p>&#8220;I have to say I quite like Launchpad, now that I&#8217;ve got used to it. If you&#8217;re an Ubuntu guy like me then it is perfect.&#8221; &#8211; from <a href="http://www.3spoken.co.uk/">Neil Wilson</a></p>
<ol>
<li><a href="https://bugs.launchpad.net/+login">Login to/Register</a> for your Launchpad account</li>
<li>From The Launchpad bug tracker click the Report a bug button.</li>
<li>Enter the name of the project, or select it from the list.</li>
<li>The project in question will almost certainly provide its own bug reporting link that takes you directly to the Report a New bug page.</li>
<li>Enter a one line summary and click Continue</li>
<li>Fill in the comment box and click Submit Bug Report</li>
<li>Then click the link &#8220;Add a comment/attachment&#8221;, and Browse for the patch file. Check &#8220;This attachment is a patch&#8221; and add a Description if required.</li>
<li>Click Save Changes</li>
</ol>
<p><a name="8z-email"></p>
<h3>8z. Email the project owner</h3>
<p>[<a href="#8z-email">link to 8z</a>]</p>
<p>See title: <em>Email the project owner</em>. Prefix the subject with [PATCH].</p>
<p>Why <strong>8z</strong>? I figured readers might want to share other ways they coordinate within a project, like Google Code, etc. I haven&#8217;t used it. So, (c) &#8211; (y) are placeholders <img src='http://drnicwilliams.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>Corollary: Tell users how to fix problems</h2>
<p>If you administer some <span class="caps">OSS</span> projects, you are doing yourself a disservice not telling your users how to quickly, easily submit patches.</p>
<p>Either copy and paste the relevant sections above, and/or link them to this &#8220;8 steps&#8221; page.</p>
<p>Make it really clear on your project website that patches are welcome and will be rewarded with free t-shirts and other complimentary items of stationary, and watch those patches roll in.</p>
<p>For example, on the New Gem Generator site (and in all default project websites), there is a link to this page and a reference to section on Google Groups as the default.</p>
<blockquote>
<h2>How to submit patches</h2>
<p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="#8b-google-groups">8b</a>, use the Google Group above..</p>
<p>The trunk repository is <a href="svn://rubyforge.org/var/svn/newgem/trunk">svn://rubyforge.org/var/svn/newgem/trunk</a> for anonymous access.</p>
</blockquote>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2009/11/04/hacking-someones-gem-with-github-and-gemcutter/' rel='bookmark' title='Permanent Link: Hacking someone&#8217;s gem with github and gemcutter'>Hacking someone&#8217;s gem with github and gemcutter</a> <small> Ever used a rubygem, found a bug, and just...</small></li><li><a href='http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/' rel='bookmark' title='Permanent Link: Future proofing your Ruby code. Ruby 1.9.1 is coming.'>Future proofing your Ruby code. Ruby 1.9.1 is coming.</a> <small> Bugger. I&#8217;m a Ruby monogamist. I use the Ruby...</small></li><li><a href='http://drnicwilliams.com/2007/06/25/rails-generators-in-rubygems/' rel='bookmark' title='Permanent Link: Where art thou generator?'>Where art thou generator?</a> <small>Summary: click to select UPDATE: Rails Generators within RubyGems support...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>New Gem Generator gets RSpec [video]</title>
		<link>http://drnicwilliams.com/2007/05/27/new-gem-generates-gets-rspec-video/</link>
		<comments>http://drnicwilliams.com/2007/05/27/new-gem-generates-gets-rspec-video/#comments</comments>
		<pubDate>Sun, 27 May 2007 14:33:53 +0000</pubDate>
		<dc:creator>Dr Nic</dc:creator>
				<category><![CDATA[Gems]]></category>
		<category><![CDATA[NewGem]]></category>
		<category><![CDATA[RejectConf]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Video]]></category>

		<guid isPermaLink="false">http://drnicwilliams.com/2007/05/27/new-gem-generates-gets-rspec-video/</guid>
		<description><![CDATA[One day you will be able to write a human description of a RubyGem and it will make it for you. Ok, that&#8217;s crap. But the New Gem Generator is doing more and more cooler things lately; so let&#8217;s take a peek&#8230; RSpec For a growing number of people, RSpec is the way to go, [...]


Related posts:<ol><li><a href='http://drnicwilliams.com/2009/11/04/hacking-someones-gem-with-github-and-gemcutter/' rel='bookmark' title='Permanent Link: Hacking someone&#8217;s gem with github and gemcutter'>Hacking someone&#8217;s gem with github and gemcutter</a> <small> Ever used a rubygem, found a bug, and just...</small></li><li><a href='http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/' rel='bookmark' title='Permanent Link: Future proofing your Ruby code. Ruby 1.9.1 is coming.'>Future proofing your Ruby code. Ruby 1.9.1 is coming.</a> <small> Bugger. I&#8217;m a Ruby monogamist. I use the Ruby...</small></li><li><a href='http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/' rel='bookmark' title='Permanent Link: newgem 1.0.0 all thanks to Cucumber'>newgem 1.0.0 all thanks to Cucumber</a> <small>The New Gem Generator (newgem) was exciting, moderately revolutionary, and...</small></li></ol>]]></description>
			<content:encoded><![CDATA[<div>
<span style="float: right"><a href="http://drnicwilliams.com/wp-content/uploads/2007/05/newgem_files.png" onclick="window.open('http://drnicwilliams.com/wp-content/uploads/2007/05/newgem_files.png','popup','width=800,height=600,scrollbars=no,resizable=yes,toolbar=no,directories=no,location=no,menubar=no,status=yes,left=0,top=0');return false"><img src="http://drnicwilliams.com/wp-content/uploads/2007/05/newgem_files-tm.png" height="100" width="133" border="1" hspace="4" vspace="4" alt="slide.007" title="slide.007" /></a></span></p>
<p>One day you will be able to write a human description of a RubyGem and it will make it for you. Ok, that&#8217;s crap. But the <a href="http://newgem.rubyforge.org/" title="New Gem Generator">New Gem Generator</a> is doing more and more cooler things lately; so let&#8217;s take a peek&#8230;</p>
<h2>RSpec</h2>
<p>For a growing number of people, RSpec is the way to go, over the Test::Unit test suite. Now, thanks to a contribution from <a href="http://www.robbyonrails.com/" title="Robby on Rails">Robby Russell</a> and <a href="http://blog.imperialdune.com/" title="graeme nelson - [ thoughts on web site design and development ]">Graeme Nelson</a> during Railsconf.</p>
</div>
<pre>
$ newgem my_cool_gem <span class="string">-t rspec</span>
$ cd my_cool_gem
$ rake  # runs specs
</pre>
<h2>Bonus website</h2>
<p>New gems now have a <code>website</code> folder with an <code>index.txt</code> file (redcloth format). Put your glorious promotional materials and tutorials here (plus add additional .txt files as well) and the <code>rake website</code> task will convert them to html files and upload them to your rubyforge website.</p>
<p>The standard template looks like this (you&#8217;re encouraged to change some colours or fonts!)</p>
<p><iframe src="http://newgem.rubyforge.org" border=0 width="100%" height="300px"></iframe></p>
<h2>Deploying gems</h2>
<p>Ready to release a new X.Y.Z version of your gem? It takes 3 minutes.</p>
<ol>
<li>Set the version number in <code>lib/<gemname>/version.rb</code>.</li>
<li>Check your Manifest.txt that it includes all new files (via <code>rake check_manifest</code>)</li>
<li>Update <code>History.txt</code> with changes. The default supported format is 2 paragraphs &#8211; a header and group of bullet points; these look nice when converted to rdoc format.</li>
<li>Commit the new version to repository.</li>
<li>Deploy/release gem</li>
</ol>
<pre>
$ rake deploy VERSION=X.Y.Z
</pre>
<p>This will release your RubyGem to rubyforge so people can install it; plus upload your website and your rdocs.</p>
<p>You&#8217;ll then be prompted to commit a copy of the trunk as a tag <code>REL-X.Y.Z</code>. This could be very useful one day!</p>
<h2>Video of NewGem at RejectConf</h2>
<p>You can read the <a href="http://drnicwilliams.com/wp-content/uploads/2007/05/RejectConf-DrNic-New_Gem_Generator.pdf">pdf slides</a> and/or watch the presentation from RejectConf:</p>
<p><embed style="width:500px; height:386px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=-4461518020671050786&#038;hl=en" flashvars=""> </embed></p>


<p>Related posts:<ol><li><a href='http://drnicwilliams.com/2009/11/04/hacking-someones-gem-with-github-and-gemcutter/' rel='bookmark' title='Permanent Link: Hacking someone&#8217;s gem with github and gemcutter'>Hacking someone&#8217;s gem with github and gemcutter</a> <small> Ever used a rubygem, found a bug, and just...</small></li><li><a href='http://drnicwilliams.com/2008/12/11/future-proofing-your-ruby-code/' rel='bookmark' title='Permanent Link: Future proofing your Ruby code. Ruby 1.9.1 is coming.'>Future proofing your Ruby code. Ruby 1.9.1 is coming.</a> <small> Bugger. I&#8217;m a Ruby monogamist. I use the Ruby...</small></li><li><a href='http://drnicwilliams.com/2008/10/31/newgem-100-all-thanks-to-cucumber/' rel='bookmark' title='Permanent Link: newgem 1.0.0 all thanks to Cucumber'>newgem 1.0.0 all thanks to Cucumber</a> <small>The New Gem Generator (newgem) was exciting, moderately revolutionary, and...</small></li></ol></p>]]></content:encoded>
			<wfw:commentRss>http://drnicwilliams.com/2007/05/27/new-gem-generates-gets-rspec-video/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
