aixm 0.3.7 → 0.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +26 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +17 -4
- data/README.md +23 -5
- data/lib/aixm/component/fato.rb +3 -3
- data/lib/aixm/component/frequency.rb +1 -1
- data/lib/aixm/component/geometry/border.rb +9 -3
- data/lib/aixm/component/helipad.rb +1 -1
- data/lib/aixm/component/lighting.rb +1 -1
- data/lib/aixm/component/runway.rb +4 -7
- data/lib/aixm/config.rb +2 -1
- data/lib/aixm/document.rb +1 -0
- data/lib/aixm/feature/address.rb +1 -1
- data/lib/aixm/feature/airport.rb +13 -4
- data/lib/aixm/feature/airspace.rb +11 -8
- data/lib/aixm/feature/navigational_aid/designated_point.rb +1 -1
- data/lib/aixm/feature/navigational_aid/dme.rb +1 -1
- data/lib/aixm/feature/navigational_aid/marker.rb +1 -1
- data/lib/aixm/feature/navigational_aid/ndb.rb +1 -1
- data/lib/aixm/feature/navigational_aid/tacan.rb +1 -1
- data/lib/aixm/feature/navigational_aid/vor.rb +1 -1
- data/lib/aixm/feature/obstacle.rb +1 -1
- data/lib/aixm/feature/obstacle_group.rb +1 -1
- data/lib/aixm/feature/organisation.rb +1 -1
- data/lib/aixm/feature/service.rb +1 -1
- data/lib/aixm/feature/unit.rb +1 -1
- data/lib/aixm/refinements.rb +39 -8
- data/lib/aixm/version.rb +1 -1
- data/rakefile.rb +22 -8
- data/spec/lib/aixm/a_spec.rb +55 -55
- data/spec/lib/aixm/component/fato_spec.rb +30 -23
- data/spec/lib/aixm/component/frequency_spec.rb +12 -13
- data/spec/lib/aixm/component/geometry/arc_spec.rb +7 -9
- data/spec/lib/aixm/component/geometry/border_spec.rb +8 -3
- data/spec/lib/aixm/component/geometry/circle_spec.rb +6 -8
- data/spec/lib/aixm/component/geometry/point_spec.rb +2 -4
- data/spec/lib/aixm/component/geometry_spec.rb +57 -62
- data/spec/lib/aixm/component/helipad_spec.rb +25 -19
- data/spec/lib/aixm/component/layer_spec.rb +17 -19
- data/spec/lib/aixm/component/lighting_spec.rb +21 -15
- data/spec/lib/aixm/component/runway_spec.rb +44 -37
- data/spec/lib/aixm/component/surface_spec.rb +24 -24
- data/spec/lib/aixm/component/timetable_spec.rb +7 -9
- data/spec/lib/aixm/component/vertical_limits_spec.rb +9 -12
- data/spec/lib/aixm/config_spec.rb +8 -8
- data/spec/lib/aixm/d_spec.rb +28 -28
- data/spec/lib/aixm/document_spec.rb +46 -37
- data/spec/lib/aixm/errors_spec.rb +2 -2
- data/spec/lib/aixm/f_spec.rb +16 -16
- data/spec/lib/aixm/feature/address_spec.rb +12 -7
- data/spec/lib/aixm/feature/airport_spec.rb +80 -74
- data/spec/lib/aixm/feature/airspace_spec.rb +32 -28
- data/spec/lib/aixm/feature/navigational_aid/designated_point_spec.rb +16 -11
- data/spec/lib/aixm/feature/navigational_aid/dme_spec.rb +22 -16
- data/spec/lib/aixm/feature/navigational_aid/marker_spec.rb +13 -7
- data/spec/lib/aixm/feature/navigational_aid/ndb_spec.rb +15 -9
- data/spec/lib/aixm/feature/navigational_aid/tacan_spec.rb +22 -16
- data/spec/lib/aixm/feature/navigational_aid/vor_spec.rb +21 -15
- data/spec/lib/aixm/feature/navigational_aid_spec.rb +6 -6
- data/spec/lib/aixm/feature/obstacle_group_spec.rb +25 -21
- data/spec/lib/aixm/feature/obstacle_spec.rb +47 -42
- data/spec/lib/aixm/feature/organisation_spec.rb +16 -10
- data/spec/lib/aixm/feature/service_spec.rb +9 -9
- data/spec/lib/aixm/feature/unit_spec.rb +21 -13
- data/spec/lib/aixm/feature_spec.rb +5 -5
- data/spec/lib/aixm/p_spec.rb +37 -37
- data/spec/lib/aixm/refinements_spec.rb +164 -115
- data/spec/lib/aixm/version_spec.rb +1 -1
- data/spec/lib/aixm/w_spec.rb +28 -28
- data/spec/lib/aixm/xy_spec.rb +34 -34
- data/spec/lib/aixm/z_spec.rb +19 -19
- data/spec/macros/marking.rb +3 -3
- data/spec/macros/organisation.rb +2 -2
- data/spec/macros/remarks.rb +3 -3
- data/spec/macros/timetable.rb +2 -2
- data/spec/macros/xy.rb +2 -2
- data/spec/macros/z_qnh.rb +2 -2
- data/spec/spec_helper.rb +7 -0
- metadata +3 -3
- data/.travis.yml +0 -8
@@ -7,61 +7,61 @@ describe AIXM::Refinements do
|
|
7
7
|
context Array do
|
8
8
|
describe :to_digest do
|
9
9
|
it "must digest single string" do
|
10
|
-
%w(a).to_digest.must_equal "1f40fc92"
|
10
|
+
_(%w(a).to_digest).must_equal "1f40fc92"
|
11
11
|
end
|
12
12
|
|
13
13
|
it "must digest double string" do
|
14
|
-
%w(a b).to_digest.must_equal "3c075e5f"
|
14
|
+
_(%w(a b).to_digest).must_equal "3c075e5f"
|
15
15
|
end
|
16
16
|
|
17
17
|
it "must digest integer" do
|
18
|
-
[5].to_digest.must_equal "06df0537"
|
18
|
+
_([5].to_digest).must_equal "06df0537"
|
19
19
|
end
|
20
20
|
|
21
21
|
it "must digest nested array" do
|
22
|
-
[1, [2, 3]].to_digest.must_equal "e9609e81"
|
22
|
+
_([1, [2, 3]].to_digest).must_equal "e9609e81"
|
23
23
|
end
|
24
24
|
|
25
25
|
it "must digest float" do
|
26
|
-
[5.0].to_digest.must_equal "78fc651d"
|
26
|
+
_([5.0].to_digest).must_equal "78fc651d"
|
27
27
|
end
|
28
28
|
|
29
29
|
it "must digest boolean" do
|
30
|
-
[true, false].to_digest.must_equal "79bdc67a"
|
30
|
+
_([true, false].to_digest).must_equal "79bdc67a"
|
31
31
|
end
|
32
32
|
|
33
33
|
it "must digest nil" do
|
34
|
-
[nil].to_digest.must_equal "cf83e135"
|
34
|
+
_([nil].to_digest).must_equal "cf83e135"
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
describe :to_uuid do
|
39
39
|
it "must digest single string" do
|
40
|
-
%w(a).to_uuid.must_equal "0cc175b9-c0f1-b6a8-31c3-99e269772661"
|
40
|
+
_(%w(a).to_uuid).must_equal "0cc175b9-c0f1-b6a8-31c3-99e269772661"
|
41
41
|
end
|
42
42
|
|
43
43
|
it "must digest double string" do
|
44
|
-
%w(a b).to_uuid.must_equal "d0726241-0206-76b1-4aa6-298ce6a18b21"
|
44
|
+
_(%w(a b).to_uuid).must_equal "d0726241-0206-76b1-4aa6-298ce6a18b21"
|
45
45
|
end
|
46
46
|
|
47
47
|
it "must digest integer" do
|
48
|
-
[5].to_uuid.must_equal "e4da3b7f-bbce-2345-d777-2b0674a318d5"
|
48
|
+
_([5].to_uuid).must_equal "e4da3b7f-bbce-2345-d777-2b0674a318d5"
|
49
49
|
end
|
50
50
|
|
51
51
|
it "must digest nested array" do
|
52
|
-
[1, [2, 3]].to_uuid.must_equal "02b12e93-0c8b-cc7e-92e7-4ff5d96ce118"
|
52
|
+
_([1, [2, 3]].to_uuid).must_equal "02b12e93-0c8b-cc7e-92e7-4ff5d96ce118"
|
53
53
|
end
|
54
54
|
|
55
55
|
it "must digest float" do
|
56
|
-
[5.0].to_uuid.must_equal "336669db-e720-233e-d557-7ddf81b653d3"
|
56
|
+
_([5.0].to_uuid).must_equal "336669db-e720-233e-d557-7ddf81b653d3"
|
57
57
|
end
|
58
58
|
|
59
59
|
it "must digest boolean" do
|
60
|
-
[true, false].to_uuid.must_equal "215c2d45-b491-f5c8-15ac-e782ce450fdf"
|
60
|
+
_([true, false].to_uuid).must_equal "215c2d45-b491-f5c8-15ac-e782ce450fdf"
|
61
61
|
end
|
62
62
|
|
63
63
|
it "must digest nil" do
|
64
|
-
[nil].to_uuid.must_equal "d41d8cd9-8f00-b204-e980-0998ecf8427e"
|
64
|
+
_([nil].to_uuid).must_equal "d41d8cd9-8f00-b204-e980-0998ecf8427e"
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -69,59 +69,59 @@ describe AIXM::Refinements do
|
|
69
69
|
context Float do
|
70
70
|
describe :to_dms do
|
71
71
|
it "must convert +1. DD to DMS" do
|
72
|
-
1.37595556.to_dms.must_equal %q(001°22'33.44")
|
72
|
+
_(1.37595556.to_dms).must_equal %q(001°22'33.44")
|
73
73
|
end
|
74
74
|
|
75
75
|
it "must convert -1. DD to DMS" do
|
76
|
-
-1.37595556.to_dms.must_equal %q(-001°22'33.44")
|
76
|
+
_(-1.37595556.to_dms).must_equal %q(-001°22'33.44")
|
77
77
|
end
|
78
78
|
|
79
79
|
it "must convert +2. DD to DMS" do
|
80
|
-
11.37595556.to_dms.must_equal %q(011°22'33.44")
|
80
|
+
_(11.37595556.to_dms).must_equal %q(011°22'33.44")
|
81
81
|
end
|
82
82
|
|
83
83
|
it "must convert -2. DD to DMS" do
|
84
|
-
-11.37595556.to_dms.must_equal %q(-011°22'33.44")
|
84
|
+
_(-11.37595556.to_dms).must_equal %q(-011°22'33.44")
|
85
85
|
end
|
86
86
|
|
87
87
|
it "must convert +3. DD to DMS" do
|
88
|
-
111.37595556.to_dms.must_equal %q(111°22'33.44")
|
88
|
+
_(111.37595556.to_dms).must_equal %q(111°22'33.44")
|
89
89
|
end
|
90
90
|
|
91
91
|
it "must convert -3. DD to DMS" do
|
92
|
-
-111.37595556.to_dms.must_equal %q(-111°22'33.44")
|
92
|
+
_(-111.37595556.to_dms).must_equal %q(-111°22'33.44")
|
93
93
|
end
|
94
94
|
|
95
95
|
it "must convert DD to DMS with degrees only" do
|
96
|
-
11.0.to_dms.must_equal %q(011°00'00.00")
|
96
|
+
_(11.0.to_dms).must_equal %q(011°00'00.00")
|
97
97
|
end
|
98
98
|
|
99
99
|
it "must convert DD to DMS with degrees and minutes only" do
|
100
|
-
11.36666667.to_dms.must_equal %q(011°22'00.00")
|
100
|
+
_(11.36666667.to_dms).must_equal %q(011°22'00.00")
|
101
101
|
end
|
102
102
|
|
103
103
|
it "must convert DD to DMS with tenth of seconds only" do
|
104
|
-
1.37594444.to_dms.must_equal %q(001°22'33.40")
|
104
|
+
_(1.37594444.to_dms).must_equal %q(001°22'33.40")
|
105
105
|
end
|
106
106
|
|
107
107
|
it "must convert DD to DMS with whole seconds only" do
|
108
|
-
1.37583333.to_dms.must_equal %q(001°22'33.00")
|
108
|
+
_(1.37583333.to_dms).must_equal %q(001°22'33.00")
|
109
109
|
end
|
110
110
|
|
111
111
|
it "must convert DD to two zero padded DMS" do
|
112
|
-
1.37595556.to_dms(2).must_equal %q(01°22'33.44")
|
112
|
+
_(1.37595556.to_dms(2)).must_equal %q(01°22'33.44")
|
113
113
|
end
|
114
114
|
|
115
115
|
it "must convert DD to no zero padded DMS" do
|
116
|
-
1.37595556.to_dms(0).must_equal %q(1°22'33.44")
|
116
|
+
_(1.37595556.to_dms(0)).must_equal %q(1°22'33.44")
|
117
117
|
end
|
118
118
|
end
|
119
119
|
|
120
120
|
describe :to_rad do
|
121
121
|
it "must convert correctly" do
|
122
|
-
0.0.to_rad.must_equal 0
|
123
|
-
180.0.to_rad.must_equal Math::PI
|
124
|
-
-123.0.to_rad.must_equal(-2.1467549799530254)
|
122
|
+
_(0.0.to_rad).must_equal 0
|
123
|
+
_(180.0.to_rad).must_equal Math::PI
|
124
|
+
_(-123.0.to_rad).must_equal(-2.1467549799530254)
|
125
125
|
end
|
126
126
|
end
|
127
127
|
end
|
@@ -133,24 +133,24 @@ describe AIXM::Refinements do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
it "must return value for key if key is present" do
|
136
|
-
subject.lookup(:one).must_equal 1
|
136
|
+
_(subject.lookup(:one)).must_equal 1
|
137
137
|
end
|
138
138
|
|
139
139
|
it "must return value if key is not found but value is present" do
|
140
|
-
subject.lookup(1).must_equal 1
|
140
|
+
_(subject.lookup(1)).must_equal 1
|
141
141
|
end
|
142
142
|
|
143
143
|
it "must return value for key if both key and value are present" do
|
144
|
-
subject.lookup(:three).must_equal 3
|
144
|
+
_(subject.lookup(:three)).must_equal 3
|
145
145
|
end
|
146
146
|
|
147
147
|
it "returns default if neither key nor value are present" do
|
148
|
-
subject.lookup(:foo, :default).must_equal :default
|
149
|
-
subject.lookup(:foo, nil).must_be_nil
|
148
|
+
_(subject.lookup(:foo, :default)).must_equal :default
|
149
|
+
_(subject.lookup(:foo, nil)).must_be_nil
|
150
150
|
end
|
151
151
|
|
152
152
|
it "fails if neither key, value nor default are present" do
|
153
|
-
|
153
|
+
_{ subject.lookup(:foo) }.must_raise KeyError
|
154
154
|
end
|
155
155
|
end
|
156
156
|
end
|
@@ -162,11 +162,11 @@ describe AIXM::Refinements do
|
|
162
162
|
end
|
163
163
|
|
164
164
|
it "must return self if the condition is false" do
|
165
|
-
subject.then_if(false) { |s| s.gsub(/o/, 'i') }.must_equal subject
|
165
|
+
_(subject.then_if(false) { |s| s.gsub(/o/, 'i') }).must_equal subject
|
166
166
|
end
|
167
167
|
|
168
168
|
it "must return apply the block if the condition is true" do
|
169
|
-
subject.then_if(true) { |s| s.gsub(/o/, 'i') }.must_equal 'fiibar'
|
169
|
+
_(subject.then_if(true) { |s| s.gsub(/o/, 'i') }).must_equal 'fiibar'
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
@@ -174,25 +174,25 @@ describe AIXM::Refinements do
|
|
174
174
|
context Regexp do
|
175
175
|
describe :decapture do
|
176
176
|
it "should replace capture groups with non-capture groups" do
|
177
|
-
/(foo) baz (bar)/.decapture.must_equal /(?-mix:(?:foo) baz (?:bar))/
|
178
|
-
/(foo) baz (bar)/i.decapture.must_equal /(?i-mx:(?:foo) baz (?:bar))/
|
177
|
+
_(/(foo) baz (bar)/.decapture).must_equal /(?-mix:(?:foo) baz (?:bar))/
|
178
|
+
_(/(foo) baz (bar)/i.decapture).must_equal /(?i-mx:(?:foo) baz (?:bar))/
|
179
179
|
end
|
180
180
|
|
181
181
|
it "should replace named capture groups with non-capture groups" do
|
182
|
-
/(?<a>foo) baz (?<b>bar)/.decapture.must_equal /(?-mix:(?:foo) baz (?:bar))/
|
183
|
-
/(?<a>foo) baz (?<b>bar)/i.decapture.must_equal /(?i-mx:(?:foo) baz (?:bar))/
|
182
|
+
_(/(?<a>foo) baz (?<b>bar)/.decapture).must_equal /(?-mix:(?:foo) baz (?:bar))/
|
183
|
+
_(/(?<a>foo) baz (?<b>bar)/i.decapture).must_equal /(?i-mx:(?:foo) baz (?:bar))/
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should not replace special groups" do
|
187
|
-
/(?:foo) (?<=baz) bar/.decapture.must_equal /(?-mix:(?:foo) (?<=baz) bar)/
|
187
|
+
_(/(?:foo) (?<=baz) bar/.decapture).must_equal /(?-mix:(?:foo) (?<=baz) bar)/
|
188
188
|
end
|
189
189
|
|
190
190
|
it "should not replace literal round brackets" do
|
191
|
-
/\(foo\)/.decapture.must_equal /(?-mix:\(foo\))/
|
191
|
+
_(/\(foo\)/.decapture).must_equal /(?-mix:\(foo\))/
|
192
192
|
end
|
193
193
|
|
194
194
|
it "should replace literal backslash followed by literal round brackets" do
|
195
|
-
/\\(foo\\)/.decapture.must_equal /(?-mix:\\(?:foo\\))/
|
195
|
+
_(/\\(foo\\)/.decapture).must_equal /(?-mix:\\(?:foo\\))/
|
196
196
|
end
|
197
197
|
end
|
198
198
|
end
|
@@ -200,21 +200,21 @@ describe AIXM::Refinements do
|
|
200
200
|
context String do
|
201
201
|
describe :indent do
|
202
202
|
it "must indent single line string" do
|
203
|
-
'foobar'.indent(2).must_equal ' foobar'
|
203
|
+
_('foobar'.indent(2)).must_equal ' foobar'
|
204
204
|
end
|
205
205
|
|
206
206
|
it "must indent multi line string" do
|
207
|
-
"foo\nbar".indent(2).must_equal " foo\n bar"
|
208
|
-
"foo\nbar\n".indent(2).must_equal " foo\n bar\n"
|
207
|
+
_("foo\nbar".indent(2)).must_equal " foo\n bar"
|
208
|
+
_("foo\nbar\n".indent(2)).must_equal " foo\n bar\n"
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
212
|
-
|
212
|
+
context "hash function" do
|
213
213
|
subject do
|
214
214
|
<<~END
|
215
215
|
<?xml version="1.0" encoding="utf-8"?>
|
216
216
|
<OFMX-Snapshot region="LF">
|
217
|
-
<Ser
|
217
|
+
<Ser active="true" type="essential">
|
218
218
|
<SerUid>
|
219
219
|
<UniUid>
|
220
220
|
<txtName>STRASBOURG APP</txtName>
|
@@ -234,112 +234,161 @@ describe AIXM::Refinements do
|
|
234
234
|
END
|
235
235
|
end
|
236
236
|
|
237
|
-
|
238
|
-
|
237
|
+
describe :payload_hash do
|
238
|
+
it "must calculate and return the hash" do
|
239
|
+
_(subject.payload_hash(region: 'LF', element: 'Ser')).must_equal "269b1f18-cabe-3c9e-1d71-48a7414a4cb9"
|
240
|
+
end
|
241
|
+
|
242
|
+
it "must upcase the region" do
|
243
|
+
_(subject.payload_hash(region: 'lf', element: 'Ser')).must_equal "269b1f18-cabe-3c9e-1d71-48a7414a4cb9"
|
244
|
+
end
|
245
|
+
|
246
|
+
it "must ignore name extensions of named associations" do
|
247
|
+
named_subject = subject.gsub(/<(.?)SerUid/, '<\1SerUidWithName')
|
248
|
+
_(named_subject.payload_hash(region: 'LF', element: 'SerUidWithName')).must_equal subject.payload_hash(region: 'LF', element: 'SerUid')
|
249
|
+
end
|
250
|
+
|
251
|
+
it "must ignore mid attributes" do
|
252
|
+
subject_with_mid = subject.sub(/(active="true")/, 'mid="123" \1')
|
253
|
+
_(subject_with_mid.payload_hash(region: 'LF', element: 'Ser')).must_equal "269b1f18-cabe-3c9e-1d71-48a7414a4cb9"
|
254
|
+
end
|
255
|
+
|
256
|
+
it "must ignore source attributes" do
|
257
|
+
subject_with_source = subject.sub(/(active="true")/, 'source="123" \1')
|
258
|
+
_(subject_with_source.payload_hash(region: 'LF', element: 'Ser')).must_equal "269b1f18-cabe-3c9e-1d71-48a7414a4cb9"
|
259
|
+
end
|
260
|
+
|
261
|
+
it "must order the element arguments alphabetically" do
|
262
|
+
subject_with_swap = subject.sub(/(active="true") (type="essential")/, '\2 \1')
|
263
|
+
_(subject_with_swap.payload_hash(region: 'LF', element: 'Ser')).must_equal "269b1f18-cabe-3c9e-1d71-48a7414a4cb9"
|
264
|
+
end
|
265
|
+
|
266
|
+
it "must use the first non-declaration element in string by default" do
|
267
|
+
_(subject.payload_hash(region: 'LF')).must_equal "fddbfb76-4868-0cd7-2afe-9f43e91867fb"
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
describe :insert_payload_hash do
|
272
|
+
it "must insert hash as mid attribute into element with arguments" do
|
273
|
+
_(subject.insert_payload_hash(region: 'LF', element: 'Ser')).must_match /<Ser mid="269b1f18-cabe-3c9e-1d71-48a7414a4cb9" active/
|
274
|
+
end
|
275
|
+
|
276
|
+
it "must insert hash as mid attribute into element without arguments" do
|
277
|
+
_(subject.insert_payload_hash(region: 'LF', element: 'txtRmk')).must_match /<txtRmk mid="8b23c36b-ff51-adfd-963f-03fcb012c0cf">/
|
278
|
+
end
|
279
|
+
|
280
|
+
it "must overwrite an already existing mid attribute" do
|
281
|
+
subject_with_mid = subject.sub(/(active="true")/, 'mid="123" \1')
|
282
|
+
_(subject_with_mid.insert_payload_hash(region: 'LF', element: 'Ser')).must_match /<Ser mid="269b1f18-cabe-3c9e-1d71-48a7414a4cb9" active/
|
283
|
+
end
|
284
|
+
|
285
|
+
it "must return string untouched if falsey region is passed" do
|
286
|
+
_(subject.insert_payload_hash(region: nil)).must_equal subject
|
287
|
+
end
|
239
288
|
end
|
240
289
|
end
|
241
290
|
|
242
291
|
describe :to_dd do
|
243
292
|
it "must convert +6.2 DMS to DD" do
|
244
|
-
%q(12°34'56.78"N).to_dd.must_equal 12.58243888888889
|
245
|
-
%q(12°34'56.78").to_dd.must_equal 12.58243888888889
|
246
|
-
%q(12°34'56.78'').to_dd.must_equal 12.58243888888889
|
247
|
-
%q(12 34 56.78).to_dd.must_equal 12.58243888888889
|
248
|
-
%q(123456.78N).to_dd.must_equal 12.58243888888889
|
293
|
+
_(%q(12°34'56.78"N).to_dd).must_equal 12.58243888888889
|
294
|
+
_(%q(12°34'56.78").to_dd).must_equal 12.58243888888889
|
295
|
+
_(%q(12°34'56.78'').to_dd).must_equal 12.58243888888889
|
296
|
+
_(%q(12 34 56.78).to_dd).must_equal 12.58243888888889
|
297
|
+
_(%q(123456.78N).to_dd).must_equal 12.58243888888889
|
249
298
|
end
|
250
299
|
|
251
300
|
it "must convert -6.2 DMS to DD" do
|
252
|
-
%q(12°34'56.78"S).to_dd.must_equal(-12.58243888888889)
|
253
|
-
%q(-12°34'56.78").to_dd.must_equal(-12.58243888888889)
|
254
|
-
%q(-12 34 56.78).to_dd.must_equal(-12.58243888888889)
|
255
|
-
%q(123456.78S).to_dd.must_equal(-12.58243888888889)
|
301
|
+
_(%q(12°34'56.78"S).to_dd).must_equal(-12.58243888888889)
|
302
|
+
_(%q(-12°34'56.78").to_dd).must_equal(-12.58243888888889)
|
303
|
+
_(%q(-12 34 56.78).to_dd).must_equal(-12.58243888888889)
|
304
|
+
_(%q(123456.78S).to_dd).must_equal(-12.58243888888889)
|
256
305
|
end
|
257
306
|
|
258
307
|
it "must convert +7.2 DMS to DD" do
|
259
|
-
%q(111°22'33.44"N).to_dd.must_equal 111.37595555555555
|
260
|
-
%q(111°22'33.44").to_dd.must_equal 111.37595555555555
|
261
|
-
%q(111 22 33.44).to_dd.must_equal 111.37595555555555
|
262
|
-
%q(1112233.44N).to_dd.must_equal 111.37595555555555
|
308
|
+
_(%q(111°22'33.44"N).to_dd).must_equal 111.37595555555555
|
309
|
+
_(%q(111°22'33.44").to_dd).must_equal 111.37595555555555
|
310
|
+
_(%q(111 22 33.44).to_dd).must_equal 111.37595555555555
|
311
|
+
_(%q(1112233.44N).to_dd).must_equal 111.37595555555555
|
263
312
|
end
|
264
313
|
|
265
314
|
it "must convert -7.2 DMS to DD" do
|
266
|
-
%q(111°22'33.44"S).to_dd.must_equal(-111.37595555555555)
|
267
|
-
%q(-111°22'33.44").to_dd.must_equal(-111.37595555555555)
|
268
|
-
%q(-111 22 33.44).to_dd.must_equal(-111.37595555555555)
|
269
|
-
%q(1112233.44S).to_dd.must_equal(-111.37595555555555)
|
315
|
+
_(%q(111°22'33.44"S).to_dd).must_equal(-111.37595555555555)
|
316
|
+
_(%q(-111°22'33.44").to_dd).must_equal(-111.37595555555555)
|
317
|
+
_(%q(-111 22 33.44).to_dd).must_equal(-111.37595555555555)
|
318
|
+
_(%q(1112233.44S).to_dd).must_equal(-111.37595555555555)
|
270
319
|
end
|
271
320
|
|
272
321
|
it "must convert +6.1 DMS to DD" do
|
273
|
-
%q(12°34'56.7"N).to_dd.must_equal 12.582416666666667
|
274
|
-
%q(12°34'56.7").to_dd.must_equal 12.582416666666667
|
275
|
-
%q(12 34 56.7).to_dd.must_equal 12.582416666666667
|
276
|
-
%q(123456.7N).to_dd.must_equal 12.582416666666667
|
322
|
+
_(%q(12°34'56.7"N).to_dd).must_equal 12.582416666666667
|
323
|
+
_(%q(12°34'56.7").to_dd).must_equal 12.582416666666667
|
324
|
+
_(%q(12 34 56.7).to_dd).must_equal 12.582416666666667
|
325
|
+
_(%q(123456.7N).to_dd).must_equal 12.582416666666667
|
277
326
|
end
|
278
327
|
|
279
328
|
it "must convert -6.1 DMS to DD" do
|
280
|
-
%q(12°34'56.7"S).to_dd.must_equal(-12.582416666666667)
|
281
|
-
%q(-12°34'56.7").to_dd.must_equal(-12.582416666666667)
|
282
|
-
%q(-12 34 56.7).to_dd.must_equal(-12.582416666666667)
|
283
|
-
%q(123456.7S).to_dd.must_equal(-12.582416666666667)
|
329
|
+
_(%q(12°34'56.7"S).to_dd).must_equal(-12.582416666666667)
|
330
|
+
_(%q(-12°34'56.7").to_dd).must_equal(-12.582416666666667)
|
331
|
+
_(%q(-12 34 56.7).to_dd).must_equal(-12.582416666666667)
|
332
|
+
_(%q(123456.7S).to_dd).must_equal(-12.582416666666667)
|
284
333
|
end
|
285
334
|
|
286
335
|
it "must convert +7.1 DMS to DD" do
|
287
|
-
%q(111°22'33.4"N).to_dd.must_equal 111.37594444444444
|
288
|
-
%q(111°22'33.4").to_dd.must_equal 111.37594444444444
|
289
|
-
%q(111 22 33.4).to_dd.must_equal 111.37594444444444
|
290
|
-
%q(1112233.4N).to_dd.must_equal 111.37594444444444
|
336
|
+
_(%q(111°22'33.4"N).to_dd).must_equal 111.37594444444444
|
337
|
+
_(%q(111°22'33.4").to_dd).must_equal 111.37594444444444
|
338
|
+
_(%q(111 22 33.4).to_dd).must_equal 111.37594444444444
|
339
|
+
_(%q(1112233.4N).to_dd).must_equal 111.37594444444444
|
291
340
|
end
|
292
341
|
|
293
342
|
it "must convert -7.1 DMS to DD" do
|
294
|
-
%q(111°22'33.4"S).to_dd.must_equal(-111.37594444444444)
|
295
|
-
%q(-111°22'33.4").to_dd.must_equal(-111.37594444444444)
|
296
|
-
%q(-111 22 33.4).to_dd.must_equal(-111.37594444444444)
|
297
|
-
%q(1112233.4S).to_dd.must_equal(-111.37594444444444)
|
343
|
+
_(%q(111°22'33.4"S).to_dd).must_equal(-111.37594444444444)
|
344
|
+
_(%q(-111°22'33.4").to_dd).must_equal(-111.37594444444444)
|
345
|
+
_(%q(-111 22 33.4).to_dd).must_equal(-111.37594444444444)
|
346
|
+
_(%q(1112233.4S).to_dd).must_equal(-111.37594444444444)
|
298
347
|
end
|
299
348
|
|
300
349
|
it "must convert +6.0 DMS to DD" do
|
301
|
-
%q(12°34'56"N).to_dd.must_equal 12.582222222222223
|
302
|
-
%q(12°34'56").to_dd.must_equal 12.582222222222223
|
303
|
-
%q(12 34 56).to_dd.must_equal 12.582222222222223
|
304
|
-
%q(123456N).to_dd.must_equal 12.582222222222223
|
350
|
+
_(%q(12°34'56"N).to_dd).must_equal 12.582222222222223
|
351
|
+
_(%q(12°34'56").to_dd).must_equal 12.582222222222223
|
352
|
+
_(%q(12 34 56).to_dd).must_equal 12.582222222222223
|
353
|
+
_(%q(123456N).to_dd).must_equal 12.582222222222223
|
305
354
|
end
|
306
355
|
|
307
356
|
it "must convert -6.0 DMS to DD" do
|
308
|
-
%q(12°34'56"S).to_dd.must_equal(-12.582222222222223)
|
309
|
-
%q(-12°34'56").to_dd.must_equal(-12.582222222222223)
|
310
|
-
%q(-12 34 56).to_dd.must_equal(-12.582222222222223)
|
311
|
-
%q(123456S).to_dd.must_equal(-12.582222222222223)
|
357
|
+
_(%q(12°34'56"S).to_dd).must_equal(-12.582222222222223)
|
358
|
+
_(%q(-12°34'56").to_dd).must_equal(-12.582222222222223)
|
359
|
+
_(%q(-12 34 56).to_dd).must_equal(-12.582222222222223)
|
360
|
+
_(%q(123456S).to_dd).must_equal(-12.582222222222223)
|
312
361
|
end
|
313
362
|
|
314
363
|
it "must convert +7.0 DMS to DD" do
|
315
|
-
%q(111°22'33"N).to_dd.must_equal 111.37583333333333
|
316
|
-
%q(111°22'33").to_dd.must_equal 111.37583333333333
|
317
|
-
%q(111 22 33).to_dd.must_equal 111.37583333333333
|
318
|
-
%q(1112233N).to_dd.must_equal 111.37583333333333
|
364
|
+
_(%q(111°22'33"N).to_dd).must_equal 111.37583333333333
|
365
|
+
_(%q(111°22'33").to_dd).must_equal 111.37583333333333
|
366
|
+
_(%q(111 22 33).to_dd).must_equal 111.37583333333333
|
367
|
+
_(%q(1112233N).to_dd).must_equal 111.37583333333333
|
319
368
|
end
|
320
369
|
|
321
370
|
it "must convert -7.0 DMS to DD" do
|
322
|
-
%q(111°22'33"S).to_dd.must_equal(-111.37583333333333)
|
323
|
-
%q(-111°22'33").to_dd.must_equal(-111.37583333333333)
|
324
|
-
%q(-111 22 33).to_dd.must_equal(-111.37583333333333)
|
325
|
-
%q(1112233S).to_dd.must_equal(-111.37583333333333)
|
371
|
+
_(%q(111°22'33"S).to_dd).must_equal(-111.37583333333333)
|
372
|
+
_(%q(-111°22'33").to_dd).must_equal(-111.37583333333333)
|
373
|
+
_(%q(-111 22 33).to_dd).must_equal(-111.37583333333333)
|
374
|
+
_(%q(1112233S).to_dd).must_equal(-111.37583333333333)
|
326
375
|
end
|
327
376
|
|
328
377
|
it "must convert all cardinal directions to DD" do
|
329
|
-
%q(111°22'33.44"N).to_dd.must_equal 111.37595555555555
|
330
|
-
%q(111°22'33.44"E).to_dd.must_equal 111.37595555555555
|
331
|
-
%q(111°22'33.44"S).to_dd.must_equal -111.37595555555555
|
332
|
-
%q(111°22'33.44"W).to_dd.must_equal -111.37595555555555
|
378
|
+
_(%q(111°22'33.44"N).to_dd).must_equal 111.37595555555555
|
379
|
+
_(%q(111°22'33.44"E).to_dd).must_equal 111.37595555555555
|
380
|
+
_(%q(111°22'33.44"S).to_dd).must_equal -111.37595555555555
|
381
|
+
_(%q(111°22'33.44"W).to_dd).must_equal -111.37595555555555
|
333
382
|
end
|
334
383
|
|
335
384
|
it "must ignore minor typos when converting to DD" do
|
336
|
-
%q(111°22'33,44"N).to_dd.must_equal 111.37595555555555
|
337
|
-
%q(111°22'33.44"n).to_dd.must_equal 111.37595555555555
|
338
|
-
%q(111°22"33.44"N).to_dd.must_equal 111.37595555555555
|
339
|
-
%q(111°22'33.44'N).to_dd.must_equal 111.37595555555555
|
340
|
-
%q(111°22'33.44" N).to_dd.must_equal 111.37595555555555
|
341
|
-
%q(111° 22' 33.44" N).to_dd.must_equal 111.37595555555555
|
342
|
-
%q(-111°22'33.44"S).to_dd.must_equal 111.37595555555555
|
385
|
+
_(%q(111°22'33,44"N).to_dd).must_equal 111.37595555555555
|
386
|
+
_(%q(111°22'33.44"n).to_dd).must_equal 111.37595555555555
|
387
|
+
_(%q(111°22"33.44"N).to_dd).must_equal 111.37595555555555
|
388
|
+
_(%q(111°22'33.44'N).to_dd).must_equal 111.37595555555555
|
389
|
+
_(%q(111°22'33.44" N).to_dd).must_equal 111.37595555555555
|
390
|
+
_(%q(111° 22' 33.44" N).to_dd).must_equal 111.37595555555555
|
391
|
+
_(%q(-111°22'33.44"S).to_dd).must_equal 111.37595555555555
|
343
392
|
end
|
344
393
|
|
345
394
|
it "must do all possible roundtrip conversions" do
|
@@ -349,7 +398,7 @@ describe AIXM::Refinements do
|
|
349
398
|
60.times.with_index do |seconds|
|
350
399
|
100.times.with_index do |fractions|
|
351
400
|
subject = %q(%03d°%02d'%02d.%02d") % [degrees, minutes, seconds, fractions]
|
352
|
-
subject.to_dd.to_dms.must_equal subject
|
401
|
+
_(subject.to_dd.to_dms).must_equal subject
|
353
402
|
end
|
354
403
|
end
|
355
404
|
end
|
@@ -363,18 +412,18 @@ describe AIXM::Refinements do
|
|
363
412
|
describe :to_time do
|
364
413
|
it "must convert valid dates and times" do
|
365
414
|
subject = '2018-01-01 17:17 +00:00'
|
366
|
-
subject.to_time.must_equal Time.parse(subject)
|
415
|
+
_(subject.to_time).must_equal Time.parse(subject)
|
367
416
|
end
|
368
417
|
|
369
418
|
it "fails on invalid dates and times" do
|
370
419
|
subject = '2018-01-77 17:17 +00:00'
|
371
|
-
|
420
|
+
_{ subject.to_time }.must_raise ArgumentError
|
372
421
|
end
|
373
422
|
end
|
374
423
|
|
375
424
|
describe :uptrans do
|
376
425
|
it "must transliterate invalid characters" do
|
377
|
-
'DÉJÀ SCHÖN'.uptrans.must_equal 'DEJA SCHOEN'
|
426
|
+
_('DÉJÀ SCHÖN'.uptrans).must_equal 'DEJA SCHOEN'
|
378
427
|
end
|
379
428
|
end
|
380
429
|
end
|