rcap 2.2.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: fcde72aed04c8e2fc3fb4438f7aa0efa8c4ea742
4
- data.tar.gz: c4da4ef49d6baa85a8ed1c2d8f6483911f7c8d83
5
- SHA512:
6
- metadata.gz: dc204739fd9dadf31a5b8681534dc0f432f3cedee19f5d4c867532273a4da3d68fa4e5f54cea9f62c73b323832a437449efdcf0c12e5cdc92443874bbfeec78f
7
- data.tar.gz: 1f12805f57d4ccb6c445b9995d5d43028b7987555ed149847c1f1520bc4d38ca6114d50f3c5c465e84d05c7a6c394b96e3709c04f2e7a3b3aace14c1f79feb72
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1bb205d2fab692f7bd6b270029a96918a32eea19
4
+ data.tar.gz: fd94605d3d3a99040c3cf183cc873f0db15dd64b
5
+ SHA512:
6
+ metadata.gz: a3c720fc8e87dddd70b4dc92f03d2eab1ff21875c33b9c83b8b714e35e4fa0bdb1d065c945b67c55d9bac02f037ac8941172eff5e943fb6209871a6095cd2126
7
+ data.tar.gz: 93bf5df1405126c70f80894da9bf0b40b10f8089c17d8877d0c92e6c0fb047475ef843aceaadc5cdd5a48d5691b7a17b044628c4821aca5bbee21653928d5eac
@@ -1,6 +1,11 @@
1
1
  Change Log
2
2
  ==========
3
3
 
4
+ ## 2.3.0 - 6 March 2014
5
+
6
+ * Fixed YAML import and export.
7
+ * Ruby 2.1 tested
8
+
4
9
  ## 2.2.1 - 16 April 2013
5
10
 
6
11
  * Added RCAP::Info to initialise an Info object semi-independently from an Alert.
data/README.md CHANGED
@@ -24,7 +24,7 @@ Installation
24
24
 
25
25
  RCAP is distributed as a Ruby gem and is available from [Rubygems.org](http://rubygems.org). From the command line you can install it with the gem command:
26
26
 
27
- $ gem install rcap
27
+ gem install rcap
28
28
 
29
29
  The gem is also available for download and manual installation at [www.aimred.com/gems](http://www.aimred.com/gems).
30
30
 
@@ -36,9 +36,8 @@ Usage
36
36
  RCAP uses a 'builder' style syntax to create alerts.
37
37
 
38
38
  require 'rcap'
39
- include RCAP::CAP_1_2
40
39
 
41
- alert = Alert.new do |alert|
40
+ alert = RCAP::CAP_1_2::Alert.new do |alert|
42
41
  alert.sender = 'cape_town_disaster_relief@capetown.municipal.za'
43
42
  alert.status = Alert::STATUS_ACTUAL
44
43
  alert.msg_type = Alert::MSG_TYPE_ALERT
@@ -121,7 +120,7 @@ To parse an alert from a XML:
121
120
 
122
121
  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.
123
122
 
124
- info = Info.new do |info|
123
+ info = RCAP::CAP_1_2::Info.new do |info|
125
124
  info.event = 'Liquid Petroleoum Tanker Fire'
126
125
  info.language = 'en-ZA'
127
126
  info.categories << Info::CATEGORY_TRANSPORT
@@ -161,7 +160,7 @@ Authors
161
160
  Change Log
162
161
  ----------
163
162
 
164
- [CHANGELOG](CHANGELOG.html)
163
+ [CHANGELOG](file.CHANGELOG.html)
165
164
 
166
165
  License
167
166
  -------
@@ -309,7 +309,7 @@ module RCAP
309
309
  [ NOTE_YAML, @note ],
310
310
  [ REFERENCES_YAML, @references ],
311
311
  [ INCIDENTS_YAML, @incidents ],
312
- [ INFOS_YAML, @infos ]).to_yaml( options )
312
+ [ INFOS_YAML, @infos.map( &:to_yaml_data )]).to_yaml( options )
313
313
  end
