relaton-iso 2.0.0 → 2.1.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: f0a58fc84ec9c809db2fc25e77930077b6a73ab11e133c4bdb2d652adf600594
4
- data.tar.gz: 3691f0bd3e4eea35141266fbaceb40f3a1dd83fb56c40852db49a3f030f46a5c
3
+ metadata.gz: fd102580f9b62955c20c472e51fa4ef1ebf17da882ec6831d29b6c50736f45d1
4
+ data.tar.gz: 90539cae8ac8b65341a3a9e169095f509f83eebd511e2379355fd1492cfd443b
5
5
  SHA512:
6
- metadata.gz: 8eaaf4e1dfb0216737f9344b2c4f43981411135f1c953f8536e1c58fdc4b56c5df3d0ef69d61c32a52647092db315c16305d07b4b76127b9b48f5a472d71b2db
7
- data.tar.gz: b1e9d5b6aef1c7686187560a0c5e83c594c158ed0e9b0dc035f36b0aadb038770080e3bc99093dc78a2c3bd7e5cb8543bee72f5dd7b08ec11879e295db68d8e4
6
+ metadata.gz: e4b23ce25925854f5f3c17e94a2dd8a5021901e6ce5c01fd6b2cf5673b6db5697335ac171ccf56dadaedeefd95814aeb7909476e5c0347bfb515cfd3267ae13e
7
+ data.tar.gz: 5f170c2c73bfa5c533a0c21b3e3bd602313731c6b3f2a6641068383fc3a5bc9ac8098a4708dcb1d5191e089df3cf07c6aeb60e0739922f32f9562f369d3a3804
data/CLAUDE.md CHANGED
@@ -29,5 +29,5 @@ Key dependency: `pubid-iso` gem handles ISO publication identifier parsing and c
29
29
 
30
30
  - **Framework:** RSpec with VCR cassettes and WebMock
31
31
  - **Network access:** fully blocked via `WebMock.disable_net_connect!`
32
- - **Index fixture:** `spec/fixtures/index-v1.zip` is served by WebMock stub (configured in `spec/support/webmock.rb`). Run `rake spec:update_index` to refresh when upstream data changes.
33
- - **VCR:** cassettes in `spec/vcr_cassettes/`, record mode `:once`, re-record interval 7 days. Index download requests are ignored by VCR (handled by WebMock stub instead).
32
+ - **Index fixture:** `spec/fixtures/index-v1.zip` is pre-loaded into `Relaton::Index` pool in `before(:suite)` (configured in `spec/support/webmock.rb`). Run `rake spec:update_index` to refresh from relaton-data-iso.
33
+ - **VCR:** cassettes in `spec/vcr_cassettes/`, record mode `:once`, re-record interval 7 days. Index download requests are ignored by VCR (handled by fixture instead).
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
5
5
  # Specify your gem's dependencies in relaton_iso.gemspec
6
6
  gemspec
7
7
 
8
+
8
9
  gem "byebug"
9
10
  gem "equivalent-xml"
10
11
  gem "pry-byebug"
data/grammars/biblio.rng CHANGED
@@ -2015,15 +2015,11 @@ provided that it is not the entire bibliographic item that is so related</a:docu
2015
2015
  <a:documentation>A version of the bibliographic item (within an edition). Can be used for drafts</a:documentation>
2016
2016
  <element name="version">
2017
2017
  <optional>
2018
- <ref name="revision-date">
2019
- <a:documentation>The date at which the current version of the bibliographic item was produced</a:documentation>
2020
- </ref>
2021
- </optional>
2022
- <optional>
2023
- <ref name="draft">
2024
- <a:documentation>The identifier for the current draft of the bibliographic item</a:documentation>
2025
- </ref>
2018
+ <attribute name="type">
2019
+ <a:documentation>Versioning scheme, in case of multiple versioning schemes</a:documentation>
2020
+ </attribute>
2026
2021
  </optional>
2022
+ <text/>
2027
2023
  </element>
2028
2024
  </define>
2029
2025
  <define name="vedition">
@@ -194,7 +194,7 @@ module Relaton
194
194
 
195
195
  def write_file(file, doc, docid)
196
196
  @files << file
197
- index.add_or_update docid.content.to_h, file
197
+ index.add_or_update docid.pubid.to_h, file
198
198
  File.write file, serialize(doc), encoding: "UTF-8"
199
199
  end
200
200
 
@@ -23,10 +23,6 @@ module Relaton
23
23
  pubid = without_date ? content.exclude(:year) : content
