RCAP - Common Alerting Protocl for Ruby

F

Farrel Lifson

OVERVIEW

RCAP is an implementation of the CAP in Ruby. It allows for the
creation of RCAP messages from Ruby applications and the parsing of
external messages.

RCAP currently supports only CAP Version 1.1.

RCAP is released under the BSD License.

INSTALLATION

RCAP is distributed as a Ruby gem and is available from Gemcutter. If
you have Gemcutter set as a source of your gems then RCAP can be
installed from the command line

$ gem install rcap

The gem is also available for download and manual installtion at
www.aimred.com/gems .

WEB RESOURCES

* The RCAP project page can be found at www.aimred.com/projects/rcap
* The RCAP API docs can be fount at www.aimred.com/projects/rcap/api

USAGE

alert = Alert.new( :sender =>
'(e-mail address removed)',
:status => Alert::STATUS_ACTUAL,
:msg_type => Alert::MSG_TYPE_ALERT,
:scope => Alert::SCOPE_PUBLIC,
:infos => Info.new( :event => 'Liquid
Petroleoum Tanker Fire',
:language => 'en-ZA',
:categories => [
Info::CATEGORY_TRANSPORT, Info::CATEGORY_FIRE ],
:urgency =>
Info::URGENCY_IMMEDIATE,
:severity => Info::SEVERITY_SEVERE,
:certainty =>
Info::CERTAINTY_OBSERVED,
:headline => 'LIQUID
PETROLEOUM TANKER FIRE ON N2 INCOMING FREEWAY',
:description => 'A liquid
petroleoum tanker has caught fire on the N2 incoming freeway 1km
after the
R300 interchange. Municipal fire fighting crews have been dispatched.
Traffic
control officers are on the scene and have diverted traffic onto
alternate routes.' ))

# Accessing attributes
puts alert.status # Print out "Actual"
puts alert.infos[0].language # Print out "en-ZA"
puts alert.infos[0].categories.join( ' ' ) # Print out "Transport Fire"

puts alert.to_xml # Print out CAP XML message

will produce the following CAP XML Message

<?xml version='1.0'?>
<alert xmlns='urn:eek:asis:names:tc:emergency:cap:1.1'>
<identifier>494207a7-f86b-4060-8318-a4b2a3ce565e</identifier>
<sender>[email protected]</sender>
<sent>2009-10-26T21:04:51+02:00</sent>
<status>Actual</status>
<msgType>Alert</msgType>
<scope>Public</scope>
<info>
<language>en-ZA</language>
<category>Transport</category>
<category>Fire</category>
<event>Liquid Petroleoum Tanker Fire</event>
<urgency>Immediate</urgency>
<severity>Severe</severity>
<certainty>Observed</certainty>
<headline>LIQUID PETROLEOUM TANKER FIRE ON N2 INCOMING FREEWAY</headline>
<description>
A liquid petroleoum tanker has caught fire on the N2 incoming freeway 1km
after the R300 interchange. Municipal fire fighting crews have been
dispatched. Traffic control officers are on the scene and have diverted
traffic onto alternate routes.
</description>
</info>
</alert>

Farrel Lifson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top