relaton-ccsds 1.19.0 → 1.20.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: d13a1ff82cb418e8778c916807bb43c5e8a3fe31f48f8f572c32e6f1631a59b1
4
- data.tar.gz: 499cafc2a2dcfd2aa2f8b1040a6d0f2a7af4ad14851df92b980e73697b95ace2
3
+ metadata.gz: 5dbc82b9af321507bb207dc43ecb39b7ab7704f167f479fd3a6170cd3f5283e1
4
+ data.tar.gz: 22633dcbb3b00c5082f5e1db82a7c693ba915ffafa16abead42d62d7b3209252
5
5
  SHA512:
6
- metadata.gz: 9cbac64eb97f0ca87f19c1274d9ff2864597fb62912a599ea8bd65c4ce722eb9c73e4c2466cdc915385425f9c08bab9f0392de64e62111c579c56df8ca6750c7
7
- data.tar.gz: 37ccb6686d9b6cc55990561a205641d809d8ced600468f919588b7a56aa8c252e06076cee066bf3a97e17dbc76d12a05124d43069e5e1f8cab2d6376996fb91a
6
+ metadata.gz: 1267cd4023932a5702bcbd5c6efbaca487d74b26659de634da34f6620d42805f70d8ef6e12e484a00dff6ffeb23bb5c46c0e5f53d2d7a5df231c77f341bbe287
7
+ data.tar.gz: 13d9d28ba550bf1a4da1bd62a35f0db7a3eb70d690edab271fae33bc68610995e23833ef41a7a8f2dcdf7a76c7d1eb1fb93dcbf8c4bd43b617c53ab8e7ec6836
@@ -39,7 +39,11 @@ module RelatonCcsds
39
39
  end
40
40
 
41
41
  def index
42
- @index ||= Relaton::Index.find_or_create "CCSDS", file: "index-v1.yaml"
42
+ @index ||= Relaton::Index.find_or_create "CCSDS", file: "index-v2.yaml", pubid_class: Pubid::Ccsds::Identifier
43
+ end
44
+
45
+ def old_index
46
+ @old_index ||= Relaton::Index.find_or_create "CCSDS", file: "index-v1.yaml"
43
47
  end
44
48
 
45
49
  #
@@ -64,6 +68,7 @@ module RelatonCcsds
64
68
  fetch_docs ACTIVE_PUBS_URL
65
69
  fetch_docs OBSOLETE_PUBS_URL, retired: true
66
70
  index.save
71
+ old_index.save
67
72
  end
68
73
 
69
74
  #
@@ -100,6 +105,10 @@ module RelatonCcsds
100
105
  save_bib bibitem
101
106
  end
102
107
 
108
+ def get_output_file(id)
109
+ File.join @output, "#{id.gsub(/[.\s-]+/, '-')}.#{@ext}"
110
+ end
111
+
103
112
  #
104
113
  # Save bibitem to file
105
114
  #
@@ -109,15 +118,11 @@ module RelatonCcsds
109
118
  #
110
119
  def save_bib(bib)
111
120
  search_instance_translation bib
112
- id = bib.docidentifier.first.id
113
- file = File.join @output, "#{id.gsub(/[.\s-]+/, '-')}.#{@ext}"
114
- if @files.include?(file)
115
- Util.info "(#{file}) file already exists. Trying to merge links ..."
116
- merge_links bib, file
117
- else @files << file
118
- end
121
+ file = get_output_file(bib.docidentifier.first.id)
122
+ merge_links bib, file
119
123
  File.write file, content(bib), encoding: "UTF-8"
120
- index.add_or_update id, file
124
+ index.add_or_update Pubid::Ccsds::Identifier.parse(bib.docidentifier.first.id), file
125
+ old_index.add_or_update bib.docidentifier.first.id, file
121
126
  end
122
127
 
123
128
  #
@@ -146,7 +151,8 @@ module RelatonCcsds
146
151
  #
147
152
  def search_relations(bibid, bib)
148
153
  index.search do |row|
149
- id = row[:id].sub(TRRGX, "")
154
+ id = row[:id].exclude(:language)
155
+ # TODO: smiplify this line?
150
156
  next if id != bibid || row[:id] == bib.docidentifier.first.id
151
157
 
152
158
  create_relations bib, row[:file]
@@ -154,8 +160,10 @@ module RelatonCcsds
154
160
  end
155
161
 
156
162
  def search_translations(bibid, bib)
163
+ # will call create_instance_relation if
164
+ # there are same identifiers in index but with word "Translated"
157
165
  index.search do |row|
