rcap 1.0.0.rc.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -2
- data/README.rdoc +1 -1
- data/lib/rcap.rb +4 -0
- data/lib/rcap/cap_1_1/alert.rb +14 -4
- data/lib/rcap/cap_1_2/alert.rb +14 -4
- data/lib/rcap/version.rb +1 -1
- metadata +6 -10
data/CHANGELOG.rdoc
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
= Change Log
|
2
2
|
|
3
|
-
== 1.0 -
|
3
|
+
== 1.0.0 - 6 April 2011
|
4
4
|
|
5
5
|
* Added CAP 1.2 Support
|
6
6
|
* Added namespaces (RCAP::CAP_1_1 and RCAP::CAP_1_2) to seperate CAP 1.1 and CAP 1.2 classes
|
7
|
+
* Moved to RSpec2 and Bundler
|
8
|
+
* Added factory methods to create Info, Resource, Area and Polygon objects from their parents
|
7
9
|
* Added factory methods to RCAP::Alert module to parse in files and return the correct RCAP objects
|
10
|
+
* Pretty print XML and JSON output
|
8
11
|
|
9
12
|
== 0.4 - 6th March 2011
|
10
13
|
|
@@ -24,4 +27,4 @@
|
|
24
27
|
|
25
28
|
== 0.1 - 5th November 2009
|
26
29
|
|
27
|
-
* Initial release
|
30
|
+
* Initial release
|
data/README.rdoc
CHANGED
data/lib/rcap.rb
CHANGED
@@ -4,6 +4,7 @@ require 'uuidtools'
|
|
4
4
|
require 'yaml'
|
5
5
|
require 'json'
|
6
6
|
require 'rexml/document'
|
7
|
+
require 'rexml/formatters/pretty'
|
7
8
|
require 'rcap/version'
|
8
9
|
require 'rcap/utilities'
|
9
10
|
require 'rcap/validations'
|
@@ -28,3 +29,6 @@ require 'rcap/cap_1_2/circle'
|
|
28
29
|
require 'rcap/cap_1_2/polygon'
|
29
30
|
require 'rcap/cap_1_2/geocode'
|
30
31
|
require 'rcap/cap_1_2/area'
|
32
|
+
|
33
|
+
XML_PRETTY_PRINTER = REXML::Formatters::Pretty.new( 2 )
|
34
|
+
XML_PRETTY_PRINTER.compact = true
|
data/lib/rcap/cap_1_1/alert.rb
CHANGED
@@ -168,8 +168,14 @@ module RCAP
|
|
168
168
|
end
|
169
169
|
|
170
170
|
# Returns a string containing the XML representation of the alert.
|
171
|
-
def to_xml
|
172
|
-
|
171
|
+
def to_xml( pretty_print = false )
|
172
|
+
if pretty_print
|
173
|
+
xml_document = ""
|
174
|
+
XML_PRETTY_PRINTER.write( self.to_xml_document, xml_document )
|
175
|
+
xml_document
|
176
|
+
else
|
177
|
+
self.to_xml_document.to_s
|
178
|
+
end
|
173
179
|
end
|
174
180
|
|
175
181
|
# Returns a string representation of the alert suitable for usage as a reference in a CAP message of the form
|
@@ -348,8 +354,12 @@ module RCAP
|
|
348
354
|
end
|
349
355
|
|
350
356
|
# Returns a JSON string representation of an Alert object
|
351
|
-
def to_json
|
352
|
-
|
357
|
+
def to_json( pretty_print = false )
|
358
|
+
if pretty_print
|
359
|
+
JSON.pretty_generate( self.to_h )
|
360
|
+
else
|
361
|
+
self.to_h.to_json
|
362
|
+
end
|
353
363
|
end
|
354
364
|
|
355
365
|
# Initiialises an Alert object from a JSON string produced by Alert#to_json
|
data/lib/rcap/cap_1_2/alert.rb
CHANGED
@@ -168,8 +168,14 @@ module RCAP
|
|
168
168
|
end
|
169
169
|
|
170
170
|
# Returns a string containing the XML representation of the alert.
|
171
|
-
def to_xml
|
172
|
-
|
171
|
+
def to_xml( pretty_print = false )
|
172
|
+
if pretty_print
|
173
|
+
xml_document = ""
|
174
|
+
XML_PRETTY_PRINTER.write( self.to_xml_document, xml_document )
|
175
|
+
xml_document
|
176
|
+
else
|
177
|
+
self.to_xml_document.to_s
|
178
|
+
end
|
173
179
|
end
|
174
180
|
|
175
181
|
# Returns a string representation of the alert suitable for usage as a reference in a CAP message of the form
|
@@ -348,8 +354,12 @@ module RCAP
|
|
348
354
|
end
|
349
355
|
|
350
356
|
# Returns a JSON string representation of an Alert object
|
351
|
-
def to_json
|
352
|
-
|
357
|
+
def to_json( pretty_print = false )
|
358
|
+
if pretty_print
|
359
|
+
JSON.pretty_generate( self.to_h )
|
360
|
+
else
|
361
|
+
self.to_h.to_json
|
362
|
+
end
|
353
363
|
end
|
354
364
|
|
355
365
|
# Initiialises an Alert object from a JSON string produced by Alert#to_json
|
data/lib/rcap/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rcap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
|
10
|
-
- 5
|
11
|
-
version: 1.0.0.rc.5
|
9
|
+
version: 1.0.0
|
12
10
|
platform: ruby
|
13
11
|
authors:
|
14
12
|
- Farrel Lifson
|
@@ -16,7 +14,7 @@ autorequire:
|
|
16
14
|
bindir: bin
|
17
15
|
cert_chain: []
|
18
16
|
|
19
|
-
date: 2011-04-
|
17
|
+
date: 2011-04-06 00:00:00 +02:00
|
20
18
|
default_executable:
|
21
19
|
dependencies:
|
22
20
|
- !ruby/object:Gem::Dependency
|
@@ -170,13 +168,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
168
|
version: "0"
|
171
169
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
170
|
requirements:
|
173
|
-
- - "
|
171
|
+
- - ">="
|
174
172
|
- !ruby/object:Gem::Version
|
175
173
|
segments:
|
176
|
-
-
|
177
|
-
|
178
|
-
- 1
|
179
|
-
version: 1.3.1
|
174
|
+
- 0
|
175
|
+
version: "0"
|
180
176
|
requirements: []
|
181
177
|
|
182
178
|
rubyforge_project: rcap
|