aixm 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,6 +34,96 @@ describe AIXM::Refinements do
34
34
  [nil].to_digest.must_equal "cf83e135"
35
35
  end
36
36
  end
37
+
38
+ describe :to_uuid do
39
+ it "must digest single string" do
40
+ %w(a).to_uuid.must_equal "0cc175b9-c0f1-b6a8-31c3-99e269772661"
41
+ end
42
+
43
+ it "must digest double string" do
44
+ %w(a b).to_uuid.must_equal "d0726241-0206-76b1-4aa6-298ce6a18b21"
45
+ end
46
+
47
+ it "must digest integer" do
48
+ [5].to_uuid.must_equal "e4da3b7f-bbce-2345-d777-2b0674a318d5"
49
+ end
50
+
51
+ it "must digest nested array" do
52
+ [1, [2, 3]].to_uuid.must_equal "02b12e93-0c8b-cc7e-92e7-4ff5d96ce118"
53
+ end
54
+
55
+ it "must digest float" do
56
+ [5.0].to_uuid.must_equal "336669db-e720-233e-d557-7ddf81b653d3"
57
+ end
58
+
59
+ it "must digest boolean" do
60
+ [true, false].to_uuid.must_equal "215c2d45-b491-f5c8-15ac-e782ce450fdf"
61
+ end
62
+
63
+ it "must digest nil" do
64
+ [nil].to_uuid.must_equal "d41d8cd9-8f00-b204-e980-0998ecf8427e"
65
+ end
66
+ end
67
+ end
68
+
69
+ context Float do
70
+ describe :to_dms do
71
+ it "must convert +1. DD to DMS" do
72
+ 1.37595556.to_dms.must_equal %q(001°22'33.44")
73
+ end
74
+
75
+ it "must convert -1. DD to DMS" do
76
+ -1.37595556.to_dms.must_equal %q(-001°22'33.44")
77
+ end
78
+
79
+ it "must convert +2. DD to DMS" do
80
+ 11.37595556.to_dms.must_equal %q(011°22'33.44")
81
+ end
82
+
83
+ it "must convert -2. DD to DMS" do
84
+ -11.37595556.to_dms.must_equal %q(-011°22'33.44")
85
+ end
86
+
87
+ it "must convert +3. DD to DMS" do
88
+ 111.37595556.to_dms.must_equal %q(111°22'33.44")
89
+ end
90
+
91
+ it "must convert -3. DD to DMS" do
92
+ -111.37595556.to_dms.must_equal %q(-111°22'33.44")
93
+ end
94
+
95
+ it "must convert DD to DMS with degrees only" do
96
+ 11.0.to_dms.must_equal %q(011°00'00.00")
97
+ end
98
+
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")
101
+ end
102
+
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")
105
+ end
106
+
107
+ it "must convert DD to DMS with whole seconds only" do
108
+ 1.37583333.to_dms.must_equal %q(001°22'33.00")
109
+ end
110
+
111
+ it "must convert DD to two zero padded DMS" do
112
+ 1.37595556.to_dms(2).must_equal %q(01°22'33.44")
113
+ end
114
+
115
+ it "must convert DD to no zero padded DMS" do
116
+ 1.37595556.to_dms(0).must_equal %q(1°22'33.44")
117
+ end
118
+ end
119
+
120
+ describe :to_rad do
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)
125
+ end
126
+ end
37
127
  end
38
128
 
39
129
  context Hash do
@@ -77,12 +167,6 @@ describe AIXM::Refinements do
77
167
  end
78
168
  end
79
169
 
80
- describe :uptrans do
81
- it "must transliterate invalid characters" do
82
- 'DÉJÀ SCHÖN'.uptrans.must_equal 'DEJA SCHOEN'
83
- end
84
- end
85
-
86
170
  describe :to_dd do
87
171
  it "must convert +6.2 DMS to DD" do
88
172
  %q(12°34'56.78").to_dd.must_equal 12.58243888888889
@@ -173,82 +257,22 @@ describe AIXM::Refinements do
173
257
  end
174
258
  end
175
259
  end
176
- end
177
-
178
- context Float do
179
- describe :to_rad do
180
- it "must convert correctly" do
181
- 0.0.to_rad.must_equal 0
182
- 180.0.to_rad.must_equal Math::PI
183
- -123.0.to_rad.must_equal(-2.1467549799530254)
184
- end
185
- end
186
-
187
- describe :to_dms do
188
- it "must convert +1. DD to DMS" do
189
- 1.37595556.to_dms.must_equal %q(001°22'33.44")
190
- end
191
-
192
- it "must convert -1. DD to DMS" do
193
- -1.37595556.to_dms.must_equal %q(-001°22'33.44")
194
- end
195
-
196
- it "must convert +2. DD to DMS" do
197
- 11.37595556.to_dms.must_equal %q(011°22'33.44")
198
- end
199
-
200
- it "must convert -2. DD to DMS" do
201
- -11.37595556.to_dms.must_equal %q(-011°22'33.44")
202
- end
203
-
204
- it "must convert +3. DD to DMS" do
205
- 111.37595556.to_dms.must_equal %q(111°22'33.44")
206
- end
207
-
208
- it "must convert -3. DD to DMS" do
209
- -111.37595556.to_dms.must_equal %q(-111°22'33.44")
210
- end
211
-
212
- it "must convert DD to DMS with degrees only" do
213
- 11.0.to_dms.must_equal %q(011°00'00.00")
214
- end
215
-
216
- it "must convert DD to DMS with degrees and minutes only" do
217
- 11.36666667.to_dms.must_equal %q(011°22'00.00")
218
- end
219
-
220
- it "must convert DD to DMS with tenth of seconds only" do
221
- 1.37594444.to_dms.must_equal %q(001°22'33.40")
222
- end
223
-
224
- it "must convert DD to DMS with whole seconds only" do
225
- 1.37583333.to_dms.must_equal %q(001°22'33.00")
226
- end
227
260
 
228
- it "must convert DD to two zero padded DMS" do
229
- 1.37595556.to_dms(2).must_equal %q(01°22'33.44")
261
+ describe :to_time do
262
+ it "must convert valid dates and times" do
263
+ subject = '2018-01-01 17:17 +00:00'
264
+ subject.to_time.must_equal Time.parse(subject)
230
265
  end
231
266
 
232
- it "must convert DD to no zero padded DMS" do
233
- 1.37595556.to_dms(0).must_equal %q(1°22'33.44")
267
+ it "fails on invalid dates and times" do
268
+ subject = '2018-01-77 17:17 +00:00'
269
+ -> { subject.to_time }.must_raise ArgumentError
234
270
  end
235
271
  end
236
272
 
237
- describe :to_km do
238
- it "must convert km to km" do
239
- 10.3.to_km(from: :km).must_equal 10.3
240
- end
241
-
242
- it "must convert m to km" do
243
- 10700.0.to_km(from: :m).must_be_close_to 10.7
244
- end
245
-
246
- it "must convert nm to km" do
247
- 3.7.to_km(from: :nm).must_be_close_to 6.8524
248
- end
249
-
250
- it "must convert ft to km" do
251
- 3200.0.to_km(from: :ft).must_be_close_to 0.97536
273
+ describe :uptrans do
274
+ it "must transliterate invalid characters" do
275
+ 'DÉJÀ SCHÖN'.uptrans.must_equal 'DEJA SCHOEN'
252
276
  end
253
277
  end
254
278
  end
@@ -137,12 +137,12 @@ describe AIXM::XY do
137
137
  end
138
138
 
139
139
  it "calculates the distance between the same point as zero" do
140
- subject.distance(subject).must_equal 0
140
+ subject.distance(subject).must_equal AIXM.d(0, :m)
141
141
  end
142
142
 
143
- it "calculates the distance between two points correctly in meters" do
143
+ it "calculates the distance between two points correctly" do
144
144
  other = AIXM.xy(lat: %q(43°59'25.31"N), long: %q(004°45'23.24"E))
145
- subject.distance(other).must_equal 1351
145
+ subject.distance(other).must_equal AIXM.d(1351, :m)
146
146
  end
147
147
  end
148
148
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aixm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Schwyn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-28 00:00:00.000000000 Z
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -183,6 +183,7 @@ files:
183
183
  - lib/aixm/component/timetable.rb
184
184
  - lib/aixm/component/vertical_limits.rb
185
185
  - lib/aixm/config.rb
186
+ - lib/aixm/d.rb
186
187
  - lib/aixm/document.rb
187
188
  - lib/aixm/errors.rb
188
189
  - lib/aixm/f.rb
@@ -196,6 +197,8 @@ files:
196
197
  - lib/aixm/feature/navigational_aid/ndb.rb
197
198
  - lib/aixm/feature/navigational_aid/tacan.rb
198
199
  - lib/aixm/feature/navigational_aid/vor.rb
200
+ - lib/aixm/feature/obstacle.rb
201
+ - lib/aixm/feature/obstacle_group.rb
199
202
  - lib/aixm/feature/organisation.rb
200
203
  - lib/aixm/feature/unit.rb
201
204
  - lib/aixm/refinements.rb
@@ -225,6 +228,7 @@ files:
225
228
  - spec/lib/aixm/component/timetable_spec.rb
226
229
  - spec/lib/aixm/component/vertical_limits_spec.rb
227
230
  - spec/lib/aixm/config_spec.rb
231
+ - spec/lib/aixm/d_spec.rb
228
232
  - spec/lib/aixm/document_spec.rb
229
233
  - spec/lib/aixm/errors_spec.rb
230
234
  - spec/lib/aixm/f_spec.rb
@@ -237,6 +241,8 @@ files:
237
241
  - spec/lib/aixm/feature/navigational_aid/tacan_spec.rb
238
242
  - spec/lib/aixm/feature/navigational_aid/vor_spec.rb
239
243
  - spec/lib/aixm/feature/navigational_aid_spec.rb
244
+ - spec/lib/aixm/feature/obstacle_group_spec.rb
245
+ - spec/lib/aixm/feature/obstacle_spec.rb
240
246
  - spec/lib/aixm/feature/organisation_spec.rb
241
247
  - spec/lib/aixm/feature/unit_spec.rb
242
248
  - spec/lib/aixm/feature_spec.rb
@@ -291,6 +297,7 @@ test_files:
291
297
  - spec/lib/aixm/component/timetable_spec.rb
292
298
  - spec/lib/aixm/component/vertical_limits_spec.rb
293
299
  - spec/lib/aixm/config_spec.rb
300
+ - spec/lib/aixm/d_spec.rb
294
301
  - spec/lib/aixm/document_spec.rb
295
302
  - spec/lib/aixm/errors_spec.rb
296
303
  - spec/lib/aixm/f_spec.rb
@@ -303,6 +310,8 @@ test_files:
303
310
  - spec/lib/aixm/feature/navigational_aid/tacan_spec.rb
304
311
  - spec/lib/aixm/feature/navigational_aid/vor_spec.rb
305
312
  - spec/lib/aixm/feature/navigational_aid_spec.rb
313
+ - spec/lib/aixm/feature/obstacle_group_spec.rb
314
+ - spec/lib/aixm/feature/obstacle_spec.rb
306
315
  - spec/lib/aixm/feature/organisation_spec.rb
307
316
  - spec/lib/aixm/feature/unit_spec.rb
308
317
  - spec/lib/aixm/feature_spec.rb