24
24
  self.id = pubid.to_s(with_prf: true).gsub(/\W+/, "")
25
25
  end
26
-
27
- def create_relation(**args)
28
- Relation.new(**args)
29
- end
30
26
  end
31
27
  end
32
28
  end
@@ -3,6 +3,7 @@ require_relative "ext"
3
3
  module Relaton
4
4
  module Iso
5
5
  class Bibdata < Item
6
+ model ItemData
6
7
  include Bib::BibdataShared
7
8
  end
8
9
  end
@@ -1,6 +1,7 @@
1
1
  module Relaton
2
2
  module Iso
3
3
  class Bibitem < Item
4
+ model ItemData
4
5
  include Bib::BibitemShared
5
6
  end
6
7
  end
@@ -1,7 +1,6 @@
1
1
  module Relaton
2
2
  module Iso
3
3
  class Contributor < Bib::Contributor
4
- # attributes[:organization].type = :boolean
5
4
  end
6
5
  end
7
6
  end
@@ -1,133 +1,122 @@
1
1
  module Relaton
2
2
  module Iso
3
- class Pubid < Lutaml::Model::Type::Value
4
- module Renderer
5
- end
6
-
7
- class << self
8
- def cast(value)
9
- value.is_a?(String) ? ::Pubid::Iso::Identifier.parse(value) : value
10
- rescue StandardError
11
- Util.warn "Failed to parse Pubid: #{value}"
12
- value
13
- end
14
- end
15
-
16
- ::Lutaml::Model::Config::AVAILABLE_FORMATS.each do |format|
17
- define_method(:"to_#{format}") { value.to_s with_prf: true }
18
- end
19
-
20
- def to_h = value.to_h
21
- def urn = value.urn
22
- end
23
-
24
3
  class Docidentifier < Bib::Docidentifier
25
- include Pubid::Renderer
4
+ attribute :content, :string
26
5
 
27
- attribute :content, Pubid
6
+ attr_reader :pubid
28
7
 
29
- # iso-tc identifiers are TC document numbers, not ISO standard
30
- # identifiers — parsing them through Pubid adds a spurious
31
- # "ISO" prefix (#178). Bypass Pubid casting for iso-tc content
32
- # in both direct construction and XML deserialization paths.
33
8
  def initialize(arg = nil, **kwargs)
34
- if arg.is_a?(Hash)
35
- raw_content = arg["content"] if arg["type"] == "iso-tc"
36
- super(arg)
37
- else
38
- raw_content = kwargs[:content] if kwargs[:type] == "iso-tc"
39
- super(**kwargs)
40
- end
41
- @content = raw_content if raw_content.is_a?(String)
9
+ arg.is_a?(Hash) ? super(arg) : super(**kwargs)
10
+ # Content may have been set before type during lutaml init. Re-run
11
+ # the setter so type-dependent parsing (e.g. iso-tc bypass) applies.
12
+ raw = arg.is_a?(Hash) ? (arg["content"] || arg[:content]) : kwargs[:content]
13
+ self.content = raw if raw
42
14
  end
43
15
 
44
- # Capture raw iso-tc content before Pubid casting (#178).
45
- # The lutaml-model setter is defined via define_method, so we
46
- # wrap it with alias_method instead of super.
47
16
  alias_method :original_content=, :content=
17
+ alias_method :original_content, :content
18
+
48
19
  def content=(value)
49
- if value.is_a?(String) && type == "iso-tc"
50
- @iso_tc_raw = value
20
+ @pubid = nil
21
+ @raw_content = nil
22
+
23
+ if type == "iso-tc" && value.is_a?(String)
24
+ @raw_content = value
25
+ else
26
+ parsed =
27
+ case value
28
+ when ::Pubid::Iso::Identifier::Base then value
29
+ when String
30
+ begin
31
+ ::Pubid::Iso::Identifier.parse(value)
32
+ rescue StandardError
33
+ Util.warn "Failed to parse Pubid: #{value}"
34
+ nil
35
+ end
36
+ end
37
+
38
+ if parsed
39
+ @pubid = parsed
40
+ elsif value.is_a?(String)
41
+ @raw_content = value
42
+ end
51
43
  end
52
- send(:original_content=, value)
44
+
45
+ send(:original_content=, to_s)
53
46
  end
54
47
 
55
- def content_to_xml(model, parent, doc)
56
- doc.add_xml_fragment parent, model.to_s
48
+ def content
49
+ return @raw_content if @raw_content
50
+ return render_pubid(@pubid) if @pubid
51
+
52
+ original_content
57
53
  end
58
54
 
59
- def content_to_key_value(model, doc)
60
- doc["content"] = model.to_s
55
+ def to_s
56
+ content.to_s
61
57
  end
62
58
 
63
59
  def to_all_parts!
64
- if content.is_a? String
65
- Util.warn "Cannot convert String to all parts: #{content}"
66
- return
67
- end
60
+ return unless @pubid
68
61
 
69
62
  remove_part!
70
63
  remove_date!
71
64
  remove_stage!
72
- content.all_parts = true
65
+ @pubid.all_parts = true
66
+ refresh_content!
73
67
  end
74
68
 
75
69
  def remove_stage!
76
- remove_attr! :stage
70
+ remove_attr!(:stage)
77
71
  end
78
72
 
79
73
  def remove_part!
80
- remove_attr! :part
74
+ remove_attr!(:part)
81
75
  end
82
76
 
83
77
  def remove_date!
84
- remove_attr! :year
78
+ remove_attr!(:year)
85
79
  end
86
80
 
87
81
  def exclude_year
88
- return content if content.is_a? String
89
-
90
- pubid = content.exclude(:year)
91
- current_pubid = pubid
92
- while current_pubid.base
93
- current_pubid.base = current_pubid.base.exclude(:year)
94
- current_pubid = current_pubid.base
82
+ return @raw_content if @raw_content
83
+ return nil unless @pubid
84
+
85
+ pubid = @pubid.exclude(:year)
86
+ current = pubid
87
+ while current.base
88
+ current.base = current.base.exclude(:year)
89
+ current = current.base
95
90
  end
96
91
  pubid
97
92
  end
98
93
 
99
- def to_s
100
- return content if content.is_a? String
101
- return @iso_tc_raw if @iso_tc_raw
94
+ private
102
95
 
96
+ def render_pubid(pubid)
103
97
  case type
104
- when "URN" then content.urn
105
- when "iso-reference", "iso-with-lang" then iso_reference
106
- else content.to_s with_prf: true
98
+ when "URN" then pubid.urn
99
+ when "iso-reference", "iso-with-lang"
100
+ pubid.to_s(format: :ref_num_short, with_prf: true)
101
+ else
102
+ pubid.to_s(with_prf: true)
107
103
  end
108
104
  end
109
105
 
110
- def iso_reference
111
- content.to_s(format: :ref_num_short, with_prf: true)
112
-
113
- # return content.to_s(format: :ref_num_short, with_prf: true) if content.language
114
-
115
- # pubid_dup = content.dup
116
- # pubid_dup.language = "en"
117
- # pubid_dup.to_s(format: :ref_num_short, with_prf: true)
118
- end
119
-
120
- private
121
-
122
106
  def remove_attr!(attr)
123
- return if content.is_a? String
107
+ return unless @pubid
124
108
 
125
- content.send("#{attr}=", nil)
126
- base = content.base
109
+ @pubid.send("#{attr}=", nil)
110
+ base = @pubid.base
127
111
  while base
128
112
  base.send("#{attr}=", nil)
129
113
  base = base.base
130
114
  end
115
+ refresh_content!
116
+ end
117
+
118
+ def refresh_content!
119
+ send(:original_content=, to_s)
131
120
  end
132
121
  end
133
122
  end
@@ -5,7 +5,6 @@ require_relative "structured_identifier"
5
5
  module Relaton
6
6
  module Iso
7
7
  class Ext < Bib::Ext
8
- attribute :schema_version, method: :get_schema_version
9
8
  attribute :doctype, Doctype
10
9
  attribute :structuredidentifier, StructuredIdentifier
11
10
  attribute :horizontal, :boolean
@@ -14,18 +13,23 @@ module Relaton
14
13
  attribute :fast_track, :boolean
15
14
  attribute :price_code, :string
16
15
 
17
- def get_schema_version
18
- Relaton.schema_versions["relaton-model-iso"]
19
- end
16
+ def get_schema_version = Relaton.schema_versions["relaton-model-iso"]
20
17
 
21
18
  xml do
22
- root "ext"
23
19
  map_element "horizontal", to: :horizontal
24
20
  map_element "stagename", to: :stagename
25
21
  map_element "updates-document-type", to: :updates_document_type
26
22
  map_element "fast-track", to: :fast_track
27
23
  map_element "price-code", to: :price_code
28
24
  end
