relaton-ccsds 1.18.1 → 1.20.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 +15 -22
- data/grammars/basicdoc.rng +3 -0
- data/lib/relaton_ccsds/bibliography.rb +3 -3
- data/lib/relaton_ccsds/data_fetcher.rb +29 -13
- data/lib/relaton_ccsds/data_parser.rb +5 -1
- data/lib/relaton_ccsds/hit_collection.rb +9 -3
- data/lib/relaton_ccsds/util.rb +1 -4
- data/lib/relaton_ccsds/version.rb +1 -1
- data/lib/relaton_ccsds/xml_parser.rb +4 -0
- data/lib/relaton_ccsds.rb +1 -1
- data/relaton_ccsds.gemspec +3 -3
- metadata +20 -7
- data/lib/relaton_ccsds/config.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5dbc82b9af321507bb207dc43ecb39b7ab7704f167f479fd3a6170cd3f5283e1
|
4
|
+
data.tar.gz: 22633dcbb3b00c5082f5e1db82a7c693ba915ffafa16abead42d62d7b3209252
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1267cd4023932a5702bcbd5c6efbaca487d74b26659de634da34f6620d42805f70d8ef6e12e484a00dff6ffeb23bb5c46c0e5f53d2d7a5df231c77f341bbe287
|
7
|
+
data.tar.gz: 13d9d28ba550bf1a4da1bd62a35f0db7a3eb70d690edab271fae33bc68610995e23833ef41a7a8f2dcdf7a76c7d1eb1fb93dcbf8c4bd43b617c53ab8e7ec6836
|
data/README.adoc
CHANGED
@@ -23,24 +23,13 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
== Usage
|
25
25
|
|
26
|
-
===
|
27
|
-
|
28
|
-
Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonCcsds.configure` block.
|
26
|
+
=== Search for a standard using keywords
|
29
27
|
|
30
28
|
[source,ruby]
|
31
29
|
----
|
32
30
|
require 'relaton_ccsds'
|
33
31
|
=> true
|
34
32
|
|
35
|
-
RelatonCcsds.configure do |config|
|
36
|
-
config.logger.level = Logger::DEBUG
|
37
|
-
end
|
38
|
-
----
|
39
|
-
|
40
|
-
=== Search for a standard using keywords
|
41
|
-
|
42
|
-
[source,ruby]
|
43
|
-
----
|
44
33
|
hits = RelatonCcsds::Bibliography.search("CCSDS 230.2-G-1")
|
45
34
|
=> <RelatonCcsds::HitCollection:0x00000000001770 @ref=CCSDS 230.2-G-1 @fetched=false>
|
46
35
|
|
@@ -54,7 +43,7 @@ item = hits[0].doc
|
|
54
43
|
[source,ruby]
|
55
44
|
----
|
56
45
|
item.to_xml
|
57
|
-
=> "<bibitem id="CCSDS230.2-G-1" schema-version="v1.2.
|
46
|
+
=> "<bibitem id="CCSDS230.2-G-1" schema-version="v1.2.9">
|
58
47
|
<fetched>2023-08-25</fetched>
|
59
48
|
<title format="text/plain" language="en" script="Latn">Next Generation Uplink</title>
|
60
49
|
<uri type="pdf">https://public.ccsds.org/Pubs/230x2g1.pdf</uri>
|
@@ -66,7 +55,7 @@ With argument `bibdata: true` it outputs XML wrapped by `bibdata` element and ad
|
|
66
55
|
[source,ruby]
|
67
56
|
----
|
68
57
|
item.to_xml bibdata: true
|
69
|
-
=> "<bibdata schema-version="v1.2.
|
58
|
+
=> "<bibdata schema-version="v1.2.9">
|
70
59
|
<fetched>2023-08-25</fetched>
|
71
60
|
<title format="text/plain" language="en" script="Latn">Next Generation Uplink</title>
|
72
61
|
<uri type="pdf">https://public.ccsds.org/Pubs/230x2g1.pdf</uri>
|
@@ -95,8 +84,8 @@ item.link
|
|
95
84
|
@type="pdf">]
|
96
85
|
|
97
86
|
RelatonCcsds::Bibliography.get("CCSDS 720.6-Y-1").link
|
98
|
-
[relaton-
|
99
|
-
[relaton-
|
87
|
+
[relaton-ccsds] (CCSDS 720.6-Y-1) Fetching from Relaton repository ...
|
88
|
+
[relaton-ccsds] (CCSDS 720.6-Y-1) Found: `CCSDS 720.6-Y-1`.
|
100
89
|
=> [#<RelatonBib::TypedUri:0x0000000114183bb0
|
101
90
|
@content=#<Addressable::URI:0xca8 URI:https://public.ccsds.org/Pubs/720x6y1.pdf>,
|
102
91
|
@language=nil,
|
@@ -113,8 +102,8 @@ RelatonCcsds::Bibliography.get("CCSDS 720.6-Y-1").link
|
|
113
102
|
[source,ruby]
|
114
103
|
----
|
115
104
|
RelatonCcsds::Bibliography.get("CCSDS 230.2-G-1")
|
116
|
-
[relaton-
|
117
|
-
[relaton-
|
105
|
+
[relaton-ccsds] (CCSDS 230.2-G-1) Fetching from Relaton repository ...
|
106
|
+
[relaton-ccsds] (CCSDS 230.2-G-1) Found: `CCSDS 230.2-G-1`.
|
118
107
|
=> #<RelatonCcsds::BibliographicItem:0x00000001135dade0
|
119
108
|
...
|
120
109
|
----
|
@@ -124,8 +113,8 @@ RelatonCcsds::Bibliography.get("CCSDS 230.2-G-1")
|
|
124
113
|
[source,ruby]
|
125
114
|
----
|
126
115
|
item = RelatonCcsds::Bibliography.get("CCSDS 720.4-Y-1 (DOC)")
|
127
|
-
[relaton-
|
128
|
-
[relaton-
|
116
|
+
[relaton-ccsds] (CCSDS 720.4-Y-1 (DOC)) Fetching from Relaton repository ...
|
117
|
+
[relaton-ccsds] (CCSDS 720.4-Y-1 (DOC)) Found: `CCSDS 720.4-Y-1`.
|
129
118
|
=> #<RelatonCcsds::BibliographicItem:0x000000011100dfe0
|
130
119
|
...
|
131
120
|
|
@@ -139,8 +128,8 @@ pry(main)> item.link[0].content.to_s
|
|
139
128
|
=> "https://public.ccsds.org/Pubs/720x4y1.doc"
|
140
129
|
|
141
130
|
item = RelatonCcsds::Bibliography.get("CCSDS 720.4-Y-1 (PDF)")
|
142
|
-
[relaton-
|
143
|
-
[relaton-
|
131
|
+
[relaton-ccsds] (CCSDS 720.4-Y-1 (PDF)) Fetching from Relaton repository ...
|
132
|
+
[relaton-ccsds] (CCSDS 720.4-Y-1 (PDF)) Found: `CCSDS 720.4-Y-1`.
|
144
133
|
=> #<RelatonCcsds::BibliographicItem:0x0000000111004620
|
145
134
|
...
|
146
135
|
|
@@ -195,6 +184,10 @@ Done in: 20 sec.
|
|
195
184
|
=> nil
|
196
185
|
----
|
197
186
|
|
187
|
+
=== Logging
|
188
|
+
|
189
|
+
RelatonCcsds uses the relaton-logger gem for logging. By default, it logs to STDOUT. To change the log levels and add other loggers, read the https://github.com/relaton/relaton-logger#usage[relaton-logger] documentation.
|
190
|
+
|
198
191
|
== Development
|
199
192
|
|
200
193
|
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.
|
data/grammars/basicdoc.rng
CHANGED
@@ -27,14 +27,14 @@ module RelatonCcsds
|
|
27
27
|
def get(reference, _year = nil, opts = {}) # rubocop:disable Metrics/MethodLength
|
28
28
|
ref = reference.sub(/\s\((DOC|PDF)\)$/, "")
|
29
29
|
opts[:format] ||= Regexp.last_match(1)
|
30
|
-
Util.
|
30
|
+
Util.info "Fetching from Relaton repository ...", key: reference
|
31
31
|
hits = search ref
|
32
32
|
doc = hits.first&.doc&.to_format(opts[:format])
|
33
33
|
unless doc
|
34
|
-
Util.
|
34
|
+
Util.info "Not found.", key: reference
|
35
35
|
return nil
|
36
36
|
end
|
37
|
-
Util.
|
37
|
+
Util.info "Found: `#{hits.first.code}`.", key: reference
|
38
38
|
doc
|
39
39
|
end
|
40
40
|
end
|
@@ -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
|
-
puts "(#{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,13 +240,21 @@ 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
|
238
|
-
|
254
|
+
Util.info "links are the same.", key: file
|
239
255
|
return
|
240
256
|
end
|
241
|
-
|
257
|
+
Util.info "links are merged.", key: file
|
242
258
|
bib.link << bib2.link[0]
|
243
259
|
end
|
244
260
|
|
@@ -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
|
21
27
|
end
|
22
28
|
end
|
23
29
|
end
|
data/lib/relaton_ccsds/util.rb
CHANGED
data/lib/relaton_ccsds.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
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
|
-
require_relative "relaton_ccsds/config"
|
9
9
|
require_relative "relaton_ccsds/util"
|
10
10
|
require_relative "relaton_ccsds/document_type"
|
11
11
|
require_relative "relaton_ccsds/bibliography"
|
data/relaton_ccsds.gemspec
CHANGED
@@ -25,9 +25,9 @@ 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.10"
|
28
|
-
spec.add_dependency "relaton-bib", "~> 1.
|
29
|
-
spec.add_dependency "relaton-index", "~> 0.2.
|
30
|
-
|
28
|
+
spec.add_dependency "relaton-bib", "~> 1.19.0"
|
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.
|
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-
|
11
|
+
date: 2024-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|
@@ -30,28 +30,42 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.19.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.19.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: relaton-index
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.2.
|
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.
|
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
|
@@ -76,7 +90,6 @@ files:
|
|
76
90
|
- lib/relaton_ccsds.rb
|
77
91
|
- lib/relaton_ccsds/bibliographic_item.rb
|
78
92
|
- lib/relaton_ccsds/bibliography.rb
|
79
|
-
- lib/relaton_ccsds/config.rb
|
80
93
|
- lib/relaton_ccsds/data_fetcher.rb
|
81
94
|
- lib/relaton_ccsds/data_parser.rb
|
82
95
|
- lib/relaton_ccsds/document_type.rb
|