Archive for the 'Ruby' Category

Some Notes about Problems I Had Updating Ruby Gems on Debian GNU/Linux

I kept on getting:

/usr/bin/gem:14: undefined method `ruby_version' ...

on a debian machine whenever I tried using gem. I ended up commenting out a few lines, then installing the latest version of rubygems-update from here with:

gem install rubygems-update-1.3.1.gem

Looks like it worked, but not for the real problem I was trying to solve. This was to try and solve this problem:

ActionView::TemplateError (undefined method `[]'

Which was solved thanks to these pages:
Re: [SOVED] AJAX error: ActionView::TemplateError (undefined method `[]’..
and
undefined method for enumerable

The actual fix was to put:

unless '1.9'.respond_to?(:force_encoding)
  String.class_eval do
    begin
      remove_method :chars
    rescue NameError
      # OK
    end
  end
end

at the beginning of config/environment.rb.

CSS Parsers

After briefly thinking about Javascript parsers, I did a quick search for CSS parsers, and found, as El Guapo might say, a plethora of piñatas.

Here’s a few which caught my attention:

I’m really intrigued that there are so many parsers written in Ruby.

Rails and Mongrel Dabbles




Just dabbling with Rails and Mongrel, its actually quite easy to get started:

apt-get install rails mongrel
mkdir rails_test
cd rails_test
rails .
mongrel_rails -p 9000 start

I’m still not sold on model view controller (MVC) methodology though.

Hpricot is an HTML Parser that uses Ragel and is Written in Ruby

After reading up on Ragel, I came across Hpricot, “a fast, flexible HTML parser written in C”. I read a little bit more, and it sounds like Hpricot is a mix of jQuery selectors, XPath, and DOM dot paths. Sounds very cool!

But just how fast is it? And can it be separated from Ruby? Should it be? The Hpricot Ragel stuff is here, and should contain a great set of ragel examples! And looks good, it appears that the ragel stuff has been completely separated from the ruby stuff, which makes it easier for me to examine.

I’m confused by the fact that there is java code in the repository. Hmmm.

More notes at the Hpricot Docunext Wikipage.