The Common Alerting Protocol is a lightweight standard to facilitate the distribution of alerting data. 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 CAP 1.0, 1.1 and 1.2.
RCAP is distributed as a Ruby gem and is available from Rubygems.org.
gem install rcap
The gem is also available for download and manual installtion at http://www.aimred.com/gems.
require 'rcap' include RCAP::CAP_1_2 # Include CAP 1.2 module into namespace # Alert creation alert = Alert.new( sent: DateTime.now, sender: 'cape_town_disaster_relief@capetown.municipal.za', status: Alert::STATUS_ACTUAL, msg_type: Alert::MSG_TYPE_ALERT, scope: Alert::SCOPE_PUBLIC ) alert.add_info( 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.' ) alert.infos.first.add_area( area_desc: 'N2 Highway/R300 Interchange' ).add_geocode( name: 'Intersection', value: 'N2-15' ) # Validation if alert.valid? puts "Alert is valid" # "Alert is valid" end # Accessing attributes puts alert.status # "Actual" info = alert.infos.first puts info.language # "en-ZA" puts info.categories.join( ', ' ) # "Transport, Fire" puts info.areas.first # "N2 Highway/R300 Interchange" # Exporting to various formats puts alert.to_xml puts alert.to_json puts alert.to_yaml
For more documentaion please refer to the full RCAP API documentation.
RCAP is distributed under the BSD License
Copyright 2010 – 2011 AIMRED CC. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY AIMRED CC ``AS IS’’ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AIMRED CC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted as representing official policies, either expressed or implied, of AIMRED CC.