Converting from REXML to Nokogiri

Eric Hodel | Thu, 18 Jun 2009 01:02:02 GMT

Nokogiri is pretty darn cool, certainly far cooler than REXML. I switched UPnP to Nokogiri, and here’s a handy guide.

require 'rexml/document'

Becomes

require 'nokogiri'
REXML::Document.new

Becomes

Nokogiri::XML

Both accept String or IO objects

my_element.element['element/path']

Becomes

my_element.at 'element > path'

You can use CSS in #at

my_element.each_element 'element/path' do |sub_element|

Becomes

my_element.xpath('./xmlns:element/xmlns:path').each do |sub_element|

”.” is used to select sub-elements of this one

See also Nokogiri’s Node documentation.

Posted in ,  | no comments

UPnP 1.2.0

Eric Hodel | Wed, 17 Jun 2009 00:06:07 GMT

An implementation of the UPnP protocol

Changes

  • 2 minor enhancements
    • Workaround for missing socket constants on Windows. Reported by Yuri.
    • upnp_discover now shows action argument and return value names.
  • 4 bug fixes
    • Method name must not include entire URI. Reported by Ian Macdonald.
    • Step in allowedValueRange is optional. Reported by Ian Macdonald.
    • upnp_listen works with all notification types. Reported by Ian Macdonald.
    • upnp_discover now warns when a device failed to instantiate. Reported by Ian Macdonald.

Posted in ,  | no comments

RubyGems 1.3.4

Eric Hodel | Sat, 30 May 2009 14:20:00 GMT

NOTE: RubyGems 1.1 and 1.2 have problems upgrading when there is no rubygems-update installed. You will need to follow the second set of update instructions if you see “Nothing to update”.

Release 1.3.4 fixes some bugs and adds some features.

Bug Fixes:

  • Fixed various warnings
  • Gem::ruby_version works correctly for 1.8 branch and trunk
  • Prerelease gems now show up in `gem list` and can be used
  • Fixed option name for `gem setup --format-executable`
  • RubyGems now matches Ruby > 1.9.1 gem paths
  • Gem::RemoteFetcher#download now works for explicit Windows paths across drives. Bug #25882 by Lars Christensen
  • Fix typo in Gem::Requirement#parse. Bug #26000 by Mike Gunderloy.

Deprecation Notices:

  • Bulk index update is no longer supported (the code currently remains, but not the tests)
  • Gem::manage_gems was removed in 1.3.3.
  • Time::today was removed in 1.3.3.

For a full list of changes to RubyGems and the contributor for each change, see the ChangeLog file.

How can I get RubyGems?

NOTE: If you have installed RubyGems using a package system you may want to install a new RubyGems through the same packaging system.

If you have a recent version of RubyGems (0.8.5 or later), then all you need to do is:

  $ gem update --system   (you might need to be admin/root)

NOTE: RubyGems 1.1 and 1.2 have problems upgrading when there is no rubygems-update installed. You will need to follow the second set of update instructions if you see “Nothing to update”.

NOTE: You may have to run the command twice if you have any previosly installed rubygems-update gems.

If you have an older version of RubyGems installed, then you can still do it in two steps:

  $ gem install rubygems-update  (again, might need to be admin/root)
  $ update_rubygems              (... here too)

If you don’t have any gems install, there is still the pre-gem approach to getting software … doing it manually:

  1. DOWNLOAD FROM: rubyforge.org/frs/?group_id=126
  2. UNPACK INTO A DIRECTORY AND CD THERE
  3. INSTALL WITH: ruby setup.rb (you may need admin/root privilege)

To File Bugs

The RubyGems bug tracker can be found on RubyForge at: rubyforge.org/tracker/?func=add&group_id=126&atid=575

When filing a bug, `gem env` output will be helpful in diagnosing the issue.

If you find a bug where RubyGems crashes, please provide debug output. You can do that with `gem —debug the_command`.

Thanks

Keep those gems coming!

— The RubyGems team

Posted in ,  | no comments

A Project Naming Recommendation

Eric Hodel | Wed, 20 May 2009 23:08:02 GMT

I’ve gone through many different styles of project names, but I think I’ve finally found a naming scheme I like.

In the past, I’ve used class names with uppercase letters, dashed names and underscored names, and I think the underscores are the best for projects I’m packaging in ruby.

Rails solidified the convention of mapping CamelCase class names to underscored file names (class IMAPProcesor is defined in imap_processor.rb). Using underscored gem names makes it easy for people to figure out what file to require (same as the project name) or what class name to look for in ri.

If I have a plugin gem or an extension I’ll tack on the sub-project’s name with a dash. If I wanted to add a new handler for imap_to_rss for Chase bank email, the gem would be named imap_to_rss-chase.

This makes it easy to find in gem list -p and it conveniently namespaces the extension. It also would look nice with gems from github which break up author and project with a dash (drbrain-imap_to_rss-chase, if I used github). As an added bonus, when double-clicking any underscored part OS X only highlights a part of the name making cut-and-paste a little more convenient for picking apart gem names.

