rcap 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. data/{CHANGELOG.rdoc → CHANGELOG.md} +26 -20
  2. data/README.md +259 -0
  3. data/Rakefile +8 -7
  4. data/lib/extensions/array.rb +7 -1
  5. data/lib/extensions/date_time.rb +5 -1
  6. data/lib/extensions/string.rb +14 -1
  7. data/lib/extensions/time.rb +5 -1
  8. data/lib/rcap.rb +1 -1
  9. data/lib/rcap/alert.rb +24 -10
  10. data/lib/rcap/cap_1_0/alert.rb +232 -166
  11. data/lib/rcap/cap_1_0/area.rb +100 -67
  12. data/lib/rcap/cap_1_0/circle.rb +47 -22
  13. data/lib/rcap/cap_1_0/event_code.rb +3 -2
  14. data/lib/rcap/cap_1_0/geocode.rb +3 -2
  15. data/lib/rcap/cap_1_0/info.rb +265 -202
  16. data/lib/rcap/cap_1_0/parameter.rb +43 -20
  17. data/lib/rcap/cap_1_0/point.rb +23 -9
  18. data/lib/rcap/cap_1_0/polygon.rb +37 -19
  19. data/lib/rcap/cap_1_0/resource.rb +77 -55
  20. data/lib/rcap/cap_1_1/alert.rb +222 -156
  21. data/lib/rcap/cap_1_1/area.rb +100 -67
  22. data/lib/rcap/cap_1_1/circle.rb +49 -22
  23. data/lib/rcap/cap_1_1/event_code.rb +3 -2
  24. data/lib/rcap/cap_1_1/geocode.rb +3 -2
  25. data/lib/rcap/cap_1_1/info.rb +281 -217
  26. data/lib/rcap/cap_1_1/parameter.rb +35 -16
  27. data/lib/rcap/cap_1_1/point.rb +23 -9
  28. data/lib/rcap/cap_1_1/polygon.rb +38 -20
  29. data/lib/rcap/cap_1_1/resource.rb +106 -65
  30. data/lib/rcap/cap_1_2/alert.rb +224 -158
  31. data/lib/rcap/cap_1_2/area.rb +100 -67
  32. data/lib/rcap/cap_1_2/circle.rb +49 -24
  33. data/lib/rcap/cap_1_2/event_code.rb +3 -2
  34. data/lib/rcap/cap_1_2/geocode.rb +3 -2
  35. data/lib/rcap/cap_1_2/info.rb +285 -219
  36. data/lib/rcap/cap_1_2/parameter.rb +39 -19
  37. data/lib/rcap/cap_1_2/point.rb +23 -9
  38. data/lib/rcap/cap_1_2/polygon.rb +37 -20
  39. data/lib/rcap/cap_1_2/resource.rb +107 -67
  40. data/lib/rcap/config.rb +4 -0
  41. data/lib/rcap/utilities.rb +55 -2
  42. data/lib/rcap/validations.rb +2 -2
  43. data/lib/rcap/version.rb +1 -1
  44. data/rcap.gemspec +2 -2
  45. data/spec/cap_1_0/parameter_spec.rb +5 -1
  46. data/spec/cap_1_1/resource_spec.rb +6 -0
  47. data/spec/cap_1_2/alert_spec.rb +8 -0
  48. data/spec/cap_1_2/resource_spec.rb +8 -2
  49. metadata +11 -10
  50. data/README.rdoc +0 -247
  51. data/lib/config.rb +0 -2
@@ -0,0 +1,4 @@
1
+ module RCAP
2
+ XML_PRETTY_PRINTER = REXML::Formatters::Pretty.new( 2 )
3
+ XML_PRETTY_PRINTER.compact = true
4
+ end
@@ -1,23 +1,61 @@
1
- ALLOWED_CHARACTERS = /[^\s&<]+/ # :nodoc:
1
+ ALLOWED_CHARACTERS = /[^\s&<]+/
2
2
 
3
- module RCAP # :nodoc:
3
+ module RCAP
4
+ # Returns a randomly generated UUID string
5
+ #
6
+ # @return [String] UUID string
4
7
  def self.generate_identifier
5
8
  UUIDTools::UUID.random_create.to_s
6
9
  end
7
10
 
