<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Code Experiments in Ruby</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/" />
    <link rel="self" type="application/atom+xml" href="http://www.ruby.code-experiments.com/blog/atom.xml" />
    <id>tag:www.ruby.code-experiments.com,2008-09-16:/blog//267</id>
    <updated>2010-08-17T02:28:03Z</updated>
    <subtitle>Experiments with the Ruby Programming Language</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.34-en</generator>

<entry>
    <title>/usr/lib/ruby/1.8/memcache.rb:24:in `read&apos;: No such file or directory - /usr/lib/ruby/1.8/../VERSION.yml (Errno::ENOENT)</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/08/usrlibruby18memcacherb24in-read-no-such-file-or-directory---usrlibruby18versionyml-errnoenoent.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.21218</id>

    <published>2010-08-17T01:01:42Z</published>
    <updated>2010-08-17T02:28:03Z</updated>

    <summary>I&apos;m getting an error when trying to use the libmemcache-client-ruby1.8 on Debian Squeeze.</summary>
    <author>
        <name>superadmin</name>
        
    </author>
    
    <category term="irb" label="irb" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="memcache" label="memcache" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ruby" label="ruby" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>I'm getting this error when trying to use the libmemcache-client-ruby1.8 on Debian Squeeze.</p>

<pre class="sh_sh">
/usr/lib/ruby/1.8/memcache.rb:24:in `read': No such file or directory - /usr/lib/ruby/1.8/../VERSION.yml (Errno::ENOENT)
</pre>

<p>To troubleshoot, I'm updating ruby1.8. Ugh, now I no longer have irb1.8!!</p>

<p>Oh well, in the end I just edited /usr/lib/ruby/1.8/memcache.rb and changed line 24:</p>

<pre class="sh_ruby">

#  VERSION = begin
#    config = YAML.load(File.read(File.dirname(__FILE__) + '/../VERSION.yml'))
#    "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
#  end
VERSION = '1.5.0'
</pre>
]]>
        

    </content>
</entry>

<entry>
    <title>Strange Fix for the Strangest Bug</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/06/strange-fix-for-the-strangest-bug.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20933</id>

    <published>2010-06-03T03:55:09Z</published>
    <updated>2010-06-13T20:14:39Z</updated>

    <summary>I have no idea why this bug fix works, but it does. When I run tidy_ffi via a Unicorn, a Sinatra app, and Rack-XSLView manually, it works fine. If I run it via daemontools, it returns an empty string because...</summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Gems" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Ruby1.9" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="bugs" label="bugs" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ruby" label="ruby" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ruby19" label="ruby 1.9" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="tidy_ffi" label="tidy_ffi" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>I have no idea why this bug fix works, but it does. When I run tidy_ffi via a Unicorn, a Sinatra app, and Rack-XSLView manually, it works fine. If I run it via daemontools, it returns an empty string because for some reason LibTidy.tidyReleaseDate isn't return a date!</p>

<pre class="sh_diff">
@@ -76,12 +76,7 @@ class TidyFFI::Interface

   def tidy_buf_object
     @tidy_buf_object ||= begin
-      release_date = Date.parse(LibTidy.tidyReleaseDate) rescue nil
-      if release_date && (release_date > Date.parse("Dec 29 2006"))
-        TidyFFI::LibTidy::TidyBufWithAllocator
-      else
-        TidyFFI::LibTidy::TidyBuf
-      end
+      TidyFFI::LibTidy::TidyBufWithAllocator
     end
   end
</pre>

<p>UPDATE: This wasn't the end of it. I submitted the fix to libc (Eugene), and he said the check was needed for Mac OS X which ships with an older version of libTidy. I dug deeper, and found that the date was getting returned, but it just wasn't getting processed correctly. After that, I did some external troubleshooting, and found that in irb1.9.1 I had to require 'date' to parse the date libTidy was returning. I switched out require 'rubygems' with require 'date', and the bug went away. Yay!</p>
]]>
        

    </content>
