Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
# Kuler, daily # Parse daily colour from .adobe.com # Author: Ben Schwarz # Thanks: Marcus Crafter, Regex fun # No thanks: Adobe for wack RSS # Usage: # Kuler::rating => Most recent rated kuler # Kuler::recent => Most recent kuler # Kuler::popular => Most recent popular kuler %w(rubygems hpricot open-uri).each{|r| require r} module Kuler def rating query(:rating) end def recent query(:recent) end def popular query(:popular) end def query(q) uri = "http://kuler.adobe.com/kuler/API/rss/get.cfm?listtype=#{q.to_s}&readerType=public" hp = Hpricot.parse open(uri) string = (hp/:item/:description).first.to_s if string =~ /Hex:(.*)<\/description\>/m $1.strip.split(', ') end end end
From the Design Piracy series on my blog: