dsv7-parser 7.0.0 → 7.0.1
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
- data/README.md +79 -15
- data/Rakefile +9 -0
- data/dsv7-parser.gemspec +5 -1
- data/lib/dsv7/lex.rb +8 -0
- data/lib/dsv7/parser/engine.rb +6 -0
- data/lib/dsv7/parser/io_util.rb +6 -0
- data/lib/dsv7/parser/version.rb +1 -1
- data/lib/dsv7/parser.rb +28 -0
- data/lib/dsv7/stream.rb +9 -0
- data/lib/dsv7/validator/cardinality.rb +6 -0
- data/lib/dsv7/validator/core.rb +12 -0
- data/lib/dsv7/validator/line_analyzer.rb +7 -0
- data/lib/dsv7/validator/line_analyzer_common.rb +8 -0
- data/lib/dsv7/validator/result.rb +10 -0
- data/lib/dsv7/validator/schemas/base.rb +17 -0
- data/lib/dsv7/validator/schemas/erg_schema.rb +3 -1
- data/lib/dsv7/validator/schemas/vml_schema.rb +1 -1
- data/lib/dsv7/validator/schemas/vrl_schema.rb +3 -1
- data/lib/dsv7/validator/schemas/wk_schema.rb +4 -1
- data/lib/dsv7/validator/types/common.rb +8 -0
- data/lib/dsv7/validator/types/datetime.rb +7 -0
- data/lib/dsv7/validator/types/enums1.rb +5 -0
- data/lib/dsv7/validator/types/enums2.rb +5 -0
- data/lib/dsv7/validator/types.rb +6 -0
- data/lib/dsv7/validator.rb +36 -0
- metadata +6 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bb8097275fb6859296653a95615ebd304fcb53a36436118946b60e035b3ccdaf
|
|
4
|
+
data.tar.gz: cc2693be6d15b7cc2654bf378f3288cd87782ec40bc4b04c5f66c52dcdaf26c3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f705afebef80f7863205632454a92f5bd2b5c910c8df0ec94ae684bcb3c9b6bc36f4afe8c887a57e537eea3b223525c8fff66e43acb007c773b179cccacb9025
|
|
7
|
+
data.tar.gz: 13628c729df524abc3a5eb2cbb9378fd76845a6cf8f258e9ef24612dcf64d9c1b22f98b96c0bf18757851513367949b91ba3b439476f0c88a328c16ea1879faf
|
data/README.md
CHANGED
|
@@ -103,21 +103,85 @@ vml_result = Dsv7::Validator.validate(vml)
|
|
|
103
103
|
puts vml_result.valid? # => true
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
Validated
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
106
|
+
## Validated elements
|
|
107
|
+
|
|
108
|
+
WKDL (Wettkampfdefinitionsliste)
|
|
109
|
+
|
|
110
|
+
- `ERZEUGER`
|
|
111
|
+
- `VERANSTALTUNG`
|
|
112
|
+
- `VERANSTALTUNGSORT`
|
|
113
|
+
- `AUSSCHREIBUNGIMNETZ`
|
|
114
|
+
- `VERANSTALTER`
|
|
115
|
+
- `AUSRICHTER`
|
|
116
|
+
- `MELDEADRESSE`
|
|
117
|
+
- `MELDESCHLUSS`
|
|
118
|
+
- `BANKVERBINDUNG`
|
|
119
|
+
- `BESONDERES`
|
|
120
|
+
- `NACHWEIS`
|
|
121
|
+
- `ABSCHNITT`
|
|
122
|
+
- `WETTKAMPF`
|
|
123
|
+
- `WERTUNG`
|
|
124
|
+
- `MELDEGELD`
|
|
125
|
+
|
|
126
|
+
VML (Vereinsmeldeliste)
|
|
127
|
+
|
|
128
|
+
- `ERZEUGER`
|
|
129
|
+
- `VERANSTALTUNG`
|
|
130
|
+
- `ABSCHNITT`
|
|
131
|
+
- `WETTKAMPF`
|
|
132
|
+
- `VEREIN`
|
|
133
|
+
- `ANSPRECHPARTNER`
|
|
134
|
+
- `KARIMELDUNG`
|
|
135
|
+
- `KARIABSCHNITT`
|
|
136
|
+
- `TRAINER`
|
|
137
|
+
- `PNMELDUNG`
|
|
138
|
+
- `HANDICAP`
|
|
139
|
+
- `STARTPN`
|
|
140
|
+
- `STMELDUNG`
|
|
141
|
+
- `STARTST`
|
|
142
|
+
- `STAFFELPERSON`
|
|
143
|
+
|
|
144
|
+
ERG (Wettkampfergebnisliste)
|
|
145
|
+
|
|
146
|
+
- `ERZEUGER`
|
|
147
|
+
- `VERANSTALTUNG`
|
|
148
|
+
- `VERANSTALTER`
|
|
149
|
+
- `AUSRICHTER`
|
|
150
|
+
- `ABSCHNITT`
|
|
151
|
+
- `KAMPFGERICHT`
|
|
152
|
+
- `WETTKAMPF`
|
|
153
|
+
- `WERTUNG`
|
|
154
|
+
- `VEREIN`
|
|
155
|
+
- `PNERGEBNIS`
|
|
156
|
+
- `PNZWISCHENZEIT`
|
|
157
|
+
- `PNREAKTION`
|
|
158
|
+
- `STAFFELERGEBNIS`
|
|
159
|
+
- `STERGEBNIS`
|
|
160
|
+
- `STAFFELPERSON`
|
|
161
|
+
- `STZWISCHENZEIT`
|
|
162
|
+
- `STABLOESE`
|
|
163
|
+
|
|
164
|
+
VRL (Vereinsergebnisliste)
|
|
165
|
+
|
|
166
|
+
- `ERZEUGER`
|
|
167
|
+
- `VERANSTALTUNG`
|
|
168
|
+
- `VERANSTALTER`
|
|
169
|
+
- `AUSRICHTER`
|
|
170
|
+
- `ABSCHNITT`
|
|
171
|
+
- `KAMPFGERICHT`
|
|
172
|
+
- `WETTKAMPF`
|
|
173
|
+
- `WERTUNG`
|
|
174
|
+
- `VEREIN`
|
|
175
|
+
- `PERSON`
|
|
176
|
+
- `PERSONENERGEBNIS`
|
|
177
|
+
- `PNZWISCHENZEIT`
|
|
178
|
+
- `PNREAKTION`
|
|
179
|
+
- `STAFFEL`
|
|
180
|
+
- `STAFFELPERSON`
|
|
181
|
+
- `STAFFELERGEBNIS`
|
|
182
|
+
- `STERGEBNIS`
|
|
183
|
+
- `STZWISCHENZEIT`
|
|
184
|
+
- `STABLOESE`
|
|
121
185
|
|
|
122
186
|
Common error and warning examples:
|
|
123
187
|
|
data/Rakefile
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require 'bundler/gem_tasks'
|
|
4
4
|
require 'rake/testtask'
|
|
5
5
|
require 'rubocop/rake_task'
|
|
6
|
+
require 'rdoc/task'
|
|
6
7
|
|
|
7
8
|
Rake::TestTask.new(:test) do |t|
|
|
8
9
|
t.libs << 'lib'
|
|
@@ -22,3 +23,11 @@ task lint: :rubocop
|
|
|
22
23
|
|
|
23
24
|
desc 'CI: run tests and lint'
|
|
24
25
|
task ci: %i[test lint]
|
|
26
|
+
|
|
27
|
+
desc 'Generate RDoc documentation into doc/'
|
|
28
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
29
|
+
rdoc.rdoc_dir = 'doc'
|
|
30
|
+
rdoc.main = 'README.md'
|
|
31
|
+
rdoc.title = 'dsv7-parser'
|
|
32
|
+
rdoc.rdoc_files.include('README.md', 'lib/**/*.rb')
|
|
33
|
+
end
|
data/dsv7-parser.gemspec
CHANGED
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.email = ['maintheme@gmail.com']
|
|
10
10
|
|
|
11
11
|
spec.summary = 'SAX parser for the DSV7 swim file format'
|
|
12
|
-
spec.description = 'Ruby gem for a DSV7
|
|
12
|
+
spec.description = 'Ruby gem for a SAX parser targeting the DSV7 swim file format'
|
|
13
13
|
spec.homepage = 'https://github.com/bigcurl/dsv7-parser'
|
|
14
14
|
spec.license = 'MIT'
|
|
15
15
|
|
|
@@ -18,6 +18,7 @@ Gem::Specification.new do |spec|
|
|
|
18
18
|
spec.metadata['homepage_uri'] = spec.homepage
|
|
19
19
|
spec.metadata['source_code_uri'] = spec.homepage
|
|
20
20
|
spec.metadata['changelog_uri'] = spec.homepage
|
|
21
|
+
spec.metadata['documentation_uri'] = 'https://www.rubydoc.info/gems/dsv7-parser'
|
|
21
22
|
spec.metadata['rubygems_mfa_required'] = 'true'
|
|
22
23
|
|
|
23
24
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
@@ -26,6 +27,9 @@ Gem::Specification.new do |spec|
|
|
|
26
27
|
|
|
27
28
|
spec.require_paths = ['lib']
|
|
28
29
|
|
|
30
|
+
# Include top-level docs in packaged RDoc
|
|
31
|
+
spec.extra_rdoc_files = ['README.md', 'LICENSE']
|
|
32
|
+
|
|
29
33
|
# Runtime dependencies (none yet)
|
|
30
34
|
# spec.add_dependency "nokogiri", ">= 1.14"
|
|
31
35
|
|
data/lib/dsv7/lex.rb
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Lexical helpers for simple DSV7 tokens.
|
|
4
|
+
#
|
|
5
|
+
# - `parse_format(line)` extracts the list type and version from an exact
|
|
6
|
+
# `FORMAT:<Listentyp>;<Version>;` line.
|
|
7
|
+
# - `element(content)` splits an element line into its name and attributes.
|
|
8
|
+
#
|
|
9
|
+
# These functions are intentionally minimal and do not perform semantic checks.
|
|
10
|
+
|
|
3
11
|
module Dsv7
|
|
4
12
|
module Lex
|
|
5
13
|
module_function
|
data/lib/dsv7/parser/engine.rb
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Internal streaming engine used by `Dsv7::Parser`.
|
|
4
|
+
#
|
|
5
|
+
# Converts an input (path/IO/String) into a stream of parser events. It
|
|
6
|
+
# performs the same line normalization as the validator (via Stream/IoUtil),
|
|
7
|
+
# strips inline comments, and stops emitting at `DATEIENDE`.
|
|
8
|
+
|
|
3
9
|
require 'stringio'
|
|
4
10
|
require_relative '../stream'
|
|
5
11
|
require_relative '../lex'
|
data/lib/dsv7/parser/io_util.rb
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Parser IO utilities.
|
|
4
|
+
#
|
|
5
|
+
# `to_io` converts supported inputs to an IO; `with_io` manages lifetime
|
|
6
|
+
# and applies Stream normalization; `each_content_line` yields non‑empty,
|
|
7
|
+
# comment‑stripped content lines with 1‑based line numbers.
|
|
8
|
+
|
|
3
9
|
require 'stringio'
|
|
4
10
|
require_relative '../stream'
|
|
5
11
|
|
data/lib/dsv7/parser/version.rb
CHANGED
data/lib/dsv7/parser.rb
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Dsv7::Parser
|
|
4
|
+
#
|
|
5
|
+
# Streaming parser for DSV7 lists. It yields a simple event stream so callers
|
|
6
|
+
# can build their own structures without loading the whole file into memory.
|
|
7
|
+
# The parser is intentionally tolerant (e.g., it scrubs invalid UTF‑8 and
|
|
8
|
+
# accepts BOM) — pair it with `Dsv7::Validator` for strict conformance.
|
|
9
|
+
#
|
|
10
|
+
# Events
|
|
11
|
+
# - `[:format, { list_type: String, version: String }, line_number]` — first
|
|
12
|
+
# effective line must be a FORMAT line.
|
|
13
|
+
# - `[:element, { name: String, attrs: Array<String> }, line_number]` — for
|
|
14
|
+
# each element line between FORMAT and DATEIENDE.
|
|
15
|
+
# - `[:end, nil, line_number]` — emitted after `DATEIENDE` (or EOF if missing).
|
|
16
|
+
#
|
|
17
|
+
# Usage
|
|
18
|
+
# Dsv7::Parser.parse(io_or_path_or_string) do |type, payload, ln|
|
|
19
|
+
# case type
|
|
20
|
+
# when :format then # inspect payload[:list_type], payload[:version]
|
|
21
|
+
# when :element then # payload[:name], payload[:attrs]
|
|
22
|
+
# when :end then # done
|
|
23
|
+
# end
|
|
24
|
+
# end
|
|
25
|
+
#
|
|
26
|
+
# Documenting new helpers
|
|
27
|
+
# - Describe when a helper raises (e.g., wrong list type for a type‑specific
|
|
28
|
+
# parser) and what it yields.
|
|
29
|
+
# - Note streaming/encoding behavior and that comments are stripped inline.
|
|
30
|
+
|
|
3
31
|
require_relative 'parser/version'
|
|
4
32
|
require_relative 'parser/engine'
|
|
5
33
|
require_relative 'validator'
|
data/lib/dsv7/stream.rb
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Low‑level IO helpers for streaming DSV7 content.
|
|
4
|
+
#
|
|
5
|
+
# Responsibilities
|
|
6
|
+
# - Binary mode, BOM detection, and UTF‑8 normalization.
|
|
7
|
+
# - Per‑line sanitization and CR/LF handling.
|
|
8
|
+
# - Inline single‑line comment removal using the `(* ... *)` syntax.
|
|
9
|
+
#
|
|
10
|
+
# These helpers are shared by both the validator and the parser.
|
|
11
|
+
|
|
3
12
|
module Dsv7
|
|
4
13
|
module Stream
|
|
5
14
|
module_function
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Element cardinality validation for each list type.
|
|
4
|
+
#
|
|
5
|
+
# Each validator receives the shared Result and a Hash of observed element
|
|
6
|
+
# counts, then asserts required presence and max occurrences according to the
|
|
7
|
+
# current understanding of the spec.
|
|
8
|
+
|
|
3
9
|
module Dsv7
|
|
4
10
|
class Validator
|
|
5
11
|
# Validates Wettkampfdefinitionsliste element cardinalities
|
data/lib/dsv7/validator/core.rb
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Core validation pipeline
|
|
4
|
+
#
|
|
5
|
+
# Implements the IO/line streaming for the validator:
|
|
6
|
+
# - puts IO in binary mode and detects BOM
|
|
7
|
+
# - normalizes lines to UTF‑8 and tracks CRLF presence
|
|
8
|
+
# - strips inline comments and delegates per‑line logic to LineAnalyzer
|
|
9
|
+
# - adds a filename warning if the provided path does not match the guidance
|
|
10
|
+
#
|
|
11
|
+
# Notes for maintainers
|
|
12
|
+
# - Keep this class side‑effect free beyond writing to `Result`.
|
|
13
|
+
# - Avoid accumulating state; process line‑by‑line to preserve streaming.
|
|
14
|
+
|
|
3
15
|
require_relative '../stream'
|
|
4
16
|
require_relative '../lex'
|
|
5
17
|
require_relative 'line_analyzer'
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Streaming line analyzer
|
|
4
|
+
#
|
|
5
|
+
# Orchestrates validation once lines have been sanitized and comments stripped.
|
|
6
|
+
# Tracks the first effective FORMAT line, enforces the final DATEIENDE, and
|
|
7
|
+
# dispatches element lines to list‑specific schema/type checks and cardinality
|
|
8
|
+
# tracking. All findings are written into the shared `Result` instance.
|
|
9
|
+
|
|
3
10
|
require_relative '../stream'
|
|
4
11
|
require_relative 'line_analyzer_common'
|
|
5
12
|
require_relative 'schemas/wk_schema'
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# List‑specific analyzer mixins
|
|
4
|
+
#
|
|
5
|
+
# These modules encapsulate per‑list tracking and validation methods used by
|
|
6
|
+
# LineAnalyzer. Each provides three responsibilities for its list type:
|
|
7
|
+
# - track_*_element: counts element occurrences for cardinality checks
|
|
8
|
+
# - validate_*_list_elements: validates the observed counts at finish
|
|
9
|
+
# - validate_*_line: validates a single element’s attributes via the schema
|
|
10
|
+
|
|
3
11
|
require_relative '../lex'
|
|
4
12
|
require_relative 'cardinality'
|
|
5
13
|
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Validation result container
|
|
4
|
+
#
|
|
5
|
+
# Collects errors and warnings during a validation run and exposes
|
|
6
|
+
# `list_type`/`version` after a valid FORMAT line is seen. `valid?` is true
|
|
7
|
+
# iff there are no errors; warnings never affect validity.
|
|
8
|
+
#
|
|
9
|
+
# Message stability
|
|
10
|
+
# - Keep message texts stable where possible; tests rely on them.
|
|
11
|
+
# - Include line numbers when relevant to aid debugging.
|
|
12
|
+
|
|
3
13
|
module Dsv7
|
|
4
14
|
class Validator
|
|
5
15
|
# Result container for validation
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Base class for per‑list schemas.
|
|
4
|
+
#
|
|
5
|
+
# A concrete schema class defines a `SCHEMAS` Hash mapping element names to an
|
|
6
|
+
# Array of attribute specs. Each attribute spec is a tuple:
|
|
7
|
+
# [type, required, opts=nil]
|
|
8
|
+
# where `type` corresponds to a `check_<type>` method mixed in from the
|
|
9
|
+
# type‑check modules, `required` is a boolean, and `opts` can be used by a
|
|
10
|
+
# specific checker.
|
|
11
|
+
#
|
|
12
|
+
# Cross‑field/element rules may be implemented by overriding
|
|
13
|
+
# `validate_cross_rules(name, attrs, line_number)`.
|
|
14
|
+
#
|
|
15
|
+
# Documentation tips when adding/adjusting schemas:
|
|
16
|
+
# - Copy the attribute count and types from the spec and real‑world examples.
|
|
17
|
+
# - Clearly mark intentionally deferred or ambiguous elements in commit msgs.
|
|
18
|
+
# - Add both positive and negative tests for each element and datatype.
|
|
19
|
+
|
|
3
20
|
module Dsv7
|
|
4
21
|
class Validator
|
|
5
22
|
class SchemaBase
|
|
@@ -5,7 +5,9 @@ require_relative 'base'
|
|
|
5
5
|
|
|
6
6
|
module Dsv7
|
|
7
7
|
class Validator
|
|
8
|
-
# Validates Wettkampfergebnisliste attribute counts and datatypes
|
|
8
|
+
# Validates Wettkampfergebnisliste attribute counts and datatypes.
|
|
9
|
+
# Accepts synonymous element names found in the wild
|
|
10
|
+
# (e.g., STAFFELERGEBNIS/STERGEBNIS).
|
|
9
11
|
class ErgSchema < SchemaBase
|
|
10
12
|
include WkTypeChecks
|
|
11
13
|
|
|
@@ -5,7 +5,9 @@ require_relative 'base'
|
|
|
5
5
|
|
|
6
6
|
module Dsv7
|
|
7
7
|
class Validator
|
|
8
|
-
# Validates Vereinsergebnisliste attribute counts and datatypes
|
|
8
|
+
# Validates Vereinsergebnisliste attribute counts and datatypes.
|
|
9
|
+
# Accepts synonymous element names found in the wild
|
|
10
|
+
# (e.g., STAFFELERGEBNIS/STERGEBNIS).
|
|
9
11
|
class VrlSchema < SchemaBase
|
|
10
12
|
include WkTypeChecks
|
|
11
13
|
|
|
@@ -5,7 +5,10 @@ require_relative 'base'
|
|
|
5
5
|
|
|
6
6
|
module Dsv7
|
|
7
7
|
class Validator
|
|
8
|
-
# Validates Wettkampfdefinitionsliste attribute counts and datatypes
|
|
8
|
+
# Validates Wettkampfdefinitionsliste attribute counts and datatypes.
|
|
9
|
+
#
|
|
10
|
+
# The `SCHEMAS` constant defines the exact attribute counts and types per
|
|
11
|
+
# element according to the current spec interpretation.
|
|
9
12
|
class WkSchema < SchemaBase
|
|
10
13
|
include WkTypeChecks
|
|
11
14
|
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Common datatype checks shared across lists.
|
|
4
|
+
#
|
|
5
|
+
# Implementations follow the spec’s informal definitions:
|
|
6
|
+
# - ZK: arbitrary UTF‑8 string (already scrubbed by the stream layer)
|
|
7
|
+
# - Zahl: integer (only digits)
|
|
8
|
+
# - Betrag: monetary amount in the form `x,yy`
|
|
9
|
+
# - Einzelstrecke: distance (1..25000) or 0 where permitted
|
|
10
|
+
|
|
3
11
|
module Dsv7
|
|
4
12
|
class Validator
|
|
5
13
|
module WkTypeChecksCommon
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Date and time datatype checks.
|
|
4
|
+
#
|
|
5
|
+
# Enforces textual formats before validating value ranges:
|
|
6
|
+
# - Datum: TT.MM.JJJJ (validated via Date.strptime)
|
|
7
|
+
# - Uhrzeit: HH:MM (0..23, 0..59)
|
|
8
|
+
# - Zeit: HH:MM:SS,hh (0..23, 0..59, 0..59, 0..99)
|
|
9
|
+
|
|
3
10
|
require 'date'
|
|
4
11
|
|
|
5
12
|
module Dsv7
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Enum/group checks (part 1): Bahnlänge, Zeitmessung, Land, etc.
|
|
4
|
+
#
|
|
5
|
+
# These normalize expectations found in the spec and examples and produce
|
|
6
|
+
# actionable error messages that include allowed values.
|
|
7
|
+
|
|
3
8
|
module Dsv7
|
|
4
9
|
class Validator
|
|
5
10
|
module WkTypeChecksEnums1
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Enum/group checks (part 2): Technik, Ausübung, Geschlecht, Wertungstyp,
|
|
4
|
+
# JG/AK, Meldegeldtypen, Reaktionsart, Nachtragskennzeichen, u. a.
|
|
5
|
+
#
|
|
6
|
+
# Keep allowed lists centralized here for clarity and reuse across schemas.
|
|
7
|
+
|
|
3
8
|
module Dsv7
|
|
4
9
|
class Validator
|
|
5
10
|
module WkTypeChecksEnums2
|
data/lib/dsv7/validator/types.rb
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Aggregates type‑check mixins used by schemas.
|
|
4
|
+
#
|
|
5
|
+
# Each `check_<type>(name, index, value, line_number, opts)` method is
|
|
6
|
+
# expected to either accept the value or call `add_error(message)` on the
|
|
7
|
+
# including schema to record a validation error with context.
|
|
8
|
+
|
|
3
9
|
require_relative 'types/common'
|
|
4
10
|
require_relative 'types/datetime'
|
|
5
11
|
require_relative 'types/enums1'
|
data/lib/dsv7/validator.rb
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# Dsv7::Validator
|
|
4
|
+
#
|
|
5
|
+
# Validates DSV7 files (German Swimming Federation “Format 7”) against a
|
|
6
|
+
# pragmatic subset of the official specification. The validator focuses on
|
|
7
|
+
# high‑level envelope rules (FORMAT/DATEIENDE, encoding, comments, delimiters),
|
|
8
|
+
# filename hints, element cardinalities, and per‑element attribute types for all
|
|
9
|
+
# four supported list types (WKDL, VML, ERG, VRL).
|
|
10
|
+
#
|
|
11
|
+
# Intent
|
|
12
|
+
# - Provide fast, streaming validation without external dependencies.
|
|
13
|
+
# - Produce precise, stable error and warning messages suitable for tooling and
|
|
14
|
+
# tests (see `test/dsv7/*`).
|
|
15
|
+
# - Keep responsibilities narrow: structural checks here; parsing in
|
|
16
|
+
# `Dsv7::Parser`.
|
|
17
|
+
#
|
|
18
|
+
# Public API
|
|
19
|
+
# - `.validate(input) -> Dsv7::Validator::Result`
|
|
20
|
+
# Accepts a file path String, an IO, or a content String (streamed via
|
|
21
|
+
# StringIO). Always returns a `Result` object with `errors`, `warnings`,
|
|
22
|
+
# `list_type`, `version`, and `valid?`.
|
|
23
|
+
#
|
|
24
|
+
# Examples
|
|
25
|
+
# result = Dsv7::Validator.validate('2024-01-01-Example-Wk.DSV7')
|
|
26
|
+
# result.valid? # => true/false
|
|
27
|
+
# result.errors # => ["..."]
|
|
28
|
+
# result.warnings # => ["..."]
|
|
29
|
+
# result.list_type # => 'Wettkampfdefinitionsliste' (after FORMAT)
|
|
30
|
+
# result.version # => '7'
|
|
31
|
+
#
|
|
32
|
+
# Writing good docs for new checks
|
|
33
|
+
# - State the rule’s purpose and scope (what it enforces, and why).
|
|
34
|
+
# - Describe inputs/outputs and when an error vs. warning is emitted.
|
|
35
|
+
# - Keep messages actionable and stable; include line numbers where helpful.
|
|
36
|
+
# - Reference spec sections or examples in commit messages or tests.
|
|
37
|
+
# - Add both accept and reject tests under `test/dsv7/`.
|
|
38
|
+
|
|
3
39
|
require 'stringio'
|
|
4
40
|
require_relative 'validator/result'
|
|
5
41
|
require_relative 'validator/core'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dsv7-parser
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.0.
|
|
4
|
+
version: 7.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- bigcurl
|
|
@@ -9,12 +9,14 @@ bindir: bin
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
|
-
description: Ruby gem for a DSV7
|
|
12
|
+
description: Ruby gem for a SAX parser targeting the DSV7 swim file format
|
|
13
13
|
email:
|
|
14
14
|
- maintheme@gmail.com
|
|
15
15
|
executables: []
|
|
16
16
|
extensions: []
|
|
17
|
-
extra_rdoc_files:
|
|
17
|
+
extra_rdoc_files:
|
|
18
|
+
- LICENSE
|
|
19
|
+
- README.md
|
|
18
20
|
files:
|
|
19
21
|
- ".gitignore"
|
|
20
22
|
- ".rubocop.yml"
|
|
@@ -57,6 +59,7 @@ metadata:
|
|
|
57
59
|
homepage_uri: https://github.com/bigcurl/dsv7-parser
|
|
58
60
|
source_code_uri: https://github.com/bigcurl/dsv7-parser
|
|
59
61
|
changelog_uri: https://github.com/bigcurl/dsv7-parser
|
|
62
|
+
documentation_uri: https://www.rubydoc.info/gems/dsv7-parser
|
|
60
63
|
rubygems_mfa_required: 'true'
|
|
61
64
|
rdoc_options: []
|
|
62
65
|
require_paths:
|