relaton-iec 2.0.0.pre.alpha.5 → 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: d57d67e4d931c25e421296bebc7ef0ebbe373c6b74cb8eb5c7001b9a4848831b
4
- data.tar.gz: 4bad45627505b55d7f922d853fd76143d853e5a7f04e7a6974997275d4c0330f
3
+ metadata.gz: b3748628a557efd3e7676f38fabb661c4d4c57f2083d7b70dd68829d72eb456b
4
+ data.tar.gz: 48ae09c4bc78be843cfd492e01c41e36cfa75247e90873aed376e47e6ca46412
5
5
  SHA512:
6
- metadata.gz: 0c3671c52a7e7f939120dcb4600270c6950cfd6f2b96b37f930b37de8e0497146ecff4cd6e8014c6d7c323964233622238a37299f59df69ba1ec3d13bb45923f
7
- data.tar.gz: 1a7afc40ad345d058e2f05df130a6fed7ada6f4a80b31c7d3d6971e5674d5b49bd1417257cd489b05e16fae36a64508afbdffab6698db8d1fc8eb74e17ebda23
6
+ metadata.gz: f2b035d0f7f47a63b6be78f9bde44988d93643d258d465a1d24a3fa06089427422f370901e93c15ca8afafead3ed52bbdc4b81d4d02504ba22e53df6798df2dd
7
+ data.tar.gz: 35cd7785aeda31254ee476482b323dd9aa58a7e3e49d5ac7970392ee375f45dfa9cba329c76c550467454071193d6b015574908ce246750fce9c82e2c558ea89
data/CLAUDE.md ADDED
@@ -0,0 +1,13 @@
1
+ # CLAUDE.md
2
+
3
+ ## Development
4
+
5
+ - `bundle install` — install dependencies
6
+ - `bundle exec rake spec` — run tests
7
+ - `bundle exec rubocop` — lint
8
+
9
+ ## Testing
10
+
11
+ - **Framework:** RSpec with VCR cassettes and WebMock
12
+ - **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-iec.
13
+ - **VCR cassettes:** `spec/vcr_cassettes/` — index download requests are ignored by VCR (handled by fixture).
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_iec.gemspec
6
6
  gemspec
7
7
 
8
+
8
9
  gem "equivalent-xml", "~> 0.6"
9
10
  gem "pry-byebug"
10
11
  gem "rake", "~> 13.0"
data/README.adoc CHANGED
@@ -286,6 +286,8 @@ Relaton::Iec uses the relaton-logger gem for logging. By default, it logs to STD
286
286
 
287
287
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
288
288
 
289
+ To update the index test fixture (used by tests), run `rake spec:update_index`. This downloads the latest `index-v1.zip` from the https://github.com/relaton/relaton-data-iec[relaton-data-iec] repository.
290
+
289
291
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
290
292
 
291
293
 
data/Rakefile CHANGED
@@ -4,3 +4,25 @@ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task :default => :spec
7
+
8
+ namespace :spec do
9
+ desc "Download latest IEC index fixture from relaton-data-iec"
10
+ task :update_index do
11
+ require "net/http"
12
+ require "uri"
13
+
14
+ url = "https://raw.githubusercontent.com/relaton/relaton-data-iec/data-v2/index-v1.zip"
15
+ dest = File.join(__dir__, "spec", "fixtures", "index-v1.zip")
16
+
17
+ puts "Downloading \#{url} ..."
18
+ uri = URI.parse(url)
19
+ response = Net::HTTP.get_response(uri)
20
+
21
+ if response.is_a?(Net::HTTPSuccess)
22
+ File.binwrite(dest, response.body)
23
+ puts "Updated \#{dest} (\#{response.body.bytesize} bytes)"
24
+ else
25
+ abort "Failed to download: HTTP \#{response.code}"
26
+ end
27
+ end
28
+ end
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">
@@ -1,6 +1,7 @@
1
1
  module Relaton
2
2
  module Iec