Currently almost 95% of gem names start with lowercase letters, 6% contain uppercase letters anywhere in the name, a little over 20% use dashes, 16% use underscore. Sixteen use both underscores and dashes (my favorite name being what_does_this_error_mean-merb).

Posted in ,  | 2 comments

orca_card 1.0

Eric Hodel | Tue, 19 May 2009 18:54:33 GMT

orca_card version 1.0 has been released!

Dumps information about your ORCA card. ORCA cards are Western Washington’s all-in-one transit smart card that allow travel via bus, train and ferry throughout King, Kitsap, Snohomish and Pierce counties.

NOTE: This is a cheap hack, patches wanted

Posted in ,  | no comments

imap_processor 1.1

Eric Hodel | Mon, 18 May 2009 22:56:00 GMT

imap_processor version 1.1 has been released!

IMAPProcessor is a client for processing messages on an IMAP server. It provides some basic mechanisms for connecting to an IMAP server, determining capabilities and handling messages.

IMAPProcessor ships with the imap_keywords executable which can query an IMAP server for keywords set on messages in mailboxes.

Changes:

  • 1 minor enhancement
    • IMAPProcessor#each_message allows messages to be omitted from the returned uid list (skipped)

Posted in ,  | no comments

imap_to_rss 1.0

Eric Hodel | Fri, 15 May 2009 18:17:00 GMT

imap_to_rss version 1.0 has been released!

IMAPToRSS turns messages on an IMAP server into RSS entries when the match a handler. Included handlers work for email from Amazon, HSBC and UPS. IMAPToRSS automatically loads handlers for any other mail.

Posted in ,  | no comments

imap_processor 1.0

Eric Hodel | Wed, 13 May 2009 03:14:00 GMT

imap_processor version 1.0 has been released!

IMAPProcessor is a client for processing messages on an IMAP server. It provides some basic mechanisms for connecting to an IMAP server, determining capabilities and handling messages.

IMAPProcessor ships with the imap_keywords executable which can query an IMAP server for keywords set on messages in mailboxes.

Posted in  | 2 comments

Fat binary gems

Eric Hodel | Tue, 12 May 2009 23:10:58 GMT

Right now people who publish native gems targeting the windows platform have a problem. Our problem is supporting ruby 1.8 and 1.9 at the same time. Right now, we can’t build one gem targeting 1.8 and one gem targeting 1.9, and have rubygems differentiate the two. I have a solution: fat binary gems. We can build a gem that contains dynamic libraries that target ruby 1.8 and ruby 1.9 on windows, with no changes to rubygems whatsoever. I’ve put together a proof of concept that I want to share. I will walk through the steps for building a fat binary gem with the tools we have today. The steps I am going to present are not necessarily the best steps, they are just the steps I took to get this idea working.

Fat binary gems make the rockin’ world go round via Tender Love Making

Posted in ,  | no comments

Mail Hosting

Eric Hodel | Sat, 09 May 2009 04:28:43 GMT

I host my own mail using the following software:

OpenBSD’s spamd sits in front of Postfix and greylists and blacklists for me (it runs on all my MXs to prevent spammers from sneaking around). spamd runs via a firewall rule that redirects unknown connections to the spamd daemon during the greylist period then later whitelists them for direct connection to Postfix. I’ve also added a few spam-collecting addresses to the spamtrap list to help with automatic blacklisting.

Postfix directs email through amavisd for spam control which allows me to bounce spam (from amavisd’s Postfix README). I have amavisd configured to use Postgresql to enable its pen pals feature which lowers spam scores for frequent correspondents (from amavisd’s SQL README and Postgresql README).

Postfix hands mail off to procmail via my .forward file (not mailbox_command) which is just "|/usr/local/bin/procmail -tf-". (It seems that other values you see around, like setting IFS, are to work around bugs in ancient versions of sendmail.)

In procmail, I use dovecot’s deliver to keep its indexes updated. A sample from my .procmailrc:

DELIVER = /usr/local/libexec/dovecot/deliver

# ...

:0 w
* List-Id:.*<rubygems-developers.rubyforge.org>
| ${DELIVER} -m Lists/Ruby/Rubygems

# ...

# last rule, delivers to INBOX
:0 w
| ${DELIVER}

My outbound mail goes through the submission port using dovecot for SASL authentication and gets filtered by amavisd for the pen pals feature and DKIM signing (set up per amavisd’s DKIM documentation).

I’ve set up DKIM and SPF records for my domain in order to be a good internet citizen. You can get an SPF record pretty quick from the SPF record wizard. I have SpamAssassin using DKIM verification for improved filtering.

To ensure delivery of my mail, one of my backup MXs is at my home for connection redundancy and the second is Ryan Davis’ primary MX (we have mutual backups). A backup MXs out of my control prevents me from losing mail by screwing up both machines under my control.

My IMAP clients include Apple’s Mail for day-to-day mail reading, IMAPCleanse for cleaning out my lists and flagging threads I should follow up on. Soon I’ll be adding an IMAP to RSS tool for mail with lots of unimportant stuff (like Amazon, bank transfers, etc.).

Posted in ,  | no comments

Older posts: 1 2 3 4 5 ... 25