Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Ris2rss

DZone's Guide to

Ris2rss

·
Free Resource
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"
   			}
   		}
	}
}
}
Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}