relaton-iho 2.1.1 → 2.2.0.pre.alpha.1

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: 769a8ebd6c928209e699b186ac472824fc0b50f40323eaec113d3e2e06088bc8
4
- data.tar.gz: 9ac611550c5bbaea64c31fb153e39fa16a1ef7d376e05a8a70572d129dcd0784
3
+ metadata.gz: 5c1eea58ab0f0e2daccb544bc1ee8a0a6ba8da806867a3ac1f778b43e766d874
4
+ data.tar.gz: 2b8fb6271f97269b294d709b81c5d136865708c5fa300587c62b298d1c44c50d
5
5
  SHA512:
6
- metadata.gz: 404e35f9413afde1f27121c96926ed7e6b9756380acf21a9d7e922bb9e9ed90037bb6c76d2ff9d46a81e97558197cd8080a37818e4b8ac0990d8b2e5fbee9fa7
7
- data.tar.gz: 335852adcf7471b126c6c17ef14a8d8a17657d4576d97392e4733c298c81a64656cf535b55790d8067cf82f94b9c140a0eb06d5e0fb0bc99721d276b6defe960
6
+ metadata.gz: f851acdff7eca4ec36e169a93a1dc410c104e3b249e4c043f7a462b433d1d247f03324d55b400931e9132fbe51e29c847734056b977a64e4395fc6a9fa479812
7
+ data.tar.gz: 34842d3043bd09c9037cfd189d81250b6055b516775da3a87ebe934991ee81137f1ea3a994029d4a36e7975ed44ad539a3f1880155f65cf9863a8e16025a77b1
data/Gemfile CHANGED
@@ -5,6 +5,13 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in relaton_iho.gemspec
6
6
  gemspec
7
7
 
8
+ # Use local monorepo sibling gems where available.
9
+ Dir["../*/"].each do |dir|
10
+ name = File.basename(dir)
11
+ next if name == File.basename(__dir__)
12
+ next unless File.exist?(File.join(dir, "#{name}.gemspec"))
13
+ gem name, path: dir
14
+ end
8
15
 
9
16
  gem "byebug"
10
17
  gem "equivalent-xml", "~> 0.6"
@@ -16,7 +16,12 @@ module Relaton
16
16
  def search(text, _year = nil, _opts = {}) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
17
17
  pubid = text.is_a?(String) ? ::Pubid::Iho::Identifier.parse(text) : text
18
18
  Util.info "Fetching from Relaton repository ...", key: pubid.to_s
19
- row = index.search { |r| pubid_match?(r[:id], pubid) }.min_by { |r| row_version(r[:id]) }
19
+ # Pass the pubid so Relaton::Index narrows candidates by number via
20
+ # binary search before applying the block. Every row's `:id` is a
21
+ # Pubid::Iho::Identifiers::* (Relaton::Index deserialized it via the
22
+ # `pubid_class` passed in `#index`), so `pubid_match?` compares pubids.
23
+ row = index.search(pubid) { |r| pubid_match?(r[:id], pubid) }
24
+ .min_by { |r| r[:id].version.to_s }
20
25
  unless row
21
26
  Util.info "Not found.", key: pubid.to_s
22
27
  return
@@ -84,40 +89,24 @@ module Relaton
84
89
  :iho,
85
90
  url: "#{ENDPOINT}#{INDEXFILE}.zip",
86
91
  file: "#{INDEXFILE}.yaml",
87
- id_keys: %i[publisher number type version part appendix annex supplement],
88
- pubid_class: ::Pubid::Iho::Identifier,
92
+ pubid_class: ::Pubid::Iho::Identifiers::Base,
89
93
  )
90
94
  end
91
95
 
96
+ # Both `row_id` and `query` are Pubid::Iho::Identifiers::* instances.
97
+ # Class identity pins the series (S/P/M/B/C). Subdivision keys
98
+ # (part/appendix/annex/supplement) use strict equality — a nil query
99
+ # must match a nil row (the umbrella), not an arbitrary subdivision
100
+ # under the same (number, version). Only :version stays nil-tolerant: an
101
+ # unqualified `IHO B-11` query is expected to find the latest edition.
92
102
  def pubid_match?(row_id, query)
93
- row_attrs = row_attributes(row_id)
94
- return false unless row_attrs
95
-
96
- query_attrs = query.to_h
97
- # Subdivision keys (part/appendix/annex/supplement) use strict
98
- # equality — a nil query must match a nil row (the umbrella),
99
- # not an arbitrary subdivision under the same (number, version).
100
- # Only :version stays nil-tolerant: an unqualified `IHO B-11`
101
- # query is expected to find the latest edition.
102
- row_attrs[:publisher] == query_attrs[:publisher] &&
103
- row_attrs[:type] == query_attrs[:type] &&
104
- row_attrs[:number] == query_attrs[:number] &&
105
- (query_attrs[:version].nil? || row_attrs[:version].to_s == query_attrs[:version].to_s) &&
106
- row_attrs[:part].to_s == query_attrs[:part].to_s &&
107
- row_attrs[:appendix].to_s == query_attrs[:appendix].to_s &&
108
- row_attrs[:annex].to_s == query_attrs[:annex].to_s &&
109
- row_attrs[:supplement].to_s == query_attrs[:supplement].to_s
110
- end
111
-
112
- def row_attributes(row_id)
113
- return row_id.to_h if row_id.is_a?(::Pubid::Core::Identifier::Base)
114
- return row_id if row_id.is_a?(Hash)
115
-
116
- nil
117
- end
118
-
119
- def row_version(row_id)
120
- row_attributes(row_id)&.dig(:version).to_s
103
+ row_id.class == query.class &&
104
+ row_id.number == query.number &&
105
+ row_id.part.to_s == query.part.to_s &&
106
+ row_id.appendix.to_s == query.appendix.to_s &&
107
+ row_id.annex.to_s == query.annex.to_s &&
108
+ row_id.supplement.to_s == query.supplement.to_s &&
109
+ (query.version.nil? || row_id.version.to_s == query.version.to_s)
121
110
  end
