DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Ris2rss
A rather nasty hack to convert RIS files to RSS. Valid enough for my requirements.
require 'open-uri'
require 'rubygems'
require_gem 'builder', '~> 1.2.3'
@rf = {
'TY' => 'ris:type',
'ER' => 'ris:end',
'TI' => 'title',
'AU' => 'ris:author',
'KW' => 'ris:keywords',
'PY' => 'ris:primary-date',
'UR' => 'link',
'N1' => 'ris:notes',
'JO' => 'ris:periodical-abbreviation',
'VL' => 'ris:volume-number',
'IS' => 'ris:issue-number',
'SP' => 'ris:start-page-number',
'EP' => 'ris:end-page-number',
'SN' => 'ris:issn-isbn',
'M3' => 'ris:miscellaneous-3'
}
target_url = ARGV[0] || "http://www.connotea.org/ris/popular"
@out = Builder::XmlMarkup.new(:target => STDOUT, :indent=>2)
@target = open(target_url).read
@out.instruct!
@out.rss {
@out.channel {
@out.title ""
@out.link ""
@out.description ""
@target.split("\n\n").each {|arr|
@out.item {
h = {}
arr.split("\n").each {|line|
unpacked = line.unpack('A6A*')
h[unpacked[0][0..1].downcase] = unpacked[1]
@out.tag!(@rf[unpacked[0][0..1]] || "ris:#{unpacked[0][0..1]}"){ @out.text! unpacked[1] } # unless unpacked[0][0..1] == "ER"
}
}
}
}
}





