Aug 4 2008

Ruby at OSCON 2008

Here are the Ruby and Rails related technical talks given at the O’Reilly Open Source Convention 2008. A PDF of the presentation is availble for each talk, but no video at this time.

Technorati Tags: , , , , , , ,


Aug 3 2008

The Rubyist: July Edition

Here is a recap of the top Ruby-related links for the month of July 2008. Links for The Rubyist are provided by A Rubyist Railstastic Adventure, a tumblelog.

News and Opinion

Tutorials

iPhone and Mobile

JRuby

Technorati Tags: , , , , , , ,


Jul 7 2008

The Rubyist: June Edition

Here is a recap of the top Ruby-related links for the month of June. The month of June saw a lot of articles, interviews, and video from RailsConf 2008. The big excitement from RailsConf was news of MagLev, a ruby implementation built on top of a Smalltalk VM. Other big news items to in the Ruby sphere was several security concerns. Links for The Rubyist are provided by A Rubyist Railstastic Adventure, a tumblelog.

Scaling and Security

RailsConf and RubyConf

News and Announcements

Tools and Tutorials

Opinion

Jobs

Technorati Tags: , , , , , ,


Jun 1 2008

MagLev

The big hype and spin cycle out of RailsConf this year is the news of a new Ruby implementation, MagLev. MagLev is only the nth implementation of Ruby to make waves, after JRuby, Rubinius, and IronRuby. MagLev is based and powered by a SmallTalk VM from GemStone. Avi Bryant described as a ‘full stack Ruby implementation.’ Avi also said that MagLeve still does not run Rails and is not RubySpec compliant, but it will soon be. From the language in the news and articles available on MagLev, it seems that this implementation of Ruby will be positioned as a ‘enterprise-y’ implementation for large-scale deployment.

Technorati Tags: , , , , ,


May 19 2008

Using Hpricot

Hpricot is a HTML parser for the Ruby programming language. With Hpricot you can scan and scape a HTML document. To illustrate how to use Hpricot i’ll write a list the code of a short script I recently wrote. The script grabs all the links for the past week from A Rubyist Railstastic Adventure, a tumblelog.

The general structure of the HTML used by the web page that I will be scraping is something like the following.

[source:html]
<div class=”post”>
<div class=”date”>
Sun
<em>
May
<big>18</bi>
</em>
</div>

<div class=”link”>
<a href=”http://www.juixe.com” class=”link”>Juixe TechKnow</a>
</div>
</div>

[/source]

One thing to note about the HTML produced by the site we will scape is that the date is optional in the post. The date is only displayed once for a day, so some posts don’t have a given date. Also, there are several other types of posts such as quotes, images, etc. We are only interested in posts with links. Again, the Ruby/Hpricot script will only gather the links for the past week.

[source:ruby]
require ‘rubygems’
require ‘hpricot’
require ‘open-uri’
require ‘parsedate’

# Convert days to number to seconds
def days_to_sec(days)
secs = days.to_i
secs *= 24
secs *= 60
secs *= 60
secs
end

# pretty print the link in a list
def print_link(link)
print ” <li>”,
“<a href=’#{link.attributes[‘href’]}’>”,
“#{link.inner_html.strip}”,
“</a>”,
“</li>\n”
end

def get_links(doc)
curr_date = Time.new
(doc/”div.post”).each do |post|
post_date_elem = (post/”div.date/em”)
date = post_date_elem.inner_html.strip

# Parse the date of the post
if date != “”
date_day = (post_date_elem/”big”).text
date_mon = nil
date.each_line do |line|
date_mon = line.strip if date_mon.nil?
break if date_mon.nil?
end
date_str = “#{date_mon} #{date_day}, #{$week_ago.year}”
data = ParseDate.parsedate date_str
curr_date = Time.local data[0], data[1], data[2]
end

# Stop if already looking past one week
break if curr_date < $week_ago

# Handle all links in post
(post/”a.link”).each do |link|
print_link link
end
end

if curr_date > $week_ago
next_page = Hpricot(open($rubyist_next))
get_links next_page
end
end

# The Rubyist home page to be scraped
$rubyist_home = “http://rubyist.tumblr.com/”
$rubyist_next = “http://rubyist.tumblr.com/page/2”
# Scrape one weeks worth of links
$week_ago = Time.new – days_to_sec(7)

# Run the script
doc = Hpricot(open($rubyist_home))
get_links doc
[/source]

Technorati Tags: , , , ,


May 18 2008

This Week in Ruby

This week we saw news of Rails running on Rubinius and several news items regarding Passenger (mod_rails), in particular Dreamhost now has Passenger support. Links for This Week in Ruby are provided by A Rubyist Railstastic Adventure, a tumblelog.

Technorati Tags: , , , , , ,