122
111
  end
123
112
  end
@@ -15,16 +15,12 @@ module Relaton
15
15
  @pubid = ::Pubid::Iho::Identifier.parse(value) if value
16
16
  end
17
17
 
18
- def to_h
19
- @pubid&.to_h || super
20
- end
21
-
22
18
  def remove_part!
23
19
  @pubid&.part = nil
24
20
  end
25
21
 
26
22
  def remove_date!
27
- @pubid&.year = nil
23
+ @pubid&.date = nil
28
24
  end
29
25
 
30
26
  def to_all_parts!
@@ -47,7 +47,7 @@ module Relaton
47
47
  #
48
48
  def remove_index_file
49
49
  require_relative "../iho"
50
- Relaton::Index.find_or_create(:iho, url: true, file: "#{INDEXFILE}.yaml}").remove_file
50
+ Relaton::Index.find_or_create(:iho, url: true, file: "#{INDEXFILE}.yaml").remove_file
51
51
  end
52
52
  end
53
53
  end
@@ -1,5 +1,5 @@
1
1
  module Relaton
2
2
  module Iho
3
- VERSION = "2.1.1".freeze
3
+ VERSION = "2.2.0.pre.alpha.1".freeze
4
4
  end
5
5
  end
data/lib/relaton/iho.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "relaton/bib"
2
2
  require "relaton/index"
3
- require "pubid/iho"
3
+ require "pubid"
4
4
  require_relative "iho/version"
5
5
  require_relative "iho/util"
6
6
  require_relative "iho/docidentifier"
@@ -11,7 +11,7 @@ require_relative "iho/bibliography"
11
11
 
12
12
  module Relaton
13
13
  module Iho
14
- INDEXFILE = "index-v2".freeze
14
+ INDEXFILE = "index-v3".freeze
15
15
 
16
16
  class Error < StandardError; end
17
17
 
data/relaton-iho.gemspec CHANGED
@@ -19,11 +19,11 @@ Gem::Specification.new do |s|
19
19
  end
20
20
  s.platform = Gem::Platform::RUBY
21
21
  s.require_paths = ["lib"]
22
- s.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
22
+ s.required_ruby_version = Gem::Requirement.new(">= 3.3.0")
23
23
 
24
24
  s.add_dependency "base64"
25
- s.add_dependency "pubid-iho", "~> 1.15.16"
26
- s.add_dependency "relaton-bib", "~> 2.1.0"
27
- s.add_dependency "relaton-core", "~> 0.0.13"
28
- s.add_dependency "relaton-index", "~> 0.2.0"
25
+ s.add_dependency "pubid", "~> 2.0.0.pre.alpha.3"
26
+ s.add_dependency "relaton-bib", "~> 2.2.0.pre.alpha.1"
27
+ s.add_dependency "relaton-core", "~> 2.2.0.pre.alpha.1"
28
+ s.add_dependency "relaton-index", "~> 2.2.0.pre.alpha.1"
29
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-iho
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0.pre.alpha.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-06 00:00:00.000000000 Z
11
+ date: 2026-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64
@@ -25,61 +25,61 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: pubid-iho
28
+ name: pubid
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.15.16
33
+ version: 2.0.0.pre.alpha.3
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: 1.15.16
40
+ version: 2.0.0.pre.alpha.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: relaton-bib
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 2.1.0
47
+ version: 2.2.0.pre.alpha.1
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 2.1.0
54
+ version: 2.2.0.pre.alpha.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: relaton-core
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.0.13
61
+ version: 2.2.0.pre.alpha.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.0.13
68
+ version: 2.2.0.pre.alpha.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: relaton-index
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.2.0
75
+ version: 2.2.0.pre.alpha.1
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.2.0
82
+ version: 2.2.0.pre.alpha.1
83
83
  description: 'Relaton::Iho: retrieve IHO Standards for bibliographic using the BibliographicItem
84
84
  model'
85
85
  email:
@@ -92,17 +92,11 @@ files:
92
92
  - ".github/workflows/release.yml"
93
93
  - ".gitignore"
94
94
  - ".rspec"
95
- - ".rubocop.yml"
96
95
  - CLAUDE.md
97
96
  - Gemfile
98
97
  - README.adoc
99
98
  - Rakefile
100
99
  - bin/rspec
101
- - grammars/basicdoc.rng
102
- - grammars/biblio-standoc.rng
103
- - grammars/biblio.rng
104
- - grammars/relaton-iho-compile.rng
105
- - grammars/relaton-iho.rng
106
100
  - lib/relaton/iho.rb
107
101
  - lib/relaton/iho/bibdata.rb
108
102
  - lib/relaton/iho/bibitem.rb
@@ -133,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
133
127
  requirements:
134
128
  - - ">="
135
129
  - !ruby/object:Gem::Version
136
- version: 3.2.0
130
+ version: 3.3.0
137
131
  required_rubygems_version: !ruby/object:Gem::Requirement
138
132
  requirements:
139
133
  - - ">="
data/.rubocop.yml DELETED
@@ -1,12 +0,0 @@
1
- # This project follows the Ribose OSS style guide.
2
- # https://github.com/riboseinc/oss-guides
3
- # All project-specific additions and overrides should be specified in this file.
4
-
5
- require: rubocop-rails
6
-
7
- inherit_from:
8
- - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
9
- AllCops:
10
- TargetRubyVersion: 3.2
11
- Rails:
12
- Enabled: false