<?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>dot.Using &#187; ruby</title>
	<atom:link href="http://blog.kesor.net/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.kesor.net</link>
	<description>Making technology about computers, and computers about usability.</description>
	<lastBuildDate>Mon, 29 Jun 2009 22:46:18 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JRuby in a JAR</title>
		<link>http://blog.kesor.net/2007/08/14/jruby-in-a-jar/</link>
		<comments>http://blog.kesor.net/2007/08/14/jruby-in-a-jar/#comments</comments>
		<pubDate>Tue, 14 Aug 2007 02:05:22 +0000</pubDate>
		<dc:creator>kesor</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.kesor.net/2007/08/14/jruby-in-a-jar/</guid>
		<description><![CDATA[A bit of fairy dust, a sprinkle of elven blood, lots of water and boil it all for 5 hours on a low fire. What you get? &#8230; I wouldn&#8217;t know, but I do know that it took me almost 2 whole days to grasp the idea of a JRuby in a JAR, with two [...]]]></description>
			<content:encoded><![CDATA[<p>A bit of fairy dust, a sprinkle of elven blood, lots of water and boil it all for 5 hours on a low fire. What you get? &#8230; I wouldn&#8217;t know, but I do know that it took me almost 2 whole days to grasp the idea of a JRuby in a JAR, with two bootstrappers!</p>
<p>Let&#8217;s assume that I wrote this great utility that does this magnificent function that will help mankind. And this utility/software needs a computer to run. Now, I speak Ruby quite well &#8211; and specify my behavior thoroughly with RSpec. But alas &#8211; most computers don&#8217;t have ruby installed (Java JRE yes, Ruby no, especially in enterprises).</p>
<p>So let&#8217;s also assume that some giants wrote a Ruby interpreter that can run on a JVM, and called it JRuby. And further more assume that most java &#8220;utilities&#8221; can be written inside a single jar, and can be executed with:</p>
<pre lang="shell">java -jar fairy_dust.jar
</pre>
<p><br/><br />
How can I take my ruby code and have it run just like the above? With just a single file and all &#8230;</p>
<p>Answer:<br />
1. <a href="http://jruby.org/">JRuby</a><br />
2. <a href="http://one-jar.sf.net">One-jar</a><br />
3. <a href="http://www.headius.com/jrubywiki/index.php/Java_Integration">Custom Bootstrapper</a></p>
<p>And the result is &#8211; a JAR file, with multiple Ruby files inside &#8211; that works just like a java jar:</p>
<pre lang="shell">java -jar rubified.jar
</pre>
<p><br/><br />
And you can get all the above (with the ant build.xml) for the price of one download!</p>
<p>Presenting: <b><a href='http://blog.kesor.net/wp-content/uploads/2007/08/rubified-01.zip' title='Rubified 0.1 BETA'>Rubified 0.1 BETA</a></b></p>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F14%2Fjruby-in-a-jar%2F&amp;title=JRuby%20in%20a%20JAR&amp;bodytext=A%20bit%20of%20fairy%20dust%2C%20a%20sprinkle%20of%20elven%20blood%2C%20lots%20of%20water%20and%20boil%20it%20all%20for%205%20hours%20on%20a%20low%20fire.%20What%20you%20get%3F%20...%20I%20wouldn%27t%20know%2C%20but%20I%20do%20know%20that%20it%20took%20me%20almost%202%20whole%20days%20to%20grasp%20the%20idea%20of%20a%20JRuby%20in%20a%20JAR%2C%20with%20two%20bootstrapper" title="Digg"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F14%2Fjruby-in-a-jar%2F&amp;title=JRuby%20in%20a%20JAR&amp;notes=A%20bit%20of%20fairy%20dust%2C%20a%20sprinkle%20of%20elven%20blood%2C%20lots%20of%20water%20and%20boil%20it%20all%20for%205%20hours%20on%20a%20low%20fire.%20What%20you%20get%3F%20...%20I%20wouldn%27t%20know%2C%20but%20I%20do%20know%20that%20it%20took%20me%20almost%202%20whole%20days%20to%20grasp%20the%20idea%20of%20a%20JRuby%20in%20a%20JAR%2C%20with%20two%20bootstrapper" title="del.icio.us"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F14%2Fjruby-in-a-jar%2F&amp;title=JRuby%20in%20a%20JAR" title="Reddit"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F14%2Fjruby-in-a-jar%2F" title="Technorati"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=JRuby%20in%20a%20JAR&amp;body=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F14%2Fjruby-in-a-jar%2F" title="email"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F14%2Fjruby-in-a-jar%2F&amp;t=JRuby%20in%20a%20JAR" title="Facebook"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F14%2Fjruby-in-a-jar%2F&amp;title=JRuby%20in%20a%20JAR&amp;annotation=A%20bit%20of%20fairy%20dust%2C%20a%20sprinkle%20of%20elven%20blood%2C%20lots%20of%20water%20and%20boil%20it%20all%20for%205%20hours%20on%20a%20low%20fire.%20What%20you%20get%3F%20...%20I%20wouldn%27t%20know%2C%20but%20I%20do%20know%20that%20it%20took%20me%20almost%202%20whole%20days%20to%20grasp%20the%20idea%20of%20a%20JRuby%20in%20a%20JAR%2C%20with%20two%20bootstrapper" title="Google Bookmarks"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="" title="Pownce"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/" title="Pownce" alt="Pownce" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="" title="TwitThis"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.kesor.net/2007/08/14/jruby-in-a-jar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install RubyGems from irb</title>
		<link>http://blog.kesor.net/2007/08/13/install-rubygems-from-irb/</link>
		<comments>http://blog.kesor.net/2007/08/13/install-rubygems-from-irb/#comments</comments>
		<pubDate>Mon, 13 Aug 2007 12:18:02 +0000</pubDate>
		<dc:creator>kesor</dc:creator>
				<category><![CDATA[gems]]></category>
		<category><![CDATA[irb]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.kesor.net/2007/08/13/install-rubygems-from-irb/</guid>
		<description><![CDATA[I started using NetBeans recently. And find it&#8217;s ruby support superb! (as far as an IDE can go). But there was an error installing gems with their gui manager, and I was wondering how to debug that.
A quick peek into ruby/bin/gem revealed much of what I needed to know.
Lets demonstrate :


Welcome to the JRuby IRB [...]]]></description>
			<content:encoded><![CDATA[<p>I started using NetBeans recently. And find it&#8217;s ruby support superb! (as far as an IDE can go). But there was an error installing gems with their gui manager, and I was wondering how to debug that.</p>
<p>A quick peek into ruby/bin/gem revealed much of what I needed to know.</p>
<p>Lets demonstrate :<br />
<span id="more-11"></span></p>
<pre lang="ruby">
Welcome to the JRuby IRB Console 

irb(main):001:0> require 'rubygems'
=> true
irb(main):002:0> Gem.manage_gems
=> true
irb(main):003:0> gem = Gem::GemRunner.new
=> #<Gem::GemRunner:...>
irb(main):004:0> gem.run(['help','commands'])
GEM commands are:

    build            Build a gem from a gemspec
    cert             Adjust RubyGems certificate settings
    check            Check installed gems
    ...
=> nil
irb(main):005:0>
</pre>
<p></p>
<p><b>update:</b> The bug that prevented me from installing gems, turned out to be a _gemrc file that had http_proxy configured. A proxy no longer in use, but since I didn&#8217;t use gems all that much on this workstation before &#8211; I forgot all about it.</p>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F13%2Finstall-rubygems-from-irb%2F&amp;title=Install%20RubyGems%20from%20irb&amp;bodytext=I%20started%20using%20NetBeans%20recently.%20And%20find%20it%27s%20ruby%20support%20superb%21%20%28as%20far%20as%20an%20IDE%20can%20go%29.%20But%20there%20was%20an%20error%20installing%20gems%20with%20their%20gui%20manager%2C%20and%20I%20was%20wondering%20how%20to%20debug%20that.%0D%0A%0D%0AA%20quick%20peek%20into%20ruby%2Fbin%2Fgem%20revealed%20much%20of%20" title="Digg"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F13%2Finstall-rubygems-from-irb%2F&amp;title=Install%20RubyGems%20from%20irb&amp;notes=I%20started%20using%20NetBeans%20recently.%20And%20find%20it%27s%20ruby%20support%20superb%21%20%28as%20far%20as%20an%20IDE%20can%20go%29.%20But%20there%20was%20an%20error%20installing%20gems%20with%20their%20gui%20manager%2C%20and%20I%20was%20wondering%20how%20to%20debug%20that.%0D%0A%0D%0AA%20quick%20peek%20into%20ruby%2Fbin%2Fgem%20revealed%20much%20of%20" title="del.icio.us"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F13%2Finstall-rubygems-from-irb%2F&amp;title=Install%20RubyGems%20from%20irb" title="Reddit"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F13%2Finstall-rubygems-from-irb%2F" title="Technorati"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=Install%20RubyGems%20from%20irb&amp;body=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F13%2Finstall-rubygems-from-irb%2F" title="email"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F13%2Finstall-rubygems-from-irb%2F&amp;t=Install%20RubyGems%20from%20irb" title="Facebook"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fblog.kesor.net%2F2007%2F08%2F13%2Finstall-rubygems-from-irb%2F&amp;title=Install%20RubyGems%20from%20irb&amp;annotation=I%20started%20using%20NetBeans%20recently.%20And%20find%20it%27s%20ruby%20support%20superb%21%20%28as%20far%20as%20an%20IDE%20can%20go%29.%20But%20there%20was%20an%20error%20installing%20gems%20with%20their%20gui%20manager%2C%20and%20I%20was%20wondering%20how%20to%20debug%20that.%0D%0A%0D%0AA%20quick%20peek%20into%20ruby%2Fbin%2Fgem%20revealed%20much%20of%20" title="Google Bookmarks"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="" title="Pownce"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/" title="Pownce" alt="Pownce" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="" title="TwitThis"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.kesor.net/2007/08/13/install-rubygems-from-irb/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HAML Caching CGI</title>
		<link>http://blog.kesor.net/2007/07/30/haml-caching-cgi/</link>
		<comments>http://blog.kesor.net/2007/07/30/haml-caching-cgi/#comments</comments>
		<pubDate>Mon, 30 Jul 2007 08:38:23 +0000</pubDate>
		<dc:creator>kesor</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.kesor.net/2007/07/30/haml-caching-cgi/</guid>
		<description><![CDATA[Mike Zillion asked about how to make HAML a processor (of haml files) for Apache on the HAML Group on Google. That inspired me to write a proper wrapper with caching that will Hamlize templates into HTML and cache those for speedy access on subsequent requests.
This is what I came up with:


#!/bin/env ruby

exit if ARGV[0].nil?
exit [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mikezillion.com">Mike Zillion</a> asked about how to make HAML a processor (of haml files) for Apache on the <a href="http://groups.google.com/group/haml/t/b2fd4dbc5f76cd61">HAML Group</a> on Google. That inspired me to write a proper wrapper with caching that will Hamlize templates into HTML and cache those for speedy access on subsequent requests.</p>
<p>This is what I came up with:<br />
<span id="more-9"></span></p>
<pre lang="ruby">
#!/bin/env ruby

exit if ARGV[0].nil?
exit unless File.exists?(ARGV[0])

CACHE_DIR_NAME='cache'

haml_file = ARGV[0]
haml_time = File.stat(haml_file).mtime

html_file = CACHE_DIR_NAME + '/' + haml_file.sub(/aml$/,'tml')
if File.exists?(html_file)
  html_time = File.stat(html_file).mtime

  if html_time > haml_time
    output = File.read(html_file)
  end
end

if output.nil?
  require 'rubygems'
  require 'haml'
  template = File.read(haml_file)
  haml_engine = Haml::Engine.new(template)
  output = haml_engine.to_html()

  # cache the output
  Dir.mkdir(CACHE_DIR_NAME) unless File.directory?(CACHE_DIR_NAME)
  html_file_io = File.open(html_file,"w")
  html_file_io.print(output)
  File.utime(Time.now, haml_time, html_file)
end

# unbuffer output
$stdout.sync = true

require 'cgi'
ENV['SERVER_SOFTWARE'] ||= 'not set'
cgi = CGI.new('html3')
print cgi.header(
        'type'     => 'text/html',
        'charset'  => 'UTF-8',
        'length'   => output.length,
        'server'   => ENV['SERVER_SOFTWARE'],
        'expires'  => Time.now + 10*3600*24, # 10 days
        'Pragma'   => 'no-cache',
        'Last-Modified' => haml_time,
        'Cache-Control' => 'no-cache'
)
print output
</pre>
<p>And as Mike suggested, adding a couple lines to your Apache configuration makes all the difference:</p>
<pre line="1">
  AddType text/haml .haml
  AddHandler haml-file .haml
  Action haml-file /dev/bin/haml_cache_cgi.rb
  Action text/haml /dev/bin/haml_cache_cgi.rb
</pre>
<p></p>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F30%2Fhaml-caching-cgi%2F&amp;title=HAML%20Caching%20CGI&amp;bodytext=Mike%20Zillion%20asked%20about%20how%20to%20make%20HAML%20a%20processor%20%28of%20haml%20files%29%20for%20Apache%20on%20the%20HAML%20Group%20on%20Google.%20That%20inspired%20me%20to%20write%20a%20proper%20wrapper%20with%20caching%20that%20will%20Hamlize%20templates%20into%20HTML%20and%20cache%20those%20for%20speedy%20access%20on%20subsequen" title="Digg"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F30%2Fhaml-caching-cgi%2F&amp;title=HAML%20Caching%20CGI&amp;notes=Mike%20Zillion%20asked%20about%20how%20to%20make%20HAML%20a%20processor%20%28of%20haml%20files%29%20for%20Apache%20on%20the%20HAML%20Group%20on%20Google.%20That%20inspired%20me%20to%20write%20a%20proper%20wrapper%20with%20caching%20that%20will%20Hamlize%20templates%20into%20HTML%20and%20cache%20those%20for%20speedy%20access%20on%20subsequen" title="del.icio.us"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F30%2Fhaml-caching-cgi%2F&amp;title=HAML%20Caching%20CGI" title="Reddit"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F30%2Fhaml-caching-cgi%2F" title="Technorati"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=HAML%20Caching%20CGI&amp;body=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F30%2Fhaml-caching-cgi%2F" title="email"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F30%2Fhaml-caching-cgi%2F&amp;t=HAML%20Caching%20CGI" title="Facebook"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F30%2Fhaml-caching-cgi%2F&amp;title=HAML%20Caching%20CGI&amp;annotation=Mike%20Zillion%20asked%20about%20how%20to%20make%20HAML%20a%20processor%20%28of%20haml%20files%29%20for%20Apache%20on%20the%20HAML%20Group%20on%20Google.%20That%20inspired%20me%20to%20write%20a%20proper%20wrapper%20with%20caching%20that%20will%20Hamlize%20templates%20into%20HTML%20and%20cache%20those%20for%20speedy%20access%20on%20subsequen" title="Google Bookmarks"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="" title="Pownce"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/" title="Pownce" alt="Pownce" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="" title="TwitThis"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.kesor.net/2007/07/30/haml-caching-cgi/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Writing helpers with Haml and rSpec</title>
		<link>http://blog.kesor.net/2007/07/22/writing-helpers-with-haml-and-rspec/</link>
		<comments>http://blog.kesor.net/2007/07/22/writing-helpers-with-haml-and-rspec/#comments</comments>
		<pubDate>Sun, 22 Jul 2007 19:02:46 +0000</pubDate>
		<dc:creator>kesor</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[specifications]]></category>

		<guid isPermaLink="false">http://blog.kesor.net/2007/07/22/writing-helpers-with-haml-and-rspec/</guid>
		<description><![CDATA[Recently Wolfman posted a description about Rails helpers written with Haml::Helpers#open and rSpec.
I want it to be more DRY than it is, since the whole application is using rSpec and Haml, all helpers should have the same before(:each)
So basically &#8211; what I did was :

[source:ruby]
Spec::Runner.configure do &#124;config&#124;
  config.with_options :behaviour_type => :helpers do &#124;config&#124;
  [...]]]></description>
			<content:encoded><![CDATA[<p>Recently <a href="http://blog.wolfman.com/articles/2007/07/14/using-rspec-to-test-haml-helpers">Wolfman</a> posted a description about <a target="_blank" title="Ruby on Rails" href="http://www.rubyonrails.com">Rails</a> helpers written with <a target="_blank" title="HAML" href="http://haml.hamptoncatlin.com">Haml</a>::<a target="_blank" title="HAML::Helpers RDoc" href="http://haml.hamptoncatlin.com/docs/rdoc/classes/Haml/Helpers.html">Helpers#open</a> and <a target="_blank" title="rSpec" href="http://rspec.rubyforge.org">rSpec</a>.</p>
<p>I want it to be more DRY than it is, since the whole application is using rSpec and Haml, all helpers should have the same <code>before(:each)</code></p>
<p>So basically &#8211; what I did was :</p>
<p><span id="more-8"></span><br />
[source:ruby]<br />
Spec::Runner.configure do |config|<br />
  config.with_options :behaviour_type => :helpers do |config|<br />
    config.include Haml::Helpers<br />
    config.include ActionView::Helpers<br />
    config.prepend_before :all do<br />
      @haml_is_haml = true<br />
      @haml_stack = [Haml::Buffer.new]<br />
    end<br />
  end<br />
end<br />
[/source]</p>
<p>Except it will not work, for various reasons.</p>
<p>Hope to solve all the quirks sometime soon. I know this will cost me some sleep.</p>
<p></p>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F22%2Fwriting-helpers-with-haml-and-rspec%2F&amp;title=Writing%20helpers%20with%20Haml%20and%20rSpec&amp;bodytext=Recently%20Wolfman%20posted%20a%20description%20about%20Rails%20helpers%20written%20with%20Haml%3A%3AHelpers%23open%20and%20rSpec.%0D%0A%0D%0AI%20want%20it%20to%20be%20more%20DRY%20than%20it%20is%2C%20since%20the%20whole%20application%20is%20using%20rSpec%20and%20Haml%2C%20all%20helpers%20should%20have%20the%20same%20before%28%3Aeach%29%0D%0A%0D%0ASo%20bas" title="Digg"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F22%2Fwriting-helpers-with-haml-and-rspec%2F&amp;title=Writing%20helpers%20with%20Haml%20and%20rSpec&amp;notes=Recently%20Wolfman%20posted%20a%20description%20about%20Rails%20helpers%20written%20with%20Haml%3A%3AHelpers%23open%20and%20rSpec.%0D%0A%0D%0AI%20want%20it%20to%20be%20more%20DRY%20than%20it%20is%2C%20since%20the%20whole%20application%20is%20using%20rSpec%20and%20Haml%2C%20all%20helpers%20should%20have%20the%20same%20before%28%3Aeach%29%0D%0A%0D%0ASo%20bas" title="del.icio.us"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F22%2Fwriting-helpers-with-haml-and-rspec%2F&amp;title=Writing%20helpers%20with%20Haml%20and%20rSpec" title="Reddit"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F22%2Fwriting-helpers-with-haml-and-rspec%2F" title="Technorati"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=Writing%20helpers%20with%20Haml%20and%20rSpec&amp;body=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F22%2Fwriting-helpers-with-haml-and-rspec%2F" title="email"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F22%2Fwriting-helpers-with-haml-and-rspec%2F&amp;t=Writing%20helpers%20with%20Haml%20and%20rSpec" title="Facebook"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fblog.kesor.net%2F2007%2F07%2F22%2Fwriting-helpers-with-haml-and-rspec%2F&amp;title=Writing%20helpers%20with%20Haml%20and%20rSpec&amp;annotation=Recently%20Wolfman%20posted%20a%20description%20about%20Rails%20helpers%20written%20with%20Haml%3A%3AHelpers%23open%20and%20rSpec.%0D%0A%0D%0AI%20want%20it%20to%20be%20more%20DRY%20than%20it%20is%2C%20since%20the%20whole%20application%20is%20using%20rSpec%20and%20Haml%2C%20all%20helpers%20should%20have%20the%20same%20before%28%3Aeach%29%0D%0A%0D%0ASo%20bas" title="Google Bookmarks"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="" title="Pownce"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/" title="Pownce" alt="Pownce" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="" title="TwitThis"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.kesor.net/2007/07/22/writing-helpers-with-haml-and-rspec/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby + proper specifications = rSpec</title>
		<link>http://blog.kesor.net/2006/05/21/ruby-proper-specifications-rspec/</link>
		<comments>http://blog.kesor.net/2006/05/21/ruby-proper-specifications-rspec/#comments</comments>
		<pubDate>Sun, 21 May 2006 20:07:53 +0000</pubDate>
		<dc:creator>kesor</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[specifications]]></category>

		<guid isPermaLink="false">http://blog.kesor.net/2006/05/21/ruby-proper-specifications-rspec/</guid>
		<description><![CDATA[I had an enlightenment today &#8211; truly an enlightenment.
After months of reading and getting to know what test driven development and extreme programming is all about, I have finally been able to practice what I preach. Since I work with several programmers and the product we are writing is so new that it is still [...]]]></description>
			<content:encoded><![CDATA[<p>I had an enlightenment today &#8211; truly an enlightenment.</p>
<p>After months of reading and getting to know what test driven development and extreme programming is all about, I have finally been able to practice what I preach. Since I work with several programmers and the product we are writing is so new that it is still in diapers (famous hebrew saying). Quality control is a demand from above management, after they got burned with too many escalations with the existing product. So part of my job description was preaching unit testing and such.</p>
<p>Anyways &#8211; I really did understand and could quote all the reasons why testing is important, and why its a sort of a documentation, and why it should be done before coding, and why it makes coding more structured and disciplined and gives the programmer a direction. But I could not make myself understand how to implement it with ruby&#8217;s <a title="Test::Unit" target="_blank" href="http://testunit.talbott.ws/">Test::Unit</a> for example, not even talking about more obscure implementations of <a title="xUnit" target="_blank" href="http://en.wikipedia.org/wiki/XUnit">xUnit </a>like <a title="cppUnit" target="_blank" href="http://cppunit.sourceforge.net/cppunit-wiki">CppUnit</a> which is something that was chosen for our project.</p>
<p>Last week I saw the presentation <a target="_blank" title="Dave Astels" href="http://www.daveastels.com/">Dave Astels</a> made at google, freely downloadable from google video. An I saw that it was god (with one &#8216;o&#8217;). And today I finally got to trash all the beginnings that I tried to do with Test::Unit on the ClearCase wrapper I&#8217;m writing &#8211; and started doing <a target="_blank" href="http://rspec.rubyforge.org/">rSpec</a> instead.</p>
<p>It flowed&#8230; like a river. And any bumps that were on the were not frustrating, they were annoying, thus actually motivating me to kick them of my route and continue flowing with the flow without any frustration. It rocks. I love it.</p>
<p>Still the one thing I miss with all this TDD and BDD are good concrete examples that are a bit more than what <a target="_blank" title="rSpec examples" href="http://rspec.rubyforge.org/examples.html">rSpec examples</a> are, I need it chewed and digested for extreme easy understanding. Maybe a step-by-step evolving kind of code, maybe even a book matching the Progmatic books quality is the thing missing in all of this. Because it always looks really great &#8211; but when a motivated but inexperienced programmer like me tries to implement this stuff it soon becomes frustrating. Even though rSpec is not too frustrating, and hopefully it will only grow to be easier and more intuitive and productive like it is already in its alpha(?) state.</p>
<p>Enough ramblings for now &#8211; back to the code! <img src='http://blog.kesor.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p></p>

<div class="sociable">

<ul>
	<li class="sociablefirst"><a rel="nofollow"  href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.kesor.net%2F2006%2F05%2F21%2Fruby-proper-specifications-rspec%2F&amp;title=Ruby%20%2B%20proper%20specifications%20%3D%20rSpec&amp;bodytext=I%20had%20an%20enlightenment%20today%20-%20truly%20an%20enlightenment.%0D%0A%0D%0AAfter%20months%20of%20reading%20and%20getting%20to%20know%20what%20test%20driven%20development%20and%20extreme%20programming%20is%20all%20about%2C%20I%20have%20finally%20been%20able%20to%20practice%20what%20I%20preach.%20Since%20I%20work%20with%20several%20pro" title="Digg"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://delicious.com/post?url=http%3A%2F%2Fblog.kesor.net%2F2006%2F05%2F21%2Fruby-proper-specifications-rspec%2F&amp;title=Ruby%20%2B%20proper%20specifications%20%3D%20rSpec&amp;notes=I%20had%20an%20enlightenment%20today%20-%20truly%20an%20enlightenment.%0D%0A%0D%0AAfter%20months%20of%20reading%20and%20getting%20to%20know%20what%20test%20driven%20development%20and%20extreme%20programming%20is%20all%20about%2C%20I%20have%20finally%20been%20able%20to%20practice%20what%20I%20preach.%20Since%20I%20work%20with%20several%20pro" title="del.icio.us"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://reddit.com/submit?url=http%3A%2F%2Fblog.kesor.net%2F2006%2F05%2F21%2Fruby-proper-specifications-rspec%2F&amp;title=Ruby%20%2B%20proper%20specifications%20%3D%20rSpec" title="Reddit"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://technorati.com/faves?add=http%3A%2F%2Fblog.kesor.net%2F2006%2F05%2F21%2Fruby-proper-specifications-rspec%2F" title="Technorati"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/technorati.png" title="Technorati" alt="Technorati" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="mailto:?subject=Ruby%20%2B%20proper%20specifications%20%3D%20rSpec&amp;body=http%3A%2F%2Fblog.kesor.net%2F2006%2F05%2F21%2Fruby-proper-specifications-rspec%2F" title="email"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.facebook.com/share.php?u=http%3A%2F%2Fblog.kesor.net%2F2006%2F05%2F21%2Fruby-proper-specifications-rspec%2F&amp;t=Ruby%20%2B%20proper%20specifications%20%3D%20rSpec" title="Facebook"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fblog.kesor.net%2F2006%2F05%2F21%2Fruby-proper-specifications-rspec%2F&amp;title=Ruby%20%2B%20proper%20specifications%20%3D%20rSpec&amp;annotation=I%20had%20an%20enlightenment%20today%20-%20truly%20an%20enlightenment.%0D%0A%0D%0AAfter%20months%20of%20reading%20and%20getting%20to%20know%20what%20test%20driven%20development%20and%20extreme%20programming%20is%20all%20about%2C%20I%20have%20finally%20been%20able%20to%20practice%20what%20I%20preach.%20Since%20I%20work%20with%20several%20pro" title="Google Bookmarks"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a></li>
	<li><a rel="nofollow"  href="" title="Pownce"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/" title="Pownce" alt="Pownce" class="sociable-hovers" /></a></li>
	<li class="sociablelast"><a rel="nofollow"  href="" title="TwitThis"><img src="http://blog.kesor.net/wp-content/plugins/sociable/images/" title="TwitThis" alt="TwitThis" class="sociable-hovers" /></a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.kesor.net/2006/05/21/ruby-proper-specifications-rspec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.872 seconds -->
