genericode 0.1.3 → 0.2.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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -28
  3. data/.rubocop_todo.yml +36 -12
  4. data/Rakefile +3 -3
  5. data/exe/genericode +2 -2
  6. data/lib/genericode/agency.rb +15 -16
  7. data/lib/genericode/annotation.rb +9 -10
  8. data/lib/genericode/any_other_content.rb +2 -3
  9. data/lib/genericode/any_other_language_content.rb +6 -6
  10. data/lib/genericode/canonical_uri.rb +3 -3
  11. data/lib/genericode/cli/code_lister.rb +19 -14
  12. data/lib/genericode/cli/code_lookup.rb +1 -1
  13. data/lib/genericode/cli/commands.rb +21 -18
  14. data/lib/genericode/cli/converter.rb +10 -4
  15. data/lib/genericode/cli/validator.rb +12 -5
  16. data/lib/genericode/cli.rb +1 -1
  17. data/lib/genericode/code_list.rb +64 -63
  18. data/lib/genericode/code_list_ref.rb +12 -13
  19. data/lib/genericode/code_list_set.rb +20 -21
  20. data/lib/genericode/code_list_set_ref.rb +14 -14
  21. data/lib/genericode/column.rb +31 -32
  22. data/lib/genericode/column_ref.rb +18 -19
  23. data/lib/genericode/column_set.rb +22 -23
  24. data/lib/genericode/column_set_ref.rb +9 -10
  25. data/lib/genericode/data.rb +14 -15
  26. data/lib/genericode/data_restrictions.rb +7 -8
  27. data/lib/genericode/datatype_facet.rb +8 -9
  28. data/lib/genericode/gc_namespace.rb +12 -0
  29. data/lib/genericode/general_identifier.rb +9 -9
  30. data/lib/genericode/identification.rb +31 -32
  31. data/lib/genericode/json/canonical_uri_mixin.rb +1 -1
  32. data/lib/genericode/json/short_name_mixin.rb +1 -1
  33. data/lib/genericode/key.rb +26 -27
  34. data/lib/genericode/key_column_ref.rb +7 -8
  35. data/lib/genericode/key_ref.rb +13 -14
  36. data/lib/genericode/long_name.rb +11 -11
  37. data/lib/genericode/mime_typed_uri.rb +5 -6
  38. data/lib/genericode/row.rb +8 -9
  39. data/lib/genericode/short_name.rb +7 -7
  40. data/lib/genericode/simple_code_list.rb +8 -9
  41. data/lib/genericode/simple_value.rb +3 -4
  42. data/lib/genericode/value.rb +14 -15
  43. data/lib/genericode/version.rb +1 -1
  44. data/lib/genericode.rb +4 -5
  45. metadata +11 -9
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/model"
3
+ require 'lutaml/model'
4
4
 
5
- require_relative "annotation"
6
- require_relative "column"
7
- require_relative "column_ref"
8
- require_relative "identification"
9
- require_relative "key"
10
- require_relative "key_ref"
5
+ require_relative 'annotation'
6
+ require_relative 'column'
7
+ require_relative 'column_ref'
8
+ require_relative 'identification'
9
+ require_relative 'key'
10
+ require_relative 'key_ref'
11
11
 
12
12
  module Genericode
13
13
  class ColumnSet < Lutaml::Model::Serializable
@@ -20,26 +20,25 @@ module Genericode
20
20
  attribute :key_ref, KeyRef, collection: true
21
21
 
22
22
  json do
23
- map "DatatypeLibrary", to: :datatype_library
24
- map "Annotation", to: :annotation
25
- map "Identification", to: :identification
26
- map "Column", to: :column
27
- map "ColumnRef", to: :column_ref
28
- map "Key", to: :key
29
- map "KeyRef", to: :key_ref
23
+ map 'DatatypeLibrary', to: :datatype_library
24
+ map 'Annotation', to: :annotation
25
+ map 'Identification', to: :identification
26
+ map 'Column', to: :column
27
+ map 'ColumnRef', to: :column_ref
28
+ map 'Key', to: :key
29
+ map 'KeyRef', to: :key_ref
30
30
  end
31
31
 
32
32
  xml do
33
- root "ColumnSet"
34
- namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
33
+ element 'ColumnSet'
35
34
 
36
- map_attribute "DatatypeLibrary", to: :datatype_library
37
- map_element "Annotation", to: :annotation, prefix: nil, namespace: nil
38
- map_element "Identification", to: :identification, prefix: nil, namespace: nil
39
- map_element "Column", to: :column, prefix: nil, namespace: nil
40
- map_element "ColumnRef", to: :column_ref, prefix: nil, namespace: nil
41
- map_element "Key", to: :key, prefix: nil, namespace: nil
42
- map_element "KeyRef", to: :key_ref, prefix: nil, namespace: nil
35
+ map_attribute 'DatatypeLibrary', to: :datatype_library
36
+ map_element 'Annotation', to: :annotation
37
+ map_element 'Identification', to: :identification
38
+ map_element 'Column', to: :column
39
+ map_element 'ColumnRef', to: :column_ref
40
+ map_element 'Key', to: :key
41
+ map_element 'KeyRef', to: :key_ref
43
42
  end
44
43
  end
45
44
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/model"
3
+ require 'lutaml/model'
4
4
 
5
- require_relative "annotation"
5
+ require_relative 'annotation'
6
6
 
7
7
  module Genericode
8
8
  class ColumnSetRef < Lutaml::Model::Serializable
@@ -11,18 +11,17 @@ module Genericode
11
11
  attribute :location_uri, :string, collection: true
12
12
 
13
13
  json do
14
- map "Annotation", to: :annotation
15
- map "CanonicalVersionUri", to: :canonical_version_uri
16
- map "LocationUri", to: :location_uri
14
+ map 'Annotation', to: :annotation
15
+ map 'CanonicalVersionUri', to: :canonical_version_uri
16
+ map 'LocationUri', to: :location_uri
17
17
  end
18
18
 
19
19
  xml do
20
- root "ColumnSetRef"
21
- namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
20
+ element 'ColumnSetRef'
22
21
 
23
- map_element "Annotation", to: :annotation, prefix: nil, namespace: nil
24
- map_element "CanonicalVersionUri", to: :canonical_version_uri, prefix: nil, namespace: nil
25
- map_element "LocationUri", to: :location_uri, prefix: nil, namespace: nil
22
+ map_element 'Annotation', to: :annotation
23
+ map_element 'CanonicalVersionUri', to: :canonical_version_uri
24
+ map_element 'LocationUri', to: :location_uri
26
25
  end
27
26
  end
28
27
  end
@@ -1,9 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/model"
3
+ require 'lutaml/model'
4
4
 
5
- require_relative "annotation"
6
- require_relative "datatype_facet"
5
+ require_relative 'annotation'
6
+ require_relative 'datatype_facet'
7
7
 
8
8
  module Genericode
9
9
  class Data < Lutaml::Model::Serializable
@@ -14,22 +14,21 @@ module Genericode
14
14
  attribute :parameter, DatatypeFacet, collection: true
15
15
 
16
16
  json do
17
- map "Type", to: :type
18
- map "DatatypeLibrary", to: :datatype_library
19
- map "Lang", to: :lang
20
- map "Annotation", to: :annotation
21
- map "Parameter", to: :parameter
17
+ map 'Type', to: :type
18
+ map 'DatatypeLibrary', to: :datatype_library
19
+ map 'Lang', to: :lang
20
+ map 'Annotation', to: :annotation
21
+ map 'Parameter', to: :parameter
22
22
  end
23
23
 
24
24
  xml do
25
- root "Data"
26
- namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
25
+ element 'Data'
27
26
 
28
- map_attribute "Type", to: :type
29
- map_attribute "DatatypeLibrary", to: :datatype_library
30
- map_attribute "Lang", to: :lang
31
- map_element "Annotation", to: :annotation, prefix: nil, namespace: nil
32
- map_element "Parameter", to: :parameter, prefix: nil, namespace: nil
27
+ map_attribute 'Type', to: :type
28
+ map_attribute 'DatatypeLibrary', to: :datatype_library
29
+ map_attribute 'Lang', to: :lang
30
+ map_element 'Annotation', to: :annotation
31
+ map_element 'Parameter', to: :parameter
33
32
  end
34
33
  end
35
34
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/model"
3
+ require 'lutaml/model'
4
4
 
5
- require_relative "datatype_facet"
5
+ require_relative 'datatype_facet'
6
6
 
7
7
  module Genericode
8
8
  class DataRestrictions < Lutaml::Model::Serializable
@@ -10,16 +10,15 @@ module Genericode
10
10
  attribute :parameter, DatatypeFacet, collection: true
11
11
 
12
12
  json do
13
- map "Lang", to: :lang
14
- map "Parameter", to: :parameter
13
+ map 'Lang', to: :lang
14
+ map 'Parameter', to: :parameter
15
15
  end
16
16
 
17
17
  xml do
18
- root "DataRestrictions"
19
- namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
18
+ element 'DataRestrictions'
20
19
 
21
- map_attribute "Lang", to: :lang
22
- map_element "Parameter", to: :parameter, prefix: nil, namespace: nil
20
+ map_attribute 'Lang', to: :lang
21
+ map_element 'Parameter', to: :parameter
23
22
  end
24
23
  end
25
24
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/model"
4
- require_relative "json/short_name_mixin"
3
+ require 'lutaml/model'
4
+ require_relative 'json/short_name_mixin'
5
5
 
6
6
  module Genericode
7
7
  class DatatypeFacet < Lutaml::Model::Serializable
@@ -12,18 +12,17 @@ module Genericode
12
12
  attribute :long_name, :string
13
13
 
14
14
  json do
15
- map "ShortName", to: :short_name, with: { from: :short_name_from_json, to: :short_name_to_json }
16
- map "LongName", to: :long_name
17
- map "_", to: :content
15
+ map 'ShortName', to: :short_name, with: { from: :short_name_from_json, to: :short_name_to_json }
16
+ map 'LongName', to: :long_name
17
+ map '_', to: :content
18
18
  end
19
19
 
20
20
  xml do
21
- root "DatatypeFacet"
22
- namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
21
+ element 'DatatypeFacet'
23
22
 
24
23
  map_content to: :content
25
- map_attribute "ShortName", to: :short_name
26
- map_attribute "LongName", to: :long_name
24
+ map_attribute 'ShortName', to: :short_name
25
+ map_attribute 'LongName', to: :long_name
27
26
  end
28
27
  end
29
28
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'lutaml/xml/namespace'
4
+
5
+ module Genericode
6
+ class GcNamespace < Lutaml::Xml::Namespace
7
+ uri 'http://docs.oasis-open.org/codelist/ns/genericode/1.0/'
8
+ prefix_default 'gc'
9
+ element_form_default :unqualified
10
+ attribute_form_default :unqualified
11
+ end
12
+ end
@@ -1,26 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/model"
3
+ require 'lutaml/model'
4
+ require 'lutaml/xml/w3c'
4
5
 
5
6
  module Genericode
6
7
  class GeneralIdentifier < Lutaml::Model::Serializable
7
8
  attribute :content, :string
8
9
  attribute :identifier, :string
9
- attribute :lang, :string
10
+ attribute :lang, Lutaml::Xml::W3c::XmlLangType
10
11
 
11
12
  json do
12
- map "Identifier", to: :identifier
13
- map "lang", to: :lang
14
- map "_", to: :content
13
+ map 'Identifier', to: :identifier
14
+ map 'lang', to: :lang
15
+ map '_', to: :content
15
16
  end
16
17
 
17
18
  xml do
18
- root "GeneralIdentifier"
19
- namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
19
+ element 'GeneralIdentifier'
20
20
 
21
21
  map_content to: :content
22
- map_attribute "Identifier", to: :identifier
23
- map_attribute "lang", to: :lang, prefix: "xml", namespace: "http://www.w3.org/XML/1998/namespace"
22
+ map_attribute 'Identifier', to: :identifier
23
+ map_attribute 'lang', to: :lang
24
24
  end
25
25
  end
26
26
  end
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/model"
3
+ require 'lutaml/model'
4
4
 
5
- require_relative "agency"
6
- require_relative "long_name"
7
- require_relative "mime_typed_uri"
8
- require_relative "canonical_uri"
9
- require_relative "short_name"
10
- require_relative "json/short_name_mixin"
11
- require_relative "json/canonical_uri_mixin"
12
- require_relative "utils"
5
+ require_relative 'agency'
6
+ require_relative 'long_name'
7
+ require_relative 'mime_typed_uri'
8
+ require_relative 'canonical_uri'
9
+ require_relative 'short_name'
10
+ require_relative 'json/short_name_mixin'
11
+ require_relative 'json/canonical_uri_mixin'
12
+ require_relative 'utils'
13
13
 
14
14
  module Genericode
15
15
  class Identification < Lutaml::Model::Serializable
@@ -26,16 +26,16 @@ module Genericode
26
26
  attribute :agency, Agency
27
27
 
28
28
  json do
29
- map "ShortName", to: :short_name, with: { from: :short_name_from_json, to: :short_name_to_json }
30
- map "LongName", to: :long_name, with: { from: :long_name_from_json, to: :long_name_to_json }
31
- map "Version", to: :version
32
- map "CanonicalUri", to: :canonical_uri, with: { from: :canonical_uri_from_json, to: :canonical_uri_to_json }
33
- map "CanonicalVersionUri", to: :canonical_version_uri
34
- map "LocationUri", to: :location_uri, with: { from: :location_uri_from_json, to: :location_uri_to_json }
35
- map "AlternateFormatLocationUri", to: :alternate_format_location_uri,
29
+ map 'ShortName', to: :short_name, with: { from: :short_name_from_json, to: :short_name_to_json }
30
+ map 'LongName', to: :long_name, with: { from: :long_name_from_json, to: :long_name_to_json }
31
+ map 'Version', to: :version
32
+ map 'CanonicalUri', to: :canonical_uri, with: { from: :canonical_uri_from_json, to: :canonical_uri_to_json }
33
+ map 'CanonicalVersionUri', to: :canonical_version_uri
34
+ map 'LocationUri', to: :location_uri, with: { from: :location_uri_from_json, to: :location_uri_to_json }
35
+ map 'AlternateFormatLocationUri', to: :alternate_format_location_uri,
36
36
  with: { from: :alternate_format_location_uri_from_json,
37
- to: :alternate_format_location_uri_to_json, }
38
- map "Agency", to: :agency
37
+ to: :alternate_format_location_uri_to_json }
38
+ map 'Agency', to: :agency
39
39
  end
40
40
 
41
41
  def long_name_from_json(model, value)
@@ -45,7 +45,7 @@ module Genericode
45
45
  def long_name_to_json(model, doc)
46
46
  return if model.long_name.nil? || model.long_name.empty?
47
47
 
48
- doc["LongName"] = LongName.as_json(model.long_name)
48
+ doc['LongName'] = LongName.as_json(model.long_name)
49
49
  end
50
50
 
51
51
  def location_uri_from_json(model, value)
@@ -57,7 +57,7 @@ module Genericode
57
57
  def location_uri_to_json(model, doc)
58
58
  return if model.location_uri.nil? || model.location_uri.empty?
59
59
 
60
- doc["LocationUri"] = Lutaml::Model::Type::String.cast(Utils.one_or_all(model.location_uri))
60
+ doc['LocationUri'] = Lutaml::Model::Type::String.cast(Utils.one_or_all(model.location_uri))
61
61
  end
62
62
 
63
63
  def alternate_format_location_uri_from_json(model, value)
@@ -67,21 +67,20 @@ module Genericode
67
67
  def alternate_format_location_uri_to_json(model, doc)
68
68
  return if model.alternate_format_location_uri.nil? || model.alternate_format_location_uri.empty?
69
69
 
70
- doc["AlternateFormatLocationUri"] = MimeTypedUri.as_json(Utils.one_or_all(model.alternate_format_location_uri))
70
+ doc['AlternateFormatLocationUri'] = MimeTypedUri.as_json(Utils.one_or_all(model.alternate_format_location_uri))
71
71
  end
72
72
 
73
73
  xml do
74
- root "Identification"
75
- namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
76
-
77
- map_element "ShortName", to: :short_name, prefix: nil, namespace: nil
78
- map_element "LongName", to: :long_name, prefix: nil, namespace: nil
79
- map_element "Version", to: :version, prefix: nil, namespace: nil
80
- map_element "CanonicalUri", to: :canonical_uri, prefix: nil, namespace: nil
81
- map_element "CanonicalVersionUri", to: :canonical_version_uri, prefix: nil, namespace: nil
82
- map_element "LocationUri", to: :location_uri, prefix: nil, namespace: nil
83
- map_element "AlternateFormatLocationUri", to: :alternate_format_location_uri, prefix: nil, namespace: nil
84
- map_element "Agency", to: :agency, prefix: nil, namespace: nil
74
+ element 'Identification'
75
+
76
+ map_element 'ShortName', to: :short_name
77
+ map_element 'LongName', to: :long_name
78
+ map_element 'Version', to: :version
79
+ map_element 'CanonicalUri', to: :canonical_uri
80
+ map_element 'CanonicalVersionUri', to: :canonical_version_uri
81
+ map_element 'LocationUri', to: :location_uri
82
+ map_element 'AlternateFormatLocationUri', to: :alternate_format_location_uri
83
+ map_element 'Agency', to: :agency
85
84
  end
86
85
  end
87
86
  end
@@ -10,7 +10,7 @@ module Genericode
10
10
  def canonical_uri_to_json(model, doc)
11
11
  return if model.canonical_uri.nil?
12
12
 
13
- doc["CanonicalUri"] = model.canonical_uri&.content
13
+ doc['CanonicalUri'] = model.canonical_uri&.content
14
14
  end
15
15
  end
16
16
  end
@@ -10,7 +10,7 @@ module Genericode
10
10
  def short_name_to_json(model, doc)
11
11
  return if model.short_name.nil?
12
12
 
13
- doc["ShortName"] = model.short_name.content
13
+ doc['ShortName'] = model.short_name.content
14
14
  end
15
15
  end
16
16
  end
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/model"
3
+ require 'lutaml/model'
4
4
 
5
- require_relative "annotation"
6
- require_relative "key_column_ref"
7
- require_relative "canonical_uri"
8
- require_relative "long_name"
9
- require_relative "short_name"
10
- require_relative "json/short_name_mixin"
11
- require_relative "json/canonical_uri_mixin"
12
- require_relative "utils"
5
+ require_relative 'annotation'
6
+ require_relative 'key_column_ref'
7
+ require_relative 'canonical_uri'
8
+ require_relative 'long_name'
9
+ require_relative 'short_name'
10
+ require_relative 'json/short_name_mixin'
11
+ require_relative 'json/canonical_uri_mixin'
12
+ require_relative 'utils'
13
13
 
14
14
  module Genericode
15
15
  class Key < Lutaml::Model::Serializable
@@ -25,13 +25,13 @@ module Genericode
25
25
  attribute :column_ref, KeyColumnRef, collection: true
26
26
 
27
27
  json do
28
- map "Id", to: :id
29
- map "Annotation", to: :annotation
30
- map "ShortName", to: :short_name, with: { from: :short_name_from_json, to: :short_name_to_json }
31
- map "LongName", to: :long_name, with: { from: :long_name_from_json, to: :long_name_to_json }
32
- map "CanonicalUri", to: :canonical_uri, with: { from: :canonical_uri_from_json, to: :canonical_uri_to_json }
33
- map "CanonicalVersionUri", to: :canonical_version_uri
34
- map "ColumnRef", to: :column_ref, with: { from: :column_ref_from_json, to: :column_ref_to_json }
28
+ map 'Id', to: :id
29
+ map 'Annotation', to: :annotation
30
+ map 'ShortName', to: :short_name, with: { from: :short_name_from_json, to: :short_name_to_json }
31
+ map 'LongName', to: :long_name, with: { from: :long_name_from_json, to: :long_name_to_json }
32
+ map 'CanonicalUri', to: :canonical_uri, with: { from: :canonical_uri_from_json, to: :canonical_uri_to_json }
33
+ map 'CanonicalVersionUri', to: :canonical_version_uri
34
+ map 'ColumnRef', to: :column_ref, with: { from: :column_ref_from_json, to: :column_ref_to_json }
35
35
  end
36
36
 
37
37
  def long_name_from_json(model, value)
@@ -41,7 +41,7 @@ module Genericode
41
41
  def long_name_to_json(model, doc)
42
42
  return if model.long_name.nil? || model.long_name.empty?
43
43
 
44
- doc["LongName"] = LongName.as_json(model.long_name)
44
+ doc['LongName'] = LongName.as_json(model.long_name)
45
45
  end
46
46
 
47
47
  def column_ref_from_json(model, value)
@@ -49,20 +49,19 @@ module Genericode
49
49
  end
50
50
 
51
51
  def column_ref_to_json(model, doc)
52
- doc["ColumnRef"] = Utils.one_or_all(model.column_ref.map(&:ref))
52
+ doc['ColumnRef'] = Utils.one_or_all(model.column_ref.map(&:ref))
53
53
  end
54
54
 
55
55
  xml do
56
- root "Key"
57
- namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
56
+ element 'Key'
58
57
 
59
- map_attribute "Id", to: :id
60
- map_element "Annotation", to: :annotation, prefix: nil, namespace: nil
61
- map_element "ShortName", to: :short_name, prefix: nil, namespace: nil
62
- map_element "LongName", to: :long_name, prefix: nil, namespace: nil
63
- map_element "CanonicalUri", to: :canonical_uri, prefix: nil, namespace: nil
64
- map_element "CanonicalVersionUri", to: :canonical_version_uri, prefix: nil, namespace: nil
65
- map_element "ColumnRef", to: :column_ref, prefix: nil, namespace: nil
58
+ map_attribute 'Id', to: :id
59
+ map_element 'Annotation', to: :annotation
60
+ map_element 'ShortName', to: :short_name
61
+ map_element 'LongName', to: :long_name
62
+ map_element 'CanonicalUri', to: :canonical_uri
63
+ map_element 'CanonicalVersionUri', to: :canonical_version_uri
64
+ map_element 'ColumnRef', to: :column_ref
66
65
  end
67
66
  end
68
67
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/model"
3
+ require 'lutaml/model'
4
4
 
5
- require_relative "annotation"
5
+ require_relative 'annotation'
6
6
 
7
7
  module Genericode
8
8
  class KeyColumnRef < Lutaml::Model::Serializable
@@ -10,16 +10,15 @@ module Genericode
10
10
  attribute :annotation, Annotation
11
11
 
12
12
  json do
13
- map "Ref", to: :ref
14
- map "Annotation", to: :annotation
13
+ map 'Ref', to: :ref
14
+ map 'Annotation', to: :annotation
15
15
  end
16
16
 
17
17
  xml do
18
- root "KeyColumnRef"
19
- namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
18
+ element 'KeyColumnRef'
20
19
 
21
- map_attribute "Ref", to: :ref
22
- map_element "Annotation", to: :annotation, prefix: nil, namespace: nil
20
+ map_attribute 'Ref', to: :ref
21
+ map_element 'Annotation', to: :annotation
23
22
  end
24
23
  end
25
24
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/model"
3
+ require 'lutaml/model'
4
4
 
5
- require_relative "annotation"
5
+ require_relative 'annotation'
6
6
 
7
7
  module Genericode
8
8
  class KeyRef < Lutaml::Model::Serializable
@@ -13,22 +13,21 @@ module Genericode
13
13
  attribute :location_uri, :string, collection: true
14
14
 
15
15
  json do
16
- map "Id", to: :id
17
- map "ExternalRef", to: :external_ref
18
- map "Annotation", to: :annotation
19
- map "CanonicalVersionUri", to: :canonical_version_uri
20
- map "LocationUri", to: :location_uri
16
+ map 'Id', to: :id
17
+ map 'ExternalRef', to: :external_ref
18
+ map 'Annotation', to: :annotation
19
+ map 'CanonicalVersionUri', to: :canonical_version_uri
20
+ map 'LocationUri', to: :location_uri
21
21
  end
22
22
 
23
23
  xml do
24
- root "KeyRef"
25
- namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
24
+ element 'KeyRef'
26
25
 
27
- map_attribute "Id", to: :id
28
- map_attribute "ExternalRef", to: :external_ref
29
- map_element "Annotation", to: :annotation, prefix: nil, namespace: nil
30
- map_element "CanonicalVersionUri", to: :canonical_version_uri, prefix: nil, namespace: nil
31
- map_element "LocationUri", to: :location_uri, prefix: nil, namespace: nil
26
+ map_attribute 'Id', to: :id
27
+ map_attribute 'ExternalRef', to: :external_ref
28
+ map_element 'Annotation', to: :annotation
29
+ map_element 'CanonicalVersionUri', to: :canonical_version_uri
30
+ map_element 'LocationUri', to: :location_uri
32
31
  end
33
32
  end
34
33
  end
@@ -1,36 +1,36 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/model"
3
+ require 'lutaml/model'
4
+ require 'lutaml/xml/w3c'
4
5
 
5
6
  module Genericode
6
7
  class LongName < Lutaml::Model::Serializable
7
8
  attribute :content, :string
8
9
  attribute :identifier, :string
9
- attribute :lang, :string
10
+ attribute :lang, Lutaml::Xml::W3c::XmlLangType
10
11
 
11
12
  json do
12
- map "Identifier", to: :identifier
13
- map "http://www.w3.org/XML/1998/namespace", to: :lang, with: { from: :lang_from_json, to: :lang_to_json }
14
- map "_", to: :content
13
+ map 'Identifier', to: :identifier
14
+ map 'http://www.w3.org/XML/1998/namespace', to: :lang, with: { from: :lang_from_json, to: :lang_to_json }
15
+ map '_', to: :content
15
16
  end
16
17
 
17
18
  def lang_from_json(model, value)
18
- model.lang = value["lang"]
19
+ model.lang = value['lang']
19
20
  end
20
21
 
21
22
  def lang_to_json(model, doc)
22
23
  return if model.lang.nil?
23
24
 
24
- doc["http://www.w3.org/XML/1998/namespace"] = { "lang" => model.lang }
25
+ doc['http://www.w3.org/XML/1998/namespace'] = { 'lang' => model.lang }
25
26
  end
26
27
 
27
28
  xml do
28
- root "LongName"
29
- namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
29
+ element 'LongName'
30
30
 
31
31
  map_content to: :content
32
- map_attribute "Identifier", to: :identifier
33
- map_attribute "lang", to: :lang, prefix: "xml", namespace: "http://www.w3.org/XML/1998/namespace"
32
+ map_attribute 'Identifier', to: :identifier
33
+ map_attribute 'lang', to: :lang
34
34
  end
35
35
  end
36
36
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "lutaml/model"
3
+ require 'lutaml/model'
4
4
 
5
5
  module Genericode
6
6
  class MimeTypedUri < Lutaml::Model::Serializable
@@ -8,16 +8,15 @@ module Genericode
8
8
  attribute :mime_type, :string
9
9
 
10
10
  json do
11
- map "MimeType", to: :mime_type
12
- map "_", to: :content
11
+ map 'MimeType', to: :mime_type
12
+ map '_', to: :content
13
13
  end
14
14
 
15
15
  xml do
16
- root "MimeTypedUri"
17
- namespace "http://docs.oasis-open.org/codelist/ns/genericode/1.0/", "gc"
16
+ element 'MimeTypedUri'
18
17
 
19
18
  map_content to: :content
20
- map_attribute "MimeType", to: :mime_type
19
+ map_attribute 'MimeType', to: :mime_type
21
20
  end
22
21
  end
23
22
  end