A rather nasty hack to convert RIS files to RSS. Valid enough for my requirements.
1
2 require 'open-uri'
3 require 'rubygems'
4 require_gem 'builder', '~> 1.2.3'
5
6 @rf = {
7 'TY' => 'ris:type',
8 'ER' => 'ris:end',
9 'TI' => 'title',
10 'AU' => 'ris:author',
11 'KW' => 'ris:keywords',
12 'PY' => 'ris:primary-date',
13 'UR' => 'link',
14 'N1' => 'ris:notes',
15 'JO' => 'ris:periodical-abbreviation',
16 'VL' => 'ris:volume-number',
17 'IS' => 'ris:issue-number',
18 'SP' => 'ris:start-page-number',
19 'EP' => 'ris:end-page-number',
20 'SN' => 'ris:issn-isbn',
21 'M3' => 'ris:miscellaneous-3'
22 }
23
24 target_url = ARGV[0] || "http://www.connotea.org/ris/popular"
25 @out = Builder::XmlMarkup.new(:target => STDOUT, :indent=>2)
26 @target = open(target_url).read
27 @out.instruct!
28 @out.rss {
29 @out.channel {
30 @out.title ""
31 @out.link ""
32 @out.description ""
33 @target.split("\n\n").each {|arr|
34 @out.item {
35 h = {}
36 arr.split("\n").each {|line|
37 unpacked = line.unpack('A6A*')
38 h[unpacked[0][0..1].downcase] = unpacked[1]
39 @out.tag!(@rf[unpacked[0][0..1]] || "ris:#{unpacked[0][0..1]}"){ @out.text! unpacked[1] }
40 }
41 }
42 }
43 }
44 }