<?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>Peter Krantz &#187; Ruby</title>
	<atom:link href="http://www.peterkrantz.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.peterkrantz.com</link>
	<description>A blog about technology, visualization, music and unmanned vehicle experiments</description>
	<lastBuildDate>Thu, 26 Aug 2010 09:16:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Rails vs Grails vs Django models</title>
		<link>http://www.peterkrantz.com/2009/rails-grails-django-models/</link>
		<comments>http://www.peterkrantz.com/2009/rails-grails-django-models/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 16:58:47 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Applications]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[domain modeling]]></category>
		<category><![CDATA[grails]]></category>

		<guid isPermaLink="false">http://www.peterkrantz.com/?p=281</guid>
		<description><![CDATA[Coming back to Rails after being away from some time in Django land I discovered a huge difference in how Rails and Django treats your models...]]></description>
			<content:encoded><![CDATA[<p>Coming back to Rails after being away from some time in Django land I discovered a huge difference in how Rails, Grails and Django treats your models. In Django and Grails you can look at a model class and see all the properties it has:</p>
<pre class="brush: python;">
class Organization(models.Model):
    name = models.CharField(max_length=255)
    url = models.URLField(verify_exists=False)
    orgtype = models.ForeignKey(OrgType)
</pre>
<p>The same model class in Rails typically looks like this:</p>
<pre class="brush: ruby;">
class Organization &lt; ActiveRecord::Base
    belongs_to :OrgType
end
</pre>
<p>&#8230;and in Grails it is more specific like Django:</p>
<pre class="brush: groovy;">
class Organization {
  String name
  String url
  static belongsTo = OrgType
  OrgType orgtype
}
</pre>
<p>It took me a while to remember that in Rails, parts of the model design is actually stored in the database schema instead of in the Ruby code. Peculiar don&#8217;t you think, given that everything else in a Rails app is nicely declared in Ruby code? There are of course benefits to both approaches, but I have started adding comments in the Rails model classes to be able to remember what properties they have without peeking in the Db. Typically I have a number of half-baked projects on my laptop and from time to time I forget what they do and these comments help me remember.</p>
<p>Check out more examples here:</p>
<ul>
<li><a href="http://docs.djangoproject.com/en/dev/topics/db/models/#topics-db-models">Django models</a></li>
<li><a href="http://www.tutorialspoint.com/ruby-on-rails/rails-models.htm">Rails models</a></li>
<li><a href="https://www.ibm.com/developerworks/java/library/j-grails02128/">Grails models</a></li>
</ul>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.peterkrantz.com%2F2009%2Frails-grails-django-models%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" title="I like this" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:auto;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://www.peterkrantz.com/2009/rails-grails-django-models/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Intricacies of PHP compared to Ruby</title>
		<link>http://www.peterkrantz.com/2008/php-for-beginners/</link>
		<comments>http://www.peterkrantz.com/2008/php-for-beginners/#comments</comments>
		<pubDate>Tue, 01 Jan 2008 09:25:19 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.peterkrantz.com/2008/php-for-beginners/</guid>
		<description><![CDATA[Via Tim Bray’s blog I found zestyping’s “Why PHP should never be taught”. In it he provides some interesting PHP code that will be difficult for beginners to understand.]]></description>
			<content:encoded><![CDATA[<p>Via <a href="http://www.tbray.org/ongoing/When/200x/2007/12/31/Year-Sweep-Tech">Tim Bray&#8217;s blog</a> I found <a href="http://zestyping.livejournal.com/124503.html">zestyping&#8217;s &#8220;Why PHP should never be taught&#8221;</a>. In it he provides some interesting PHP code that will be difficult for beginners to understand:</p>
<pre>
$a = 0;
$b = "eggs";
$c = "spam";
</pre>
<p>yields:</p>
<pre>
a == b
b != c
a == c
a == d
b != d
c != d
</pre>
<p>(Please note that d hasn&#8217;t been defined). In the comments, people freak out and tell him that this behaviour is defined in the documentation. I guess that makes it even worse. </p>
<p>Trying the same thing in Ruby:</p>
<p>a = 0<br />
b = &#8220;eggs&#8221;<br />
c = &#8220;spam&#8221;</p>
<p>a == b<br />
=> false</p>
<p>b == c<br />
=> false</p>
<p>a == c<br />
=> false</p>
<p>a == d<br />
NameError: undefined local variable or method &#8216;d&#8217; for main:Object from (irb):7</code></p>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.peterkrantz.com%2F2008%2Fphp-for-beginners%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" title="I like this" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:auto;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://www.peterkrantz.com/2008/php-for-beginners/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>SimpleCrawler for your everyday web crawling needs</title>
		<link>http://www.peterkrantz.com/2007/ruby-web-crawler/</link>
		<comments>http://www.peterkrantz.com/2007/ruby-web-crawler/#comments</comments>
		<pubDate>Mon, 27 Aug 2007 19:22:43 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Markup]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.peterkrantz.com/2007/ruby-web-crawler/</guid>
		<description><![CDATA[<img src='http://www.peterkrantz.com/wp-content/uploads/2007/08/simplecrawler.gif' alt='' class="illustration" />Over at the <a href="http://www.standards-schmandards.com/">standards-schmandards blog</a> I often test websites to gather statistics on specific HTML use, accessibility and other things. Each time I have written a web crawler to collect the data. In Python and Ruby this is a simple task but last time it was like a déjà vu and I decided to create a Ruby library that I could use in the future.]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.peterkrantz.com/wp-content/uploads/2007/08/simplecrawler.gif' alt='' class="illustration" />Over at the <a href="http://www.standards-schmandards.com/">standards-schmandards blog</a> I often test websites to gather statistics on specific HTML use, accessibility and other things. Each time I have written a web crawler to collect the data. In Python and Ruby this is a simple task but last time it was like a déjà vu and I decided to create a Ruby library that I could use in the future.</p>
<p><a href="http://www.peterkrantz.com/simplecrawler/wiki/">SimpleCrawler</a> is a Ruby gem that covers basic web crawling needs. Coupled with Raakt and Ruport it can be used to create a <a href="http://www.peterkrantz.com/simplecrawler/wiki/examples/accessibility-report">basic accessibility report</a> for a website. </p>
<p>A minimal example:</p>
<p>require &#8216;simplecrawler&#8217;</p>
<p># Set up a new crawler<br />
sc = SimpleCrawler::Crawler.new(&#8220;http://www.peterkrantz.com/&#8221;)</p>
<p>sc.crawl { |document|<br />
   # output the crawled uri<br />
   puts document.uri<br />
}</p>
<p>For more details and examples see the <a href="http://www.peterkrantz.com/simplecrawler/wiki/">SimpleCrawler wiki</a>.</p>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.peterkrantz.com%2F2007%2Fruby-web-crawler%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" title="I like this" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:auto;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://www.peterkrantz.com/2007/ruby-web-crawler/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hackety Hack &#8211; The Foundation for a Revolution</title>
		<link>http://www.peterkrantz.com/2007/hackety-hack-revolution/</link>
		<comments>http://www.peterkrantz.com/2007/hackety-hack-revolution/#comments</comments>
		<pubDate>Mon, 09 Jul 2007 11:11:26 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Trends]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.peterkrantz.com/2007/hackety-hack-revolution/</guid>
		<description><![CDATA[<img src="http://www.peterkrantz.com/wp-content/uploads/2007/07/hackety-hack.jpg" alt="Hackety Hack t-shirt" class="right"><a href="http://whytheluckystiff.net/">Why the lucky stiff</a> is a well known name among most Ruby developers. Many have read his Ruby programming tutorials and seen his spectacular performances (or whatever they are) at RailsConf and elsewhere. Personally, I owe him a lot for Hpricot, the liberal HTML parser (at <a href="http://www.verva.se/web/t/Page____492.aspx">my government agency</a> we use it to run the <a href="http://www.verva.se/web/t/Page____2135.aspx">quarterly test of all public websites in Sweden</a>). Here are some thoughts on why I think Hackety Hack may be important than I first thought.]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.peterkrantz.com/wp-content/uploads/2007/07/hackety-hack.jpg" alt="Hackety Hack t-shirt" class="right"><a href="http://whytheluckystiff.net/">Why the lucky stiff</a> is a well known name among most Ruby developers. Many have read his Ruby programming tutorials and seen his spectacular performances (or whatever they are) at RailsConf and elsewhere. Personally, I owe him a lot for Hpricot, the liberal HTML parser (at <a href="http://www.verva.se/web/t/Page____492.aspx">my government agency</a> we use it to run the <a href="http://www.verva.se/web/t/Page____2135.aspx">quarterly test of all public websites in Sweden</a>). Hpricot is also the default parser for the <a href="http://www.peterkrantz.com/raakt/wiki/">Ruby Accessibility Analysis Kit</a>.</p>
<h2>The Hackety Hack</h2>
<p>Hi latest endeavour seemed uninteresting at first. Hackety Hack, a toolbox to <a href="http://hacketyhack.net/">teach programming to kids</a>. But after a while it dawned on me. If Ruby on Rails is beginning to make inroads into the Enterprise by challenging web development paradigms, Hackety Hack will in time question many of the programming paradigms taught at universities today. </p>
<p>My first programming class at university was in <a href="http://en.wikipedia.org/wiki/ML_programming_language">ML, a functional programming language</a>. I remember that we played with lists a lot. And recursion. Then we made a parser for our own symbolic programming language. I guess that pretty much killed my entrepreneurial spirit for a couple of years.</p>
<p>Kids who learn how to set up a blog in five lines of code, send messages over the internet and play with mp3 files will not accept that. The first kids out of Hackety Hack camp will soon be arriving at universities all over the place. And they will question the curly braces, the semicolons and <a href="http://en.wikipedia.org/wiki/Aspect-oriented_programming">Arcane ways to make Old programming languages Pleasant</a>.</p>
<p>If I was a university professor I would make sure to have a look at some other programming languages apart from Java and C# (do they teach C# at universities?) before these kids come and ruin my programming classes.</p>
<p>I predict that Sweden will be the last bastion of uninterested software developers. To make some sort of vague statement I have made a Hackety Hack t-shirt for my 2 year old son. I hope he will be at the front lines of the Hackety Hack revolution.</p>
<p><strong>Update:</strong> A bunch of people asked me where the highres print came from. The <a href="http://hacketyhack.net/art/">original logo is of course from Why the lucky stiff</a>. Here is the <a href='http://www.peterkrantz.com/wp-content/uploads/2007/07/hackety-hack-print.pdf'>Hackety Hack logo PDF</a> that I created in Inkscape.</p>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.peterkrantz.com%2F2007%2Fhackety-hack-revolution%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" title="I like this" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:auto;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://www.peterkrantz.com/2007/hackety-hack-revolution/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Checking for Model Classes Before Using Them in Rails Migrations</title>
		<link>http://www.peterkrantz.com/2007/models-in-migrations-tip/</link>
		<comments>http://www.peterkrantz.com/2007/models-in-migrations-tip/#comments</comments>
		<pubDate>Thu, 07 Jun 2007 11:39:27 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.peterkrantz.com/2007/models-in-migrations-tip/</guid>
		<description><![CDATA[If you are using model objects in migrations (e.g. for inserting data) you should make sure that the migration works even if that model class is removed. I discovered this when setting up a new development environment and running all migrations in an empty database. Let&#8217;s say you have the following migration code: class InsertCounties [...]]]></description>
			<content:encoded><![CDATA[<p>If you are using model objects in migrations (e.g. for inserting data) you should make sure that the migration works even if that model class is removed. I discovered this when setting up a new development environment and running all migrations in an empty database.</p>
<p>Let&#8217;s say you have the following migration code:</p>
<p>class InsertCounties < ActiveRecord::Migration<br />
  def self.up<br />
    County.create :code => &#8217;10&#8242;, :name => &#8216;Blekinge&#8217;<br />
    County.create :code => &#8217;20&#8242;, :name => &#8216;Dalarna&#8217;<br />
  end<br />
end</p>
<p>This assumes that the County model is available when the migration is run. If you checked out the most recent version of your code from svn it is possible that it doesn&#8217;t contain the County model and the migration will fail. To check if County is available before trying to use it <a href="http://redhanded.hobix.com/inspect/methodCheckDefined.html">we can use Ruby&#8217;s defined?</a> like this:</p>
<p><strong>Update:</strong> No we can&#8217;t. defined? always returns false inside an ActiveRecord migration for some reason (maybe the class isn&#8217;t loaded before the actual call?). We have to use a begin&#8230;rescue&#8230;end block instead:</p>
<p>class InsertCounties < ActiveRecord::Migration<br />
  def self.up<br />
    begin<br />
      County.create :code => &#8217;10&#8242;, :name => &#8216;Blekinge&#8217;<br />
      County.create :code => &#8217;20&#8242;, :name => &#8216;Dalarna&#8217;<br />
    rescue<br />
      puts &#8220;Could not add data&#8230;&#8221;<br />
    end<br />
  end<br />
end</p>
<p>This way the rest of the migrations will run.</p>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.peterkrantz.com%2F2007%2Fmodels-in-migrations-tip%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" title="I like this" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:auto;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://www.peterkrantz.com/2007/models-in-migrations-tip/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Bringing Ruby to the .NET environment</title>
		<link>http://www.peterkrantz.com/2007/bringing-ruby-to-the-net-environment/</link>
		<comments>http://www.peterkrantz.com/2007/bringing-ruby-to-the-net-environment/#comments</comments>
		<pubDate>Tue, 05 Jun 2007 09:04:15 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Trends]]></category>

		<guid isPermaLink="false">http://www.peterkrantz.com/2007/bringing-ruby-to-the-net-environment/</guid>
		<description><![CDATA[Things are heating up in the Ruby-as-a-dotnet-language area. Martin Fowler voiced his concerns on Microsoft not being able to look at source code and therefore having trouble implementing Ruby properly. Microsoft, with John Lam in the cockpit, is implementting Ruby for the .net platform (if you have been reading my previous blog posts I predicted [...]]]></description>
			<content:encoded><![CDATA[<p>Things are heating up in the Ruby-as-a-dotnet-language area. <a href="http://martinfowler.com/bliki/RubyMicrosoft.html">Martin Fowler voiced his concerns</a> on Microsoft not being able to look at source code and therefore having trouble implementing Ruby properly. Microsoft, with <a href="http://www.iunknown.com/">John Lam</a> in the cockpit, is implementting Ruby for the .net platform (if you have been reading my previous blog posts I predicted way <a href="http://www.peterkrantz.com/2006/using-ruby-as-a-net-language/">back in february 2006</a> that John Lam would get scooped up my Microsoft:-).</p>
<p><a href="http://ola-bini.blogspot.com/2007/06/there-can-be-only-one-tale-about-ruby.html">Ola Bini is also concerned</a> about Microsoft not letting ther developers look at the Ruby implementation. If you remember the whole SCO debacle I guess it isn&#8217;t that strange. Microsoft is in the position where software they develop potentially may end up in millions of computers. Apparently the US legal system awards damages in proportion to this. Thus, any issues with a Ruby implementation on .net can quickly become costly.</p>
<p>It is all quite bizarre. Does this mean that the Microsoft version of the Ruby language is different from the &#8220;original&#8221; Ruby? I guess we will never know. Developers will probably write a lot of Ruby code that runs happily on the CLR. Rails applications will be deployed. But I am sure that there will be &#8220;special cases&#8221; where IronRuby will differ from &#8220;original&#8221; Ruby.</p>
<p>Therefore is was refreshing to see that Queensland University of Technology are progressing steadily with <a href="http://plas2003.fit.qut.edu.au/Ruby.NET/">their Ruby.NET implementation</a>. Currently you can actually compile a Ruby script into a .NET 2.0 assembly that other CLR languages can talk to. This may be the spearhead into the <a href="http://www.peterkrantz.com/2007/enterprise-rails-deployment/">other half of enterprise deployment options</a>.</p>
<p>All in all the future of software development looks bright. Will developers that invested a lot of time in Java or C# switch? Or will they move on to maintaining applications?</p>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.peterkrantz.com%2F2007%2Fbringing-ruby-to-the-net-environment%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" title="I like this" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:auto;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://www.peterkrantz.com/2007/bringing-ruby-to-the-net-environment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with UTF-8 in PDF::Writer and Ruby on Rails</title>
		<link>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/</link>
		<comments>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/#comments</comments>
		<pubDate>Thu, 31 May 2007 14:26:00 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.peterkrantz.com/2007/utf8-in-pdf-writer/</guid>
		<description><![CDATA[Googling for information on how to use PDF::Writer shows that there are many european developers frustrated with the lack of UTF-8 support in PDF::Writer. As Ruby on Rails works great with UTF-8 these days this can be a bit of an issue. Part of the problem lies in the fact that the PDF specification (at [...]]]></description>
			<content:encoded><![CDATA[<p>Googling for information on how to use <a href="http://ruby-pdf.rubyforge.org/pdf-writer/index.html">PDF::Writer</a> shows that there are many european developers frustrated with the lack of UTF-8 support in PDF::Writer. As Ruby on Rails works great with UTF-8 these days this can be a bit of an issue. </p>
<p>Part of the problem lies in the fact that the PDF specification (at least up to 1.6) does not support UTF-8 (you can use UTF-16 if you like). I had the misfortune of plowing thorugh it a couple of years ago when developing a PDF form filler library for a customer (don&#8217;t ask).</p>
<p>In Ruby on Rails, this is easy to solve as long as you only use Latin characters with diacritics. The solution is to switch encoding back to <a href="http://en.wikipedia.org/wiki/ISO_8859-15">ISO-8859-15</a> for text strings you feed to PDF::Writer. </p>
<p>A simple extension to the String class will do the trick:</p>
<p>class String<br />
  require &#8216;iconv&#8217;<br />
  def to_iso<br />
    c = Iconv.new(&#8216;ISO-8859-15&#8242;,&#8217;UTF-8&#8242;)<br />
    c.iconv(self)<br />
  end<br />
end</p>
<p>If you are working in Rails you can put this code in the lib folder (I usually call the file string_extensions.rb). </p>
<p>Then, when you call the text method on your PDF::Writer intance you can easily pass a correctly encoded string.</p>
<h2>Overriding PDF::Writer text method</h2>
<p>A much cleaner approach, as Aníbal describes in the comment below, is to override PDF::Writer&#8217;s text method.</p>
<p>Put the following code in a file called pdfwriter_extensions.rb (or whatever you choose to call it) in your lib directory:</p>
<p>CONVERTER = Iconv.new( &#8216;ISO-8859-15//IGNORE//TRANSLIT&#8217;, &#8216;utf-8&#8242;)</p>
<p>module PDF<br />
	class Writer<br />
		alias_method :old_text, :text</p>
<p>		def text(textto, options = {})<br />
			old_text(CONVERTER.iconv(textto), options)<br />
		end</p>
<p>	end<br />
end</p>
<p>In your controller that handles the PDF output you add:</p>
<p>  require &#8216;pdf/writer&#8217;<br />
  require &#8216;pdfwriter_extensions&#8217;</p>
<p>&#8230;after which you can use PDF::Writer like in the tutorial:</p>
<p>    pdf = PDF::Writer.new<br />
    pdf.select_font &#8220;Helvetica&#8221;, :encoding => nil<br />
    pdf.text &#8220;User name: <b>#{@user.name}</b>&#8220;, :font_size => 16, :justification => :left<br />
    send_data pdf.render, :disposition => &#8216;inline&#8217;, :filename => &#8220;user_details.pdf&#8221;, :type => &#8220;application/pdf&#8221;</p>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.peterkrantz.com%2F2007%2Futf8-in-pdf-writer%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" title="I like this" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:auto;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://www.peterkrantz.com/2007/utf8-in-pdf-writer/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>New release of the Ruby Accessibility Analysis Kit and online interface</title>
		<link>http://www.peterkrantz.com/2007/raakt-052/</link>
		<comments>http://www.peterkrantz.com/2007/raakt-052/#comments</comments>
		<pubDate>Sun, 01 Apr 2007 20:37:43 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.peterkrantz.com/2007/raakt-052/</guid>
		<description><![CDATA[The current version has some minor bug fixes that will speed up testing. The online test interface has been updated to support direct input of markup. This is for those of you unable to install Raakt locally. This means that there is no reason to skip basic accessibility testing of whatever you are developing! To [...]]]></description>
			<content:encoded><![CDATA[<p>The current version has some minor bug fixes that will speed up testing. The <a href="http://www.peterkrantz.com/bacc/">online test interface</a> has been updated to support direct input of markup. This is for those of you unable to install Raakt locally.</p>
<p>This means that there is no reason to skip basic accessibility testing of whatever you are developing! To find out more on how you can integrate Raakt in your testing framework check out the <a href="http://www.peterkrantz.com/raakt/wiki/">Raakt wiki</a> which now has a lot more information.</p>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.peterkrantz.com%2F2007%2Fraakt-052%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" title="I like this" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:auto;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://www.peterkrantz.com/2007/raakt-052/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Putting Camping in the Camping logo</title>
		<link>http://www.peterkrantz.com/2007/camping-steganography/</link>
		<comments>http://www.peterkrantz.com/2007/camping-steganography/#comments</comments>
		<pubDate>Sun, 11 Mar 2007 13:53:48 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.peterkrantz.com/2007/camping-steganography/</guid>
		<description><![CDATA[<img src='http://www.peterkrantz.com/wp-content/uploads/2007/03/camping-in-camping.png' alt='The camping framework embedded in the campin logo' class="illustration"/>Having played with the <a href="http://diit.sourceforge.net/">Digital Invisible Ink Toolkit (DIIT)</a> lately it was interesting to see how big the logo file for the <a href="https://code.whytheluckystiff.net/camping">camping framework</a> would become if the camping framework itself was embedded in it...]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.peterkrantz.com/wp-content/uploads/2007/03/camping-in-camping.png' alt='The camping framework embedded in the campin logo' class="illustration"/>Having played with the <a href="http://diit.sourceforge.net/">Digital Invisible Ink Toolkit (DIIT)</a> lately it was interesting to see how big the logo file for the <a href="https://code.whytheluckystiff.net/camping">camping framework</a> would become if the camping framework itself was embedded in it. The original logo file (stolen from Why&#8217;s site) is a 73 Kb PNG file. Embedding <a href="https://code.whytheluckystiff.net/camping/browser/trunk/lib/camping.rb">camping.rb</a> in it creates a 101 Kb file visible to the right.<br />
<span id="more-72"></span><br />
Maybe this is the future of software distribution? Programmers and photographers can work together to distribute software and pretty pics? Is the porn industry in on this? What type of image would it take to distribute Oracle 9? Remember where you heard it first&#8230;</p>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.peterkrantz.com%2F2007%2Fcamping-steganography%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" title="I like this" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:auto;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://www.peterkrantz.com/2007/camping-steganography/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A new version of the Ruby Accessibility Analysis Kit</title>
		<link>http://www.peterkrantz.com/2007/raakt-in-watir/</link>
		<comments>http://www.peterkrantz.com/2007/raakt-in-watir/#comments</comments>
		<pubDate>Sat, 03 Mar 2007 16:58:22 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Testing]]></category>

		<guid isPermaLink="false">http://www.peterkrantz.com/2007/raakt-in-watir/</guid>
		<description><![CDATA[This is to announce that RAAKT (The Ruby Accessibility Analysis Kit) has been updated. This release includes more accessibility tests and an initial mapping of tests to the Unified Web Evaluation Methodology (UWEM). Also, thanks to Derek Perrault RAAKT now uses Hpricot to parse the HTML document. This solves the problem where the previous parser [...]]]></description>
			<content:encoded><![CDATA[<p>This is to announce that <a href="http://rubyforge.org/projects/raakt">RAAKT (The Ruby Accessibility Analysis Kit)</a> has been updated. This release includes more accessibility tests and an initial mapping of tests to the <a href="http://www.wabcluster.org/uwem/tests/">Unified Web Evaluation Methodology</a> (UWEM). Also, thanks to Derek Perrault RAAKT now uses <a href="http://code.whytheluckystiff.net/hpricot/">Hpricot</a> to parse the HTML document. This solves the problem where the previous parser (RubyfulSoup) declared a class &#8220;Tag&#8221; that was likely to clash with your local classes in Rails.</p>
<p>To install the new version simply type <kbd>gem update raakt</kbd> or <kbd>gem install raakt</kbd> if you have a previous version installed.</p>
<h2>Changelog</h2>
<p>Summary of changes from version 0.4 to version 0.5.1.</p>
<ul>
<li>Example of how to use RAAKT in <a href="http://wtr.rubyforge.org/">Watir unit tests</a>.</li>
<li>Tests for area element alt attribute.</li>
<li><a href="http://www.wabcluster.org/uwem/tests/">UWEM</a> mapped in comments for relevant test methods.</li>
<li>Test to check that input fields of type image have an alt attribute with text.</li>
<li>Refactoring of some methods for more compact syntax. Patch by Derek Perrault.</li>
<li>Added test to verify that fieldsets have legends.</li>
<li>Fixed alt_to_text that needed to check element type before attempting to read attribute value.</li>
<li>Fixed language attribute check (downcased value). Added iso language code list.</li>
<li>Applied patch from Derek Perrault (better use of Hpricot features).</li>
<li>Fixed check for lang attribute (now requires a value as well). </li>
<li>Test for charset mismatch in http headers and document meta element.</li>
<li>Switch to Hpricot. Patch by Derek Perrault.</li>
</ul>
<p>An article on the value of, and how to integrate basic accessibility tests in your development process is in the works for <a href="http://www.standards-schmandards.com/">standards-schmandards.com</a>. In the meantime check out the <a href="http://www.peterkrantz.com/raakt/wiki/">Raakt wiki</a>.</p>
<p>If you are using Watir it is very simple:</p>
<p>require &#8216;watir&#8217;<br />
require &#8216;raakt&#8217;<br />
require &#8216;test/unit&#8217;</p>
<p>class TC_myTest < Test::Unit::TestCase<br />
	attr_accessor :ie</p>
<p>	def setup<br />
		@ie = Watir::IE.start(&#8220;http://www.peterkrantz.com&#8221;)<br />
	end</p>
<p>	def test_startPagePassesBasicAccessibilityCheck<br />
		#set up the accessibility test and pass html to raakt<br />
		raakttest = Raakt::Test.new(@ie.document.body.parentelement.outerhtml)</p>
<p>		#run all tests on the current page<br />
		result = raakttest.all</p>
<p>		#make sure raakt didn&#8217;t return any error messages<br />
		assert(result.length == 0, result)<br />
	end<br />
end</p>
<div id="facebook_like"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.peterkrantz.com%2F2007%2Fraakt-in-watir%2F&amp;layout=standard&amp;show-faces=true&amp;width=450&amp;action=like&amp;font=arial&amp;colorscheme=light" scrolling="no" title="I like this" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:auto;"></iframe></div>]]></content:encoded>
			<wfw:commentRss>http://www.peterkrantz.com/2007/raakt-in-watir/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