25
+
26
+ key_value do
27
+ map_element "horizontal", to: :horizontal
28
+ map_element "stagename", to: :stagename
29
+ map_element "updates_document_type", to: :updates_document_type
30
+ map_element "fast_track", to: :fast_track
31
+ map_element "price_code", to: :price_code
32
+ end
29
33
  end
30
34
  end
31
35
  end
@@ -1,19 +1,22 @@
1
+ require_relative "docidentifier"
2
+
1
3
  module Relaton
2
4
  module Iso
3
- # The class is for relaton bibitem instances.
4
- # The in relaton bibitem instances dosn't have schema-version & fetched attributes.
5
- class ItemBase < Item
5
+ class ItemBase < Lutaml::Model::Serializable
6
+ include Bib::NamespaceHelper
7
+
8
+ attr_accessor :type
9
+
6
10
  model ItemData
7
11
 
8
- # we don't need schema-version & fetched attributes in reation/bibitem
9
- mappings[:xml].instance_variable_get(:@attributes).delete("id")
10
- mappings[:xml].instance_variable_get(:@attributes).delete("schema-version")
11
- mappings[:xml].instance_variable_get(:@elements).delete("fetched")
12
- mappings[:xml].instance_variable_get(:@elements).delete("ext")
13
- attributes.delete :id
14
- attributes.delete :schema_version
15
- attributes.delete :fetched
16
- attributes.delete :ext
12
+ instance_exec(&Bib::ItemShared::ATTRIBUTES)
13
+ attribute :docidentifier, Docidentifier, collection: true, initialize_empty: true
14
+ attribute :relation, Relation, collection: true, initialize_empty: true
15
+
16
+ xml do
17
+ map_attribute "type", to: :type
18
+ instance_exec(&Bib::ItemShared::XML_BODY)
19
+ end
17
20
  end
18
21
  end
19
22
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Relaton
4
4
  module Iso
5
- VERSION = "2.0.0"
5
+ VERSION = "2.1.0"
6
6
  end
7
7
  end
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency "isoics", "~> 0.1.6"
30
30
  spec.add_dependency "openssl", "~> 3.3.2" # 3.3.0 raised an error on Ruby 3.4.7
31
31
  spec.add_dependency "pubid-iso", "~> 1.15.8"
32
- spec.add_dependency "relaton-bib", "~> 2.0.0"
32
+ spec.add_dependency "relaton-bib", "~> 2.1.0"
33
33
  spec.add_dependency "relaton-core", "~> 0.0.12"
34
34
  spec.add_dependency "relaton-index", "~> 0.2.12"
35
35
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iso
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
+ autorequire:
8
9
  bindir: exe
9
10
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
11
+ date: 2026-05-04 00:00:00.000000000 Z
11
12
  dependencies:
12
13
  - !ruby/object:Gem::Dependency
13
14
  name: isoics
@@ -57,14 +58,14 @@ dependencies:
57
58
  requirements:
58
59
  - - "~>"
59
60
  - !ruby/object:Gem::Version
60
- version: 2.0.0
61
+ version: 2.1.0
61
62
  type: :runtime
62
63
  prerelease: false
63
64
  version_requirements: !ruby/object:Gem::Requirement
64
65
  requirements:
65
66
  - - "~>"
66
67
  - !ruby/object:Gem::Version
67
- version: 2.0.0
68
+ version: 2.1.0
68
69
  - !ruby/object:Gem::Dependency
69
70
  name: relaton-core
70
71
  requirement: !ruby/object:Gem::Requirement
@@ -147,11 +148,12 @@ files:
147
148
  - lib/relaton/iso/scraper.rb
148
149
  - lib/relaton/iso/util.rb
149
150
  - lib/relaton/iso/version.rb
150
- - relaton_iso.gemspec
151
+ - relaton-iso.gemspec
151
152
  homepage: https://github.com/relaton/relaton-iso
152
153
  licenses:
153
154
  - BSD-2-Clause
154
155
  metadata: {}
156
+ post_install_message:
155
157
  rdoc_options: []
156
158
  require_paths:
157
159
  - lib
@@ -166,7 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
168
  - !ruby/object:Gem::Version
167
169
  version: '0'
168
170
  requirements: []
169
- rubygems_version: 3.6.9
171
+ rubygems_version: 3.5.22
172
+ signing_key:
170
173
  specification_version: 4
171
174
  summary: 'Relaton::Iso: retrieve ISO Standards for bibliographic use using the IsoBibliographicItem
172
175
  model'