11
+ # Returns the text of the first descendent that matches the given XPath
12
+ # expression.
13
+ #
14
+ # @param [REXML::Element] xml_element Element to start matching from.
15
+ # @param [String] xpath XPath expression
16
+ # @param [String] namepsace Namespace in which to do the matching
17
+ # @return [String,nil] Text content of element matching XPath query or nil
8
18
  def self.xpath_text( xml_element, xpath, namespace )
9
19
  element = self.xpath_first( xml_element, xpath, namespace )
10
20
  element.text if element
11
21
  end
12
22
 
23
+ # Returns first descendent that matches the given XPath expression.
24
+ #
25
+ # @param [REXML::Element] xml_element Element to start matching from.
26
+ # @param [String] xpath XPath expression
27
+ # @param [String] namepsace Namespace in which to do the matching
28
+ # @return [REXML::Element,nil] Element matching XPath query or nil
13
29
  def self.xpath_first( xml_element, xpath, namespace )
14
30
  REXML::XPath.first( xml_element, xpath, { 'cap' => namespace })
15
31
  end
16
32
 
33
+ # Returns all descendents that match the given XPath expression.
34
+ #
35
+ # @param [REXML::Element] xml_element Element to start matching from.
36
+ # @param [String] xpath XPath expression
37
+ # @param [String] namepsace Namespace in which to do the matching
38
+ # @return [Array<REXML::Element>] Collection of elements matching XPath query
17
39
  def self.xpath_match( xml_element, xpath, namespace )
18
40
  REXML::XPath.match( xml_element, xpath, { 'cap' => namespace })
19
41
  end
20
42
 
43
+ # Formats output for inspect
44
+ #
45
+ # @param [String] header Output header
46
+ # @param [String] inspect_string String to be output
47
+ # @return [String] Formatted output for inspect
48
+ #
49
+ # @example
50
+ # RCAP.format_lines_for_inspect( 'Test', 'one\ntwo\nthree' )
51
+ # # returns
52
+ # # .-------.
53
+ # # | Test |
54
+ # # |-------|
55
+ # # | one |
56
+ # # | two |
57
+ # # | three |
58
+ # # '-------'
21
59
  def self.format_lines_for_inspect( header, inspect_string )
22
60
  max_line_length = inspect_string.lines.map{ |line| line.chomp.length }.max
23
61
  "\n." + '-' * (max_line_length + 2) + ".\n"+
@@ -27,10 +65,21 @@ module RCAP # :nodoc:
27
65
  "'" + '-' * ( max_line_length + 2 ) + "'\n"
28
66
  end
29
67
 
68
+ # Converts an array of key value pairs into a hash, excluding any value that is nil or empty
69
+ #
70
+ # @param [Array<Array(Object,Object)>] attribte_values An array of arrays of key/value pairs
71
+ # @return [Hash] Hash of attributes
72
+ #
73
+ # @example
74
+ # RCAP.attribute_values_to_hash( ['a', 1], ['b' , []]) # => { 'a' => 1 }
30
75
  def self.attribute_values_to_hash( *attribute_values )
31
76
  Hash[ *attribute_values.reject{ |key, value| value.nil? || ( value.respond_to?( :'empty?' ) && value.empty? )}.flatten( 1 )]
32
77
  end
33
78
 
79
+ # Calls #to_s_for_cap on the object it it responds to that otherwise just calls #to_s
80
+ #
81
+ # @param [#to_s, #to_s_for_cap]
82
+ # @return [String]
34
83
  def self.to_s_for_cap( object )
35
84
  if object
36
85
  if object.respond_to?( :to_s_for_cap )
@@ -41,6 +90,10 @@ module RCAP # :nodoc:
41
90
  end
42
91
  end
43
92
 
93
+ # If the parameter is a string the datetime is parsed out of it, otherwise returns nil.
94
+ #
95
+ # @param [String] date_string String to parse
96
+ # @return [String,nil]
44
97
  def self.parse_datetime( date_string )
45
98
  if date_string.is_a?( String )
46
99
  DateTime.parse( date_string )
@@ -1,5 +1,5 @@
1
- module Validation # :nodoc:
2
- module ClassMethods # :nodoc:
1
+ module Validation
2
+ module ClassMethods
3
3
 
4
4
  CAP_NUMBER_REGEX = Regexp.new( '^-{0,1}\d*\.{0,1}\d+$' )
5
5
  CAP_INTEGER_REGEX = Regexp.new( '\-{0,1}A[+-]?\d+\Z' )