314
314
 
315
315
  # Initialise an Alert object from a YAML string. Any object that is a subclass of IO (e.g. File) can be passed in.
@@ -150,14 +150,19 @@ module RCAP
150
150
  GEOCODES_YAML = 'Geocodes'
151
151
  POLYGONS_YAML = 'Polygons'
152
152
 
153
- # @return [String] YAML representation of object
154
- def to_yaml( options = {} )
153
+ # @return [Hash]
154
+ def to_yaml_data
155
155
  RCAP.attribute_values_to_hash( [ AREA_DESC_YAML, @area_desc ],
156
156
  [ ALTITUDE_YAML, @altitude ],
157
157
  [ CEILING_YAML, @ceiling ],
158
158
  [ CIRCLES_YAML, @circles.map{ |circle| circle.to_a }],
159
159
  [ GEOCODES_YAML, @geocodes.inject({}){|h,geocode| h.merge( geocode.name => geocode.value )}],
160
- [ POLYGONS_YAML, @polygons ]).to_yaml( options )
160
+ [ POLYGONS_YAML, @polygons.map( &:to_yaml_data )])
161
+ end
162
+
163
+ # @return [String] YAML representation of object
164
+ def to_yaml( options = {} )
165
+ self.to_yaml_data.to_yaml( options )
161
166
  end
162
167
 
163
168
  # @param [Hash] area_yaml_data
@@ -335,8 +335,8 @@ module RCAP
335
335
  RESOURCES_YAML = 'Resources'
336
336
  AREAS_YAML = 'Areas'
337
337
 
338
- # @return [String]
339
- def to_yaml( options = {} )
338
+ # @return [Hash]
339
+ def to_yaml_data
340
340
  parameter_to_hash = lambda{ |hash, parameter| hash.merge( parameter.name => parameter.value )}
341
341
 
342
342
  RCAP.attribute_values_to_hash( [ LANGUAGE_YAML, @language ],
@@ -357,8 +357,13 @@ module RCAP
357
357
  [ CONTACT_YAML, @contact ],
358
358
  [ EVENT_CODES_YAML, @event_codes.inject({}, &parameter_to_hash )],
359
359
  [ PARAMETERS_YAML, @parameters.inject({}, &parameter_to_hash )],
360
- [ RESOURCES_YAML, @resources ],
361
- [ AREAS_YAML, @areas ]).to_yaml( options )
360
+ [ RESOURCES_YAML, @resources.map( &:to_yaml_data )],
361
+ [ AREAS_YAML, @areas.map(&:to_yaml_data )])
362
+ end
363
+
364
+ # @return [String]
365
+ def to_yaml( options = {} )
366
+ self.to_yaml_data.to_yaml( options )
362
367
  end
363
368
 
364
369
  # @param [Hash] info_yaml_data
@@ -92,9 +92,14 @@ module RCAP
92
92
  end
93
93
  end
94
94
 
95
+ # @return [Hash]
96
+ def to_yaml_data
97
+ @points.map{ |point| [ point.lattitude, point.longitude ]}
98
+ end
99
+
95
100
  # @return [String]
96
101
  def to_yaml( options = {} )
97
- @points.map{ |point| [ point.lattitude, point.longitude ]}.to_yaml( options )
102
+ self.to_yaml_data.to_yaml( options )
98
103
  end
99
104
 
100
105
  POINTS_KEY = 'points'
@@ -63,9 +63,9 @@ module RCAP
63
63
  end
64
64
  end
65
65
 
66
- # Calculates the SHA-1 hash and size of the contents of {#deref_uri}.
66
+ # Calculates the SHA-1 hash and size of the contents of {RCAP::Base::Resource#deref_uri}.
67
67
  # Returns an array containing the size (in bytes) and SHA-1 hash if