158
- next unless row[:id].match?(/^#{bibid}#{TRRGX}/)
166
+ next unless row[:id].language && row[:id].exclude(:language) == bibid
159
167
 
160
168
  create_instance_relation bib, row[:file]
161
169
  end
@@ -232,6 +240,14 @@ module RelatonCcsds
232
240
  # @return [void]
233
241
  #
234
242
  def merge_links(bib, file) # rubocop:disable Metrics/AbcSize
243
+ # skip merging when new file
244
+ unless @files.include?(file)
245
+ @files << file
246
+ return
247
+ end
248
+
249
+ puts "(#{file}) file already exists. Trying to merge links ..."
250
+
235
251
  hash = YAML.load_file file
236
252
  bib2 = BibliographicItem.from_hash hash
237
253
  if bib.link[0].type == bib2.link[0].type
@@ -38,7 +38,10 @@ module RelatonCcsds
38
38
  end
39
39
 
40
40
  def parse_docid
41
- [RelatonBib::DocumentIdentifier.new(id: docidentifier, type: "CCSDS", primary: true)]
41
+ [RelatonBib::DocumentIdentifier.new(
42
+ id: docidentifier,
43
+ type: "CCSDS", primary: true
44
+ )]
42
45
  end
43
46
 
44
47
  def docidentifier(id = nil)
@@ -104,6 +107,7 @@ module RelatonCcsds
104
107
  [create_relation("hasSuccessor", @successor.docidentifier[0].id)]
105
108
  end
106
109
 
110
+ # TODO: cover this
107
111
  def relation_type(rel_id)
108
112
  return if rel_id == docidentifier ||
109
113
  rel_id.match(DataFetcher::TRRGX).to_s != docidentifier.match(DataFetcher::TRRGX).to_s
@@ -1,7 +1,7 @@
1
1
  module RelatonCcsds
2
2
  class HitCollection < RelatonBib::HitCollection
3
3
  GHURL = "https://raw.githubusercontent.com/relaton/relaton-data-ccsds/main/".freeze
4
- INDEX_FILE = "index-v1.yaml".freeze
4
+ INDEX_FILE = "index-v2.yaml".freeze
5
5
 
6
6
  #
7
7
  # Search his in index.
@@ -9,7 +9,13 @@ module RelatonCcsds
9
9
  # @return [<Type>] <description>
10
10
  #
11
11
  def fetch
12
- rows = index.search text
12
+ pubid = Pubid::Ccsds::Identifier.parse(text)
13
+ rows = if pubid.edition
14
+ index.search(pubid)
15
+ # index.search { |r| Pubid::Ccsds::Identifier.create(**r[:id]) == pubid }
16
+ else
17
+ index.search { |r| r[:id].exclude(:edition) == pubid }
18
+ end
13
19
  @array = rows.map { |row| Hit.new code: row[:id], url: "#{GHURL}#{row[:file]}" }
14
20
  self
15
21
  rescue SocketError, OpenURI::HTTPError, OpenSSL::SSL::SSLError, Errno::ECONNRESET => e
@@ -17,7 +23,7 @@ module RelatonCcsds
17
23
  end
18
24
 
19
25
  def index
20
- @index ||= Relaton::Index.find_or_create :ccsds, url: "#{GHURL}index-v1.zip", file: INDEX_FILE
26
+ @index ||= Relaton::Index.find_or_create :ccsds, url: "#{GHURL}index-v2.zip", file: INDEX_FILE
21
27
  end
22
28
  end
23
29
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RelatonCcsds
4
- VERSION = "1.19.0"
4
+ VERSION = "1.20.0"
5
5
  end
data/lib/relaton_ccsds.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require "mechanize"
4
4
  require "relaton_bib"
5
5
  require "relaton/index"
6
+ require "pubid-ccsds"
6
7
  require_relative "relaton_ccsds/version"
7
8
  require_relative "relaton_ccsds/bibliographic_item"
8
9
  require_relative "relaton_ccsds/util"
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
26
26
  # Uncomment to register a new dependency of your gem
27
27
  spec.add_dependency "mechanize", "~> 2.10"
28
28
  spec.add_dependency "relaton-bib", "~> 1.19.0"
29
- spec.add_dependency "relaton-index", "~> 0.2.0"
30
-
29
+ spec.add_dependency "relaton-index", "~> 0.2.13"
30
+ spec.add_dependency "pubid-ccsds", "~> 0.1.6"
31
31
  # For more information and examples about making a new gem, check out our
32
32
  # guide at: https://bundler.io/guides/creating_gem.html
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: relaton-ccsds
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.0
4
+ version: 1.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-03 00:00:00.000000000 Z
11
+ date: 2024-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -44,14 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.2.0
47
+ version: 0.2.13
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: 0.2.0
54
+ version: 0.2.13
55
+ - !ruby/object:Gem::Dependency
56
+ name: pubid-ccsds
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.6
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.6
55
69
  description: 'RelatonCcsds: retrive www.ccsds.org Standards'
56
70
  email:
57
71
  - open.source@ribose.com