Redcloth 4.0 released: 40 times faster!

written July 21 2008 by
{ Kommen }
Comments 0

Redcloth 4.0: was just released and according to Jason Garber it is 40 times faster than the previous version.

Sounds like a huge speed up for textilize and co. I guess it will be shortly available through the rubyforge gem severs.

RubyGems 1.2.0 released: Big Time Saver

written June 22 2008 by
{ Kommen }
Comments 0

RubyGems 1.2.0 was released yesterday and the announcement starts like this:


RubyGems no longer performs bulk updates and instead only fetches the gemspec
files it needs.

Finally! This should save me quite a lot of time, since I have gems.github.com as a gem source and it often had to update 300+ gemspec files.

Parse natural language date/time strings in Ruby with Chronic

written September 14 2006 by
{ Kommen }
Comments 1

Yesterday, while fighting against spam on the Ruby on Rails wiki, I came over a nice gem: Chronic

With Chronic you can easily parse natural language date and time formats into a DateTime object. You don’t have to mess around with regex to parse things manually. As gem, it’s easy to install and it’s also very handy to use.

Install it

$ gem install chronic
Thats it.

Use it

Put this in your model or controller file:


require 'chronic'


Then you can use Chronic.parse in your methods. E.g. Chronic.parse('tomorrow'),
Chronic.parse('monday', :context => :past), Chronic.parse('this tuesday 5:00')

Or more complex: Chronic.parse('3rd thursday this september'), Chronic.parse('3 months ago saturday at 5:00 pm')

And of course it can do a lot more! For a complete reference and more examples see chronic.rubyforge.org

Validate with it

 1 You can also use Chronic to validate malformed date strings:
 2 
 3 class Meeting < ActiveRecord::Base
 4 
 5   def validation
 6     errors.add :meeting_date, 'is not a valid date' if Chronic.parse(meeting_date.to_s).nil?
 7   end
 8 
 9 end

Ressources (Sites I’ve looked at and borrowed the code snippets) for writing this article

You've reached the end of this page. Feel free to dig into the archives of this blog or subscribe to our newsfeed.