aixm 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +26 -0
  3. data/.ruby-version +1 -1
  4. data/CHANGELOG.md +17 -4
  5. data/README.md +23 -5
  6. data/lib/aixm/component/fato.rb +3 -3
  7. data/lib/aixm/component/frequency.rb +1 -1
  8. data/lib/aixm/component/geometry/border.rb +9 -3
  9. data/lib/aixm/component/helipad.rb +1 -1
  10. data/lib/aixm/component/lighting.rb +1 -1
  11. data/lib/aixm/component/runway.rb +4 -7
  12. data/lib/aixm/config.rb +2 -1
  13. data/lib/aixm/document.rb +1 -0
  14. data/lib/aixm/feature/address.rb +1 -1
  15. data/lib/aixm/feature/airport.rb +13 -4
  16. data/lib/aixm/feature/airspace.rb +11 -8
  17. data/lib/aixm/feature/navigational_aid/designated_point.rb +1 -1
  18. data/lib/aixm/feature/navigational_aid/dme.rb +1 -1
  19. data/lib/aixm/feature/navigational_aid/marker.rb +1 -1
  20. data/lib/aixm/feature/navigational_aid/ndb.rb +1 -1
  21. data/lib/aixm/feature/navigational_aid/tacan.rb +1 -1
  22. data/lib/aixm/feature/navigational_aid/vor.rb +1 -1
  23. data/lib/aixm/feature/obstacle.rb +1 -1
  24. data/lib/aixm/feature/obstacle_group.rb +1 -1
  25. data/lib/aixm/feature/organisation.rb +1 -1
  26. data/lib/aixm/feature/service.rb +1 -1
  27. data/lib/aixm/feature/unit.rb +1 -1
  28. data/lib/aixm/refinements.rb +39 -8
  29. data/lib/aixm/version.rb +1 -1
  30. data/rakefile.rb +22 -8
  31. data/spec/lib/aixm/a_spec.rb +55 -55
  32. data/spec/lib/aixm/component/fato_spec.rb +30 -23
  33. data/spec/lib/aixm/component/frequency_spec.rb +12 -13
  34. data/spec/lib/aixm/component/geometry/arc_spec.rb +7 -9
  35. data/spec/lib/aixm/component/geometry/border_spec.rb +8 -3
  36. data/spec/lib/aixm/component/geometry/circle_spec.rb +6 -8
  37. data/spec/lib/aixm/component/geometry/point_spec.rb +2 -4
  38. data/spec/lib/aixm/component/geometry_spec.rb +57 -62
  39. data/spec/lib/aixm/component/helipad_spec.rb +25 -19
  40. data/spec/lib/aixm/component/layer_spec.rb +17 -19
  41. data/spec/lib/aixm/component/lighting_spec.rb +21 -15
  42. data/spec/lib/aixm/component/runway_spec.rb +44 -37
  43. data/spec/lib/aixm/component/surface_spec.rb +24 -24
  44. data/spec/lib/aixm/component/timetable_spec.rb +7 -9
  45. data/spec/lib/aixm/component/vertical_limits_spec.rb +9 -12
  46. data/spec/lib/aixm/config_spec.rb +8 -8
  47. data/spec/lib/aixm/d_spec.rb +28 -28
  48. data/spec/lib/aixm/document_spec.rb +46 -37
  49. data/spec/lib/aixm/errors_spec.rb +2 -2
  50. data/spec/lib/aixm/f_spec.rb +16 -16
  51. data/spec/lib/aixm/feature/address_spec.rb +12 -7
  52. data/spec/lib/aixm/feature/airport_spec.rb +80 -74
  53. data/spec/lib/aixm/feature/airspace_spec.rb +32 -28
  54. data/spec/lib/aixm/feature/navigational_aid/designated_point_spec.rb +16 -11
  55. data/spec/lib/aixm/feature/navigational_aid/dme_spec.rb +22 -16
  56. data/spec/lib/aixm/feature/navigational_aid/marker_spec.rb +13 -7
  57. data/spec/lib/aixm/feature/navigational_aid/ndb_spec.rb +15 -9
  58. data/spec/lib/aixm/feature/navigational_aid/tacan_spec.rb +22 -16
  59. data/spec/lib/aixm/feature/navigational_aid/vor_spec.rb +21 -15
  60. data/spec/lib/aixm/feature/navigational_aid_spec.rb +6 -6
  61. data/spec/lib/aixm/feature/obstacle_group_spec.rb +25 -21
  62. data/spec/lib/aixm/feature/obstacle_spec.rb +47 -42
  63. data/spec/lib/aixm/feature/organisation_spec.rb +16 -10
  64. data/spec/lib/aixm/feature/service_spec.rb +9 -9
  65. data/spec/lib/aixm/feature/unit_spec.rb +21 -13
  66. data/spec/lib/aixm/feature_spec.rb +5 -5
  67. data/spec/lib/aixm/p_spec.rb +37 -37
  68. data/spec/lib/aixm/refinements_spec.rb +164 -115
  69. data/spec/lib/aixm/version_spec.rb +1 -1
  70. data/spec/lib/aixm/w_spec.rb +28 -28
  71. data/spec/lib/aixm/xy_spec.rb +34 -34
  72. data/spec/lib/aixm/z_spec.rb +19 -19
  73. data/spec/macros/marking.rb +3 -3
  74. data/spec/macros/organisation.rb +2 -2
  75. data/spec/macros/remarks.rb +3 -3
  76. data/spec/macros/timetable.rb +2 -2
  77. data/spec/macros/xy.rb +2 -2
  78. data/spec/macros/z_qnh.rb +2 -2
  79. data/spec/spec_helper.rb +7 -0
  80. metadata +3 -3
  81. data/.travis.yml +0 -8
