rcap 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +12 -0
- data/README.md +8 -13
- data/lib/rcap/utilities.rb +3 -3
- data/lib/rcap/version.rb +1 -1
- data/spec/extensions_spec.rb +0 -4
- metadata +2 -2
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
Change Log
|
2
2
|
==========
|
3
3
|
|
4
|
+
## 2.1.0 - 12 January 2013
|
5
|
+
|
6
|
+
* RCAP.attribute_values_to_hash now does not filter out values that are empty, only nil.
|
7
|
+
|
8
|
+
## 2.0.2
|
9
|
+
|
10
|
+
* Fixed typo
|
11
|
+
|
12
|
+
## 2.0.1
|
13
|
+
|
14
|
+
* Use CAP date format in Alert reference and to_s
|
15
|
+
|
4
16
|
## 2.0.0 - 17 November 2012
|
5
17
|
|
6
18
|
* Changed initialisation to block/builder style
|
data/README.md
CHANGED
@@ -31,15 +31,14 @@ The gem is also available for download and manual installation at [www.aimred.co
|
|
31
31
|
Usage
|
32
32
|
-----
|
33
33
|
|
34
|
-
To include RCAP into your application add the following require
|
35
|
-
|
36
|
-
require 'rcap'
|
37
|
-
|
38
34
|
### Creating an Alert
|
39
35
|
|
40
36
|
RCAP uses a 'builder' style syntax to create alerts.
|
41
37
|
|
42
|
-
|
38
|
+
require 'rcap'
|
39
|
+
include RCAP::CAP_1_2
|
40
|
+
|
41
|
+
alert = Alert.new do |alert|
|
43
42
|
alert.sender = 'cape_town_disaster_relief@capetown.municipal.za'
|
44
43
|
alert.status = Alert::STATUS_ACTUAL
|
45
44
|
alert.msg_type = Alert::MSG_TYPE_ALERT
|
@@ -112,8 +111,6 @@ Will print the following CAP XML
|
|
112
111
|
|
113
112
|
### Parsing an Alert From An External Source
|
114
113
|
|
115
|
-
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.
|
116
|
-
|
117
114
|
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.
|
118
115
|
|
119
116
|
To parse an alert from a XML:
|
@@ -122,9 +119,9 @@ To parse an alert from a XML:
|
|
122
119
|
|
123
120
|
### Validation
|
124
121
|
|
125
|
-
The RCAP API aims to codify as many of the rules of the CAP XML format into validation rules
|
122
|
+
The RCAP API aims to codify as many of the rules of the CAP XML format into validation rules. The following Info object has two attributes ('severity' and 'certainty') set to incorrect values.
|
126
123
|
|
127
|
-
info =
|
124
|
+
info = Info.new do |info|
|
128
125
|
info.event = 'Liquid Petroleoum Tanker Fire'
|
129
126
|
info.language = 'en-ZA'
|
130
127
|
info.categories << Info::CATEGORY_TRANSPORT
|
@@ -142,8 +139,6 @@ Will produce the following output:
|
|
142
139
|
Error: severity is not present
|
143
140
|
Error: certainty can only be assigned the following values: Observed, Likely, Possible, Unlikely, Unknown
|
144
141
|
|
145
|
-
All RCAP classes include the Validation module.
|
146
|
-
|
147
142
|
A full spec suite using [RSpec](http://www.rspec.info) was used to test the validations and currently numbers over 1000 tests.
|
148
143
|
|
149
144
|
Web resources
|
@@ -166,14 +161,14 @@ Authors
|
|
166
161
|
Change Log
|
167
162
|
----------
|
168
163
|
|
169
|
-
[CHANGELOG](
|
164
|
+
[CHANGELOG](CHANGELOG.html)
|
170
165
|
|
171
166
|
License
|
172
167
|
-------
|
173
168
|
|
174
169
|
RCAP is released under the BSD License.
|
175
170
|
|
176
|
-
Copyright 2010 -
|
171
|
+
Copyright 2010 - 2013 AIMRED CC. All rights reserved.
|
177
172
|
|
178
173
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
179
174
|
|
data/lib/rcap/utilities.rb
CHANGED
@@ -65,15 +65,15 @@ module RCAP
|
|
65
65
|
"'" + '-' * ( max_line_length + 2 ) + "'\n"
|
66
66
|
end
|
67
67
|
|
68
|
-
# Converts an array of key value pairs into a hash, excluding any value that is nil
|
68
|
+
# Converts an array of key value pairs into a hash, excluding any value that is nil.
|
69
69
|
#
|
70
70
|
# @param [Array<Array(Object,Object)>] attribute_values An array of arrays of key/value pairs
|
71
71
|
# @return [Hash] Hash of attributes
|
72
72
|
#
|
73
73
|
# @example
|
74
|
-
# RCAP.attribute_values_to_hash( ['a', 1], ['b' ,
|
74
|
+
# RCAP.attribute_values_to_hash( ['a', 1], ['b' , nil ]) # => { 'a' => 1 }
|
75
75
|
def self.attribute_values_to_hash( *attribute_values )
|
76
|
-
Hash[ *attribute_values.reject{ |key, value| value.nil?
|
76
|
+
Hash[ *attribute_values.reject{ |key, value| value.nil? }.flatten( 1 )]
|
77
77
|
end
|
78
78
|
|
79
79
|
# Calls #to_s_for_cap on the object it it responds to that otherwise just calls #to_s
|
data/lib/rcap/version.rb
CHANGED
data/spec/extensions_spec.rb
CHANGED
@@ -60,10 +60,6 @@ describe( String ) do
|
|
60
60
|
RCAP.attribute_values_to_hash( ["a", nil ]).should == {}
|
61
61
|
end
|
62
62
|
|
63
|
-
it( 'should reject empty values' ) do
|
64
|
-
RCAP.attribute_values_to_hash( ["a", []]).should == {}
|
65
|
-
end
|
66
|
-
|
67
63
|
it( 'should not reject non-nil and non-empty values' ) do
|
68
64
|
RCAP.attribute_values_to_hash( [ "a", 1 ], [ "b", [ 2 ]]).should == { "a" => 1, "b" => [ 2 ]}
|
69
65
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rcap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 2.0
|
5
|
+
version: 2.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Farrel Lifson
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2013-01-
|
13
|
+
date: 2013-01-12 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: assistance
|