data/lib/rcap/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RCAP
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
data/rcap.gemspec CHANGED
@@ -19,12 +19,12 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ['lib']
21
21
 
22
- s.extra_rdoc_files = ['README.rdoc','CHANGELOG.rdoc']
22
+ s.extra_rdoc_files = ['README.md','CHANGELOG.md']
23
23
  s.add_dependency('assistance', '>= 0.1.5')
24
24
  s.add_dependency('json', '>= 1.5.1')
25
25
  s.add_dependency('uuidtools', '>= 2.1.2')
26
26
 
27
27
  s.add_development_dependency( 'rspec', '>= 2.5.0' )
28
- s.add_development_dependency( 'rdoc' )
28
+ s.add_development_dependency( 'yard' )
29
29
  s.add_development_dependency( 'webmock' )
30
30
  end
@@ -40,9 +40,13 @@ describe( RCAP::CAP_1_0::Parameter ) do
40
40
  end
41
41
 
42
42
  describe( '.parse_parameter' ) do
43
- it( 'should parse the content correctly' ) do
43
+ it( 'should parse valid content correctly' ) do
44
44
  RCAP::CAP_1_0::Parameter.parse_parameter( "name=value" ).should == { :name => 'name', :value => 'value' }
45
45
  end
46
+
47
+ it( 'should parse invalid content correctly' ) do
48
+ RCAP::CAP_1_0::Parameter.parse_parameter( 'name' ).should == nil
49
+ end
46
50
  end
47
51
 
48
52
  describe( '.to_xml_element' ) do
@@ -199,5 +199,11 @@ describe( RCAP::CAP_1_1::Resource ) do
199
199
  lambda{ @resource.calculate_hash_and_size }.should( change( @resource, :size ).to( @encoded_content.bytesize ))
200
200
  end
201
201
  end
202
+
203
+ describe( '#decoded_deref_uri' ) do
204
+ it( 'should return the original content' ) do
205
+ @resource.decoded_deref_uri.should == @content
206
+ end
207
+ end
202
208
  end
203
209
  end
@@ -229,5 +229,13 @@ describe( RCAP::CAP_1_2::Alert ) do
229
229
  @alert.infos.size.should == 1
230
230
  end
231
231
  end
232
+
233
+ describe( '#to_xml' ) do
234
+ context( 'with pretty_print = true' ) do
235
+ it( 'should not raise an exception' ) do
236
+ lambda{ @alert.to_xml( true ) }.should_not( raise_exception )
237
+ end
238
+ end
239
+ end
232
240
  end
233
241
  end
@@ -173,7 +173,7 @@ describe( RCAP::CAP_1_2::Resource ) do
173
173
  stub_request( :get, @resource.uri ).to_return( :status => 200, :body => @content )
174
174
  end
175
175
 
176
- describe( '#dereference_uri!' ) do
176
+ describe( 'calling dereference_uri!' ) do
177
177
  it( 'should fetch the content and store it in deref_uri as Base64 encoded content' ) do
178
178
  lambda{ @resource.dereference_uri! }.should( change( @resource, :deref_uri ).to( @encoded_content ))
179
179
  end
@@ -192,7 +192,7 @@ describe( RCAP::CAP_1_2::Resource ) do
192
192
  before( :each ) do
193
193
  @content = "1,2\n3,4"
194
194
  @encoded_content = Base64.encode64( @content )
195
- @resource = RCAP::CAP_1_1::Resource.new( :resource_desc => 'Resource Description', :mime_type => 'text/csv', :uri => 'http://tempuri.org/resource.csv', :deref_uri => @encoded_content )
195
+ @resource = RCAP::CAP_1_2::Resource.new( :resource_desc => 'Resource Description', :mime_type => 'text/csv', :uri => 'http://tempuri.org/resource.csv', :deref_uri => @encoded_content )
196
196
  end
197
197
 
198
198
  describe( '#calculate_hash_and_size' ) do
@@ -204,5 +204,11 @@ describe( RCAP::CAP_1_2::Resource ) do
204
204
  lambda{ @resource.calculate_hash_and_size }.should( change( @resource, :size ).to( @encoded_content.bytesize ))
205
205
  end
206
206
  end
207
+
208
+ describe( '#decoded_deref_uri' ) do
209
+ it( 'should return the original content' ) do
210
+ @resource.decoded_deref_uri.should == @content
211
+ end
212
+ end
207
213
  end