3
3
  class Bibdata < Item
4
+ model ItemData
4
5
  include Bib::BibdataShared
5
6
  end
6
7
  end
@@ -1,6 +1,7 @@
1
1
  module Relaton
2
2
  module Iec
3
3
  class Bibitem < Item
4
+ model ItemData
4
5
  include Bib::BibitemShared
5
6
  end
6
7
  end
@@ -1,74 +1,100 @@
1
1
  module Relaton
2
2
  module Iec
3
- class Pubid < Lutaml::Model::Type::Value
4
- class << self
5
- def cast(value)
6
- value.is_a?(String) ? ::Pubid::Iec::Identifier.parse(value) : value
7
- rescue StandardError
8
- Util.warn "Failed to parse Pubid: #{value}"
9
- value
10
- end
11
- end
3
+ class Docidentifier < Bib::Docidentifier
4
+ attribute :content, :string
12
5
 
13
- ::Lutaml::Model::Config::AVAILABLE_FORMATS.each do |format|
14
- define_method(:"to_#{format}") { value.to_s }
6
+ attr_reader :pubid
7
+
8
+ def initialize(arg = nil, **kwargs)
9
+ arg.is_a?(Hash) ? super(arg) : super(**kwargs)
10
+ raw = arg.is_a?(Hash) ? (arg["content"] || arg[:content]) : kwargs[:content]
11
+ self.content = raw if raw
15
12
  end
16
13
 
17
- def to_h = value.to_h
18
- def urn = value.urn
19
- end
14
+ alias_method :original_content=, :content=
15
+ alias_method :original_content, :content
20
16
 
21
- class Docidentifier < Bib::Docidentifier
22
- attribute :content, Pubid
17
+ def content=(value)
18
+ @pubid = nil
19
+ @raw_content = nil
23
20
 
24
- def content_to_xml(model, parent, doc)
25
- doc.add_xml_fragment parent, model.to_s
21
+ parsed =
22
+ case value
23
+ when ::Pubid::Iec::Base then value
24
+ when String
25
+ begin
26
+ ::Pubid::Iec::Identifier.parse(value)
27
+ rescue StandardError
28
+ Util.warn "Failed to parse Pubid: #{value}"
29
+ nil
30
+ end
31
+ end
32
+
33
+ if parsed
34
+ @pubid = parsed
35
+ elsif value.is_a?(String)
36
+ @raw_content = value
37
+ end
38
+
39
+ send(:original_content=, to_s)
26
40
  end
27
41
 
28
- def content_to_key_value(model, doc)
29
- doc["content"] = model.to_s
42
+ def content
43
+ return @raw_content if @raw_content
44
+ return render_pubid(@pubid) if @pubid
45
+
46
+ original_content
47
+ end
48
+
49
+ def to_s
50
+ content.to_s
30
51
  end
31
52
 
32
53
  def to_all_parts!
33
- if content.is_a? String
34
- Util.warn "Cannot convert String to all parts: #{content}"
35
- return
36
- end
54
+ return unless @pubid
37
55
 
38
56
  remove_part!
39
57
  remove_date!
40
58
  remove_stage!
41
- content.all_parts = true if content.respond_to?(:all_parts=)
59
+ @pubid.all_parts = true if @pubid.respond_to?(:all_parts=)
60
+ refresh_content!
42
61
  end
43
62
 
44
63
  def remove_stage!
45
- remove_attr! :stage
64
+ remove_attr!(:stage)
46
65
  end
47
66
 
48
67
  def remove_part!
49
- remove_attr! :part
68
+ remove_attr!(:part)
50
69
  end
51
70
 
52
71
  def remove_date!
53
- remove_attr! :year
72
+ remove_attr!(:year)
54
73
  end
55
74
 
56
- def to_s
57
- return content if content.is_a? String
75
+ private
58
76
 
77
+ def render_pubid(pubid)
59
78
  case type
