relaton-ccsds 1.19.0 → 1.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_ccsds/data_fetcher.rb +27 -11
- data/lib/relaton_ccsds/data_parser.rb +5 -1
- data/lib/relaton_ccsds/hit_collection.rb +9 -3
- data/lib/relaton_ccsds/version.rb +1 -1
- data/lib/relaton_ccsds.rb +1 -0
- data/relaton_ccsds.gemspec +2 -2
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86c6245ab704696461bdb9379550a2e6af44dda99bbb35c16358bec90fe6c841
|
4
|
+
data.tar.gz: 0a3818911b0da9431d70023bd1e9aaa8d153012b24b51f493ab6aede7f3f1d4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 219cf90573c4a5398d0e732a35e9b694529d155565ceff9cf2b58eb58c166e3bc311ee04e7a09bd536d88d1981cad43862ceadfbdb7a75f9120a0bffda8c882c
|
7
|
+
data.tar.gz: 251ef2fbe9bd0062addf2ae9a3dd9e3bb8b95e899319161a03bebc32732c664cc4d3caaccf4fde9e4a129e9744966eaed4e43c7393a13d4c4745da9167e34b90
|
@@ -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-
|
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
|
-
|
113
|
-
|
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].
|
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].
|
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(
|
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-
|
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
|
-
|
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-
|
26
|
+
@index ||= Relaton::Index.find_or_create :ccsds, url: "#{GHURL}index-v2.zip", file: INDEX_FILE, pubid_class: Pubid::Ccsds::Identifier
|
21
27
|
end
|
22
28
|
end
|
23
29
|
end
|
data/lib/relaton_ccsds.rb
CHANGED
data/relaton_ccsds.gemspec
CHANGED
@@ -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.
|
30
|
-
|
29
|
+
spec.add_dependency "relaton-index", "~> 0.2.16"
|
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.
|
4
|
+
version: 1.20.1
|
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-
|
11
|
+
date: 2024-08-19 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.
|
47
|
+
version: 0.2.16
|
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.
|
54
|
+
version: 0.2.16
|
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
|