Skip to content

Instantly share code, notes, and snippets.

@kellyrob99
Created June 17, 2012 19:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kellyrob99/2945511 to your computer and use it in GitHub Desktop.
Save kellyrob99/2945511 to your computer and use it in GitHub Desktop.
Reads RSS feeds from Adobe kuler site and extracts the hexadecimal representation of each five element theme, writing those values to a file.
/**
* Reads RSS feeds from kuler and extracts the hexadecimal representation of each five element theme, writing those
* values to a file.
*/
def feeds = [
new URL("http://kuler-api.adobe.com/feeds/rss/get.cfm?itemsPerPage=100&listType=rating"),
new URL("http://kuler-api.adobe.com/feeds/rss/get.cfm?itemsPerPage=100&listType=popular")
]
def mappedThemes = [:]
def slurp = {rssXML, themes ->
def xml = new XmlSlurper().parseText(rssXML)
xml.channel.item.each { theme ->
println theme.title
def desc = theme.description.toString().split('\n')
def hex = desc[-1]
hex = hex.replaceAll('\t', '')
hex = hex.replaceAll(' ', '')
themes.put(theme.title.toString().replaceAll('Theme Title:', '').trim().replaceAll(' ', '_').replaceAll('\'',
'_').toLowerCase(), hex.split(','))
}
}
feeds.each { URL url ->
slurp(url.text, mappedThemes)
}
println mappedThemes.keySet().size()
def themeMapFile = new File("kulerThemeMap-${new Date().format('yyMMddHHmmss')}.groovy")
themeMapFile << "themeMap = ${mappedThemes.inspect()}"
themeMapFile.absolutePath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment