genericode 0.1.1 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a658f75042c1064fc1032f885e266baeb816d38fd1f48324bdc791739abbd71e
4
- data.tar.gz: 7ebc14d95ed7538b3c3991baba75b78bd0661102e00e85625a7ef17f6d47ed1f
3
+ metadata.gz: e291ef80bb1e2146628255afde45053ca058c30da6bf183c4b53ff8e65b46fc2
4
+ data.tar.gz: fc1d89c86ed420b4b1969959dbd250bf768c719e0cedae2197613dfc7996c46f
5
5
  SHA512:
6
- metadata.gz: 304c01513d153bb25eed9cfc146a1502e2212404aa138574ded480e503142a1f2b11891e1ebddd08373780fef19d95133a2b97f969ef2501bb6bdb15b7aba3f8
7
- data.tar.gz: 5f801ef2ea74a25c30c1a189c9cf5d55d768f45cac0d223436d3e6bb0d2e26610f7c7c4efaf09ca604396e61c7192135532f75bfa2e6997b7fac321015163e0d
6
+ metadata.gz: 12e6bbca723ee3b97fa3da11a3ca65757988824df665b877836ed5c53c5d610fb81f2282659e64acbb9ab37ad99a6291c851598eb5fe689c3009d2e73b7d64c8
7
+ data.tar.gz: 5bbb18bbede6f7d905eea7b75c616f2c8466da97cdb992cfb518ba884aa56b2d126203549337162ebaaee9f160990f09a785e4ebe0ec5d7bd3a89aaa39ed36fd
data/.rubocop_todo.yml CHANGED
@@ -1,17 +1,32 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2024-08-27 09:46:41 UTC using RuboCop version 1.65.1.
3
+ # on 2025-01-11 09:46:54 UTC using RuboCop version 1.70.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
+ # Offense count: 4
10
+ # This cop supports safe autocorrection (--autocorrect).
11
+ # Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
12
+ # Include: **/*.gemfile, **/Gemfile, **/gems.rb
13
+ Bundler/OrderedGems:
14
+ Exclude:
15
+ - 'Gemfile'
16
+
9
17
  # Offense count: 1
10
- # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches.
18
+ # Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches, IgnoreDuplicateElseBranch.
11
19
  Lint/DuplicateBranch:
12
20
  Exclude:
13
21
  - 'lib/genericode/code_list.rb'
14
22
 
23
+ # Offense count: 1
24
+ # This cop supports safe autocorrection (--autocorrect).
25
+ # Configuration parameters: AutoCorrect, CheckForMethodsWithNoSideEffects.
26
+ Lint/Void:
27
+ Exclude:
28
+ - 'lib/genericode/code_list.rb'
29
+
15
30
  # Offense count: 8
16
31
  # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
17
32
  Metrics/AbcSize:
@@ -26,7 +41,7 @@ Metrics/BlockLength:
26
41
  # Offense count: 1
27
42
  # Configuration parameters: CountComments, CountAsOne.
28
43
  Metrics/ClassLength:
29
- Max: 220
44
+ Max: 216
30
45
 
31
46
  # Offense count: 5
32
47
  # Configuration parameters: AllowedMethods, AllowedPatterns.
@@ -45,7 +60,7 @@ Metrics/PerceivedComplexity:
45
60
 
46
61
  # Offense count: 2
47
62
  # This cop supports safe autocorrection (--autocorrect).
48
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
63
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
49
64
  # URISchemes: http, https
50
65
  Layout/LineLength:
51
66
  Max: 121
@@ -26,7 +26,7 @@ module Genericode
26
26
  namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
27
27
 
28
28
  map_element "Description", to: :description, prefix: nil, namespace: nil
29
- map_element "AppInfo", to: :app_info, prefix: nil, namespace: nil, render_nil: true
29
+ map_element "AppInfo", to: :app_info, prefix: nil, namespace: nil, value_map: { to: { nil: :empty } }
30
30
  end
31
31
  end
32
32
  end
@@ -22,13 +22,6 @@ module Genericode
22
22
 
23
23
  File.write(output_path, result)
24
24
  true
25
- # rescue JSON::ParserError => e
26
- # raise Error, "Invalid JSON in input file: #{e.message}"
27
- # rescue Shale::ParseError => e
28
- # raise Error, "Invalid XML in input file: #{e.message}"
29
- # rescue StandardError => e
30
- # raise Error, "Conversion error: #{e.message}"
31
- # end
32
25
  end
33
26
  end
34
27
  end
@@ -108,7 +108,7 @@ module Genericode
108
108
  result.value.to_h do |v|
109
109
  [column_set.column.find do |c|
110
110
  c.id == v.column_ref
111
- end.short_name.content, v.simple_value.content]
111
+ end.short_name.content, v.simple_value.content,]
112
112
  end
113
113
  end
114
114
  end
@@ -123,13 +123,13 @@ module Genericode
123
123
  # Rule 1: ColumnSet presence
124
124
  if column_set.nil? || column_set.column.empty?
125
125
  errors << { code: "MISSING_COLUMN_SET",
126
- message: "ColumnSet is missing or empty" }
126
+ message: "ColumnSet is missing or empty", }
127
127
  end
128
128
 
129
129
  # Rule 2: SimpleCodeList presence
130
130
  if simple_code_list.nil? || simple_code_list.row.empty?
131
131
  errors << { code: "MISSING_SIMPLE_CODE_LIST",
132
- message: "SimpleCodeList is missing or empty" }
132
+ message: "SimpleCodeList is missing or empty", }
133
133
  end
134
134
 
135
135
  # Rule 3: Unique column IDs
@@ -143,7 +143,7 @@ module Genericode
143
143
  row.value.each do |value|
144
144
  unless column_ids.include?(value.column_ref)
145
145
  errors << { code: "INVALID_COLUMN_REF",
146
- message: "Invalid ColumnRef '#{value.column_ref}' in row #{index + 1}" }
146
+ message: "Invalid ColumnRef '#{value.column_ref}' in row #{index + 1}", }
147
147
  end
148
148
  end
149
149
  end
@@ -165,7 +165,7 @@ module Genericode
165
165
  required_columns.each do |col|
166
166
  unless row.value.any? { |v| v.column_ref == col.id && v.simple_value&.content }
167
167
  errors << { code: "MISSING_REQUIRED_VALUE",
168
- message: "Missing value for required column '#{col.short_name&.content}' in row #{index + 1}" }
168
+ message: "Missing value for required column '#{col.short_name&.content}' in row #{index + 1}", }
169
169
  end
170
170
  end
171
171
  end
@@ -177,7 +177,7 @@ module Genericode
177
177
  value = row.value.find { |v| v.column_ref == col.id }&.simple_value&.content
178
178
  unless value_matches_type?(value, data_type)
179
179
  errors << { code: "INVALID_DATA_TYPE",
180
- message: "Invalid data type for column '#{col.short_name&.content}' in row #{index + 1}" }
180
+ message: "Invalid data type for column '#{col.short_name&.content}' in row #{index + 1}", }
181
181
  end
182
182
  end
183
183
  end
@@ -191,19 +191,19 @@ module Genericode
191
191
  column_set&.column&.each do |col|
192
192
  if col.data&.type && !valid_datatype_id?(col.data.type)
193
193
  errors << { code: "INVALID_DATATYPE_ID",
194
- message: "Invalid datatype ID for column '#{col.short_name&.content}'" }
194
+ message: "Invalid datatype ID for column '#{col.short_name&.content}'", }
195
195
  end
196
196
 
197
197
  # Rule 20 and 22: Complex data validation
198
198
  if col.data&.type == "*" && col.data&.datatype_library != "*"
199
199
  errors << { code: "INVALID_COMPLEX_DATA",
200
- message: "Invalid complex data configuration for column '#{col.short_name&.content}'" }
200
+ message: "Invalid complex data configuration for column '#{col.short_name&.content}'", }
201
201
  end
202
202
 
203
203
  # Rule 23: Language attribute validation
204
204
  if col.data&.lang && col.data_restrictions&.lang
205
205
  errors << { code: "DUPLICATE_LANG_ATTRIBUTE",
206
- message: "Duplicate lang attribute for column '#{col.short_name&.content}'" }
206
+ message: "Duplicate lang attribute for column '#{col.short_name&.content}'", }
207
207
  end
208
208
  end
209
209
 
@@ -218,7 +218,7 @@ module Genericode
218
218
  column_set&.column&.each do |col|
219
219
  if col.short_name&.content&.match?(/\s/)
220
220
  errors << { code: "INVALID_SHORT_NAME",
221
- message: "ShortName '#{col.short_name&.content}' contains whitespace" }
221
+ message: "ShortName '#{col.short_name&.content}' contains whitespace", }
222
222
  end
223
223
  end
224
224
 
@@ -229,7 +229,7 @@ module Genericode
229
229
 
230
230
  unless valid_complex_value?(value.complex_value, column_set&.column&.find { |c| c.id == value.column_ref })
231
231
  errors << { code: "INVALID_COMPLEX_VALUE",
232
- message: "Invalid ComplexValue in row #{index + 1}, column '#{value.column_ref}'" }
232
+ message: "Invalid ComplexValue in row #{index + 1}, column '#{value.column_ref}'", }
233
233
  end
234
234
  end
235
235
  end
@@ -20,7 +20,7 @@ module Genericode
20
20
  attribute :use, :string, default: -> { "optional" }
21
21
  attribute :annotation, Annotation
22
22
  attribute :short_name, ShortName
23
- attribute :long_name, LongName, collection: true
23
+ attribute :long_name, LongName, collection: true, initialize_empty: true
24
24
  attribute :canonical_uri, CanonicalUri
25
25
  attribute :canonical_version_uri, :string
26
26
  attribute :data, Data
@@ -50,7 +50,7 @@ module Genericode
50
50
  end
51
51
 
52
52
  def long_name_to_json(model, doc)
53
- return if model.long_name.empty?
53
+ return if model.long_name.nil? || model.long_name.empty?
54
54
 
55
55
  doc["LongName"] = LongName.as_json(Utils.one_or_all(model.long_name))
56
56
  end
@@ -14,8 +14,8 @@ module Genericode
14
14
  attribute :datatype_library, :string
15
15
  attribute :annotation, Annotation
16
16
  attribute :identification, Identification
17
- attribute :column, Column, collection: true
18
- attribute :column_ref, ColumnRef, collection: true
17
+ attribute :column, Column, collection: true, initialize_empty: true
18
+ attribute :column_ref, ColumnRef, collection: true, initialize_empty: true
19
19
  attribute :key, Key, collection: true
20
20
  attribute :key_ref, KeyRef, collection: true
21
21
 
@@ -17,12 +17,12 @@ module Genericode
17
17
  include Json::ShortNameMixin
18
18
 
19
19
  attribute :short_name, ShortName
20
- attribute :long_name, LongName, collection: true
20
+ attribute :long_name, LongName, collection: true, initialize_empty: true
21
21
  attribute :version, :string
22
22
  attribute :canonical_uri, CanonicalUri
23
23
  attribute :canonical_version_uri, :string
24
- attribute :location_uri, :string, collection: true
25
- attribute :alternate_format_location_uri, MimeTypedUri, collection: true
24
+ attribute :location_uri, :string, collection: true, initialize_empty: true
25
+ attribute :alternate_format_location_uri, MimeTypedUri, collection: true, initialize_empty: true
26
26
  attribute :agency, Agency
27
27
 
28
28
  json do
@@ -43,20 +43,19 @@ module Genericode
43
43
  end
44
44
 
45
45
  def long_name_to_json(model, doc)
46
- return if model.long_name.empty?
46
+ return if model.long_name.nil? || model.long_name.empty?
47
47
 
48
48
  doc["LongName"] = LongName.as_json(model.long_name)
49
49
  end
50
50
 
51
51
  def location_uri_from_json(model, value)
52
- # model.location_uri = Shale::Type::String.of_json(Utils.array_wrap(value))
53
52
  model.location_uri = Utils.array_wrap(value).map do |val|
54
53
  Lutaml::Model::Type::String.cast(val)
55
54
  end
56
55
  end
57
56
 
58
57
  def location_uri_to_json(model, doc)
59
- return if model.location_uri.empty?
58
+ return if model.location_uri.nil? || model.location_uri.empty?
60
59
 
61
60
  doc["LocationUri"] = Lutaml::Model::Type::String.cast(Utils.one_or_all(model.location_uri))
62
61
  end
@@ -66,7 +65,7 @@ module Genericode
66
65
  end
67
66
 
68
67
  def alternate_format_location_uri_to_json(model, doc)
69
- return if model.alternate_format_location_uri.empty?
68
+ return if model.alternate_format_location_uri.nil? || model.alternate_format_location_uri.empty?
70
69
 
71
70
  doc["AlternateFormatLocationUri"] = MimeTypedUri.as_json(Utils.one_or_all(model.alternate_format_location_uri))
72
71
  end
@@ -19,7 +19,7 @@ module Genericode
19
19
  attribute :id, :string
20
20
  attribute :annotation, Annotation
21
21
  attribute :short_name, ShortName
22
- attribute :long_name, LongName, collection: true
22
+ attribute :long_name, LongName, collection: true, initialize_empty: true
23
23
  attribute :canonical_uri, CanonicalUri
24
24
  attribute :canonical_version_uri, :string
25
25
  attribute :column_ref, KeyColumnRef, collection: true
@@ -39,7 +39,7 @@ module Genericode
39
39
  end
40
40
 
41
41
  def long_name_to_json(model, doc)
42
- return if model.long_name.empty?
42
+ return if model.long_name.nil? || model.long_name.empty?
43
43
 
44
44
  doc["LongName"] = LongName.as_json(model.long_name)
45
45
  end
@@ -8,7 +8,7 @@ require_relative "row"
8
8
  module Genericode
9
9
  class SimpleCodeList < Lutaml::Model::Serializable
10
10
  attribute :annotation, Annotation
11
- attribute :row, Row, collection: true
11
+ attribute :row, Row, collection: true, initialize_empty: true
12
12
 
13
13
  json do
14
14
  map "Annotation", to: :annotation
@@ -9,7 +9,7 @@ require_relative "column_ref"
9
9
 
10
10
  module Genericode
11
11
  class Value < Lutaml::Model::Serializable
12
- attribute :column_ref, ColumnRef
12
+ attribute :column_ref, :string
13
13
  attribute :annotation, Annotation
14
14
  attribute :simple_value, SimpleValue
15
15
  attribute :complex_value, AnyOtherContent
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Genericode
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genericode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-07 00:00:00.000000000 Z
11
+ date: 2025-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: csv
@@ -28,16 +28,16 @@ dependencies:
28
28
  name: lutaml-model
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '0.7'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '0.7'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: tabulo
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,90 +66,6 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: nokogiri
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: rake
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop-performance
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: xml-c14n
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
69
  description: Parser and generator for OASIS Genericode
154
70
  email:
155
71
  - open.source@ribose.com'
@@ -213,7 +129,7 @@ metadata:
213
129
  homepage_uri: https://github.com/lutaml/genericode
214
130
  source_code_uri: https://github.com/lutaml/genericode
215
131
  changelog_uri: https://github.com/lutaml/genericode/releases
216
- post_install_message:
132
+ post_install_message:
217
133
  rdoc_options: []
218
134
  require_paths:
219
135
  - lib
@@ -228,8 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
144
  - !ruby/object:Gem::Version
229
145
  version: '0'
230
146
  requirements: []
231
- rubygems_version: 3.3.27
232
- signing_key:
147
+ rubygems_version: 3.5.22
148
+ signing_key:
233
149
  specification_version: 4
234
150
  summary: Parser and generator for OASIS Genericode
235
151
  test_files: []