aixm 1.3.1 → 1.3.3
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +12 -0
- data/README.md +3 -3
- data/lib/aixm/concerns/xml_builder.rb +4 -4
- data/lib/aixm/document.rb +6 -3
- data/lib/aixm/executables.rb +39 -36
- data/lib/aixm/feature/generic.rb +1 -1
- data/lib/aixm/refinements.rb +21 -22
- data/lib/aixm/schedule/date.rb +6 -2
- data/lib/aixm/schedule/day.rb +35 -4
- data/lib/aixm/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49f4c417f17321e81579c5ec2f63e94e95e3e5b466def5304051e508aac0db04
|
4
|
+
data.tar.gz: 78dcbe01cde6c2eac9bf49ed2f8828a96f1ea112393e2730e2e2a902177ee0b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6901fd3474f200ef670161e5377c550c882e9adbc24fd34c3a790b6ca7c44157f5509ee737c85ad10187ce93acaba7b81635e385b461944f5cbf29436f522f5
|
7
|
+
data.tar.gz: 9a204bb3611c4405252dfff814ab5d10f628b85936067ccf10358786446ad719c25753cb1a9d8aafb26540311034e6c6c30994cad96fe44a73807ce847fe14ef
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,18 @@
|
|
2
2
|
|
3
3
|
Nothing so far
|
4
4
|
|
5
|
+
## 1.3.3
|
6
|
+
|
7
|
+
#### Changes
|
8
|
+
* Extend `ckmid` and `mkmid` to accept multiple files and globbing.
|
9
|
+
|
10
|
+
## 1.3.2
|
11
|
+
|
12
|
+
#### Changes
|
13
|
+
* Add `#pred` (aliased `#prev`) and `#succ` (alias `#next`) to both
|
14
|
+
`AIXM::Date` and `AIXM::Day` in order to use them for iterations
|
15
|
+
* Pretty print generic features only to prevent segfaults on large documents
|
16
|
+
|
5
17
|
## 1.3.1
|
6
18
|
|
7
19
|
#### Changes
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[](https://rubygems.org/gems/aixm)
|
2
|
-
[](https://github.com/svoop/aixm/actions?workflow=Test)
|
3
3
|
[](https://codeclimate.com/github/svoop/aixm/)
|
4
4
|
[](https://donorbox.org/bitcetera)
|
5
5
|
|
@@ -291,7 +291,7 @@ By `using AIXM::Refinements` you get a few handy [extensions to Ruby core classe
|
|
291
291
|
|
292
292
|
### mkmid
|
293
293
|
|
294
|
-
The `mkmid` executable reads
|
294
|
+
The `mkmid` executable reads OFMX files, adds [OFMX-compliant `mid` values](https://gitlab.com/openflightmaps/ofmx/wikis/Features#mid) into all `*Uid` elements and validates the result against the schema.
|
295
295
|
|
296
296
|
```
|
297
297
|
mkmid --help
|
@@ -299,7 +299,7 @@ mkmid --help
|
|
299
299
|
|
300
300
|
### ckmid
|
301
301
|
|
302
|
-
The `chmid` executable reads
|
302
|
+
The `chmid` executable reads OFMX files, validates them against the schema and checks all `mid` attributes for [OFMX-compliance](https://gitlab.com/openflightmaps/ofmx/wikis/Features#mid).
|
303
303
|
|
304
304
|
```
|
305
305
|
ckmid --help
|
@@ -10,11 +10,11 @@ module AIXM
|
|
10
10
|
# @yield [Nokogiri::XML::Builder]
|
11
11
|
# @return [Nokogiri::XML::DocumentFragment]
|
12
12
|
def build_fragment
|
13
|
-
Nokogiri::XML::DocumentFragment.parse('').tap do |
|
14
|
-
Nokogiri::XML::Builder.with(
|
15
|
-
yield
|
13
|
+
Nokogiri::XML::DocumentFragment.parse('').tap do |fragment|
|
14
|
+
Nokogiri::XML::Builder.with(fragment) do |builder|
|
15
|
+
yield builder
|
16
16
|
end
|
17
|
-
|
17
|
+
fragment.elements.each { _1.add_next_sibling("\n") } # add newline between tags on top level
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/lib/aixm/document.rb
CHANGED
@@ -168,10 +168,13 @@ module AIXM
|
|
168
168
|
effective: @effective_at.xmlschema,
|
169
169
|
expiration: (@expiration_at&.xmlschema if AIXM.ofmx?)
|
170
170
|
}.compact
|
171
|
-
Nokogiri::XML::Builder.new do |builder|
|
171
|
+
Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |builder|
|
172
172
|
builder.send(AIXM.schema(:root), meta) do |root|
|
173
|
+
root.text("\n")
|
173
174
|
AIXM::Concerns::Memoize.method :to_uid do
|
174
|
-
|
175
|
+
# TODO: indent is lost if added directly to the builder
|
176
|
+
# features.each { _1.add_to(root) }
|
177
|
+
features.each { root << _1.to_xml.indent(2) }
|
175
178
|
end
|
176
179
|
if AIXM.ofmx? && AIXM.config.mid
|
177
180
|
AIXM::PayloadHash::Mid.new(builder.doc).insert_mid
|
@@ -182,7 +185,7 @@ module AIXM
|
|
182
185
|
|
183
186
|
# @return [String] AIXM or OFMX markup
|
184
187
|
def to_xml
|
185
|
-
document.
|
188
|
+
document.to_xml
|
186
189
|
end
|
187
190
|
end
|
188
191
|
end
|
data/lib/aixm/executables.rb
CHANGED
@@ -8,36 +8,37 @@ module AIXM
|
|
8
8
|
@options = options
|
9
9
|
OptionParser.new do |o|
|
10
10
|
o.banner = <<~END
|
11
|
-
Add mid attributes to
|
12
|
-
Usage: #{File.basename($0)}
|
11
|
+
Add mid attributes to OFMX files.
|
12
|
+
Usage: #{File.basename($0)} files
|
13
13
|
END
|
14
14
|
o.on('-i', '--[no-]in-place', 'overwrite file instead of dumping to STDOUT (default: false)') { @options[:in_place] = _1 }
|
15
15
|
o.on('-f', '--[no-]force', 'ignore XML schema validation errors (default: false)') { @options[:force] = _1 }
|
16
16
|
o.on('-A', '--about', 'show author/license information and exit') { AIXM::Executables.about }
|
17
17
|
o.on('-V', '--version', 'show version and exit') { AIXM::Executables.version }
|
18
18
|
end.parse!
|
19
|
-
@
|
19
|
+
@files = ARGV
|
20
20
|
end
|
21
21
|
|
22
22
|
def run
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
23
|
+
@files.each do |file|
|
24
|
+
fail "cannot read #{file}" unless file && File.readable?(file)
|
25
|
+
fail "#{file} is not OFMX" unless file.match?(/\.ofmx$/)
|
26
|
+
AIXM.ofmx!
|
27
|
+
document = File.open(file) { Nokogiri::XML(_1) }
|
28
|
+
AIXM::PayloadHash::Mid.new(document).insert_mid
|
29
|
+
errors = Nokogiri::XML::Schema(File.open(AIXM.schema(:xsd))).validate(document)
|
30
|
+
case
|
31
|
+
when errors.any? && !@options[:force]
|
32
|
+
fail (["#{file} is not valid..."] + errors).join("\n")
|
33
|
+
when @options[:in_place]
|
34
|
+
File.write(file, document.to_xml)
|
35
|
+
else
|
36
|
+
puts document.to_xml
|
37
|
+
end
|
38
|
+
rescue => error
|
39
|
+
puts "ERROR: #{error.message}"
|
40
|
+
exit 1
|
37
41
|
end
|
38
|
-
rescue => error
|
39
|
-
puts "ERROR: #{error.message}"
|
40
|
-
exit 1
|
41
42
|
end
|
42
43
|
end
|
43
44
|
|
@@ -45,29 +46,31 @@ module AIXM
|
|
45
46
|
def initialize(**options)
|
46
47
|
OptionParser.new do |o|
|
47
48
|
o.banner = <<~END
|
48
|
-
Check mid attributes of
|
49
|
-
Usage: #{File.basename($0)}
|
49
|
+
Check mid attributes of OFMX files.
|
50
|
+
Usage: #{File.basename($0)} files
|
50
51
|
END
|
51
52
|
o.on('-A', '--about', 'show author/license information and exit') { AIXM::Executables.about }
|
52
53
|
o.on('-V', '--version', 'show version and exit') { AIXM::Executables.version }
|
53
54
|
end.parse!
|
54
|
-
@
|
55
|
+
@files = ARGV
|
55
56
|
end
|
56
57
|
|
57
58
|
def run
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
59
|
+
exit(
|
60
|
+
@files.reduce(true) do |success, file|
|
61
|
+
fail "cannot read #{file}" unless file && File.readable?(file)
|
62
|
+
fail "#{file} is not OFMX" unless file.match?(/\.ofmx$/)
|
63
|
+
AIXM.ofmx!
|
64
|
+
document = File.open(file) { Nokogiri::XML(_1) }
|
65
|
+
errors = Nokogiri::XML::Schema(File.open(AIXM.schema(:xsd))).validate(document)
|
66
|
+
errors += AIXM::PayloadHash::Mid.new(document).check_mid
|
67
|
+
fail (["#{file} is not valid..."] + errors).join("\n") if errors.any?
|
68
|
+
success && true
|
69
|
+
rescue RuntimeError => error
|
70
|
+
puts "ERROR: #{error.message}"
|
71
|
+
false
|
72
|
+
end
|
73
|
+
)
|
71
74
|
end
|
72
75
|
end
|
73
76
|
|
data/lib/aixm/feature/generic.rb
CHANGED
data/lib/aixm/refinements.rb
CHANGED
@@ -129,33 +129,32 @@ module AIXM
|
|
129
129
|
end
|
130
130
|
end
|
131
131
|
|
132
|
-
# @!method
|
133
|
-
#
|
132
|
+
# @!method to_pretty_xml
|
133
|
+
# Pretty printing alternative of +to_xml+
|
134
134
|
#
|
135
135
|
# @example
|
136
136
|
# xml = <<~END
|
137
|
-
# <
|
137
|
+
# <aaa></aaa>
|
138
138
|
# <bbb/>
|
139
|
-
#
|
140
|
-
#
|
141
|
-
#
|
142
|
-
# </
|
139
|
+
# <ccc foo="bar" >
|
140
|
+
# <ddd>
|
141
|
+
# </ddd>
|
142
|
+
# </ccc>
|
143
143
|
# END
|
144
|
-
# Nokogiri.
|
145
|
-
# # =>
|
146
|
-
# <
|
147
|
-
#
|
148
|
-
# <
|
149
|
-
#
|
150
|
-
#
|
151
|
-
#
|
152
|
-
#
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
PRETTY_XSLT.transform(self)
|
144
|
+
# Nokogiri::XML::DocumentFragment.parse(xml).to_pretty_xml
|
145
|
+
# # => <aaa/>
|
146
|
+
# <bbb/>
|
147
|
+
# <ccc foo="bar">
|
148
|
+
# <ddd/>
|
149
|
+
# </ccc>
|
150
|
+
#
|
151
|
+
# @note This is a refinement for +Nokogiri::XML::DocumentFragment+
|
152
|
+
# @return [String]
|
153
|
+
refine Nokogiri::XML::DocumentFragment do
|
154
|
+
def to_pretty_xml
|
155
|
+
builder = Nokogiri::XML::Builder.new
|
156
|
+
builder.DocumentFragment { _1 << self.to_html }
|
157
|
+
AIXM::Refinements::PRETTY_XSLT.transform(builder.doc).at_css('DocumentFragment').children.map(&:to_xml).join("\n")
|
159
158
|
end
|
160
159
|
end
|
161
160
|
|
data/lib/aixm/schedule/date.rb
CHANGED
@@ -84,16 +84,20 @@ module AIXM
|
|
84
84
|
end
|
85
85
|
|
86
86
|
# Create new date one day prior to this one.
|
87
|
-
|
87
|
+
#
|
88
|
+
# @return [AIXM::Schedule::Date]
|
89
|
+
def pred
|
88
90
|
self.class.new(date.prev_day.to_s.sub(/^-/, '')).at(year: (YEARLESS_YEAR if yearless?))
|
89
91
|
end
|
92
|
+
alias_method :prev, :pred
|
90
93
|
|
91
94
|
# Create new date one day after this one.
|
92
95
|
#
|
93
96
|
# @return [AIXM::Schedule::Date]
|
94
|
-
def
|
97
|
+
def succ
|
95
98
|
self.class.new(date.next_day).at(year: (YEARLESS_YEAR if yearless?))
|
96
99
|
end
|
100
|
+
alias_method :next, :succ
|
97
101
|
|
98
102
|
# Calculate difference in days between two dates.
|
99
103
|
#
|
data/lib/aixm/schedule/day.rb
CHANGED
@@ -13,8 +13,8 @@ module AIXM
|
|
13
13
|
include AIXM::Concerns::HashEquality
|
14
14
|
include Comparable
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
WEEKDAYS = %i(sunday monday tuesday wednesday thursday friday saturday).freeze
|
17
|
+
DAYS = (WEEKDAYS + %i(workday day_preceding_workday day_following_workday holiday day_preceding_holiday day_following_holiday any)).freeze
|
18
18
|
|
19
19
|
# Day of the week or special named day
|
20
20
|
#
|
@@ -31,7 +31,7 @@ module AIXM
|
|
31
31
|
self.day = day
|
32
32
|
when Integer
|
33
33
|
fail ArgumentError unless day.between?(0, 6)
|
34
|
-
self.day =
|
34
|
+
self.day = WEEKDAYS[day]
|
35
35
|
else
|
36
36
|
fail ArgumentError
|
37
37
|
end
|
@@ -44,10 +44,37 @@ module AIXM
|
|
44
44
|
day.to_s.gsub('_', ' ')
|
45
45
|
end
|
46
46
|
|
47
|
+
# Symbol used to initialize this day
|
48
|
+
#
|
49
|
+
# @return [Symbol]
|
50
|
+
def to_sym
|
51
|
+
day.to_s.to_sym
|
52
|
+
end
|
53
|
+
|
47
54
|
def inspect
|
48
55
|
%Q(#<#{self.class} #{to_s}>)
|
49
56
|
end
|
50
57
|
|
58
|
+
# Create new day one day prior to this one.
|
59
|
+
#
|
60
|
+
# @return [AIXM::Schedule::Day]
|
61
|
+
def pred
|
62
|
+
return self if any?
|
63
|
+
fail(TypeError, "can't iterate from #{day}") unless wday
|
64
|
+
self.class.new(WEEKDAYS[wday.pred % 7])
|
65
|
+
end
|
66
|
+
alias_method :prev, :pred
|
67
|
+
|
68
|
+
# Create new day one day after this one.
|
69
|
+
#
|
70
|
+
# @return [AIXM::Schedule::Day]
|
71
|
+
def succ
|
72
|
+
return self if any?
|
73
|
+
fail(TypeError, "can't iterate from #{day}") unless wday
|
74
|
+
self.class.new(WEEKDAYS[wday.succ % 7])
|
75
|
+
end
|
76
|
+
alias_method :next, :succ
|
77
|
+
|
51
78
|
# Whether two days are equal.
|
52
79
|
#
|
53
80
|
# @return [Boolean]
|
@@ -71,7 +98,7 @@ module AIXM
|
|
71
98
|
#
|
72
99
|
# @return [Boolean]
|
73
100
|
def sortable?
|
74
|
-
|
101
|
+
WEEKDAYS.include? day
|
75
102
|
end
|
76
103
|
|
77
104
|
# Whether this schedule day falls within the given range of schedule
|
@@ -104,6 +131,10 @@ module AIXM
|
|
104
131
|
fail ArgumentError unless DAYS.include? @day
|
105
132
|
end
|
106
133
|
|
134
|
+
def wday
|
135
|
+
WEEKDAYS.index(day.to_sym)
|
136
|
+
end
|
137
|
+
|
107
138
|
# @note Necessary to use this class in Range.
|
108
139
|
def <=>(other)
|
109
140
|
DAYS.index(day) <=> DAYS.index(other.day) || day.to_s <=> other.to_s
|
data/lib/aixm/version.rb
CHANGED
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aixm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sven Schwyn
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
kAyiRqgxF4dJviwtqI7mZIomWL63+kXLgjOjMe1SHxfIPo/0ji6+r1p4KYa7o41v
|
30
30
|
fwIwU1MKlFBdsjkd
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2023-01-05 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: nokogiri
|
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
312
312
|
- !ruby/object:Gem::Version
|
313
313
|
version: '0'
|
314
314
|
requirements: []
|
315
|
-
rubygems_version: 3.
|
315
|
+
rubygems_version: 3.4.2
|
316
316
|
signing_key:
|
317
317
|
specification_version: 4
|
318
318
|
summary: Builder for AIXM/OFMX aeronautical information
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
Z
|
2
|
-
|
1
|
+
���Yw�����c�+˥wZ�I9��~T������%�+-��uF0���V�������
|
2
|
+
��\��% {����5�&x��vy����٤R?J$�O�/��9�?��IC��D��:H�o�@q"��E��YC��̅;\^�7�XZD2�_O�����Ĝ;.{���:�.�u��n�ۛw�$7��v�o�{���.�?C�O]� ��
|