60
- when "URN" then content.urn
61
- else content.to_s
79
+ when "URN" then pubid.urn
80
+ else pubid.to_s
62
81
  end
63
82
  end
64
83
 
65
- private
66
-
67
84
  def remove_attr!(attr)
68
- return false if content.is_a? String
85
+ return unless @pubid
86
+
87
+ @pubid.send("#{attr}=", nil)
88
+ base = @pubid.base
89
+ while base
90
+ base.send("#{attr}=", nil)
91
+ base = base.base
92
+ end
93
+ refresh_content!
94
+ end
69
95
 
70
- content.send(:"#{attr}=", nil)
71
- true
96
+ def refresh_content!
97
+ send(:original_content=, to_s)
72
98
  end
73
99
  end
74
100
  end
@@ -3,11 +3,10 @@ require_relative "stage_name"
3
3
 
4
4
  module Relaton
5
5
  module Iec
6
- class Ext < Lutaml::Model::Serializable
7
- attribute :schema_version, method: :get_schema_version
6
+ class Ext < Bib::Ext
8
7
  attribute :doctype, Doctype
9
8
  attribute :subdoctype, :string, values: %w[specification method-of-test vocabulary code-of-practice]
10
- attribute :flavor, :string
9
+ attribute :structuredidentifier, Iso::StructuredIdentifier
11
10
  attribute :horizontal, :boolean
12
11
  attribute :stagename, StageName
13
12
  attribute :updates_document_type, :string, values: Doctype::TYPES
@@ -18,15 +17,9 @@ module Relaton
18
17
  attribute :cen_processing, :boolean
19
18
  attribute :secretary, :string
20
19
  attribute :interest_to_committees, :string
21
- attribute :ics, Bib::ICS, collection: true
22
- attribute :structuredidentifier, Iso::StructuredIdentifier
23
20
  attribute :tc_sc_officers_note, :string, raw: true
24
21
 
25
22
  xml do
26
- map_attribute "schema-version", to: :schema_version
27
- map_element "doctype", to: :doctype
28
- map_element "subdoctype", to: :subdoctype
29
- map_element "flavor", to: :flavor
30
23
  map_element "horizontal", to: :horizontal
31
24
  map_element "stagename", to: :stagename
32
25
  map_element "updates-document-type", to: :updates_document_type
@@ -37,14 +30,24 @@ module Relaton
37
30
  map_element "cen-processing", to: :cen_processing
38
31
  map_element "secretary", to: :secretary
39
32
  map_element "interest-to-committees", to: :interest_to_committees
40
- map_element "ics", to: :ics
41
- map_element "structuredidentifier", to: :structuredidentifier
42
33
  map_element "tc-sc-officers-note", to: :tc_sc_officers_note
43
34
  end
44
35
 
45
- def get_schema_version
46
- Relaton.schema_versions["relaton-model-iec"]
36
+ key_value do
37
+ map_element "horizontal", to: :horizontal
38
+ map_element "stagename", to: :stagename
39
+ map_element "updates_document_type", to: :updates_document_type
40
+ map_element "fast_track", to: :fast_track
41
+ map_element "price_code", to: :price_code
42
+ map_element "function", to: :function
43
+ map_element "accessibility_color_inside", to: :accessibility_color_inside
44
+ map_element "cen_processing", to: :cen_processing
45
+ map_element "secretary", to: :secretary
46
+ map_element "interest_to_committees", to: :interest_to_committees
47
+ map_element "tc_sc_officers_note", to: :tc_sc_officers_note
47
48
  end
49
+
50
+ def get_schema_version = Relaton.schema_versions["relaton-model-iec"]
48
51
  end
49
52
  end
50
53
  end
@@ -3,10 +3,14 @@ require_relative "ext"
3
3
 
4
4
  module Relaton
5
5
  module Iec
6
+ class Relation < Bib::Relation
7
+ end
8
+
6
9
  class Item < Iso::Item
7
10
  model ItemData
8
11
 