208
214
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcap
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 0
10
- version: 1.3.0
9
+ - 1
10
+ version: 1.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Farrel Lifson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-15 00:00:00 Z
18
+ date: 2012-02-26 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: assistance
@@ -82,7 +82,7 @@ dependencies:
82
82
  type: :development
83
83
  version_requirements: *id004
84
84
  - !ruby/object:Gem::Dependency
85
- name: rdoc
85
+ name: yard
86
86
  prerelease: false
87
87
  requirement: &id005 !ruby/object:Gem::Requirement
88
88
  none: false
@@ -117,15 +117,14 @@ executables: []
117
117
  extensions: []
118
118
 
119
119
  extra_rdoc_files:
120
- - README.rdoc
121
- - CHANGELOG.rdoc
120
+ - README.md
121
+ - CHANGELOG.md
122
122
  files:
123
123
  - .gitignore
124
- - CHANGELOG.rdoc
124
+ - CHANGELOG.md
125
125
  - Gemfile
126
- - README.rdoc
126
+ - README.md
127
127
  - Rakefile
128
- - lib/config.rb
129
128
  - lib/extensions/array.rb
130
129
  - lib/extensions/date_time.rb
131
130
  - lib/extensions/string.rb
@@ -162,6 +161,7 @@ files:
162
161
  - lib/rcap/cap_1_2/point.rb
163
162
  - lib/rcap/cap_1_2/polygon.rb
164
163
  - lib/rcap/cap_1_2/resource.rb
164
+ - lib/rcap/config.rb
165
165
  - lib/rcap/utilities.rb
166
166
  - lib/rcap/validations.rb
167
167
  - lib/rcap/version.rb
@@ -296,3 +296,4 @@ test_files:
296
296
  - spec/spec_helper.rb
297
297
  - spec/utilities_spec.rb
298
298
  - spec/validations_spec.rb
