relaton-ccsds 1.14.0 → 1.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +3 -3
- data/grammars/biblio.rng +1 -1
- data/lib/relaton_ccsds/bibliographic_item.rb +1 -1
- data/lib/relaton_ccsds/data_fetcher.rb +52 -4
- data/lib/relaton_ccsds/data_parser.rb +10 -8
- data/lib/relaton_ccsds/processor.rb +1 -1
- data/lib/relaton_ccsds/version.rb +1 -1
- data/relaton_ccsds.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0602ceadb233363fed871dd43d456cb6405f815dc2785be2f80b6a67aa703b1
|
4
|
+
data.tar.gz: 0a84d458511b7cd6348a6703d8ce577edf33fd81e10586d1e10a41f5dea1a1fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 567d1816a6697be3b12fca33d370de62db7610dde78c2c0dca565c50b9f8702fd2c1cf4d9e2f05774caa4f94bd926707901c3891e89c72742da288f026489cbf
|
7
|
+
data.tar.gz: 3ea91fc332082907c86e00b162a2f30024084a5e17926d23bdb0534607dea7ff68ad9970a3b7a5ff4b7781e75dce52ac3509d0ab1f8a5c8f0a827181021e8ade
|
data/README.adoc
CHANGED
@@ -43,7 +43,7 @@ item = hits[0].fetch
|
|
43
43
|
[source,ruby]
|
44
44
|
----
|
45
45
|
item.to_xml
|
46
|
-
=> "<bibitem id="CCSDS230.2-G-1" schema-version="v1.2.
|
46
|
+
=> "<bibitem id="CCSDS230.2-G-1" schema-version="v1.2.4">
|
47
47
|
<fetched>2023-08-25</fetched>
|
48
48
|
<title format="text/plain" language="en" script="Latn">Next Generation Uplink</title>
|
49
49
|
<uri type="pdf">https://public.ccsds.org/Pubs/230x2g1.pdf</uri>
|
@@ -55,7 +55,7 @@ With argument `bibdata: true` it outputs XML wrapped by `bibdata` element and ad
|
|
55
55
|
[source,ruby]
|
56
56
|
----
|
57
57
|
item.to_xml bibdata: true
|
58
|
-
=> "<bibdata schema-version="v1.2.
|
58
|
+
=> "<bibdata schema-version="v1.2.4">
|
59
59
|
<fetched>2023-08-25</fetched>
|
60
60
|
<title format="text/plain" language="en" script="Latn">Next Generation Uplink</title>
|
61
61
|
<uri type="pdf">https://public.ccsds.org/Pubs/230x2g1.pdf</uri>
|
@@ -120,7 +120,7 @@ RelatonCcsds::XMLParser.from_xml File.read('spec/fixtures/ccsds_230_2-g-1.xml')
|
|
120
120
|
[source,ruby]
|
121
121
|
----
|
122
122
|
hash = YAML.load_file 'spec/fixtures/ccsds_230_2-g-1.yaml'
|
123
|
-
=> {"schema-version"=>"v1.2.
|
123
|
+
=> {"schema-version"=>"v1.2.4",
|
124
124
|
"id"=>"CCSDS230.2-G-1",
|
125
125
|
...
|
126
126
|
|
data/grammars/biblio.rng
CHANGED
@@ -15,6 +15,8 @@ module RelatonCcsds
|
|
15
15
|
FileRef,ISO_x0020_Number,Patents,Extra_x0020_Link,Area,calHtmlColorCode&$filter=Book_x0020_Type%20eq%20%27Silver%20Book%27
|
16
16
|
URL
|
17
17
|
|
18
|
+
TRRGX = /\s-\s\w+\sTranslated$/.freeze
|
19
|
+
|
18
20
|
def initialize(output, format)
|
19
21
|
@output = output
|
20
22
|
@format = format
|
@@ -68,18 +70,64 @@ module RelatonCcsds
|
|
68
70
|
end
|
69
71
|
|
70
72
|
def save_bib(bib)
|
73
|
+
search_translation bib
|
71
74
|
id = bib.docidentifier.first.id
|
72
|
-
file = File.join @output, "#{id.gsub(/[.\s]+/, '-')}.#{@ext}"
|
73
|
-
if @files.include?
|
75
|
+
file = File.join @output, "#{id.gsub(/[.\s-]+/, '-')}.#{@ext}"
|
76
|
+
if @files.include?(file)
|
74
77
|
puts "(#{file}) file already exists. Trying to merge links ..."
|
75
78
|
merge_links bib, file
|
76
|
-
else
|
77
|
-
@files << file
|
79
|
+
else @files << file
|
78
80
|
end
|
79
81
|
File.write file, content(bib), encoding: "UTF-8"
|
80
82
|
index.add_or_update id, file
|
81
83
|
end
|
82
84
|
|
85
|
+
def search_translation(bib) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
86
|
+
bibid = bib.docidentifier.first.id.dup
|
87
|
+
if bibid.sub!(TRRGX, "")
|
88
|
+
index.search do |row|
|
89
|
+
id = row[:id].sub(TRRGX, "")
|
90
|
+
next if id != bibid || row[:id] == bib.docidentifier.first.id
|
91
|
+
|
92
|
+
create_translation_relation bib, row[:file]
|
93
|
+
end
|
94
|
+
else
|
95
|
+
index.search do |row|
|
96
|
+
next unless row[:id].match?(/^#{bibid}#{TRRGX}/)
|
97
|
+
|
98
|
+
create_instance_relation bib, row[:file]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def create_translation_relation(bib, file) # rubocop:disable Metrics/MethodLength
|
104
|
+
hash = YAML.load_file file
|
105
|
+
inst = BibliographicItem.from_hash hash
|
106
|
+
if inst.docidentifier.first.id.match?(TRRGX)
|
107
|
+
type1 = type2 = "hasTranslation"
|
108
|
+
else
|
109
|
+
type1 = "instanceOf"
|
110
|
+
type2 = "hasInstance"
|
111
|
+
end
|
112
|
+
create_relation(bib, inst, type1)
|
113
|
+
create_relation(inst, bib, type2)
|
114
|
+
File.write file, content(inst), encoding: "UTF-8"
|
115
|
+
end
|
116
|
+
|
117
|
+
def create_instance_relation(bib, file)
|
118
|
+
hash = YAML.load_file file
|
119
|
+
inst = BibliographicItem.from_hash hash
|
120
|
+
create_relation bib, inst, "hasInstance"
|
121
|
+
create_relation inst, bib, "instanceOf"
|
122
|
+
File.write file, content(inst), encoding: "UTF-8"
|
123
|
+
end
|
124
|
+
|
125
|
+
def create_relation(bib1, bib2, type)
|
126
|
+
fref = RelatonBib::FormattedRef.new content: bib2.docidentifier.first.id
|
127
|
+
rel = BibliographicItem.new docid: bib2.docidentifier, formattedref: fref
|
128
|
+
bib1.relation << RelatonBib::DocumentRelation.new(type: type, bibitem: rel)
|
129
|
+
end
|
130
|
+
|
83
131
|
def merge_links(bib, file) # rubocop:disable Metrics/AbcSize
|
84
132
|
hash = YAML.load_file file
|
85
133
|
bib2 = BibliographicItem.from_hash hash
|
@@ -76,13 +76,13 @@ module RelatonCcsds
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def parse_edition
|
79
|
-
@doc["Issue_x0020_Number"]
|
79
|
+
@doc["Issue_x0020_Number"].match(/^\d+/)&.to_s
|
80
80
|
end
|
81
81
|
|
82
82
|
def parse_relation
|
83
83
|
@docs.each_with_object(successor + adopted) do |d, a|
|
84
84
|
id = docidentifier d["Document_x0020_Number"].strip
|
85
|
-
type =
|
85
|
+
type = relation_type id
|
86
86
|
next unless type
|
87
87
|
|
88
88
|
a << create_relation(type, id)
|
@@ -104,12 +104,14 @@ module RelatonCcsds
|
|
104
104
|
[create_relation("hasSuccessor", @successor.docidentifier[0].id)]
|
105
105
|
end
|
106
106
|
|
107
|
-
def
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
"
|
107
|
+
def relation_type(rel_id)
|
108
|
+
return if rel_id == docidentifier ||
|
109
|
+
rel_id.match(DataFetcher::TRRGX).to_s != docidentifier.match(DataFetcher::TRRGX).to_s
|
110
|
+
|
111
|
+
if rel_id.include?(docidentifier.sub(DataFetcher::TRRGX, ""))
|
112
|
+
"updatedBy"
|
113
|
+
elsif docidentifier.include?(rel_id.sub(DataFetcher::TRRGX, ""))
|
114
|
+
"updates"
|
113
115
|
end
|
114
116
|
end
|
115
117
|
|
@@ -54,7 +54,7 @@ module RelatonCcsds
|
|
54
54
|
# Remove index file
|
55
55
|
#
|
56
56
|
def remove_index_file
|
57
|
-
Relaton::Index.find_or_create(:
|
57
|
+
Relaton::Index.find_or_create(:ccsds, url: true, file: HitCollection::INDEX_FILE).remove_file
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
data/relaton_ccsds.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
|
26
26
|
# Uncomment to register a new dependency of your gem
|
27
27
|
spec.add_dependency "mechanize", "~> 2.7"
|
28
|
-
spec.add_dependency "relaton-bib", "~> 1.
|
28
|
+
spec.add_dependency "relaton-bib", "~> 1.16.0"
|
29
29
|
spec.add_dependency "relaton-index", "~> 0.2.0"
|
30
30
|
|
31
31
|
# For more information and examples about making a new gem, check out our
|
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.16.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: 2023-
|
11
|
+
date: 2023-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.16.0
|
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.
|
40
|
+
version: 1.16.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: relaton-index
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|