rcap 2.4.1 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/rcap/alert.rb +28 -29
- data/lib/rcap/base/alert.rb +192 -192
- data/lib/rcap/base/area.rb +84 -86
- data/lib/rcap/base/circle.rb +32 -32
- data/lib/rcap/base/info.rb +248 -253
- data/lib/rcap/base/parameter.rb +23 -24
- data/lib/rcap/base/point.rb +23 -23
- data/lib/rcap/base/polygon.rb +32 -32
- data/lib/rcap/base/resource.rb +57 -57
- data/lib/rcap/cap_1_0/alert.rb +79 -83
- data/lib/rcap/cap_1_0/area.rb +0 -2
- data/lib/rcap/cap_1_0/circle.rb +0 -1
- data/lib/rcap/cap_1_0/info.rb +1 -3
- data/lib/rcap/cap_1_0/parameter.rb +11 -12
- data/lib/rcap/cap_1_0/point.rb +0 -1
- data/lib/rcap/cap_1_0/polygon.rb +0 -2
- data/lib/rcap/cap_1_0/resource.rb +0 -3
- data/lib/rcap/cap_1_1/alert.rb +4 -6
- data/lib/rcap/cap_1_1/area.rb +0 -2
- data/lib/rcap/cap_1_1/circle.rb +0 -1
- data/lib/rcap/cap_1_1/info.rb +120 -129
- data/lib/rcap/cap_1_1/parameter.rb +0 -2
- data/lib/rcap/cap_1_1/point.rb +0 -1
- data/lib/rcap/cap_1_1/polygon.rb +0 -2
- data/lib/rcap/cap_1_1/resource.rb +32 -34
- data/lib/rcap/cap_1_2/alert.rb +4 -6
- data/lib/rcap/cap_1_2/area.rb +0 -2
- data/lib/rcap/cap_1_2/circle.rb +0 -1
- data/lib/rcap/cap_1_2/info.rb +114 -121
- data/lib/rcap/cap_1_2/parameter.rb +0 -2
- data/lib/rcap/cap_1_2/point.rb +0 -1
- data/lib/rcap/cap_1_2/polygon.rb +1 -3
- data/lib/rcap/cap_1_2/resource.rb +32 -34
- data/lib/rcap/config.rb +3 -3
- data/lib/rcap/custom_validators.rb +72 -76
- data/lib/rcap/extensions/array.rb +1 -1
- data/lib/rcap/extensions/date.rb +2 -2
- data/lib/rcap/extensions/date_time.rb +3 -3
- data/lib/rcap/extensions/string.rb +3 -3
- data/lib/rcap/extensions/time.rb +2 -3
- data/lib/rcap/info.rb +4 -5
- data/lib/rcap/utilities.rb +24 -25
- data/lib/rcap/validation.rb +19 -20
- data/lib/rcap/version.rb +1 -1
- data/spec/alert_spec.rb +141 -141
- data/spec/cap_1_0/alert_spec.rb +92 -94
- data/spec/cap_1_0/area_spec.rb +86 -86
- data/spec/cap_1_0/circle_spec.rb +39 -39
- data/spec/cap_1_0/event_code_spec.rb +15 -15
- data/spec/cap_1_0/geocode_spec.rb +16 -16
- data/spec/cap_1_0/info_spec.rb +175 -177
- data/spec/cap_1_0/parameter_spec.rb +27 -27
- data/spec/cap_1_0/point_spec.rb +18 -18
- data/spec/cap_1_0/polygon_spec.rb +38 -38
- data/spec/cap_1_0/resource_spec.rb +63 -64
- data/spec/cap_1_1/alert_spec.rb +107 -109
- data/spec/cap_1_1/area_spec.rb +90 -90
- data/spec/cap_1_1/circle_spec.rb +34 -34
- data/spec/cap_1_1/event_code_spec.rb +15 -16
- data/spec/cap_1_1/geocode_spec.rb +16 -16
- data/spec/cap_1_1/info_spec.rb +194 -196
- data/spec/cap_1_1/parameter_spec.rb +17 -17
- data/spec/cap_1_1/point_spec.rb +18 -18
- data/spec/cap_1_1/polygon_spec.rb +36 -36
- data/spec/cap_1_1/resource_spec.rb +106 -107
- data/spec/cap_1_2/alert_spec.rb +98 -99
- data/spec/cap_1_2/area_spec.rb +90 -90
- data/spec/cap_1_2/circle_spec.rb +43 -43
- data/spec/cap_1_2/event_code_spec.rb +19 -20
- data/spec/cap_1_2/geocode_spec.rb +20 -20
- data/spec/cap_1_2/info_spec.rb +196 -198
- data/spec/cap_1_2/parameter_spec.rb +19 -19
- data/spec/cap_1_2/point_spec.rb +21 -21
- data/spec/cap_1_2/polygon_spec.rb +47 -47
- data/spec/cap_1_2/resource_spec.rb +96 -97
- data/spec/extensions_spec.rb +29 -29
- data/spec/info_spec.rb +15 -15
- data/spec/spec_helper.rb +3 -3
- data/spec/validations_spec.rb +73 -73
- metadata +2 -2
data/lib/rcap/cap_1_2/point.rb
CHANGED
data/lib/rcap/cap_1_2/polygon.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
module RCAP
|
2
2
|
module CAP_1_2
|
3
|
-
|
4
3
|
# A Polygon object is valid if
|
5
4
|
# * it has a minimum of three points
|
6
5
|
# * each Point object in the points collection is valid
|
7
6
|
class Polygon < RCAP::Base::Polygon
|
8
|
-
|
9
|
-
validates_length_of( :points, :minimum => 4 )
|
7
|
+
validates_length_of(:points, minimum: 4)
|
10
8
|
|
11
9
|
# @return [Class]
|
12
10
|
def point_class
|
@@ -1,15 +1,13 @@
|
|
1
1
|
module RCAP
|
2
2
|
module CAP_1_2
|
3
|
-
|
4
3
|
# A Resource object is valid if
|
5
4
|
# * it has a resource description
|
6
5
|
# * it has a mime_type
|
7
6
|
class Resource < RCAP::Base::Resource
|
8
|
-
|
9
7
|
# @return [String] Dereferenced URI - contents of URI Base64 encoded
|
10
|
-
attr_accessor(
|
8
|
+
attr_accessor(:deref_uri)
|
11
9
|
|
12
|
-
validates_presence_of(
|
10
|
+
validates_presence_of(:mime_type)
|
13
11
|
|
14
12
|
DEREF_URI_ELEMENT_NAME = 'derefUri'
|
15
13
|
|
@@ -18,13 +16,13 @@ module RCAP
|
|
18
16
|
# @return [REXML::Element]
|
19
17
|
def to_xml_element
|
20
18
|
xml_element = super
|
21
|
-
xml_element = REXML::Element.new(
|
22
|
-
xml_element.add_element(
|
23
|
-
xml_element.add_element(
|
24
|
-
xml_element.add_element(
|
25
|
-
xml_element.add_element(
|
26
|
-
xml_element.add_element(
|
27
|
-
xml_element.add_element(
|
19
|
+
xml_element = REXML::Element.new(XML_ELEMENT_NAME)
|
20
|
+
xml_element.add_element(RESOURCE_DESC_ELEMENT_NAME).add_text(@resource_desc)
|
21
|
+
xml_element.add_element(MIME_TYPE_ELEMENT_NAME).add_text(@mime_type) if @mime_type
|
22
|
+
xml_element.add_element(SIZE_ELEMENT_NAME).add_text(@size.to_s) if @size
|
23
|
+
xml_element.add_element(URI_ELEMENT_NAME).add_text(@uri) if @uri
|
24
|
+
xml_element.add_element(DEREF_URI_ELEMENT_NAME).add_text(@deref_uri) if @deref_uri
|
25
|
+
xml_element.add_element(DIGEST_ELEMENT_NAME).add_text(@digest) if @digest
|
28
26
|
xml_element
|
29
27
|
end
|
30
28
|
|
@@ -39,9 +37,9 @@ module RCAP
|
|
39
37
|
#
|
40
38
|
# @return [Array(Integer,String)]
|
41
39
|
def dereference_uri!
|
42
|
-
content = URI.parse(
|
43
|
-
@deref_uri = Base64.encode64(
|
44
|
-
|
40
|
+
content = URI.parse(uri).read
|
41
|
+
@deref_uri = Base64.encode64(content)
|
42
|
+
calculate_hash_and_size
|
45
43
|
end
|
46
44
|
|
47
45
|
# @return [String]
|
@@ -51,31 +49,31 @@ module RCAP
|
|
51
49
|
|
52
50
|
# @param [REXML::Element] resource_xml_element
|
53
51
|
# @return [Resource]
|
54
|
-
def self.from_xml_element(
|
52
|
+
def self.from_xml_element(resource_xml_element)
|
55
53
|
super.tap do |resource|
|
56
|
-
resource.deref_uri = RCAP.xpath_text(
|
54
|
+
resource.deref_uri = RCAP.xpath_text(resource_xml_element, DEREF_URI_XPATH, resource.xmlns)
|
57
55
|
end
|
58
56
|
end
|
59
57
|
|
60
|
-
DEREF_URI_YAML =
|
58
|
+
DEREF_URI_YAML = 'Derefrenced URI Data'
|
61
59
|
|
62
60
|
# @param [Hash] options
|
63
61
|
# @return [String]
|
64
|
-
def to_yaml(
|
62
|
+
def to_yaml(options = {})
|
65
63
|
RCAP.attribute_values_to_hash(
|
66
|
-
[
|
67
|
-
[
|
68
|
-
[
|
69
|
-
[
|
70
|
-
[
|
71
|
-
[
|
64
|
+
[RESOURCE_DESC_YAML, @resource_desc],
|
65
|
+
[URI_YAML, @uri],
|
66
|
+
[MIME_TYPE_YAML, @mime_type],
|
67
|
+
[DEREF_URI_YAML, @deref_uri],
|
68
|
+
[SIZE_YAML, @size],
|
69
|
+
[DIGEST_YAML, @digest]).to_yaml(options)
|
72
70
|
end
|
73
71
|
|
74
72
|
# @param [Hash] resource_yaml_data
|
75
73
|
# @return [Resource]
|
76
|
-
def self.from_yaml_data(
|
74
|
+
def self.from_yaml_data(resource_yaml_data)
|
77
75
|
super.tap do |resource|
|
78
|
-
resource.deref_uri = resource_yaml_data[
|
76
|
+
resource.deref_uri = resource_yaml_data[DEREF_URI_YAML].strip if resource_yaml_data[DEREF_URI_YAML]
|
79
77
|
end
|
80
78
|
end
|
81
79
|
|
@@ -83,19 +81,19 @@ module RCAP
|
|
83
81
|
|
84
82
|
# @return [Hash]
|
85
83
|
def to_h
|
86
|
-
RCAP.attribute_values_to_hash(
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
84
|
+
RCAP.attribute_values_to_hash([RESOURCE_DESC_KEY, @resource_desc],
|
85
|
+
[URI_KEY, @uri],
|
86
|
+
[MIME_TYPE_KEY, @mime_type],
|
87
|
+
[DEREF_URI_KEY, @deref_uri],
|
88
|
+
[SIZE_KEY, @size],
|
89
|
+
[DIGEST_KEY, @digest])
|
92
90
|
end
|
93
91
|
|
94
92
|
# @param [Hash] resource_hash
|
95
93
|
# @return [Resource]
|
96
|
-
def self.from_h(
|
94
|
+
def self.from_h(resource_hash)
|
97
95
|
super.tap do |resource|
|
98
|
-
resource.deref_uri = resource_hash[
|
96
|
+
resource.deref_uri = resource_hash[DEREF_URI_KEY].strip if resource_hash[DEREF_URI_KEY]
|
99
97
|
end
|
100
98
|
end
|
101
99
|
end
|
data/lib/rcap/config.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module RCAP
|
2
|
-
XML_PRETTY_PRINTER = REXML::Formatters::Pretty.new(
|
2
|
+
XML_PRETTY_PRINTER = REXML::Formatters::Pretty.new(2)
|
3
3
|
XML_PRETTY_PRINTER.compact = true
|
4
4
|
|
5
|
-
RCAP_TIME_FORMAT =
|
6
|
-
RCAP_ZONE_FORMAT =
|
5
|
+
RCAP_TIME_FORMAT = '%Y-%m-%dT%H:%M:%S'
|
6
|
+
RCAP_ZONE_FORMAT = '%+03i:00'
|
7
7
|
end
|
@@ -1,20 +1,19 @@
|
|
1
1
|
module Validation
|
2
2
|
module ClassMethods
|
3
|
-
|
4
|
-
|
5
|
-
CAP_INTEGER_REGEX = Regexp.new( '\-{0,1}A[+-]?\d+\Z' )
|
3
|
+
CAP_NUMBER_REGEX = Regexp.new('^-{0,1}\d*\.{0,1}\d+$')
|
4
|
+
CAP_INTEGER_REGEX = Regexp.new('\-{0,1}A[+-]?\d+\Z')
|
6
5
|
|
7
6
|
# @example
|
8
7
|
# validates_inclusion_of( :status, :in => VALID_STATUSES )
|
9
|
-
def validates_inclusion_of(
|
8
|
+
def validates_inclusion_of(*attributes)
|
10
9
|
options = {
|
11
|
-
:
|
12
|
-
}.merge!(
|
10
|
+
message: 'is not in the required range'
|
11
|
+
}.merge!(attributes.extract_options!)
|
13
12
|
|
14
|
-
validates_each(
|
15
|
-
next if
|
16
|
-
unless options[
|
17
|
-
object.errors[
|
13
|
+
validates_each(*attributes) do |object, attribute, value|
|
14
|
+
next if value.nil? && options[:allow_nil]
|
15
|
+
unless options[:in].include?(value)
|
16
|
+
object.errors[attribute] << options[:message]
|
18
17
|
end
|
19
18
|
end
|
20
19
|
end
|
@@ -22,134 +21,131 @@ module Validation
|
|
22
21
|
# Will validate all members of a collection are found in a given collection.
|
23
22
|
# @example
|
24
23
|
# validates_inclusion_of_members_of( :categories, :in => VALID_CATEGORIES )
|
25
|
-
def validates_inclusion_of_members_of(
|
24
|
+
def validates_inclusion_of_members_of(*attributes)
|
26
25
|
options = {
|
27
|
-
:
|
28
|
-
}.merge!(
|
26
|
+
message: 'contains members that are not valid'
|
27
|
+
}.merge!(attributes.extract_options!)
|
29
28
|
|
30
|
-
validates_each(
|
31
|
-
next if ( collection.nil? && options[
|
32
|
-
unless collection.all?{ |member| options[
|
33
|
-
object.errors[
|
29
|
+
validates_each(*attributes) do |object, attribute, collection|
|
30
|
+
next if ( collection.nil? && options[:allow_nil]) || ( collection.empty? && options[:allow_empty])
|
31
|
+
unless collection.all? { |member| options[:in].include?(member) }
|
32
|
+
object.errors[attribute] << options[:message]
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
38
|
-
def validates_length_of_members_of(
|
37
|
+
def validates_length_of_members_of(*attributes)
|
39
38
|
options = {
|
40
|
-
:
|
41
|
-
}.merge!(
|
39
|
+
message: 'contains members with incorrect length'
|
40
|
+
}.merge!(attributes.extract_options!)
|
42
41
|
|
43
|
-
validates_each(
|
44
|
-
next if ( collection.nil? && options[
|
45
|
-
unless options[
|
46
|
-
object.errors[
|
42
|
+
validates_each(*attributes) do |object, attribute, collection|
|
43
|
+
next if ( collection.nil? && options[:allow_nil]) || ( collection.empty? && options[:allow_empty])
|
44
|
+
unless options[:minimum] && collection.length >= options[:minimum]
|
45
|
+
object.errors[attribute] << options[:message]
|
47
46
|
end
|
48
47
|
end
|
49
48
|
end
|
50
49
|
|
51
|
-
def validates_validity_of(
|
50
|
+
def validates_validity_of(*attributes)
|
52
51
|
options = {
|
53
|
-
:
|
54
|
-
}.merge!(
|
52
|
+
message: 'is not valid'
|
53
|
+
}.merge!(attributes.extract_options!)
|
55
54
|
|
56
|
-
validates_each(
|
57
|
-
next if
|
55
|
+
validates_each(*attributes) do |object, attribute, value|
|
56
|
+
next if value.nil? && options[:allow_nil]
|
58
57
|
unless value && value.valid?
|
59
|
-
object.errors[
|
58
|
+
object.errors[attribute] << options[:message]
|
60
59
|
end
|
61
60
|
end
|
62
61
|
end
|
63
62
|
|
64
|
-
def validates_collection_of(
|
63
|
+
def validates_collection_of(*attributes)
|
65
64
|
options = {
|
66
|
-
:
|
67
|
-
}.merge!(
|
65
|
+
message: 'contains an invalid element'
|
66
|
+
}.merge!(attributes.extract_options!)
|
68
67
|
|
69
|
-
validates_each(
|
70
|
-
next if ( collection.nil? && options[
|
71
|
-
unless collection.all?{ |element| element.valid? }
|
72
|
-
object.errors[
|
68
|
+
validates_each(*attributes) do |object, attribute, collection|
|
69
|
+
next if ( collection.nil? && options[:allow_nil]) || ( collection.empty? && options[:allow_empty])
|
70
|
+
unless collection.all? { |element| element.valid? }
|
71
|
+
object.errors[attribute] << options[:message]
|
73
72
|
end
|
74
73
|
end
|
75
74
|
end
|
76
75
|
|
77
|
-
def validates_dependency_of(
|
76
|
+
def validates_dependency_of(*attributes)
|
78
77
|
options = {
|
79
|
-
:
|
80
|
-
}.merge!(
|
78
|
+
message: 'is dependent on :attribute being defined'
|
79
|
+
}.merge!(attributes.extract_options!)
|
81
80
|
|
82
|
-
validates_each(
|
81
|
+
validates_each(*attributes) do |object, attribute, value|
|
83
82
|
next if value.blank?
|
84
|
-
contingent_on_attribute = object.send(
|
85
|
-
contingent_on_attribute_value = options[
|
83
|
+
contingent_on_attribute = object.send(options[:on])
|
84
|
+
contingent_on_attribute_value = options[:with_value]
|
86
85
|
|
87
86
|
if contingent_on_attribute.nil? || !contingent_on_attribute_value.nil? && contingent_on_attribute_value != contingent_on_attribute
|
88
|
-
object.errors[
|
87
|
+
object.errors[attribute] << options[:message].gsub(/:attribute/, options[:on].to_s)
|
89
88
|
end
|
90
89
|
end
|
91
90
|
end
|
92
91
|
|
93
|
-
def validates_conditional_presence_of(
|
92
|
+
def validates_conditional_presence_of(*attributes)
|
94
93
|
options = {
|
95
|
-
:
|
96
|
-
}.merge!(
|
94
|
+
message: 'is not defined but is required by :contingent_attribute'
|
95
|
+
}.merge!(attributes.extract_options!)
|
97
96
|
|
98
|
-
validates_each(
|
99
|
-
contingent_attribute_value = object.send(
|
100
|
-
required_contingent_attribute_value = options[
|
97
|
+
validates_each(*attributes) do |object, attribute, value|
|
98
|
+
contingent_attribute_value = object.send(options[:when])
|
99
|
+
required_contingent_attribute_value = options[:is]
|
101
100
|
|
102
|
-
next if contingent_attribute_value.nil? || contingent_attribute_value != required_contingent_attribute_value && !options[
|
101
|
+
next if contingent_attribute_value.nil? || contingent_attribute_value != required_contingent_attribute_value && !options[:is].blank?
|
103
102
|
if value.blank?
|
104
|
-
object.errors[
|
103
|
+
object.errors[attribute] << options[:message].gsub(/:contingent_attribute/, options[:whenn].to_s)
|
105
104
|
end
|
106
105
|
end
|
107
106
|
end
|
108
107
|
|
109
|
-
|
110
|
-
def validates_numericality_of( *attributes )
|
108
|
+
def validates_numericality_of(*attributes)
|
111
109
|
options = {
|
112
|
-
:
|
110
|
+
message: 'is not a number or does not meet a conditional requirement',
|
113
111
|
}.merge!(attributes.extract_options!)
|
114
112
|
|
115
113
|
re = options[:only_integer] ? CAP_INTEGER_REGEX : CAP_NUMBER_REGEX
|
116
114
|
|
117
|
-
validates_each(
|
118
|
-
next if
|
119
|
-
unless ( value.to_s =~ re
|
120
|
-
( options[
|
121
|
-
( options[
|
122
|
-
object.errors[
|
115
|
+
validates_each(*attributes) do |object, attribute, value|
|
116
|
+
next if value.nil? && options[:allow_nil]
|
117
|
+
unless ( value.to_s =~ re) &&
|
118
|
+
( options[:greater_than].nil? || value && value > options[:greater_than]) &&
|
119
|
+
( options[:greater_than_or_equal].nil? || value && value >= options[:greater_than_or_equal])
|
120
|
+
object.errors[attribute] << options[:message]
|
123
121
|
end
|
124
122
|
end
|
125
123
|
end
|
126
124
|
|
127
|
-
|
128
|
-
def validates_responsiveness_of( *attributes )
|
125
|
+
def validates_responsiveness_of(*attributes)
|
129
126
|
options = {
|
130
|
-
:
|
131
|
-
}.merge!(
|
127
|
+
message: 'does not respond to the given method'
|
128
|
+
}.merge!(attributes.extract_options!)
|
132
129
|
|
133
|
-
validates_each(
|
134
|
-
next if
|
135
|
-
unless options[
|
136
|
-
object.errors[
|
130
|
+
validates_each(*attributes) do |object, attribute, _value|
|
131
|
+
next if collection.nil? && options[:allow_nil]
|
132
|
+
unless options[:to].all? { |method_name| object.respond_to?(method_name) }
|
133
|
+
object.errors[attribute] << options [:message]
|
137
134
|
end
|
138
135
|
end
|
139
136
|
end
|
140
137
|
|
141
|
-
def validates_equality_of_first_and_last(
|
138
|
+
def validates_equality_of_first_and_last(*attributes)
|
142
139
|
options = {
|
143
|
-
:
|
144
|
-
}.merge!(
|
140
|
+
message: 'does not have equal first and last elements'
|
141
|
+
}.merge!(attributes.extract_options!)
|
145
142
|
|
146
|
-
validates_each(
|
147
|
-
next if
|
143
|
+
validates_each(*attributes) do |object, attribute, collection|
|
144
|
+
next if collection.nil? && options[:allow_nil]
|
148
145
|
unless collection.first == collection.last
|
149
|
-
object.errors[
|
146
|
+
object.errors[attribute] << options[:message]
|
150
147
|
end
|
151
148
|
end
|
152
149
|
end
|
153
150
|
end
|
154
151
|
end
|
155
|
-
|
@@ -6,7 +6,7 @@ class Array
|
|
6
6
|
# [ "one", "two words", "three" ].to_s_for_cap # => "one \"two words\" three"
|
7
7
|
# @see String#unpack_cap_list
|
8
8
|
def to_s_for_cap
|
9
|
-
|
9
|
+
map { |element| element.to_s.for_cap_list }.join(' ')
|
10
10
|
end
|
11
11
|
|
12
12
|
def blank?
|
data/lib/rcap/extensions/date.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
class Date
|
2
|
-
|
2
|
+
alias_method :inspect, :to_s
|
3
3
|
|
4
4
|
# Returns a string representaion of the time suitable for CAP.
|
5
5
|
# @return [String]
|
6
6
|
# @example
|
7
7
|
# Date.today.to_s_for_cap # => "2011-10-26T00:00:00+00:00"
|
8
8
|
def to_s_for_cap
|
9
|
-
|
9
|
+
to_datetime.to_s_for_cap
|
10
10
|
end
|
11
11
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class DateTime
|
2
|
-
|
2
|
+
alias_method :inspect, :to_s
|
3
3
|
|
4
4
|
# Returns a string representaion of the time suitable for CAP.
|
5
5
|
# @return [String]
|
6
6
|
# @example
|
7
7
|
# DateTime.now.to_s_for_cap # => "2011-10-26T21:45:00+02:00"
|
8
8
|
def to_s_for_cap
|
9
|
-
t =
|
9
|
+
t = strftime(RCAP::RCAP_TIME_FORMAT) + format(RCAP::RCAP_ZONE_FORMAT, utc_hours_offset)
|
10
10
|
t.sub(/\+(00:\d\d)$/, '-\1')
|
11
11
|
end
|
12
12
|
|
@@ -16,6 +16,6 @@ class DateTime
|
|
16
16
|
|
17
17
|
private
|
18
18
|
def utc_hours_offset
|
19
|
-
|
19
|
+
offset * 24
|
20
20
|
end
|
21
21
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class String
|
2
|
-
CAP_LIST_REGEX = Regexp.new(
|
2
|
+
CAP_LIST_REGEX = Regexp.new('"([\w\s]+)"|(\S+)')
|
3
3
|
WHITESPACE_REGEX = Regexp.new('^\s+$')
|
4
4
|
|
5
5
|
# Reformats string for a CAP list. If the string contains whitespace it will
|
@@ -11,7 +11,7 @@ class String
|
|
11
11
|
# "two words".for_cap_list # => "\"two words\""
|
12
12
|
def for_cap_list
|
13
13
|
if self =~ /\s/
|
14
|
-
'"'+self+'"'
|
14
|
+
'"' + self + '"'
|
15
15
|
else
|
16
16
|
self
|
17
17
|
end
|
@@ -24,7 +24,7 @@ class String
|
|
24
24
|
# "one \"two words\" three".unpack_cap_list # => [ "one", "two words", "three" ]
|
25
25
|
# @see Array#to_s_for_cap
|
26
26
|
def unpack_cap_list
|
27
|
-
|
27
|
+
split(CAP_LIST_REGEX).reject { |match| match == '' || match =~ WHITESPACE_REGEX }
|
28
28
|
end
|
29
29
|
|
30
30
|
def blank?
|