uddf 0.2.0 → 0.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09cfbcdb61be33c2f4197bdc466092bdc4c074054964b3aa19ed5acbf1922872'
4
- data.tar.gz: dbba5685e435e1a8b13944101b0ba73c1bfd34db6401b035290c0edefdc03231
3
+ metadata.gz: f5921b223dcc3e5f11aa591f8d7c2d2a4750d648a479453987c7c3d880f8a5f5
4
+ data.tar.gz: c370f0a496d02d07796ebf143f3cdf36ba8f46e4dd2b5ce4c28fdc43a72a2dc2
5
5
  SHA512:
6
- metadata.gz: 8fe628617c563846e599200c543c8bee52537e341587c4f283352af229f20c2557e7f31f48c139f00697c96e63cdc0581bd5b6a4db63e70474c58ed37e0163f0
7
- data.tar.gz: 22b6415ea1545394a71225cde9b06aee15b579e218bbaccb5c245bcd6262912a49d5ccdabac639872aff152f639fe83728c694beb3f13e14e1c973a53df12b6b
6
+ metadata.gz: 1aaab5423b3bf1e2584b6f03a712f3c13c8dc915c8d9a9d398c2d1971a9a6109175a25fb282df1626fc00ac6e1a0a2a60ca31daeea2f2fc796d4e9b1859dce76
7
+ data.tar.gz: 9b0f55690bf093b8650a0778905456b98bf560bfa72f89a0676c304c3d1ae767228430bd5865d178e8f0f2ba3e351f241d81e619c31d2e837ca7c45bd57e2f5c
data/.rubocop.yml CHANGED
@@ -1,4 +1,8 @@
1
- plugins: rubocop-rake
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ plugins:
4
+ - rubocop-rake
5
+ - rubocop-rspec
2
6
 
3
7
  AllCops:
4
8
  NewCops: enable
@@ -25,4 +29,7 @@ Style/Documentation:
25
29
  Exclude:
26
30
  - "spec/**/*"
27
31
  - "test/**/*"
32
+ - "lib/uddf/base/models.rb"
28
33
  - "lib/uddf/v323/models.rb"
34
+ - "lib/uddf/v330/models.rb"
35
+ - "lib/uddf/v331/models.rb"
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,62 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2025-08-23 14:52:40 UTC using RuboCop version 1.80.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 2
10
+ Lint/ShadowedException:
11
+ Exclude:
12
+ - 'lib/uddf/base/models.rb'
13
+
14
+ # Offense count: 4
15
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
16
+ Metrics/AbcSize:
17
+ Max: 35
18
+
19
+ # Offense count: 1
20
+ # Configuration parameters: AllowedMethods, AllowedPatterns.
21
+ Metrics/CyclomaticComplexity:
22
+ Max: 8
23
+
24
+ # Offense count: 3
25
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
26
+ Metrics/MethodLength:
27
+ Max: 21
28
+
29
+ # Offense count: 1
30
+ # Configuration parameters: IgnoredMetadata.
31
+ RSpec/DescribeClass:
32
+ Exclude:
33
+ - '**/spec/features/**/*'
34
+ - '**/spec/requests/**/*'
35
+ - '**/spec/routing/**/*'
36
+ - '**/spec/system/**/*'
37
+ - '**/spec/views/**/*'
38
+ - 'spec/uddf_parser_spec.rb'
39
+
40
+ # Offense count: 3
41
+ # Configuration parameters: CountAsOne.
42
+ RSpec/ExampleLength:
43
+ Max: 7
44
+
45
+ # Offense count: 5
46
+ RSpec/MultipleExpectations:
47
+ Max: 4
48
+
49
+ # Offense count: 5
50
+ # Configuration parameters: AllowedPatterns.
51
+ # AllowedPatterns: ^expect_, ^assert_
52
+ RSpec/NoExpectationExample:
53
+ Exclude:
54
+ - 'spec/uddf_parser_spec.rb'
55
+
56
+ # Offense count: 1
57
+ # This cop supports unsafe autocorrection (--autocorrect-all).
58
+ # Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
59
+ # AllowedMethods: present?, blank?, presence, try, try!
60
+ Style/SafeNavigation:
61
+ Exclude:
62
+ - 'spec/uddf_parser_spec.rb'
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.4
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uddf (0.1.0)
4
+ uddf (0.3.0)
5
+ nokogiri (~> 1.18)
5
6
  nokogiri-happymapper
6
7
 
7
8
  GEM
@@ -10,6 +11,8 @@ GEM
10
11
  ast (2.4.3)
11
12
  cgi (0.5.0)
12
13
  date (3.4.1)
14
+ diff-lcs (1.6.2)
15
+ docile (1.4.1)
13
16
  erb (4.0.4)
14
17
  cgi (>= 0.3.3)
15
18
  io-console (0.8.1)
@@ -20,9 +23,9 @@ GEM
20
23
  json (2.13.2)
21
24
  language_server-protocol (3.17.0.5)
22
25
  lint_roller (1.1.0)
23
- nokogiri (1.17.2-arm64-darwin)
26
+ nokogiri (1.18.9-arm64-darwin)
24
27
  racc (~> 1.4)
25
- nokogiri (1.17.2-x86_64-linux)
28
+ nokogiri (1.18.9-x86_64-linux-gnu)
26
29
  racc (~> 1.4)