299
+ has_rdoc:
data/README.rdoc DELETED
@@ -1,247 +0,0 @@
1
- = RCAP - Common Alerting Protocol for Ruby
2
-
3
- == Overview
4
-
5
- The Common Alerting Protocol is a lightweight standard to facilitate the distribution of alerting data. RCAP is an implementation of the CAP document protocol in Ruby. It allows for the creation of RCAP messages from Ruby applications and the parsing of external messages.
6
-
7
- RCAP currently supports CAP 1.0, 1.1 and 1.2.
8
-
9
- == Version
10
-
11
- 1.3.0
12
-
13
- == Dependencies
14
-
15
- RCAP depends on the following gems
16
-
17
- * Assistance[http://assistance.rubyforge.org]
18
- * UUIDTools[http://uuidtools.rubyforge.org]
19
- * JSON[http://json.rubyforge.org]
20
-
21
- RCAP uses the REXML API, included in Ruby, to parse and generate XML.
22
-
23
- == Installation
24
-
25
- RCAP is distributed as a Ruby gem and is available from Rubygems.org[http://rubygems.org].
26
-
27
- gem install rcap
28
-
29
- The gem is also available for download and manual installtion at {www.aimred.com/gems}[http://www.aimred.com/gems].
30
-
31
- == Web resources
32
-
33
- * The RCAP project page can be found at http://www.aimred.com/projects/rcap
34
- * The RCAP API docs can be found at http://www.aimred.com/projects/rcap/api
35
- * A public git repository can be found at git://github.com/farrel/RCAP.git
36
-
37
- == Usage
38
-
39
- To include RCAP into your application add the following require
40
-
41
- require 'rcap'
42
-
43
- All RCAP classes reside in the RCAP namespace but including the RCAP module makes the classes available at the top level without the RCAP prefix.
44
-
45
- include RCAP:CAP_1_2 # Include RCAP:CAP_1_2 module into namespace
46
- alert = Alert.new(...
47
-
48
- === Creating an Alert
49
-
50
- alert = Alert.new( identifier: RCAP.generate_identifier,
51
- sent: DateTime.now,
52
- sender: 'cape_town_disaster_relief@capetown.municipal.za',
53
- status: Alert::STATUS_ACTUAL,
54
- msg_type: Alert::MSG_TYPE_ALERT,
55
- scope: Alert::SCOPE_PUBLIC )
56
-
57
- alert.add_info( event: 'Liquid Petroleoum Tanker Fire',
58
- language: 'en-ZA',
59
- categories: [ Info::CATEGORY_TRANSPORT, Info::CATEGORY_FIRE ],
60
- urgency: Info::URGENCY_IMMEDIATE,
61
- severity: Info::SEVERITY_SEVERE,
62
- certainty: Info::CERTAINTY_OBSERVED,
63
- headline: 'LIQUID PETROLEOUM TANKER FIRE ON N2 INCOMING FREEWAY',
64
- description: 'A liquid petroleoum tanker has caught fire on the N2 incoming freeway 1km
65
- after the R300 interchange. Municipal fire fighting crews have been dispatched.
66
- Traffic control officers are on the scene and have diverted traffic onto
67
- alternate routes.' )
68
-
69
- alert.infos.first.add_area( area_desc: 'N2 Highway/R300 Interchange' ).add_geocode( name: 'Intersection', value: 'N2-15' )
70
-
71
- # Accessing attributes
72
- alert.status # "Actual"
73
- alert.infos[0].language # "en-ZA"
74
- alert.infos[0].categories.join( ', ' ) # "Transport, Fire"
75
- alert.infos[0].areas[0] # "N2 Highway/R300 Interchange"
76
-
77
- === Parsing an Alert From An External Source
78
-
79
- RCAP can parse a CAP alert from a varierty of file formats. Besides the {standard XML}[http://www.oasis-emergency.org/cap] representation, YAML[http://yaml.org] and JSON[http://json.org] support is also included.
80
-
81
- To ensure the correct RCAP Alert object (RCAP::CAP_1_1::Alert or RCAP::CAP_1_2::Alert) is returned from an external source, a number of factories are defined in the RCAP::Alert module. If the version of the document to be parsed can not be ascertained a CAP 1.2 document will be assumed.
82
-
83
- ==== From XML
84
-
85
- RCAP allows for the parsing of a CAP XML string
86
-
87
- alert = RCAP::Alert.from_xml( xml_string )
88
-
89
- ==== From YAML
90
-
91
- Alert messgaes can be read in from text files containing data formatted in YAML[http://yaml.org] as generated by RCAP::CAP_1_2::Alert#to_yaml.
92
-
93
- alert = RCAP::Alert.from_yaml( yaml_string )
94
-
95
- ==== From JSON
96
-
97
- An Alert can also be initialised from a JSON[http://json.org] string produced by Alert#to_json
98
-
99
- alert = RCAP::Alert.from_json( json_string )
100
-
101
- === Validating an alert
102
-
103
- The RCAP API aims to codify as many of the rules of the CAP XML format into validation rules that can be checked using the Assistance API. The following Info object has two attributes ('severity' and 'certainty') set to incorrect values.
104
-
105
- info = Info.new( event: 'Liquid Petroleoum Tanker Fire',
106
- language: 'en-ZA',
107
- categories: [ Info::CATEGORY_TRANSPORT, Info::CATEGORY_FIRE ],
108
- urgency: Info::URGENCY_IMMEDIATE,
109
- severity: nil, # Severity is not assigned
110
- certainty: 'Unknown Certainty' ) # Certainty is assigned in incorrect value
111
-
112
- puts "Is info valid: #{ info.valid? }"
113
- info.errors.full_messages.each{ |message| puts "Error: #{ message }" }
114
-
115
- Will produce the following output:
116
-
117
- Is info valid: false
118
- Error: severity is not present
119
- Error: certainty can only be assigned the following values: Observed, Likely, Possible, Unlikely, Unknown
120
-
121
- All RCAP classes include the Validation module.
122
-
123
- A full spec suite using {RSpec}[http://www.rspec.info] was used to test the validations and currently numbers over 1000 tests.
124
-
125
- === Exporting an Alert
126
-
127
- ==== To XML
128
-
129
- Using the alert message created above
130
-
131
- puts alert.to_xml # Print out CAP XML message
132
-
133
- Will print the following CAP XML
134
-
135
- <?xml version='1.0'?>
136
- <alert xmlns='urn:oasis:names:tc:emergency:cap:1.2'>
137
- <identifier>494207a7-f86b-4060-8318-a4b2a3ce565e</identifier>
138
- <sender>cape_town_disaster_relief@capetown.municipal.za</sender>
139
- <sent>2009-10-26T21:04:51+02:00</sent>
140
- <status>Actual</status>
141
- <msgType>Alert</msgType>
142
- <scope>Public</scope>
143
- <info>
144
- <language>en-ZA</language>
145
- <category>Transport</category>
146
- <category>Fire</category>
147
- <event>Liquid Petroleoum Tanker Fire</event>
148
- <urgency>Immediate</urgency>
149
- <severity>Severe</severity>
150
- <certainty>Observed</certainty>
151
- <headline>LIQUID PETROLEOUM TANKER FIRE ON N2 INCOMING FREEWAY</headline>
152
- <description>
153
- A liquid petroleoum tanker has caught fire on the N2 incoming freeway 1km
154
- after the R300 interchange. Municipal fire fighting crews have been
155
- dispatched. Traffic control officers are on the scene and have diverted
156
- traffic onto alternate routes.
157
- </description>
158
- </info>
159
- </alert>
160
-
161
- ==== To YAML
162
-
163
- YAML is a plain text serialization format designed to be easily readable and editable by both human and machine. RCAP has custom YAML generation and parsing methods to produce a YAML document that is as human friendly as possible. The following code
164
-
165
- alert.to_yaml
166
-
167
- will produce the following YAML document
168
-
169
- ---
170
- CAP Version: 1.2
171
- Identifier: 2a1ba96d-16e4-4f52-85ea-0258c1440bd5
172
- Sender: cape_town_disaster_relief@capetown.municipal.za
173
- Sent: 2009-11-19T02:41:29+02:00
174
- Status: Actual
175
- Message Type: Alert
176
- Scope: Public
177
- Information:
178
- - Language: en-ZA
179
- Categories: [Transport, Fire]
180
- Event: Liquid Petroleoum Tanker Fire
181
- Urgency: Immediate
182
- Severity: Severe
183
- Certainty: Observed
184
- Headline: LIQUID PETROLEOUM TANKER FIRE ON N2 INCOMING FREEWAY
185
- Description: |-
186
- A liquid petroleoum tanker has caught fire on the N2 incoming freeway 1km
187
- after the R300 interchange. Municipal fire fighting crews have been dispatched.
188
- Traffic control officers are on the scene and have diverted traffic onto
189
- alternate routes.
190
-
191
- Note: If you use Ruby 1.8 the order of the attributes is jumbled due to hashes being unorderd (Ruby 1.9 implements ordered hashes). This does not affect the ability to parse documents generated from RCAP::Alert#to_yaml, it just makes things the output slightly messy.
192
-
193
- ==== To JSON
194
-
195
- JSON(JavaScript Object Notation) is a text serialization format that can be easily loaded in a JavaScript environment.
196
-
197
- alert.to_json
198
-
199
- will produce the following JSON string
200
-
201
- {"cap_version":"1.2",
202
- "identifier":"0eb97e40-195b-437b-9a01-55fe89691def",
203
- "sender":"cape_town_disaster_relief@capetown.municipal.za",
204
- "sent":"2011-03-04T15:58:01+02:00",
205
- "status":"Actual",
206
- "msg_type":"Alert",
207
- "scope":"Public",
208
- "infos":[
209
- {"language":"en-ZA",
210
- "categories":["Transport","Fire"],
211
- "event":"Liquid Petroleoum Tanker Fire",
212
- "urgency":"Immediate",
213
- "severity":"Severe",
214
- "certainty":"Observed",
215
- "headline":"LIQUID PETROLEOUM TANKER FIRE ON N2 INCOMING FREEWAY",
216
- "description":"A liquid petroleoum tanker has caught fire on the N2 incoming freeway 1km
217
- after the R300 interchange. Municipal fire fighting crews have been dispatched.
218
- Traffic control officers are on the scene and have diverted traffic onto \nalternate routes."}]}
219
-
220
-
221
- === DateTime and Time
222
-
223
- It is highly recommended that when dealing with date and time fields (onset, expires etc) that the DateTime class is used to ensure the correct formatting of dates. The Time class can be used when generating a CAP alert XML message however any CAP alert that is parsed from an external XML source will use DateTime by default.
224
-
225
- == Authors
226
-
227
- * Farrel Lifson - farrel.lifson@aimred.com - http://www.aimred.com
228
-
229
- === Contributors
230
-
231
- * Earle Clubb - http://github.com/eclubb
232
-
233
- == License
234
-
235
- RCAP is released under the BSD License.
236
-
237
- Copyright 2010 - 2011 AIMRED CC. All rights reserved.
238
-
239
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
240
-
241
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
242
-
243
- 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.
244
-
245
- 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.
246
-
247
- 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.