RCAP - Common Alerting Protocl for Ruby

View: New views
2 Messages — Rating Filter:   Alert me  

RCAP - Common Alerting Protocl for Ruby

by Farrel Lifson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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   =>
'cape_town_disaster_relief@...',
                   :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:oasis:names:tc:emergency:cap:1.1'>
   <identifier>494207a7-f86b-4060-8318-a4b2a3ce565e</identifier>
   <sender>cape_town_disaster_relief@...</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
--
Aimred - Ruby Development and Consulting
http://www.aimred.com


Re: RCAP - Common Alerting Protocl for Ruby

by Farrel Lifson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Apologies for the bad code formatting. The RCAP project page -
http://www.aimred.com/projects/rcap - makes it look a lot better.

Farrel
--
Aimred - Ruby Development and Consulting
http://www.aimred.com