27
30
  nokogiri-happymapper (0.10.0)
28
31
  nokogiri (~> 1.5)
@@ -46,6 +49,20 @@ GEM
46
49
  regexp_parser (2.11.2)
47
50
  reline (0.6.2)
48
51
  io-console (~> 0.5)
52
+ rexml (3.4.1)
53
+ rspec (3.13.1)
54
+ rspec-core (~> 3.13.0)
55
+ rspec-expectations (~> 3.13.0)
56
+ rspec-mocks (~> 3.13.0)
57
+ rspec-core (3.13.5)
58
+ rspec-support (~> 3.13.0)
59
+ rspec-expectations (3.13.5)
60
+ diff-lcs (>= 1.2.0, < 2.0)
61
+ rspec-support (~> 3.13.0)
62
+ rspec-mocks (3.13.5)
63
+ diff-lcs (>= 1.2.0, < 2.0)
64
+ rspec-support (~> 3.13.0)
65
+ rspec-support (3.13.5)
49
66
  rubocop (1.80.0)
50
67
  json (~> 2.3)
51
68
  language_server-protocol (~> 3.17.0.2)
@@ -63,7 +80,19 @@ GEM
63
80
  rubocop-rake (0.7.1)
64
81
  lint_roller (~> 1.1)
65
82
  rubocop (>= 1.72.1)
83
+ rubocop-rspec (3.6.0)
84
+ lint_roller (~> 1.1)
85
+ rubocop (~> 1.72, >= 1.72.1)
66
86
  ruby-progressbar (1.13.0)
87
+ simplecov (0.22.0)
88
+ docile (~> 1.1)
89
+ simplecov-html (~> 0.11)
90
+ simplecov_json_formatter (~> 0.1)
91
+ simplecov-cobertura (3.0.0)
92
+ rexml
93
+ simplecov (~> 0.19)
94
+ simplecov-html (0.13.2)
95
+ simplecov_json_formatter (0.1.4)
67
96
  stringio (3.1.7)
68
97
  unicode-display_width (3.1.5)
69
98
  unicode-emoji (~> 4.0, >= 4.0.4)
@@ -76,9 +105,13 @@ PLATFORMS
76
105
  DEPENDENCIES
77
106
  irb
78
107
  rake (~> 13.0)
108
+ rspec (~> 3.13)
79
109
  rubocop (~> 1.7)
80
110
  rubocop-rake (~> 0.7)
111
+ rubocop-rspec (~> 3.6)
112
+ simplecov (~> 0.21)
113
+ simplecov-cobertura (~> 3)
81
114
  uddf!
82
115
 
83
116
  BUNDLED WITH
84
- 2.5.23
117
+ 2.7.1
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/uddf.svg)](https://badge.fury.io/rb/uddf)
2
+
1
3
  # UDDF
2
4
 
3
5
  Ruby parser and validator for Universal Dive Data Format (UDDF) files. Supports multiple UDDF versions with version-specific model loading.
@@ -21,8 +23,10 @@ Ruby parser and validator for Universal Dive Data Format (UDDF) files. Supports
21
23
  | 3.2.1 | ✗ | ✓ |
22
24
  | 3.2.2 | ✗ | ✓ |
23
25
  | 3.2.3 | ✓ | ✓ |
24
- | 3.3.0 | | ✓ |
25
- | 3.3.1 | | ✓ |
26
+ | 3.3.0 | | ✓ |
27
+ | 3.3.1 | | ✓ |
28
+
29
+ > **Note**: The UDDF 3.3.0 and 3.3.1 schema files included in this gem have been locally modified to fix XML Schema validation errors that prevented them from loading with Nokogiri. These fixes address syntax issues in the original schemas but may not represent the upstream maintainers' intentions. The modifications ensure compatibility with standard XML Schema validators while preserving the core schema structure and validation rules.
26
30
 
27
31
  ## Usage
28
32
 
@@ -34,6 +34,42 @@ module UDDF
34
34
  has_many :mobile_phones, String, tag: "mobilephone"
35
35
  has_many :phones, String, tag: "phone"
36
36
  end
37
+
38
+ class DateTimeField
39
+ include HappyMapper
40
+
41
+ element :raw, String, tag: "datetime"
42
+
43
+ # Lazily parse on first access; memoize in @date_time
44
+ def date_time
45
+ return @date_time if @date_time
46
+
47
+ content = raw.to_s.strip
48
+ return nil if content.empty?
49
+
50
+ @date_time =
51
+ case content
52
+ when /^\d{4}$/ # "YYYY"
53
+ DateTime.new(content.to_i, 1, 1)
54
+ when /^\d{4}-\d{2}$/ # "YYYY-MM"
55
+ y, m = content.split("-").map!(&:to_i)
56
+ DateTime.new(y, m, 1)
57
+ else
58
+ begin
59
+ DateTime.iso8601(content)
60
+ rescue ArgumentError, Date::Error
61
+ begin
62
+ DateTime.rfc3339(content)
63
+ rescue ArgumentError, Date::Error
64
+ DateTime.parse(content)
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ # Allow manual assignment if you ever need it
71
+ attr_writer :date_time
72
+ end
37
73
  end
38
74
  end
39
75
  end