68
- # {#deref_uri} is present otherwise returns nil.
68
+ # {RCAP::Base::Resource#deref_uri} is present otherwise returns nil.
69
69
  #
70
70
  # @return [nil,Array(Integer,String)]
71
71
  def calculate_hash_and_size
@@ -76,7 +76,7 @@ module RCAP
76
76
  end
77
77
  end
78
78
 
79
- # The decoded contents of {#deref_uri} if present otherwise nil.
79
+ # The decoded contents of {RCAP::Base::Resource#deref_uri} if present otherwise nil.
80
80
  #
81
81
  # @return [nil,String]
82
82
  def decoded_deref_uri
@@ -115,14 +115,18 @@ module RCAP
115
115
  SIZE_YAML = "Size"
116
116
  DIGEST_YAML = "Digest"
117
117
 
118
- # @param [Hash] options
119
- # @return [String]
120
- def to_yaml( options = {} )
118
+ def to_yaml_data
121
119
  RCAP.attribute_values_to_hash( [ RESOURCE_DESC_YAML, @resource_desc ],
122
120
  [ URI_YAML, @uri ],
123
121
  [ MIME_TYPE_YAML, @mime_type ],
124
122
  [ SIZE_YAML, @size ],
125
- [ DIGEST_YAML, @digest ]).to_yaml( options )
123
+ [ DIGEST_YAML, @digest ])
124
+ end
125
+
126
+ # @param [Hash] options
127
+ # @return [String]
128
+ def to_yaml( options = {} )
129
+ self.to_yaml_data.to_yaml( options )
126
130
  end
127
131
 
128
132
  # @param [Hash] resource_yaml_data
@@ -117,7 +117,7 @@ module RCAP
117
117
  [ NOTE_YAML, @note ],
118
118
  [ REFERENCES_YAML, @references ],
119
119
  [ INCIDENTS_YAML, @incidents ],
120
- [ INFOS_YAML, @infos ]).to_yaml( options )
120
+ [ INFOS_YAML, @infos.map( &:to_yaml_data )]).to_yaml( options )
121
121
  end
122
122
 
123
123
  # @param [Hash] alert_yaml_data
@@ -190,9 +190,9 @@ module RCAP
190
190
 
191
191
  RESPONSE_TYPES_YAML = 'Response Types'
192
192
 
193
- # @return [String]
194
- def to_yaml( options = {} )
195
- parameter_to_hash = lambda{ |hash, parameter| hash.merge( parameter.name => parameter.value )}
193
+ # @return [Hash]
194
+ def to_yaml_data
195
+ parameter_to_hash = lambda{ |hash, parameter| hash.merge( parameter.name => parameter.value )}
196
196
 
197
197
  RCAP.attribute_values_to_hash( [ LANGUAGE_YAML, @language ],
198
198
  [ CATEGORIES_YAML, @categories ],
@@ -213,8 +213,13 @@ module RCAP
213
213
  [ CONTACT_YAML, @contact ],
214
214
  [ EVENT_CODES_YAML, @event_codes.inject({}, &parameter_to_hash )],
215
215
  [ PARAMETERS_YAML, @parameters.inject({}, &parameter_to_hash )],
216
- [ RESOURCES_YAML, @resources ],
217
- [ AREAS_YAML, @areas ]).to_yaml( options )
216
+ [ RESOURCES_YAML, @resources.map( &:to_yaml_data )],
217
+ [ AREAS_YAML, @areas.map( &:to_yaml_data )])
218
+ end
219
+
220
+ # @return [String]
221
+ def to_yaml( options = {} )
222
+ self.to_yaml_data.to_yaml( options )
218
223
  end
219
224
 
220
225
  # @param [Hash] info_yaml_data
@@ -55,15 +55,19 @@ module RCAP
55
55
 
56
56
  DEREF_URI_YAML = "Derefrenced URI Data"
57
57
 
58
- # @param [Hash] options
59
- # @return [String]
60
- def to_yaml( options = {} )
58
+ def to_yaml_data
61
59
  RCAP.attribute_values_to_hash( [ RESOURCE_DESC_YAML, @resource_desc ],
62
60
  [ URI_YAML, @uri ],
63
61
  [ MIME_TYPE_YAML, @mime_type ],
64
62
  [ DEREF_URI_YAML, @deref_uri ],
65
63
  [ SIZE_YAML, @size ],
66
- [ DIGEST_YAML, @digest ]).to_yaml( options )
64
+ [ DIGEST_YAML, @digest ])
65
+ end
66
+
67
+ # @param [Hash] options
68
+ # @return [String]
69
+ def to_yaml( options = {} )
70
+ self.to_yaml_data.to_yaml( options )
67
71
  end
68
72
 
69
73
  # @param [Hash] resource_yaml_data
@@ -164,8 +164,8 @@ module RCAP
164
164
 
165
165
  RESPONSE_TYPES_YAML = 'Response Types'
166
166
 
167
- # @return [String]
168
- def to_yaml( options = {} )
167
+ # @return [Hash]
168
+ def to_yaml_data
169
169
  parameter_to_hash = lambda{ |hash, parameter| hash.merge( parameter.name => parameter.value )}
170
170
 
171
171
  RCAP.attribute_values_to_hash( [ LANGUAGE_YAML, @language ],
@@ -187,8 +187,13 @@ module RCAP
187
187
  [ CONTACT_YAML, @contact ],
188
188
  [ EVENT_CODES_YAML, @event_codes.inject({}, &parameter_to_hash )],
189
189
  [ PARAMETERS_YAML, @parameters.inject({}, &parameter_to_hash )],
190
- [ RESOURCES_YAML, @resources ],
191
- [ AREAS_YAML, @areas ]).to_yaml( options )
190
+ [ RESOURCES_YAML, @resources.map( &:to_yaml_data )],
191
+ [ AREAS_YAML, @areas.map( &:to_yaml_data )])
192
+ end
193
+
194
+ # @return [String]
195
+ def to_yaml( options = {} )
196
+ self.to_yaml_data.to_yaml( options )
192
197
  end
193
198
 
194
199
  # @param [Hash] info_yaml_data
@@ -131,7 +131,7 @@ module RCAP
131
131
  # if the string is given, String#strip and then String#to_f are applied
132
132
  # otherwise nil is returned.
133
133
  #
134
- # @param [String] string
134
+ # @param [String] number
135
135
  # @return [Float,nil]
136
136
  def RCAP.to_f_if_given( number )
137
137
  if number
@@ -149,7 +149,7 @@ module RCAP
149
149
  # if the string is given, String#strip and then String#to_i are applied
150
150
  # otherwise nil is returned.
151
151
  #
152
- # @param [String] string
152
+ # @param [String] number
153
153
  # @return [Integer,nil]
154
154
  def RCAP.to_i_if_given( number )
155
155
  if number
@@ -1,3 +1,3 @@
1
1
  module RCAP
2
- VERSION = '2.2.1'
2
+ VERSION = '2.3.0'
3
3
  end
metadata CHANGED
@@ -1,87 +1,110 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rcap
3
- version: !ruby/object:Gem::Version
4
- version: 2.2.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.3.0
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Farrel Lifson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2013-04-16 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
11
+ date: 2014-03-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
15
14
  name: assistance
16
- prerelease: false
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- requirements:
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
19
17
  - - ">="
20
- - !ruby/object:Gem::Version
18
+ - !ruby/object:Gem::Version
21
19
  version: 0.1.5
22
20
  type: :runtime
23
- version_requirements: *id001
24
- - !ruby/object:Gem::Dependency
25
- name: json
26
21
  prerelease: false
27
- requirement: &id002 !ruby/object:Gem::Requirement
28
- requirements:
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
29
31
  - - ">="
30
- - !ruby/object:Gem::Version
32
+ - !ruby/object:Gem::Version
31
33
  version: 1.5.1
32
34
  type: :runtime
33
- version_requirements: *id002
34
- - !ruby/object:Gem::Dependency
35
- name: uuidtools
36
35
  prerelease: false
37
- requirement: &id003 !ruby/object:Gem::Requirement
38
- requirements:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
39
38
  - - ">="
40
- - !ruby/object:Gem::Version
39
+ - !ruby/object:Gem::Version
40
+ version: 1.5.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: uuidtools
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
41
47
  version: 2.1.2
42
48
  type: :runtime
43
- version_requirements: *id003
44
- - !ruby/object:Gem::Dependency
45
- name: rspec
46
49
  prerelease: false
47
- requirement: &id004 !ruby/object:Gem::Requirement
48
- requirements:
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.1.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
49
59
  - - ">="
50
- - !ruby/object:Gem::Version
60
+ - !ruby/object:Gem::Version
51
61
  version: 2.5.0
52
62
  type: :development
53
- version_requirements: *id004
54
- - !ruby/object:Gem::Dependency
55
- name: yard
56
63
  prerelease: false
57
- requirement: &id005 !ruby/object:Gem::Requirement
58
- requirements:
59
- - &id006
60
- - ">="
61
- - !ruby/object:Gem::Version
62
- version: "0"
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 2.5.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
63
76
  type: :development
64
- version_requirements: *id005
65
- - !ruby/object:Gem::Dependency
66
- name: webmock
67
77
  prerelease: false
68
- requirement: &id007 !ruby/object:Gem::Requirement
69
- requirements:
70
- - *id006
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
71
90
  type: :development
72
- version_requirements: *id007
73
- description: A Ruby API providing parsing, generation and validation of CAP(Common Alerting Protocol) messages.
74
- email:
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: A Ruby API providing parsing, generation and validation of CAP(Common
98
+ Alerting Protocol) messages.
99
+ email:
75
100
  - farrel.lifson@aimred.com
76
101
  executables: []
77
-
78
102
  extensions: []
79
-
80
- extra_rdoc_files:
103
+ extra_rdoc_files:
81
104
  - README.md
82
105
  - CHANGELOG.md
83
- files:
84
- - .gitignore
106
+ files:
107
+ - ".gitignore"
85
108
  - CHANGELOG.md
86
109
  - Gemfile
87
110
  - README.md
@@ -190,28 +213,28 @@ files:
190
213
  - spec/validations_spec.rb
191
214
  homepage: http://www.aimred.com/projects/rcap
192
215
  licenses: []
193
-
194
216
  metadata: {}
195
-
196
217
  post_install_message:
197
218
  rdoc_options: []
198
-
199
- require_paths:
219
+ require_paths:
200
220
  - lib
201
- required_ruby_version: !ruby/object:Gem::Requirement
202
- requirements:
203
- - *id006
204
- required_rubygems_version: !ruby/object:Gem::Requirement
205
- requirements:
206
- - *id006
221
+ required_ruby_version: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - ">="
224
+ - !ruby/object:Gem::Version
225
+ version: '0'
226
+ required_rubygems_version: !ruby/object:Gem::Requirement
227
+ requirements:
228
+ - - ">="
229
+ - !ruby/object:Gem::Version
230
+ version: '0'
207
231
  requirements: []
208
-
209
232
  rubyforge_project: rcap
210
- rubygems_version: 2.0.3
233
+ rubygems_version: 2.2.0
211
234
  signing_key:
212
235
  specification_version: 4
213
236
  summary: CAP(Common Alerting Protocol) API
214
- test_files:
237
+ test_files:
215
238
  - spec/alert_spec.rb
216
239
  - spec/assets/amber.atom
217
240
  - spec/assets/canada.cap