9
12
  attribute :docidentifier, Docidentifier, collection: true, initialize_empty: true
13
+ attribute :relation, Relation, collection: true, initialize_empty: true
10
14
  attribute :ext, Ext
11
15
  end
12
16
  end
@@ -14,11 +18,3 @@ end
14
18
 
15
19
  require_relative "item_base"
16
20
  require_relative "relation"
17
-
18
- module Relaton
19
- module Iec
20
- class Item
21
- attribute :relation, Relation, collection: true, initialize_empty: true
22
- end
23
- end
24
- end
@@ -1,9 +1,12 @@
1
+ require_relative "docidentifier"
2
+
1
3
  module Relaton
2
4
  module Iec
3
- class ItemBase < Item
5
+ class ItemBase < Iso::ItemBase
4
6
  model ItemData
5
7
 
6
- include Bib::ItemBaseAttributes
8
+ attribute :docidentifier, Docidentifier, collection: true, initialize_empty: true
9
+ attribute :relation, Relation, collection: true, initialize_empty: true
7
10
  end
8
11
  end
9
12
  end
@@ -1,6 +1,6 @@
1
1
  module Relaton
2
2
  module Iec
3
- class Relation < Bib::Relation
3
+ class Relation
4
4
  attribute :bibitem, ItemBase
5
5
  end
6
6
  end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Iec
3
- VERSION = "2.0.0-alpha.5".freeze
3
+ VERSION = "2.1.0".freeze
4
4
  end
5
5
  end
@@ -28,6 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency "pubid-iec", "~> 1.15.11"
29
29
  spec.add_dependency "relaton-core", "~> 0.0.13"
30
30
  spec.add_dependency "relaton-index", "~> 0.2.20"
31
- spec.add_dependency "relaton-iso", "~> 2.0.0-alpha.7"
31
+ spec.add_dependency "relaton-iso", "~> 2.1.0"
32
32
  spec.add_dependency "rubyzip"
33
33
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iec
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.alpha.5
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: addressable
@@ -85,14 +86,14 @@ dependencies:
85
86
  requirements:
86
87
  - - "~>"
87
88
  - !ruby/object:Gem::Version
88
- version: 2.0.0.pre.alpha.7
89
+ version: 2.1.0
89
90
  type: :runtime
90
91
  prerelease: false
91
92
  version_requirements: !ruby/object:Gem::Requirement
92
93
  requirements:
93
94
  - - "~>"
94
95
  - !ruby/object:Gem::Version
95
- version: 2.0.0.pre.alpha.7
96
+ version: 2.1.0
96
97
  - !ruby/object:Gem::Dependency
97
98
  name: rubyzip
98
99
  requirement: !ruby/object:Gem::Requirement
@@ -120,6 +121,7 @@ files:
120
121
  - ".gitignore"
121
122
  - ".rspec"
122
123
  - ".rubocop.yml"
124
+ - CLAUDE.md
123
125
  - Gemfile
124
126
  - LICENSE.txt
125
127
  - README.adoc
@@ -152,11 +154,12 @@ files:
152
154
  - lib/relaton/iec/statuses.yml
153
155
  - lib/relaton/iec/util.rb
154
156
  - lib/relaton/iec/version.rb
155
- - relaton_iec.gemspec
157
+ - relaton-iec.gemspec
156
158
  homepage: https://github.com/relaton/relaton-iec
157
159
  licenses:
158
160
  - MIT
159
161
  metadata: {}
162
+ post_install_message:
160
163
  rdoc_options: []
161
164
  require_paths:
162
165
  - lib
@@ -171,7 +174,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
171
174
  - !ruby/object:Gem::Version
172
175
  version: '0'
173
176
  requirements: []
174
- rubygems_version: 3.6.9
177
+ rubygems_version: 3.5.22
178
+ signing_key:
175
179
  specification_version: 4
176
180
  summary: 'Relaton::Iec: retrieve IEC Standards for bibliographic use using the IecBibliographicItem
177
181
  model'