uddf 0.2.1 → 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: 2940685ef35816892c65ed029b230a73674018fa36801b53b4923d36da744c61
4
- data.tar.gz: b750a7bd240203df8aa939d73405c6fa003cc4f857612074edf0b6e84d5b1e63
3
+ metadata.gz: f5921b223dcc3e5f11aa591f8d7c2d2a4750d648a479453987c7c3d880f8a5f5
4
+ data.tar.gz: c370f0a496d02d07796ebf143f3cdf36ba8f46e4dd2b5ce4c28fdc43a72a2dc2
5
5
  SHA512:
6
- metadata.gz: b9afdce2237a0fb1c4ac923b6ef881a936f7d352f2f18f8d603b32b76a112fadfcf0a7ba8ce33023ea1d4144bc78446fdee4e1ba4a02fa9b3c39bb9bbe20138e
7
- data.tar.gz: cfc3637fdb8cb46dba294f36328c3952494ddf26c21558ada177accc57239f5b630424c4e1d6352bb3b91f086e468de11f26d9990f6bdf41763b647101d7b001
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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uddf (0.2.0)
4
+ uddf (0.3.0)
5
5
  nokogiri (~> 1.18)
6
6
  nokogiri-happymapper
7
7
 
@@ -11,6 +11,8 @@ GEM
11
11
  ast (2.4.3)
12
12
  cgi (0.5.0)
13
13
  date (3.4.1)
14
+ diff-lcs (1.6.2)
15
+ docile (1.4.1)
14
16
  erb (4.0.4)
15
17
  cgi (>= 0.3.3)
16
18
  io-console (0.8.1)
@@ -47,6 +49,20 @@ GEM
47
49
  regexp_parser (2.11.2)
48
50
  reline (0.6.2)
49
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)
50
66
  rubocop (1.80.0)
51
67
  json (~> 2.3)
52
68
  language_server-protocol (~> 3.17.0.2)
@@ -64,7 +80,19 @@ GEM
64
80
  rubocop-rake (0.7.1)
65
81
  lint_roller (~> 1.1)
66
82
  rubocop (>= 1.72.1)
83
+ rubocop-rspec (3.6.0)
84
+ lint_roller (~> 1.1)
85
+ rubocop (~> 1.72, >= 1.72.1)
67
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)
68
96
  stringio (3.1.7)
69
97
  unicode-display_width (3.1.5)
70
98
  unicode-emoji (~> 4.0, >= 4.0.4)
@@ -77,8 +105,12 @@ PLATFORMS
77
105
  DEPENDENCIES
78
106
  irb
79
107
  rake (~> 13.0)
108
+ rspec (~> 3.13)
80
109
  rubocop (~> 1.7)
81
110
  rubocop-rake (~> 0.7)
111
+ rubocop-rspec (~> 3.6)
112
+ simplecov (~> 0.21)
113
+ simplecov-cobertura (~> 3)
82
114
  uddf!
83
115
 
84
116
  BUNDLED WITH
data/README.md CHANGED
@@ -23,8 +23,8 @@ Ruby parser and validator for Universal Dive Data Format (UDDF) files. Supports
23
23
  | 3.2.1 | ✗ | ✓ |
24
24
  | 3.2.2 | ✗ | ✓ |
25
25
  | 3.2.3 | ✓ | ✓ |
26
- | 3.3.0 | | ✓ |
27
- | 3.3.1 | | ✓ |
26
+ | 3.3.0 | | ✓ |
27
+ | 3.3.1 | | ✓ |
28
28
 
29
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.
30
30
 
@@ -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