@@ -114,7 +114,7 @@ module AIXM
114
114
  ogr_uid.txtName(name)
115
115
  ogr_uid.geoLat(obstacles.first.xy.lat(AIXM.schema))
116
116
  ogr_uid.geoLong(obstacles.first.xy.long(AIXM.schema))
117
- end
117
+ end.insert_payload_hash(region: AIXM.config.mid_region)
118
118
  end
119
119
 
120
120
  # @return [String] AIXM or OFMX markup
@@ -76,7 +76,7 @@ module AIXM
76
76
  builder = Builder::XmlMarkup.new(indent: 2)
77
77
  builder.OrgUid do |org_uid|
78
78
  org_uid.txtName(name)
79
- end
79
+ end.insert_payload_hash(region: AIXM.config.mid_region)
80
80
  end
81
81
 
82
82
  # @return [String] AIXM or OFMX markup
@@ -197,7 +197,7 @@ module AIXM
197
197
  ser_uid << unit.to_uid.indent(2)
198
198
  ser_uid.codeType(TYPES.key(type).to_s)
199
199
  ser_uid.noSeq(@sequence)
200
- end
200
+ end.insert_payload_hash(region: AIXM.config.mid_region)
201
201
  end
202
202
 
203
203
  # @return [String] AIXM or OFMX markup
@@ -160,7 +160,7 @@ module AIXM
160
160
  builder = Builder::XmlMarkup.new(indent: 2)
161
161
  builder.UniUid do |uni_uid|
162
162
  uni_uid.txtName(name)
163
- end
163
+ end.insert_payload_hash(region: AIXM.config.mid_region)
164
164
  end
165
165
 
166
166
  # @return [String] AIXM or OFMX markup
@@ -180,11 +180,11 @@ module AIXM
180
180
  end
181
181
 
182
182
  # @!method payload_hash(region:, element:)
183
- # Calculate the UUIDv3 hash of an OFMX XML string.
183
+ # Calculate the UUIDv3 hash of an AIXM/OFMX XML string.
184
184
  #
185
185
  # A word of warning: This is a minimalistic implementation for the AIXM
186
186
  # gem and won't work unless the following conditions are met:
187
- # * the XML string must be OFMX
187
+ # * the XML string must be AIXM/OFMX
188
188
  # * the XML string must be valid
189
189
  # * the XML string must be pretty-printed
190
190
  #
@@ -194,14 +194,21 @@ module AIXM
194
194
  #
195
195
  # @note This is a refinement for +String+
196
196
  # @param region [String] OFMX region (e.g. "LF")
197
- # @param element [String] tag to calculate the payload hash for
198
- # @return [String] UUID version 3
197
+ # @param element [String] tag to calculate the payload hash for (default:
198
+ # first element in the string)
199
+ # @return [String] UUIDv3
200
+ # @raise [ArgumentError] if the given element is not found or no element
201
+ # at all
199
202
  refine String do
200
- def payload_hash(region:, element:)
201
- gsub(%r(mid="[^"]*"), ''). # remove existing mid attributes
203
+ def payload_hash(region:, element: nil)
204
+ element = $1 if element.nil? && match(/<([^?].*?)[\s>]/)
205
+ fail(ArgumentError, "no element found") unless element
206
+ fail(ArgumentError, "element `#{element}' not found") unless match? /<#{element}[\s>]/
207
+ gsub(%r((?:mid|source)="[^"]*"), ''). # remove existing mid and source attributes
202
208
  sub(%r(\A.*?(?=<#{element}))m, ''). # remove everything before first <element>
203
- sub(%r(</#{element}>.*\z)m, ''). # remove everything after first </element>
204
- scan(%r(<([\w-]+)([^>]*)>([^<]*))).each_with_object([region]) do |(e, a, t), m|
209
+ sub(%r(</#{element}>.*\z)m, ''). # remove everything after and including first </element>
210
+ sub(%r(\A(<\w+Uid)\w+), '\1'). # remove Uid name extension
211
+ scan(%r(<([\w-]+)([^>]*)>([^<]*))).each_with_object([region.upcase]) do |(e, a, t), m|
205
212
  m << e << a.scan(%r(([\w-]+)="([^"]*)")).sort.flatten << t
206
213
  end.
207
214
  flatten.
@@ -211,6 +218,30 @@ module AIXM
211
218
  end
212
219
  end
213
220
 
221
+ # @!method insert_payload_hash(region:, element:)
222
+ # Calculate the UUIDv3 hash of an AIXM/OFMX XML string and insert it into
223
+ # the AIXM/OFMX XML string as an mid attribute.
224
+ #
225
+ # If the region is explicitly set to +nil+ or false, the AIXM/OFMX string
226
+ # is returned unchanged.
227
+ #
228
+ # @note This is a refinement for +String+
229
+ # @see String#payload_hash
230
+ # @param region [String] OFMX region (e.g. "LF")
231
+ # @param element [String] tag to calculate the payload hash for (default:
232
+ # first element in the string)
233
+ # @return [String] AIXM/OFMX XML with UUIDv3 inserted as mid attribute
234
+ # @raise [ArgumentError] if the given element is not found or no element
235
+ # at all
236
+ refine String do
237
+ def insert_payload_hash(region:, element: nil)
238
+ return self unless region
239
+ element = $1 if element.nil? && match(/<([^?].*?)[\s>]/)
240
+ hash = payload_hash(region: region, element: element)
241
+ sub(/(<#{element})([^>]*?)(\s+mid=".*?")?/, %Q(\\1 mid="#{hash}"\\2))
242
+ end
243
+ end
244
+
214
245
  # @!method to_dd
215
246
  # Convert DMS angle to DD or +nil+ if the notation is not recognized.
216
247
  #
data/lib/aixm/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module AIXM
2
- VERSION = "0.3.7".freeze
2
+ VERSION = "0.3.8".freeze
3
3
  end
data/rakefile.rb CHANGED
@@ -9,14 +9,28 @@ Rake::TestTask.new do |t|
9
9
  t.warning = true
10
10
  end
11
11
 
12
- desc "Run local YARD documentation server"
13
- task :yard do
14
- `rm -rf ./.yardoc`
15
- Thread.new do
16
- sleep 2
17
- `open http://localhost:8808`
12
+ namespace :schema do
13
+ desc "Update OFMX schema"
14
+ task :update do
15
+ `rm -rf schemas/ofmx/0/*`
16
+ `wget http://schema.openflightmaps.org/0/OFMX-CSV-Obstacle.json -P schemas/ofmx/0/ -q --show-progress`
17
+ `wget http://schema.openflightmaps.org/0/OFMX-CSV.json -P schemas/ofmx/0/ -q --show-progress`
18
+ `wget http://schema.openflightmaps.org/0/OFMX-DataTypes.xsd -P schemas/ofmx/0/ -q --show-progress`
19
+ `wget http://schema.openflightmaps.org/0/OFMX-Features.xsd -P schemas/ofmx/0/ -q --show-progress`
20
+ `wget http://schema.openflightmaps.org/0/OFMX-Snapshot.xsd -P schemas/ofmx/0/ -q --show-progress`
18
21
  end
19
- `yard server -r`
20
- end
22
+ end
23
+
24
+ namespace :yard do
25
+ desc "Run local YARD documentation server"
26
+ task :server do
27
+ `rm -rf ./.yardoc`
28
+ Thread.new do
29
+ sleep 2
30
+ `open http://localhost:8808`
31
+ end
32
+ `yard server -r`
33
+ end
34
+ end
21
35
 
22
36
  task default: :test
@@ -11,22 +11,22 @@ describe AIXM::A do
11
11
 
12
12
  describe :initialize do
13
13
  it "fails on invalid values" do
14
- -> { AIXM.a('foobar') }.must_raise ArgumentError
14
+ _{ AIXM.a('foobar') }.must_raise ArgumentError
15
15
  end
16
16
 
17
17
  it "parses String as angle with precision=2" do
18
18
  AIXM.a('34L').tap do |h|
19
- h.deg.must_equal 340
20
- h.precision.must_equal 2
21
- h.suffix.must_equal :L
19
+ _(h.deg).must_equal 340
20
+ _(h.precision).must_equal 2
21
+ _(h.suffix).must_equal :L
22
22
  end
23
23
  end
24
24
 
25
25
  it "parses Numeric as angle with precision=3" do
26
26
  AIXM.a(12).tap do |h|
27
- h.deg.must_equal 12
28
- h.precision.must_equal 3
29
- h.suffix.must_be :nil?
27
+ _(h.deg).must_equal 12
28
+ _(h.precision).must_equal 3
29
+ _(h.suffix).must_be :nil?
30
30
  end
31
31
  end
32
32
  end
@@ -34,43 +34,43 @@ describe AIXM::A do
34
34
  describe :to_s do
35
35
  context "precision=2" do
36
36
  it "rounds and zero-pad deg to length 2 and concats suffix" do
37
- AIXM.a('05').to_s.must_equal '05'
38
- AIXM.a('05').tap { |a| a.suffix = :L }.to_s.must_equal '05L'
39
- AIXM.a('05').tap { |a| a.deg = 0 }.to_s.must_equal '36'
37
+ _(AIXM.a('05').to_s).must_equal '05'
38
+ _(AIXM.a('05').tap { |a| a.suffix = :L }.to_s).must_equal '05L'
39
+ _(AIXM.a('05').tap { |a| a.deg = 0 }.to_s).must_equal '36'
40
40
  end
41
41
  end
42
42
 
43
43
  context "precition=3" do
44
44
  it "rounds and zero-pad deg to length 3" do
45
- AIXM.a(5).to_s.must_equal '005'
46
- AIXM.a(5).tap { |a| a.deg = 0 }.to_s.must_equal '000'
45
+ _(AIXM.a(5).to_s).must_equal '005'
46
+ _(AIXM.a(5).tap { |a| a.deg = 0 }.to_s).must_equal '000'
47
47
  end
48
48
  end
49
49
  end
50
50
 
51
51
  describe :deg= do
52
52
  it "fails on invalid values" do
53
- [:foobar, '1', -1, 361].wont_be_written_to subject_2, :deg
54
- [:foobar, '1', -1, 361].wont_be_written_to subject_3, :deg
53
+ _([:foobar, '1', -1, 361]).wont_be_written_to subject_2, :deg
54
+ _([:foobar, '1', -1, 361]).wont_be_written_to subject_3, :deg
55
55
  end
56
56
 
57
57
  context "precision=2" do
58
58
  it "rounds to 10 degree steps" do
59
- subject_2.tap { |s| s.deg = 0 }.deg.must_equal 0
60
- subject_2.tap { |s| s.deg = 5 }.deg.must_equal 10
61
- subject_2.tap { |s| s.deg = 154 }.deg.must_equal 150
62
- subject_2.tap { |s| s.deg = 359 }.deg.must_equal 0
63
- subject_2.tap { |s| s.deg = 360 }.deg.must_equal 0
59
+ _(subject_2.tap { |s| s.deg = 0 }.deg).must_equal 0
60
+ _(subject_2.tap { |s| s.deg = 5 }.deg).must_equal 10
61
+ _(subject_2.tap { |s| s.deg = 154 }.deg).must_equal 150
62
+ _(subject_2.tap { |s| s.deg = 359 }.deg).must_equal 0
63
+ _(subject_2.tap { |s| s.deg = 360 }.deg).must_equal 0
64
64
  end
65
65
  end
66
66
 
67
67
  context "precision=3" do
68
68
  it "accepts 1 degree steps" do
69
- subject_3.tap { |s| s.deg = 0 }.deg.must_equal 0
70
- subject_3.tap { |s| s.deg = 5 }.deg.must_equal 5
71
- subject_3.tap { |s| s.deg = 154 }.deg.must_equal 154
72
- subject_3.tap { |s| s.deg = 359 }.deg.must_equal 359
73
- subject_3.tap { |s| s.deg = 360 }.deg.must_equal 0
69
+ _(subject_3.tap { |s| s.deg = 0 }.deg).must_equal 0
70
+ _(subject_3.tap { |s| s.deg = 5 }.deg).must_equal 5
71
+ _(subject_3.tap { |s| s.deg = 154 }.deg).must_equal 154
72
+ _(subject_3.tap { |s| s.deg = 359 }.deg).must_equal 359
73
+ _(subject_3.tap { |s| s.deg = 360 }.deg).must_equal 0
74
74
  end
75
75
  end
76
76
  end
@@ -78,21 +78,21 @@ describe AIXM::A do
78
78
  describe :suffix= do
79
79
  context "precision=2" do
80
80
  it "fails on invalid values" do
81
- [123, 'r'].wont_be_written_to subject_2, :suffix
81
+ _([123, 'r']).wont_be_written_to subject_2, :suffix
82
82
  end
83
83
 
84
84
  it "accepts nil value" do
85
- [nil].must_be_written_to subject_2, :suffix
85
+ _([nil]).must_be_written_to subject_2, :suffix
86
86
  end
87
87
 
88
88
  it "symbolizes valid values" do
89
- subject_2.tap { |s| s.suffix = 'Z' }.suffix.must_equal :Z
89
+ _(subject_2.tap { |s| s.suffix = 'Z' }.suffix).must_equal :Z
90
90
  end
91
91
  end
92
92
 
93
93
  context "precision=3" do
94
94
  it "always fails" do
95
- -> { subject_3.tap { |s| s.suffix = 'Z' } }.must_raise RuntimeError
95
+ _{ subject_3.tap { |s| s.suffix = 'Z' } }.must_raise RuntimeError
96
96
  end
97
97
  end
98
98
  end
@@ -100,47 +100,47 @@ describe AIXM::A do
100
100
  describe :invert do
101
101
  it "must calculate inverse deg correctly" do
102
102
  { 0 => 180, 90 => 270, 179 => 359, 180 => 0, 270 => 90, 359 => 179, 360 => 180 }.each do |from, to|
103
- AIXM.a(from).invert.deg.must_equal to
103
+ _(AIXM.a(from).invert.deg).must_equal to
104
104
  end
105
105
  end
106
106
 
107
107
  it "must invert left/right suffix" do
108
- AIXM.a('34L').invert.suffix.must_equal :R
108
+ _(AIXM.a('34L').invert.suffix).must_equal :R
109
109
  end
110
110
 
111
111
  it "must leave other suffixes untouched" do
112
- AIXM.a('35X').invert.suffix.must_equal :X
112
+ _(AIXM.a('35X').invert.suffix).must_equal :X
113
113
  end
114
114
  end
115
115
 
116
116
  describe :inverse_of? do
117
117
  it "must return true for inverse pairs" do
118
- AIXM.a('34L').inverse_of?(AIXM.a('16R')).must_equal true
118
+ _(AIXM.a('34L').inverse_of?(AIXM.a('16R'))).must_equal true
119
119
  end
120
120
 
121
121
  it "must return false for non-inverse pairs" do
122
- AIXM.a('34L').inverse_of?(AIXM.a('12L')).must_equal false
122
+ _(AIXM.a('34L').inverse_of?(AIXM.a('12L'))).must_equal false
123
123
  end
124
124
  end
125
125
 
126
126
  describe :+ do
127
127
  context "precision=2" do
128
128
  it "adds degrees as Integer" do
129
- (subject_2 + 14).must_equal AIXM.a('01')
130
- (subject_2 + 16).must_equal AIXM.a('02')
131
- (subject_2 + 370).must_equal AIXM.a('01')
132
- (AIXM.a('05L') + 20).must_equal AIXM.a('07L')
129
+ _((subject_2 + 14)).must_equal AIXM.a('01')
130
+ _((subject_2 + 16)).must_equal AIXM.a('02')
131
+ _((subject_2 + 370)).must_equal AIXM.a('01')
132
+ _((AIXM.a('05L') + 20)).must_equal AIXM.a('07L')
133
133
  end
134
134
 
135
135
  it "adds another angle" do
136
- (AIXM.a('10') + AIXM.a('08')).must_equal AIXM.a('18')
136
+ _((AIXM.a('10') + AIXM.a('08'))).must_equal AIXM.a('18')
137
137
  end
138
138
  end
139
139
 
140
140
  context "precision=3" do
141
141
  it "adds degrees as Integer" do
142
- (subject_3 + 15).must_equal AIXM.a(15)
143
- (subject_3 + 370).must_equal AIXM.a(10)
142
+ _((subject_3 + 15)).must_equal AIXM.a(15)
143
+ _((subject_3 + 370)).must_equal AIXM.a(10)
144
144
  end
145
145
  end
146
146
  end
@@ -148,56 +148,56 @@ describe AIXM::A do
148
148
  describe :- do
149
149
  context "precision=2" do
150
150
  it "subtracts degrees as Integer" do
151
- (subject_2 - 14).must_equal AIXM.a('35')
152
- (subject_2 - 16).must_equal AIXM.a('34')
153
- (AIXM.a('05') - 20).must_equal AIXM.a('03')
154
- (AIXM.a('05L') - 20).must_equal AIXM.a('03L')
151
+ _((subject_2 - 14)).must_equal AIXM.a('35')
152
+ _((subject_2 - 16)).must_equal AIXM.a('34')
153
+ _((AIXM.a('05') - 20)).must_equal AIXM.a('03')
154
+ _((AIXM.a('05L') - 20)).must_equal AIXM.a('03L')
155
155
  end
156
156
 
157
157
  it "subtracts another angle" do
158
- (AIXM.a('10') - AIXM.a('08')).must_equal AIXM.a('02')
158
+ _((AIXM.a('10') - AIXM.a('08'))).must_equal AIXM.a('02')
159
159
  end
160
160
  end
161
161
 
162
162
  context "precision=3" do
163
163
  it "subtracts degrees as Integer" do
164
- (subject_3 - 15).must_equal AIXM.a(345)
165
- (AIXM.a(55) - 20).must_equal AIXM.a(35)
164
+ _((subject_3 - 15)).must_equal AIXM.a(345)
165
+ _((AIXM.a(55) - 20)).must_equal AIXM.a(35)
166
166
  end
167
167
  end
168
168
  end
169
169
 
170
170
  describe :== do
171
171
  it "recognizes angles with identical deg and suffix as equal" do
172
- AIXM.a('34L').must_equal AIXM.a('34L')
172
+ _(AIXM.a('34L')).must_equal AIXM.a('34L')
173
173
  end
174
174
 
175
175
  it "recognizes angles with different deg or suffix as unequal" do
176
- AIXM.a('34L').wont_equal AIXM.a('35L')
177
- AIXM.a('34L').wont_equal AIXM.a('34R')
176
+ _(AIXM.a('34L')).wont_equal AIXM.a('35L')
177
+ _(AIXM.a('34L')).wont_equal AIXM.a('34R')
178
178
  end
179
179
 
180
180
  it "recognizes angles with different precision as unequal" do
181
- AIXM.a('34').wont_equal AIXM.a(340)
181
+ _(AIXM.a('34')).wont_equal AIXM.a(340)
182
182
  end
183
183
 
184
184
  it "recognizes objects of different class as unequal" do
185
- subject_2.wont_equal :oggy
185
+ _(subject_2).wont_equal :oggy
186
186
  end
187
187
  end
188
188
 
189
189
  describe :hash do
190
190
  it "returns an integer" do
191
- subject_2.hash.must_be_instance_of Integer
191
+ _(subject_2.hash).must_be_instance_of Integer
192
192
  end
193
193
 
194
194
  it "returns different hashes for different precisions" do
195
- subject_2.hash.wont_equal subject_3.hash
195
+ _(subject_2.hash).wont_equal subject_3.hash
196
196
  end
197
197
 
198
198
  it "allows for the use of instances as hash keys" do
199
199
  dupe = subject_2.dup
200
- { subject_2 => true }[dupe].must_equal true
200
+ _({ subject_2 => true }[dupe]).must_equal true
201
201
  end
202
202
  end
203
203
  end
@@ -7,31 +7,31 @@ describe AIXM::Component::FATO do
7
7
 
8
8
  describe :name= do
9
9
  it "fails on invalid values" do
10
- [nil, :foobar, 123].wont_be_written_to subject, :name
10
+ _([nil, :foobar, 123]).wont_be_written_to subject, :name
11
11
  end
12
12
 
13
13
  it "upcases and transcodes valid values" do
14
- subject.tap { |s| s.name = 'h1' }.name.must_equal 'H1'
14
+ _(subject.tap { |s| s.name = 'h1' }.name).must_equal 'H1'
15
15
  end
16
16
  end
17
17
 
18
18
  describe :length= do
19
19
  it "fails on invalid values" do
20
- [:foobar, 0, 1, AIXM.d(0, :m)].wont_be_written_to subject, :length
20
+ _([:foobar, 0, 1, AIXM.d(0, :m)]).wont_be_written_to subject, :length
21
21
  end
22
22
 
23
23
  it "accepts nil value" do
24
- [nil].must_be_written_to subject, :length
24
+ _([nil]).must_be_written_to subject, :length
25
25
  end
26
26
  end
27
27
 
28
28
  describe :width= do
29
29
  it "fails on invalid values" do
30
- [:foobar, 0, 1, AIXM.d(0, :m)].wont_be_written_to subject, :width
30
+ _([:foobar, 0, 1, AIXM.d(0, :m)]).wont_be_written_to subject, :width
31
31
  end
32
32
 
33
33
  it "accepts nil value" do
34
- [nil].must_be_written_to subject, :width
34
+ _([nil]).must_be_written_to subject, :width
35
35
  end
36
36
  end
37
37
 
@@ -41,27 +41,27 @@ describe AIXM::Component::FATO do
41
41
 
42
42
  describe :profile= do
43
43
  it "accepts nil value" do
44
- [nil].must_be_written_to subject, :profile
44
+ _([nil]).must_be_written_to subject, :profile
45
45
  end
46
46
 
47
47
  it "stringifies valid values" do
48
- subject.tap { |s| s.profile = 'foobar' }.profile.must_equal 'foobar'
49
- subject.tap { |s| s.profile = 123 }.profile.must_equal '123'
48
+ _(subject.tap { |s| s.profile = 'foobar' }.profile).must_equal 'foobar'
49
+ _(subject.tap { |s| s.profile = 123 }.profile).must_equal '123'
50
50
  end
51
51
  end
52
52
 
53
53
  describe :status= do
54
54
  it "fails on invalid values" do
55
- [:foobar, 123].wont_be_written_to subject, :status
55
+ _([:foobar, 123]).wont_be_written_to subject, :status
56
56
  end
57
57
 
58
58
  it "accepts nil value" do
59
- [nil].must_be_written_to subject, :status
59
+ _([nil]).must_be_written_to subject, :status
60
60
  end
61
61
 
62
62
  it "looks up valid values" do
63
- subject.tap { |s| s.status = :closed }.status.must_equal :closed
64
- subject.tap { |s| s.status = :SPOWER }.status.must_equal :secondary_power
63
+ _(subject.tap { |s| s.status = :closed }.status).must_equal :closed
64
+ _(subject.tap { |s| s.status = :SPOWER }.status).must_equal :secondary_power
65
65
  end
66
66
  end
67
67
 
@@ -72,7 +72,7 @@ describe AIXM::Component::FATO do
72
72
  describe :xml= do
73
73
  it "builds correct complete OFMX" do
74
74
  AIXM.ofmx!
75
- subject.to_xml.must_equal <<~END
75
+ _(subject.to_xml).must_equal <<~END
76
76
  <Fto>
77
77
  <FtoUid>
78
78
  <AhpUid>
@@ -114,7 +114,7 @@ describe AIXM::Component::FATO do
114
114
  <txtDesig>35</txtDesig>
115
115
  </FdnUid>
116
116
  <valTrueBrg>355</valTrueBrg>
117
- <valMagBrg>356</valMagBrg>
117
+ <valMagBrg>354</valMagBrg>
118
118
  <txtRmk>Avoid flight over residental area</txtRmk>
119
119
  </Fdn>
120
120
  <Fls>
@@ -143,7 +143,7 @@ describe AIXM::Component::FATO do
143
143
  %i(length width profile marking status remarks).each { |a| subject.send(:"#{a}=", nil) }
144
144
  %i(composition preparation condition pcn siwl_weight siwl_tire_pressure auw_weight remarks).each { |a| subject.surface.send(:"#{a}=", nil) }
145
145
  subject.directions['35'].instance_eval { @lightings.clear }
146
- subject.to_xml.must_equal <<~END
146
+ _(subject.to_xml).must_equal <<~END
147
147
  <Fto>
148
148
  <FtoUid>
149
149
  <AhpUid>
@@ -163,11 +163,18 @@ describe AIXM::Component::FATO do
163
163
  <txtDesig>35</txtDesig>
164
164
  </FdnUid>
165
165
  <valTrueBrg>355</valTrueBrg>
166
- <valMagBrg>356</valMagBrg>
166
+ <valMagBrg>354</valMagBrg>
167
167
  <txtRmk>Avoid flight over residental area</txtRmk>
168
168
  </Fdn>
169
169
  END
170
170
  end
171
+
172
+ it "builds OFMX with mid" do
173
+ AIXM.ofmx!
174
+ AIXM.config.mid_region = 'LF'
175
+ _(subject.to_xml).must_match /<FtoUid mid="9753290e-774e-2600-9b16-f7f951e06e9d">/
176
+ _(subject.to_xml).must_match /<FdnUid mid="ac550e74-73e2-4feb-4934-d0b4aafccfe6">/
177
+ end
171
178
  end
172
179
  end
173
180
 
@@ -178,13 +185,13 @@ describe AIXM::Component::FATO::Direction do
178
185
 
179
186
  describe :name= do
180
187
  it "fails on invalid values" do
181
- [nil, :foobar, 'OGGY'].wont_be_written_to subject, :name
188
+ _([nil, :foobar, 'OGGY']).wont_be_written_to subject, :name
182
189
  end
183
190
  end
184
191
 
185
192
  describe :geographic_orientation= do
186
193
  it "fails on invalid values" do
187
- [:foobar, -1, 10].wont_be_written_to subject, :geographic_orientation
194
+ _([:foobar, -1, 10]).wont_be_written_to subject, :geographic_orientation
188
195
  end
189
196
  end
190
197
 
@@ -195,14 +202,14 @@ describe AIXM::Component::FATO::Direction do
195
202
  describe :magnetic_orientation do
196
203
  it "is calculated correctly" do
197
204
  subject.geographic_orientation = AIXM.a(16)
198
- subject.magnetic_orientation.must_equal AIXM.a(17)
205
+ _(subject.magnetic_orientation).must_equal AIXM.a(15)
199
206
  end
200
207
  end
201
208
 
202
209
  describe :xml= do
203
210
  it "builds correct complete OFMX" do
204
211
  AIXM.ofmx!
205
- subject.to_xml.must_equal <<~END
212
+ _(subject.to_xml).must_equal <<~END
206
213
  <Fdn>
207
214
  <FdnUid>
208
215
  <FtoUid>
@@ -214,7 +221,7 @@ describe AIXM::Component::FATO::Direction do
214
221
  <txtDesig>35</txtDesig>
215
222
  </FdnUid>
216
223
  <valTrueBrg>355</valTrueBrg>
217
- <valMagBrg>356</valMagBrg>
224
+ <valMagBrg>354</valMagBrg>
218
225
  <txtRmk>Avoid flight over residental area</txtRmk>
219
226
  </Fdn>
220
227
  <Fls>
@@ -242,7 +249,7 @@ describe AIXM::Component::FATO::Direction do
242
249
  AIXM.ofmx!
243
250
  %i(geographic_orientation remarks).each { |a| subject.send(:"#{a}=", nil) }
244
251
  subject.instance_eval { @lightings.clear }
245
- subject.to_xml.must_equal <<~END
252
+ _(subject.to_xml).must_equal <<~END
246
253
  <Fdn>
247
254
  <FdnUid>
248
255
  <FtoUid>