dsv7-parser 7.0.0 → 7.0.2

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.
@@ -5,6 +5,39 @@ require_relative 'validator/result'
5
5
  require_relative 'validator/core'
6
6
 
7
7
  module Dsv7
8
+ ##
9
+ # Dsv7::Validator
10
+ #
11
+ # Validates DSV7 files (German Swimming Federation “Format 7”) against a
12
+ # pragmatic subset of the official specification. The validator focuses on
13
+ # high‑level envelope rules (FORMAT/DATEIENDE, encoding, comments, delimiters),
14
+ # filename hints, element cardinalities, and per‑element attribute types for all
15
+ # four supported list types (WKDL, VML, ERG, VRL).
16
+ #
17
+ # Intent
18
+ # - Provide fast, streaming validation without external dependencies.
19
+ # - Produce precise, stable error and warning messages suitable for tooling and
20
+ # tests (see `test/dsv7/*`).
21
+ # - Keep responsibilities narrow: structural checks here; parsing in
22
+ # {Dsv7::Parser}.
23
+ #
24
+ # Semantics
25
+ # - Errors on UTF‑8 BOM and on invalid UTF‑8 (input is scrubbed for messages).
26
+ # - Warns once when CRLF line endings are detected (still valid).
27
+ # - When validating a file path, may add a filename pattern warning if it
28
+ # does not match `JJJJ-MM-TT-Ort-Zusatz.DSV7`.
29
+ #
30
+ # @api public
31
+ # @since 7.0.0
32
+ # @example Validate a file by path
33
+ # result = Dsv7::Validator.validate('2024-01-01-Example-Wk.DSV7')
34
+ # result.valid? # => true/false
35
+ # result.errors # => ["..."]
36
+ # result.warnings # => ["..."]
37
+ # result.list_type # => 'Wettkampfdefinitionsliste' (after FORMAT)
38
+ # result.version # => '7'
39
+ #
40
+ # @see Dsv7::Parser For streaming parsing helpers and event API
8
41
  # Validates overall conformity of a DSV7 file against high-level rules
9
42
  # extracted from the specification markdown under `specification/dsv7`.
10
43
  #
@@ -12,6 +45,7 @@ module Dsv7
12
45
  # knowledge of the full element schemas.
13
46
  class Validator
14
47
  # Known list types from the overview section
48
+ # @return [Array<String>]
15
49
  ALLOWED_LIST_TYPES = %w[
16
50
  Wettkampfdefinitionsliste
17
51
  Vereinsmeldeliste
@@ -19,10 +53,18 @@ module Dsv7
19
53
  Vereinsergebnisliste
20
54
  ].freeze
21
55
 
22
- # Single public entrypoint. Accepts:
23
- # - IO-like objects (respond_to?(:read)) → streamed
56
+ # Validate a DSV7 input.
57
+ #
58
+ # Accepts:
59
+ # - IO-like objects (`respond_to?(:read)`) → streamed
24
60
  # - String paths to files → streamed
25
61
  # - String content → streamed via StringIO
62
+ #
63
+ # @param input [IO, String] An IO, a file path String, or a String with file content
64
+ # @api public
65
+ # @since 7.0.0
66
+ # @return [Dsv7::Validator::Result] Validation result with errors/warnings and metadata
67
+ # @raise [ArgumentError] if an unsupported input type is provided
26
68
  def self.validate(input)
27
69
  return new.send(:validate_stream, input) if input.respond_to?(:read)
28
70
  return validate_path(input) if input.is_a?(String) && File.file?(input)
@@ -34,6 +76,7 @@ module Dsv7
34
76
  class << self
35
77
  private
36
78
 
79
+ # @api private
37
80
  def validate_path(path)
38
81
  File.open(path, 'rb') do |io|
39
82
  return new.send(:validate_stream, io, filename: File.basename(path))
@@ -43,6 +86,10 @@ module Dsv7
43
86
 
44
87
  private
45
88
 
89
+ # @api private
90
+ # @param io [IO]
91
+ # @param filename [String, nil]
92
+ # @return [Dsv7::Validator::Result]
46
93
  def validate_stream(io, filename: nil)
47
94
  result = Result.new
48
95
  Core.new(result, filename).call_io(io)
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.0
4
+ version: 7.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - bigcurl
@@ -9,16 +9,19 @@ 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 SAX parser.
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"
21
23
  - ".ruby-version"
24
+ - ".yardopts"
22
25
  - AGENTS.md
23
26
  - Gemfile
24
27
  - Gemfile.lock
@@ -57,6 +60,7 @@ metadata:
57
60
  homepage_uri: https://github.com/bigcurl/dsv7-parser
58
61
  source_code_uri: https://github.com/bigcurl/dsv7-parser
59
62
  changelog_uri: https://github.com/bigcurl/dsv7-parser
63
+ documentation_uri: https://www.rubydoc.info/gems/dsv7-parser
60
64
  rubygems_mfa_required: 'true'
61
65
  rdoc_options: []
62
66
  require_paths: