I’ve just sponsored the upload of libevolution-ruby (Ruby Evolution Data Server bindings) a few moments ago, maintained by David Moreno Garza. It is really a small nice thing with some potential. I’ve just written this script email_of to perform a regex search in my contacts and print them in a “email-style” manner:

#!/usr/bin/env ruby

require 'revolution'

# Add functionality to the Contact class for 
# displaying using an "email-style" format.
class Revolution::Contact
  def name_and_email
    email_addresses.values.flatten.map { |email|
      "%s %s <%s>" % [first_name, last_name, email]
    }.join("\n")
  end
end

# Get the pattern from the command-line (if any).
if ARGV.length == 1
  pattern = Regexp.new(ARGV.first)
else
  $stderr.puts "Usage: #{$PROGRAM_NAME} <pattern>"
  exit 1
end

# Find the contacts matching the pattern.
evo = Revolution::Revolution.new
found = evo.get_all_contacts.find_all do |contact|
          pattern.match(contact.first_name) or 
          pattern.match(contact.last_name)
        end

puts found.map { |c| c.name_and_email }.join("\n")

Easy does it!

GUADEC

Bram Senders and I are arranging for Spacelabs trip to go to GUADEC this year. For us the entrance fee was a surprise as well, but enough about that. We hope to get it all settled soon, so we can just sit and wait for it to become May 26. Right :)



Published

Category

Tags