</entry>

<entry>
    <title>`instance_method&apos;: {:metaclass=&gt;:singleton_class} is not a symbol (TypeError) *RESOLVED*</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/05/instance-method-metaclasssingleton-class-is-not-a-symbol-typeerror-resolved.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20924</id>

    <published>2010-05-28T17:52:51Z</published>
    <updated>2010-05-28T06:27:30Z</updated>

    <summary>I got this error today when trying to run a Sinatra web application. Not sure what the root of the problem is, but I found a workaround: sudo gem1.9.1 install activesupport --version 2.3.5 $ sudo gem uninstall activesupport Select gem...</summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Bugs" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Ruby1.9" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="activesupport" label="activesupport" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="errors" label="errors" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ruby" label="ruby" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>I got this error today when trying to run a Sinatra web application. Not sure what the root of the problem is, but I found a workaround:</p>

<pre class="sh_sh">
sudo gem1.9.1 install activesupport --version 2.3.5
</pre>

<pre class="sh_sh">
$ sudo gem uninstall activesupport

Select gem to uninstall:
 1. activesupport-2.3.5
 2. activesupport-2.3.8
 3. All versions
> 2   
</pre>

<p>For reference, the full error:</p>

<pre class="sh_sh">

/var/lib/gems/1.9.1/gems/deprecated-2.0.1/lib/deprecated.rb:176:in `instance_method': {:metaclass=>:singleton_class} is not a symbol (TypeError)
    from /var/lib/gems/1.9.1/gems/deprecated-2.0.1/lib/deprecated.rb:176:in `block in &lt;top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/core_ext/object/metaclass.rb:13:in `&lt;class:Object>'
    from /var/lib/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/core_ext/object/metaclass.rb:3:in `&lt;top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/core_ext/object.rb:5:in `require'
    from /var/lib/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/core_ext/object.rb:5:in `&lt;top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/core_ext.rb:8:in `require'
    from /var/lib/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/core_ext.rb:8:in `block in &lt;top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/core_ext.rb:8:in `each'
    from /var/lib/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support/core_ext.rb:8:in `&lt;top (required)>'
    from /var/lib/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support.rb:56:in `require'
    from /var/lib/gems/1.9.1/gems/activesupport-2.3.8/lib/active_support.rb:56:in `&lt;top (required)>'
    from /var/lib/gems/1.9.1/gems/mail-2.2.1/lib/mail.rb:6:in `require'
    from /var/lib/gems/1.9.1/gems/mail-2.2.1/lib/mail.rb:6:in `&lt;module:Mail>'
    from /var/lib/gems/1.9.1/gems/mail-2.2.1/lib/mail.rb:2:in `&lt;top (required)>'
    from /var/lib/gems/1.9.1/gems/pony-1.0/lib/pony.rb:2:in `require'
    from /var/lib/gems/1.9.1/gems/pony-1.0/lib/pony.rb:2:in `&lt;top (required)>'
    from /home/albertlash/svxbox/lib/svxbox/ponyboy.rb:6:in `require'
    from /home/albertlash/svxbox/lib/svxbox/ponyboy.rb:6:in `&lt;top (required)>'
    from /home/albertlash/svxbox/lib/svxbox.rb:8:in `require'
    from /home/albertlash/svxbox/lib/svxbox.rb:8:in `&lt;top (required)>'
    from /home/albertlash/yodnsconf/yodnsconf.rb:45:in `require'
    from /home/albertlash/yodnsconf/yodnsconf.rb:45:in `&lt;top (required)>'
    from config.ru:11:in `require'
    from config.ru:11:in `block in &lt;main>'
    from /var/lib/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `instance_eval'
    from /var/lib/gems/1.9.1/gems/rack-1.1.0/lib/rack/builder.rb:46:in `initialize'
    from config.ru:1:in `new'
    from config.ru:1:in `&lt;main>'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:46:in `eval'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:46:in `block in builder'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:816:in `call'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:816:in `build_app!'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:673:in `init_worker_process'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:688:in `worker_loop'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:605:in `block (2 levels) in spawn_missing_workers'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:602:in `fork'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:602:in `block in spawn_missing_workers'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:598:in `each'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:598:in `spawn_missing_workers'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:612:in `maintain_worker_count'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:408:in `block in join'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:396:in `loop'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:396:in `join'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/lib/unicorn.rb:28:in `run'
    from /var/lib/gems/1.9.1/gems/unicorn-0.99.0/bin/unicorn:126:in `&lt;top (required)>'
    from /var/lib/gems/1.9.1/bin/unicorn:19:in `load'
    from /var/lib/gems/1.9.1/bin/unicorn:19:in `&lt;main>'
I, [2010-05-28T04:48:24.242011 #28838]  INFO -- : reaped #&lt;Process::Status: pid 28848 exit 1> worker=0
I, [2010-05-28T04:48:24.242246 #28838]  INFO -- : master complete
</pre>
]]>
        

    </content>
</entry>

<entry>
    <title>The Strangest Bug I&apos;ve Ever Encountered</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/05/the-strangest-bug-ive-ever-encountered.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20921</id>

    <published>2010-05-27T03:54:56Z</published>
    <updated>2010-06-13T18:40:16Z</updated>

    <summary>Earlier this week I can across a bug like none I&apos;d ever seen before. The bug is causing tidy_ffi to fail in its efforts to tidify a string when daemontools is running the Unicorn process, whereas it works fine if...</summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Bugs" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Unicorn" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="daemontools" label="daemontools" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ffi" label="ffi" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="processmonitoring" label="process monitoring" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="tidy_ffi" label="tidy_ffi" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="unicorn" label="unicorn" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>Earlier this week I can across a bug like none I'd ever seen before. The bug is causing tidy_ffi to fail in its efforts to tidify a string when daemontools is running the Unicorn process, whereas it works fine if my user (or root) runs the process.</p>

<p>At first I thought it was an environment variable missing, causing the string encoding to get messed up, but alas, no, that's not the problem.</p>

<p>I checked and set most of the environment variables, including LANG, then debugged the process by putting the encoding name out. They were the same if I was running the process or if daemontools was running it.</p>

<p>Anyone have <strong>any</strong> idea why this might happen?</p>

<p>UPDATE: I found a solution, but I still don't know why this was happening:</p>

<p><a href="http://www.ruby.code-experiments.com/blog/2010/06/strange-fix-for-the-strangest-bug.html">Strange Fix for the Strangest Bug</a></p>
]]>
        

    </content>
</entry>

<entry>
    <title>Ruby&apos;s Autoload Mechanism While Developing Gems</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/05/rubys-autoload-mechanism-while-developing-gems.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20919</id>

    <published>2010-05-23T19:19:24Z</published>
    <updated>2010-06-13T18:33:57Z</updated>

    <summary>I&apos;m making some modifications to a fork of a gem which I offers the functionality I&apos;m looking for but lacks configuration capabilities I need. I found that the gem uses Ruby&apos;s autoload mechanism, which I&apos;ve read is a good thing,...</summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Gems" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="autoload" label="autoload" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gems" label="gems" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="require" label="require" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>I'm making some modifications to a fork of a gem which I offers the functionality I'm looking for but lacks configuration capabilities I need.</p>

<p>I found that the gem uses Ruby's autoload mechanism, which I've read is a good thing, but the paths it was using messed me up.</p>

<p>This is what I've changed to make it work for me:</p>

<pre class="sh_diff">
5,6c4,5
&lt;   self.autoload :LibTidy, File.dirname(__FILE__) + '/tidy_ffi/lib_tidy'
&lt;   self.autoload :Interface, File.dirname(__FILE__) + '/tidy_ffi/interface'
---
&gt;   self.autoload :LibTidy, 'tidy_ffi/lib_tidy'
&gt;   self.autoload :Interface, 'tidy_ffi/interface'
9,11c8,10
&lt; require File.dirname(__FILE__) + '/tidy_ffi/options_container'
&lt; require File.dirname(__FILE__) + '/tidy_ffi/tidy'
&lt; require File.dirname(__FILE__) + '/tidy_ffi/tidy_ffi_extensions'
\ No newline at end of file
---
&gt; require 'tidy_ffi/options_container'
&gt; require 'tidy_ffi/tidy'
&gt; require 'tidy_ffi/tidy_ffi_extensions'
\ No newline at end of file
</pre>

<ul>
<li>http://www.subelsky.com/2008/05/using-rubys-autoload-method-to.html</li>
</ul>
]]>
        

    </content>
</entry>

<entry>
    <title>Chimailmadmin Sinatra Port</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/05/chimailmadmin-sinatra-port.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20907</id>

    <published>2010-05-20T17:29:46Z</published>
    <updated>2010-05-20T18:12:20Z</updated>

    <summary>I&apos;m porting Chimailmadmin, an email management tool I&apos;ve been working on for a couple of years, to Sinatra. Actually I&apos;m working on porting a bunch of web applications I work on, but Chimailmadmin is the furthest along. I&apos;m glad I...</summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Sinatra" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="XML" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="chimailmadmin" label="chimailmadmin" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="email" label="email" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="sinatra" label="sinatra" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="webapplications" label="web applications" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>I'm porting <a href="http://www.chimailmadmin.com/blog/">Chimailmadmin</a>, an email management tool I've been working on for a couple of years, to Sinatra.</p>

<p>Actually I'm working on porting a bunch of web applications I work on, but Chimailmadmin is the furthest along.</p>

<p>I'm glad I held off for a bit while I became more familiar with Sinatra. Its a really sweet little web application framework.</p>

<p>And yes - its open source (Affero GPLv3) and available on <a href="http://github.com/docunext/chimailmadmin">Github</a>!</p>
]]>
        

    </content>
</entry>

<entry>
    <title>gd2-ffij</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/05/gd2-ffij.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20904</id>

    <published>2010-05-20T04:04:54Z</published>
    <updated>2010-05-20T04:08:45Z</updated>

    <summary>I forked another ruby library today: gd2-ffij, which happens to be a fork of a fork of sorts. It provides bindings to the gd2 library (think awesome graphics utility) via ffi (foreign function interface). There is another ffi interface, gd2-ffi,...</summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Gems" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Ruby1.9" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="ffi" label="ffi" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gd" label="gd" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ruby" label="ruby" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>I forked another ruby library today: <a href="http://github.com/docunext/gd2-ffij">gd2-ffij</a>, which happens to be a fork of a fork of sorts.</p>

<p>It provides bindings to the gd2 library (think awesome graphics utility) via ffi (foreign function interface).</p>

<p>There is another ffi interface, gd2-ffi, but its limited in the functionality it covers.</p>

<p>This one didn't work with Ruby 1.9.1 right out of the box, but with a little bit of hackage, I was able to get things going. I reported by experience back to dark panda (J) who responded speedily.</p>

<p>Hopefully this will be the standard GD2 library.</p>

<p>FWIW: I became interested in the ruby bindings after <a href="http://www.gdofcgi.com/blog/2010/05/finally-moved-to-github.html">finally moving the source code for gdofcgi to github</a>.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Ruby Xapian-Fu</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/04/ruby-xapian-fu.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20850</id>

    <published>2010-04-27T03:36:27Z</published>
    <updated>2010-04-27T03:54:11Z</updated>

    <summary>Ruby has been a joy for me to learn and that positive experience has led me to try certain tasks I had previously hesitated to undertake. Building a Xapian database for searching, for instance. I first tried using the standard...</summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Ruby1.9" scheme="http://www.sixapart.com/ns/types#category" />
    
        <category term="Rubyisms" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="apt" label="apt" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ruby" label="ruby" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="xapian" label="xapian" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="xapianfu" label="xapian-fu" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>Ruby has been a joy for me to learn and that positive experience has led me to try certain tasks I had previously hesitated to undertake.</p>

<p>Building a Xapian database for searching, for instance. I first tried using the standard Xapian bindings, but then I found xapian-fu, a much more Rubyish gem.</p>

<p>It works fine with ruby 1.9.1 for me and is quite speedy. Here's a very simple example for a search (using the databases generated by the debian package apt-xapian-index):</p>

<pre class="sh_ruby">
#!/usr/bin/ruby1.9.1

require 'xapian-fu'
include XapianFu

db = XapianDb.new(:dir => '/var/lib/apt-xapian-index/index.1')

db.search(ARGV[0]).each do |match|
  puts match.data
end
</pre>

<ul>
<li><a href="http://rdoc.info/projects/johnl/xapian-fu">http://rdoc.info/projects/johnl/xapian-fu</a></li>
</ul>
]]>
        

    </content>
</entry>

<entry>
    <title><![CDATA[Read error: &lt;IndexError: string not matched>]]></title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/04/read-error-indexerror-string-not-matched.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20848</id>

    <published>2010-04-26T15:55:24Z</published>
    <updated>2010-04-26T16:10:07Z</updated>

    <summary><![CDATA[This was an interesting error to debug! It comes from a Sinatra app traceback, but the full traceback wasn't much help, here's a little bit of it: Read error: #&lt;IndexError: string not matched> /var/lib/gems/1.9.1/gems/sinatra-1.0.a/lib/sinatra/base.rb:600:in `[]=' /var/lib/gems/1.9.1/gems/sinatra-1.0.a/lib/sinatra/base.rb:600:in `handle_exception!' /var/lib/gems/1.9.1/gems/sinatra-1.0.a/lib/sinatra/base.rb:586:in `rescue in...]]></summary>
    <author>
        <name>Albert</name>
        
    </author>
    
    <category term="encodings" label="encodings" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="errors" label="errors" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="utf8" label="utf-8" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>This was an interesting error to debug! It comes from a Sinatra app traceback, but the full traceback wasn't much help, here's a little bit of it:</p>

<pre class="sh_sh">
Read error: #&lt;IndexError: string not matched>
/var/lib/gems/1.9.1/gems/sinatra-1.0.a/lib/sinatra/base.rb:600:in `[]='
/var/lib/gems/1.9.1/gems/sinatra-1.0.a/lib/sinatra/base.rb:600:in `handle_exception!'
/var/lib/gems/1.9.1/gems/sinatra-1.0.a/lib/sinatra/base.rb:586:in `rescue in dispatch!'
/var/lib/gems/1.9.1/gems/sinatra-1.0.a/lib/sinatra/base.rb:589:in `dispatch!'
</pre>

<p>I think it turned out to be an encoding error, but I'm not sure why this IndexError was showing up. Turns out that this bit of code doesn't cause a problem when there are no errors, but causes the IndexError when there is a problem:</p>

<pre class="sh_ruby">
@env = settings.environment
</pre>

<p>This is most likely Sinatra specific, if I change @env to @myenv, its OK. Since I don't actually need it, I've removed it altogether.</p>

<p>And to fix  the encoding issue:</p>

<pre class="sh_ruby">
rlinks.encode('UTF-8', undef: :replace, invalid: :replace)
</pre>
]]>
        

    </content>
</entry>

<entry>
    <title>Ruby Software Tools For All My Projects</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/04/ruby-software-tools-for-all-my-projects.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20840</id>

    <published>2010-04-24T21:13:06Z</published>
    <updated>2010-04-24T21:19:38Z</updated>

    <summary>I was just reading up some more about Rake when I realized how many awesome tools there are to write Ruby software with. I decided I should make a list of my favorite tools these days just in case someone...</summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Gems" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="automation" label="automation" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gemcutter" label="gemcutter" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="gems" label="gems" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="jeweler" label="jeweler" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="rake" label="rake" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ruby" label="ruby" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="vlad" label="vlad" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>I was just reading up some more about Rake when I realized how many awesome tools there are to write Ruby software with. I decided I should make a list of my favorite tools these days just in case someone else hasn't happened to have tried one - it could make their day!</p>

<ul>
<li><strong>Rake</strong> - an awesome, awesome make tool, heroic defender of system administrators' time and energy, helpful with testing and synthetic automation - in other words, its a good dog.</li>
<li><strong>Gems</strong> - yes, this is a tool! And it comes with a bike shop, too. I use gems for conveniently organizing <em>and distributing</em> my common Ruby libraries. Since I predominantly write open source software, other people can use them too. More specifically, I use gemcutter and jeweler to package and distribute my gems.</li>
<li><strong>Vlad</strong> - this is a simple "continuous integration" tool, and I like that it is simple and focused, leaving what's already been built to those existing libraries, like Rake</li>
</ul>

<p>I'll share more of my favorite tool choices as they come to mind.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Learning to Build Tests with Ruby</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/04/learning-to-build-tests-with-ruby.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20839</id>

    <published>2010-04-24T19:18:23Z</published>
    <updated>2010-04-24T19:20:51Z</updated>

    <summary>I&apos;m taking a moment to study up on how to build tests with Ruby. I&apos;m taking a step back and starting with some very simple examples, to make sure I have the concepts down cold! require &apos;test/unit&apos; class DoggyTest What...</summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Testing" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="testing" label="testing" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="unittest" label="unit test" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>I'm taking a moment to study up on how to build tests with Ruby. I'm taking a step back and starting with some very simple examples, to make sure I have the concepts down cold!</p>

<pre class="sh_ruby">

require 'test/unit'

class DoggyTest < Test::Unit::TestCase


    def test_chekit
        assert "hi" == "hi"
    end
    def test_barkit
        assert "bark" == "hi"
    end

end

</pre>

<p>What do you know? Before I tried this I didn't know that test/unit required methods to be prefixed with "test_" to be auto-run.</p>

<p>You learn something new everyday. I try to, if I can!</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Ryan Tomayko&apos;s Shotgun: A Forking Implementation of Rackup</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/04/ryan-tomaykos-shotgun-a-forking-implementation-of-rackup.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20837</id>

    <published>2010-04-24T15:34:43Z</published>
    <updated>2010-04-24T15:38:35Z</updated>

    <summary>Thanks to Nesta, I found out about Shotgun - a Ruby library used for running Rack applications and middleware. Its works good, but I prefer using Unicorn. I&apos;ll probably use it when I don&apos;t have access to Unicorn. Shotgun was...</summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Unicorn" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="middlware" label="middlware" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="rack" label="rack" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ruby" label="ruby" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="shotgun" label="shotgun" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="unicorn" label="unicorn" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>Thanks to Nesta, I found out about Shotgun - a Ruby library used for running Rack applications and middleware.</p>

<p>Its works good, but I prefer using Unicorn. I'll probably use it when I don't have access to Unicorn.</p>

<p>Shotgun was written and is maintained by Ryan Tomayko, who coincidentally wrote an article about Unicorn which is where I found out about it.</p>
]]>
        

    </content>
</entry>

<entry>
    <title>Testing Ruby Applications</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/04/testing-ruby-applications.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20836</id>

    <published>2010-04-24T10:58:42Z</published>
    <updated>2010-04-24T11:16:24Z</updated>

    <summary>I feel more empowered when using Ruby than almost any other tool I&apos;ve ever used. Besides how awesome that is unto itself, my experience using it thus far has inspired me to push beyond my comfort zone and work on...</summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Testing" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="rack" label="rack" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="rspec" label="rspec" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="selenium" label="selenium" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="watir" label="watir" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="webapplicationtesting" label="web application testing" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="webrat" label="webrat" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>I feel more empowered when using Ruby than almost any other tool I've ever used. Besides how awesome that is unto itself, my experience using it thus far has inspired me to push beyond my comfort zone and work on areas where my programming skills need improvement.</p>

<p>Testing is one of these areas that needs improvement. I've always respected the importance of testing software, but I was often so daunted by the scope of what can, in general, be done with software. Its often so flexible and configurable, I have a tough time balancing between non-exhaustive tests and tests which could become "big O" problems of their own.</p>

<p>Thankfully I'm starting to see some convergence between the scope of the tasks and the tools at my disposal. I'm starting to get comfortable with expansive, maybe even factorial style programming, where I'm instructing other instructions on how to create new instructions, and my work is increasingly focused on less complex applications.</p>

<p>More specifically, I'm using the <strong>Rack::Test::Methods</strong> mixin with <strong>RSpec</strong>, and that is making things nice and straightforward. I don't consider these "real world" tests because they lack the involvement of web browsers and thus cannot process javascript, but in my experience it is a solid testing platform.</p>

<p>I'd like to evolve to using <strong>Webrat</strong>, <strong>Watir</strong>, or <strong>Selenium</strong> or some combination of those at some point in the near future, but I just haven't had the time as of late.</p>

<p>Cucumber looks interesting, too, but its not for me. I prefer to develop more rapidly.</p>

<p>This is a helpful page:</p>

<ul>
<li><a href="http://www.sinatrarb.com/testing.html">http://www.sinatrarb.com/testing.html</a></li>
</ul>
]]>
        

    </content>
</entry>

<entry>
    <title>ArgumentError - XML object #0x14 not supported</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/04/argumenterror---xml-object-0x14-not-supported.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20830</id>

    <published>2010-04-23T06:19:27Z</published>
    <updated>2010-04-23T12:34:20Z</updated>

    <summary><![CDATA[I'm getting this odd error from Unicorn.... ArgumentError - XML object #0x14 not supported For whatever reason, I had set my XML content to be a symbol. Doh! xml = :'&lt;root />'...]]></summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Unicorn" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="errors" label="errors" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ruby" label="ruby" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="unicorn" label="unicorn" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>I'm getting this odd error from Unicorn....</p>

<pre class="sh_sh">
ArgumentError - XML object #0x14 not supported
</pre>

<p>For whatever reason, I had set my XML content to be a symbol. Doh!</p>

<pre class="sh_ruby">
xml = :'&lt;root />'
</pre>
]]>
        

    </content>
</entry>

<entry>
    <title>Pony 1.0 works with Ruby 1.9.1</title>
    <link rel="alternate" type="text/html" href="http://www.ruby.code-experiments.com/blog/2010/04/pony-10-works-with-ruby-191.html" />
    <id>tag:www.ruby.code-experiments.com,2010:/blog//267.20828</id>

    <published>2010-04-23T06:04:12Z</published>
    <updated>2010-04-23T06:05:36Z</updated>

    <summary>Thankfully the new maintainer of Pony, benprew, has upgraded it to use Mail instead of TMail. This means it works fine with Ruby 1.9.1! Kudos, benprew. Thanks!...</summary>
    <author>
        <name>Albert</name>
        
    </author>
    
        <category term="Ruby1.9" scheme="http://www.sixapart.com/ns/types#category" />
    
    <category term="email" label="email" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="pony" label="pony" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ruby" label="ruby" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="ruby19" label="ruby 1.9" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="tmail" label="tmail" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://www.ruby.code-experiments.com/blog/">
        <![CDATA[<p>Thankfully the new maintainer of <a href="http://github.com/benprew/pony">Pony, benprew</a>, has upgraded it to use Mail instead of TMail.</p>

<p>This means it works fine with Ruby 1.9.1!</p>

<p>Kudos, benprew. Thanks!</p>
]]>
        

    </content>
</entry>

</feed>
