relaton-ccsds 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/rake.yml +13 -0
- data/.github/workflows/release.yml +24 -0
- data/.gitignore +15 -0
- data/.rspec +3 -0
- data/.rubocop.yml +12 -0
- data/.vscode/launch.json +40 -0
- data/Gemfile +16 -0
- data/README.adoc +164 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/rspec +27 -0
- data/bin/setup +8 -0
- data/grammars/basicdoc.rng +1125 -0
- data/grammars/biblio-standoc.rng +164 -0
- data/grammars/biblio.rng +1461 -0
- data/lib/relaton_ccsds/bibliographic_item.rb +49 -0
- data/lib/relaton_ccsds/bibliography.rb +37 -0
- data/lib/relaton_ccsds/config.rb +10 -0
- data/lib/relaton_ccsds/data_fetcher.rb +102 -0
- data/lib/relaton_ccsds/data_parser.rb +139 -0
- data/lib/relaton_ccsds/hash_converter.rb +21 -0
- data/lib/relaton_ccsds/hit.rb +21 -0
- data/lib/relaton_ccsds/hit_collection.rb +23 -0
- data/lib/relaton_ccsds/processor.rb +60 -0
- data/lib/relaton_ccsds/util.rb +9 -0
- data/lib/relaton_ccsds/version.rb +5 -0
- data/lib/relaton_ccsds/xml_parser.rb +31 -0
- data/lib/relaton_ccsds.rb +28 -0
- data/relaton_ccsds.gemspec +33 -0
- metadata +114 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
module RelatonCcsds
|
2
|
+
class BibliographicItem < RelatonBib::BibliographicItem
|
3
|
+
DOCTYPES = %w[standard practice report specification record].freeze
|
4
|
+
|
5
|
+
attr_reader :technology_area
|
6
|
+
|
7
|
+
# @param technology_area [String, nil]
|
8
|
+
def initialize(**args)
|
9
|
+
if args[:doctype] && !DOCTYPES.include?(args[:doctype])
|
10
|
+
Util.warn "WARNING: invalid doctype: #{args[:doctype]}"
|
11
|
+
end
|
12
|
+
@technology_area = args.delete(:technology_area)
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Fetch flavor schema version
|
18
|
+
#
|
19
|
+
# @return [String] schema version
|
20
|
+
#
|
21
|
+
def ext_schema
|
22
|
+
@ext_schema ||= schema_versions["relaton-model-ccsds"]
|
23
|
+
end
|
24
|
+
|
25
|
+
# @param builder [Nokogiri::XML::Builder]
|
26
|
+
def to_xml(**opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
27
|
+
super do |builder|
|
28
|
+
if opts[:bibdata] && (doctype || editorialgroup || technology_area)
|
29
|
+
ext = builder.ext do |b|
|
30
|
+
b.doctype doctype if doctype
|
31
|
+
editorialgroup&.to_xml b
|
32
|
+
b.send(:"technology-area", technology_area) if technology_area
|
33
|
+
end
|
34
|
+
ext["schema-version"] = ext_schema if !opts[:embedded] && respond_to?(:ext_schema) && ext_schema
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# @return [Hash]
|
40
|
+
def to_hash
|
41
|
+
hash = super
|
42
|
+
if technology_area
|
43
|
+
hash["ext"] ||= {}
|
44
|
+
hash["ext"]["technology_area"] = technology_area
|
45
|
+
end
|
46
|
+
hash
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module RelatonCcsds
|
2
|
+
module Bibliography
|
3
|
+
extend self
|
4
|
+
|
5
|
+
#
|
6
|
+
# Search for CCSDS standards by document reference.
|
7
|
+
#
|
8
|
+
# @param [String] ref document reference
|
9
|
+
#
|
10
|
+
# @return [RelatonCcsds::HitCollection] collection of hits
|
11
|
+
#
|
12
|
+
def search(ref)
|
13
|
+
RelatonCcsds::HitCollection.new(ref).fetch
|
14
|
+
end
|
15
|
+
|
16
|
+
#
|
17
|
+
# Get CCSDS standard by document reference.
|
18
|
+
#
|
19
|
+
# @param text [String]
|
20
|
+
# @param year [String, nil]
|
21
|
+
# @param opts [Hash]
|
22
|
+
#
|
23
|
+
# @return [RelatonCcsds::BibliographicItem]
|
24
|
+
#
|
25
|
+
def get(ref, _year = nil, _opts = {})
|
26
|
+
Util.warn "(#{ref}) fetching..."
|
27
|
+
hits = search ref
|
28
|
+
if hits.empty?
|
29
|
+
Util.warn "(#{ref}) not found."
|
30
|
+
return nil
|
31
|
+
end
|
32
|
+
doc = hits.first.doc
|
33
|
+
Util.warn "(#{ref}) found `#{hits.first.code}`."
|
34
|
+
doc
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module RelatonCcsds
|
2
|
+
class DataFetcher
|
3
|
+
ACTIVE_PUBS_URL = <<~URL.freeze
|
4
|
+
https://public.ccsds.org/_api/web/lists/getbytitle('CCSDS%20Publications')/items?$top=1000&$select=Dcoument_x0020_Title,
|
5
|
+
Document_x0020_Number,Book_x0020_Type,Issue_x0020_Number,calPublishedMonth,calPublishedYear,Description0,Working_x0020_Group,
|
6
|
+
FileRef,ISO_x0020_Number,Patents,Extra_x0020_Link,Area,calActive,calHtmlColorCode&$filter=Book_x0020_Type%20eq%20%27Blue%20
|
7
|
+
Book%27%20or%20Book_x0020_Type%20eq%20%27Magenta%20Book%27%20or%20Book_x0020_Type%20eq%20%27Green%20Book%27%20or%20
|
8
|
+
Book_x0020_Type%20eq%20%27Orange%20Book%27%20or%20Book_x0020_Type%20eq%20%27Yellow%20Book%20-%20Reports%20and%20Records%27%20
|
9
|
+
or%20Book_x0020_Type%20eq%20%27Yellow%20Book%20-%20CCSDS%20Normative%20Procedures%27
|
10
|
+
URL
|
11
|
+
|
12
|
+
OBSOLETE_PUBS_URL = <<~URL.freeze
|
13
|
+
https://public.ccsds.org/_api/web/lists/getbytitle('CCSDS%20Publications')/items?$top=1000&$select=Dcoument_x0020_Title,
|
14
|
+
Document_x0020_Number,Book_x0020_Type,Issue_x0020_Number,calPublishedMonth,calPublishedYear,Description0,Working_x0020_Group,
|
15
|
+
FileRef,ISO_x0020_Number,Patents,Extra_x0020_Link,Area,calHtmlColorCode&$filter=Book_x0020_Type%20eq%20%27Silver%20Book%27
|
16
|
+
URL
|
17
|
+
|
18
|
+
def initialize(output, format)
|
19
|
+
@output = output
|
20
|
+
@format = format
|
21
|
+
@ext = format.sub "bibxml", "xml"
|
22
|
+
@files = []
|
23
|
+
end
|
24
|
+
|
25
|
+
def agent
|
26
|
+
return @agent if @agent
|
27
|
+
|
28
|
+
@agent = Mechanize.new
|
29
|
+
@agent.request_headers = { "Accept" => "application/json;odata=verbose" }
|
30
|
+
@agent
|
31
|
+
end
|
32
|
+
|
33
|
+
def index
|
34
|
+
@index ||= Relaton::Index.find_or_create "CCSDS", file: "index-v1.yaml"
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.fetch(output: "data", format: "yaml")
|
38
|
+
t1 = Time.now
|
39
|
+
puts "Started at: #{t1}"
|
40
|
+
FileUtils.mkdir_p output
|
41
|
+
new(output, format).fetch
|
42
|
+
t2 = Time.now
|
43
|
+
puts "Stopped at: #{t2}"
|
44
|
+
puts "Done in: #{(t2 - t1).round} sec."
|
45
|
+
end
|
46
|
+
|
47
|
+
def fetch
|
48
|
+
fetch_docs ACTIVE_PUBS_URL
|
49
|
+
fetch_docs OBSOLETE_PUBS_URL, retired: true
|
50
|
+
index.save
|
51
|
+
end
|
52
|
+
|
53
|
+
def fetch_docs(url, retired: false)
|
54
|
+
resp = agent.get(url)
|
55
|
+
json = JSON.parse resp.body
|
56
|
+
@array = json["d"]["results"].map do |doc|
|
57
|
+
parse_and_save doc, json["d"]["results"], retired
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def parse_and_save(doc, results, retired)
|
62
|
+
bibitem = DataParser.new(doc, results).parse
|
63
|
+
if retired
|
64
|
+
predecessor = DataParser.new(doc, results, bibitem).parse
|
65
|
+
save_bib predecessor
|
66
|
+
end
|
67
|
+
save_bib bibitem
|
68
|
+
end
|
69
|
+
|
70
|
+
def save_bib(bib)
|
71
|
+
id = bib.docidentifier.first.id
|
72
|
+
file = File.join @output, "#{id.gsub(/[.\s]+/, '-')}.#{@ext}"
|
73
|
+
if @files.include? file
|
74
|
+
puts "(#{file}) file already exists. Trying to merge links ..."
|
75
|
+
merge_links bib, file
|
76
|
+
else
|
77
|
+
@files << file
|
78
|
+
end
|
79
|
+
File.write file, content(bib), encoding: "UTF-8"
|
80
|
+
index.add_or_update id, file
|
81
|
+
end
|
82
|
+
|
83
|
+
def merge_links(bib, file) # rubocop:disable Metrics/AbcSize
|
84
|
+
hash = YAML.load_file file
|
85
|
+
bib2 = BibliographicItem.from_hash hash
|
86
|
+
if bib.link[0].type == bib2.link[0].type
|
87
|
+
warn "(#{file}) links are the same."
|
88
|
+
return
|
89
|
+
end
|
90
|
+
warn "(#{file}) links are merged."
|
91
|
+
bib.link << bib2.link[0]
|
92
|
+
end
|
93
|
+
|
94
|
+
def content(bib)
|
95
|
+
case @format
|
96
|
+
when "yaml" then bib.to_hash.to_yaml
|
97
|
+
when "xml" then bib.to_xml(bibdata: true)
|
98
|
+
else bib.send "to_#{@format}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
module RelatonCcsds
|
2
|
+
class DataParser
|
3
|
+
DOCTYPES = { B: "standard", M: "practice", G: "report", O: "specification", Y: "record" }.freeze
|
4
|
+
DOMAIN = "https://public.ccsds.org".freeze
|
5
|
+
|
6
|
+
AREAS = {
|
7
|
+
"SEA" => "Systems Engineering Area",
|
8
|
+
"MOIMS" => "Mission Operations and Information Management Services Area",
|
9
|
+
"CSS" => "Cross Support Services Area",
|
10
|
+
"SOIS" => "Spacecraft Onboard Interface Services Area",
|
11
|
+
"SLS" => "Space Link Services Area",
|
12
|
+
"SIS" => "Space Internetworking Services Area",
|
13
|
+
}.freeze
|
14
|
+
|
15
|
+
ATTRS = %i[
|
16
|
+
title docid abstract doctype date docstatus link edition relation editorialgroup technology_area
|
17
|
+
].freeze
|
18
|
+
|
19
|
+
ID_MAPPING = {
|
20
|
+
"CCSDS 320.0-B-1-S Corrigendum 1" => "CCSDS 320.0-B-1-S Cor. 1", # TODO relaton/relaton-data-ccsds#5
|
21
|
+
"CCSDS 701.00-R-3" => "CCSDS 701.00-R-3-S", # TODO relaton/relaton-data-ccsds#8
|
22
|
+
}.freeze
|
23
|
+
|
24
|
+
def initialize(doc, docs, successor = nil)
|
25
|
+
@doc = doc
|
26
|
+
@docs = docs
|
27
|
+
@successor = successor
|
28
|
+
end
|
29
|
+
|
30
|
+
def parse
|
31
|
+
args = ATTRS.each_with_object({}) { |a, o| o[a] = send "parse_#{a}" }
|
32
|
+
BibliographicItem.new(**args)
|
33
|
+
end
|
34
|
+
|
35
|
+
def parse_title
|
36
|
+
t = @doc["Dcoument_x0020_Title"]
|
37
|
+
[RelatonBib::TypedTitleString.new(content: t, language: "en", script: "Latn")]
|
38
|
+
end
|
39
|
+
|
40
|
+
def parse_docid
|
41
|
+
[RelatonBib::DocumentIdentifier.new(id: docidentifier, type: "CCSDS", primary: true)]
|
42
|
+
end
|
43
|
+
|
44
|
+
def docidentifier(id = nil)
|
45
|
+
id ||= @doc["Document_x0020_Number"].strip
|
46
|
+
docid = ID_MAPPING[id] || id
|
47
|
+
return docid unless @successor
|
48
|
+
|
49
|
+
docid.sub(/(-S|s)(?=\s|$)/, "")
|
50
|
+
end
|
51
|
+
|
52
|
+
def parse_abstract
|
53
|
+
a = @doc["Description0"]
|
54
|
+
[RelatonBib::FormattedString.new(content: a, language: "en", script: "Latn")]
|
55
|
+
end
|
56
|
+
|
57
|
+
def parse_doctype
|
58
|
+
/^CCSDS\s[\d.]+-(?<type>\w+)/ =~ @doc["Document_x0020_Number"]
|
59
|
+
DOCTYPES[type&.to_sym]
|
60
|
+
end
|
61
|
+
|
62
|
+
def parse_date
|
63
|
+
on = "#{@doc['calPublishedMonth']} #{@doc['calPublishedYear']}"
|
64
|
+
[RelatonBib::BibliographicDate.new(type: "published", on: on)]
|
65
|
+
end
|
66
|
+
|
67
|
+
def parse_docstatus
|
68
|
+
stage = @successor ? "withdrawn" : "published"
|
69
|
+
RelatonBib::DocumentStatus.new stage: stage
|
70
|
+
end
|
71
|
+
|
72
|
+
def parse_link
|
73
|
+
l = "#{DOMAIN}#{@doc['FileRef']}"
|
74
|
+
t = File.extname(@doc["FileRef"])&.sub(/^\./, "")
|
75
|
+
[RelatonBib::TypedUri.new(type: t, content: l)]
|
76
|
+
end
|
77
|
+
|
78
|
+
def parse_edition
|
79
|
+
@doc["Issue_x0020_Number"]
|
80
|
+
end
|
81
|
+
|
82
|
+
def parse_relation
|
83
|
+
@docs.each_with_object(successor + adopted) do |d, a|
|
84
|
+
id = docidentifier d["Document_x0020_Number"].strip
|
85
|
+
type = relaton_type id
|
86
|
+
next unless type
|
87
|
+
|
88
|
+
a << create_relation(type, id)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def adopted
|
93
|
+
return [] unless @doc["ISO_x0020_Number"]
|
94
|
+
|
95
|
+
code = @doc["ISO_x0020_Number"]["Description"].match(/(?<=\s)\d+$/)
|
96
|
+
id = "ISO #{code}"
|
97
|
+
[create_relation("adoptedAs", id)]
|
98
|
+
end
|
99
|
+
|
100
|
+
def successor
|
101
|
+
return [] unless @successor
|
102
|
+
|
103
|
+
@successor.relation << create_relation("successorOf", docidentifier)
|
104
|
+
[create_relation("hasSuccessor", @successor.docidentifier[0].id)]
|
105
|
+
end
|
106
|
+
|
107
|
+
def relaton_type(rel_id)
|
108
|
+
same = rel_id == docidentifier
|
109
|
+
if rel_id.include?(docidentifier) && !same
|
110
|
+
"hasEdition"
|
111
|
+
elsif docidentifier.include?(rel_id) && !same
|
112
|
+
"editionOf"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def create_relation(type, rel_id)
|
117
|
+
id = RelatonBib::DocumentIdentifier.new id: rel_id, type: "CCSDS", primary: true
|
118
|
+
fref = RelatonBib::FormattedRef.new content: rel_id
|
119
|
+
bibitem = RelatonBib::BibliographicItem.new docid: [id], formattedref: fref
|
120
|
+
RelatonBib::DocumentRelation.new type: type, bibitem: bibitem
|
121
|
+
end
|
122
|
+
|
123
|
+
def parse_editorialgroup
|
124
|
+
name = @doc.dig("Working_x0020_Group", "Description")
|
125
|
+
return unless name
|
126
|
+
|
127
|
+
wg = RelatonBib::WorkGroup.new name: name
|
128
|
+
tc = RelatonBib::TechnicalCommittee.new wg
|
129
|
+
RelatonBib::EditorialGroup.new([tc])
|
130
|
+
end
|
131
|
+
|
132
|
+
def parse_technology_area
|
133
|
+
desc = @doc.dig("Working_x0020_Group", "Description")
|
134
|
+
return unless desc
|
135
|
+
|
136
|
+
AREAS[desc.match(/^[A-Z]+(?=-)/)&.to_s]
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RelatonCcsds
|
2
|
+
class HashConverter < RelatonBib::HashConverter
|
3
|
+
class << self
|
4
|
+
# @param args [Hash]
|
5
|
+
# @return [Hash]
|
6
|
+
def hash_to_bib(args)
|
7
|
+
ret = super
|
8
|
+
return unless ret
|
9
|
+
|
10
|
+
ret[:technology_area] = ret[:ext][:technology_area] if ret[:ext]
|
11
|
+
ret
|
12
|
+
end
|
13
|
+
|
14
|
+
# @param item_hash [Hash]
|
15
|
+
# @return [RelatonCie::BibliographicItem]
|
16
|
+
def bib_item(item_hash)
|
17
|
+
BibliographicItem.new(**item_hash)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RelatonCcsds
|
2
|
+
class Hit
|
3
|
+
attr_reader :code
|
4
|
+
|
5
|
+
def initialize(code:, url:)
|
6
|
+
@code = code
|
7
|
+
@url = url
|
8
|
+
end
|
9
|
+
|
10
|
+
def doc
|
11
|
+
return @doc if @doc
|
12
|
+
|
13
|
+
resp = Mechanize.new.get(@url)
|
14
|
+
hash = YAML.safe_load(resp.body)
|
15
|
+
hash["fetched"] = Date.today.to_s
|
16
|
+
@doc = BibliographicItem.from_hash(hash)
|
17
|
+
rescue Mechanize::Error => e
|
18
|
+
raise RelatonBib::RequestError, e.message
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module RelatonCcsds
|
2
|
+
class HitCollection < RelatonBib::HitCollection
|
3
|
+
GHURL = "https://raw.githubusercontent.com/relaton/relaton-data-ccsds/main/".freeze
|
4
|
+
INDEX_FILE = "index-v1.yaml".freeze
|
5
|
+
|
6
|
+
#
|
7
|
+
# Search his in index.
|
8
|
+
#
|
9
|
+
# @return [<Type>] <description>
|
10
|
+
#
|
11
|
+
def fetch
|
12
|
+
rows = index.search text
|
13
|
+
@array = rows.map { |row| Hit.new code: row[:id], url: "#{GHURL}#{row[:file]}" }
|
14
|
+
self
|
15
|
+
rescue SocketError, OpenURI::HTTPError, OpenSSL::SSL::SSLError, Errno::ECONNRESET => e
|
16
|
+
raise RelatonBib::RequestError, e.message
|
17
|
+
end
|
18
|
+
|
19
|
+
def index
|
20
|
+
@index ||= Relaton::Index.find_or_create :ccsds, url: "#{GHURL}index-v1.zip", file: INDEX_FILE
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "relaton/processor"
|
2
|
+
|
3
|
+
module RelatonCcsds
|
4
|
+
class Processor < Relaton::Processor
|
5
|
+
attr_reader :idtype
|
6
|
+
|
7
|
+
def initialize # rubocop:disable Lint/MissingSuper
|
8
|
+
@short = :relaton_ccsds
|
9
|
+
@prefix = "CCSDS"
|
10
|
+
@defaultprefix = %r{^CCSDS(?!\w)}
|
11
|
+
@idtype = "CCSDS"
|
12
|
+
@datasets = %w[ccsds]
|
13
|
+
end
|
14
|
+
|
15
|
+
# @param code [String]
|
16
|
+
# @param date [String, NilClass] year
|
17
|
+
# @param opts [Hash]
|
18
|
+
# @return [RelatonCcsds::BibliographicItem]
|
19
|
+
def get(code, date, opts)
|
20
|
+
::RelatonCcsds::Bibliography.get(code, date, opts)
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Fetch all the documents from a source
|
25
|
+
#
|
26
|
+
# @param [String] _source source name
|
27
|
+
# @param [Hash] opts
|
28
|
+
# @option opts [String] :output directory to output documents
|
29
|
+
# @option opts [String] :format
|
30
|
+
#
|
31
|
+
def fetch_data(_source, opts)
|
32
|
+
DataFetcher.fetch(**opts)
|
33
|
+
end
|
34
|
+
|
35
|
+
# @param xml [String]
|
36
|
+
# @return [RelatonCcsds::CcBibliographicItem]
|
37
|
+
def from_xml(xml)
|
38
|
+
::RelatonCcsds::XMLParser.from_xml xml
|
39
|
+
end
|
40
|
+
|
41
|
+
# @param hash [Hash]
|
42
|
+
# @return [RelatonIsoBib::CcBibliographicItem]
|
43
|
+
def hash_to_bib(hash)
|
44
|
+
::RelatonCcsds::BibliographicItem.from_hash hash
|
45
|
+
end
|
46
|
+
|
47
|
+
# Returns hash of XML grammar
|
48
|
+
# @return [String]
|
49
|
+
def grammar_hash
|
50
|
+
@grammar_hash ||= ::RelatonCcsds.grammar_hash
|
51
|
+
end
|
52
|
+
|
53
|
+
#
|
54
|
+
# Remove index file
|
55
|
+
#
|
56
|
+
def remove_index_file
|
57
|
+
Relaton::Index.find_or_create(:CC, url: true, file: HitCollection::INDEX_FILE).remove_file
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module RelatonCcsds
|
2
|
+
class XMLParser < RelatonBib::XMLParser
|
3
|
+
class << self
|
4
|
+
private
|
5
|
+
|
6
|
+
#
|
7
|
+
# Parse bibitem data
|
8
|
+
#
|
9
|
+
# @param bibitem [Nokogiri::XML::Element] bibitem element
|
10
|
+
#
|
11
|
+
# @return [Hash] bibitem data
|
12
|
+
#
|
13
|
+
def item_data(doc)
|
14
|
+
resp = super
|
15
|
+
resp[:technology_area] = doc.at("./ext/technology-area")&.text
|
16
|
+
resp
|
17
|
+
end
|
18
|
+
|
19
|
+
#
|
20
|
+
# override RelatonBib::XMLParser#bib_item method
|
21
|
+
#
|
22
|
+
# @param item_hash [Hash]
|
23
|
+
#
|
24
|
+
# @return [RelatonCcsds::BibliographicItem]
|
25
|
+
#
|
26
|
+
def bib_item(item_hash)
|
27
|
+
BibliographicItem.new(**item_hash)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mechanize"
|
4
|
+
require "relaton_bib"
|
5
|
+
require "relaton/index"
|
6
|
+
require_relative "relaton_ccsds/version"
|
7
|
+
require_relative "relaton_ccsds/bibliographic_item"
|
8
|
+
require_relative "relaton_ccsds/config"
|
9
|
+
require_relative "relaton_ccsds/util"
|
10
|
+
require_relative "relaton_ccsds/bibliography"
|
11
|
+
require_relative "relaton_ccsds/hit"
|
12
|
+
require_relative "relaton_ccsds/hit_collection"
|
13
|
+
require_relative "relaton_ccsds/data_fetcher"
|
14
|
+
require_relative "relaton_ccsds/data_parser"
|
15
|
+
require_relative "relaton_ccsds/hash_converter"
|
16
|
+
require_relative "relaton_ccsds/xml_parser"
|
17
|
+
|
18
|
+
module RelatonCcsds
|
19
|
+
class Error < StandardError; end
|
20
|
+
# Your code goes here...
|
21
|
+
|
22
|
+
def self.grammar_hash
|
23
|
+
gem_path = File.expand_path "..", __dir__
|
24
|
+
grammars_path = File.join gem_path, "grammars", "*"
|
25
|
+
grammars = Dir[grammars_path].sort.map { |gp| File.read gp }.join
|
26
|
+
Digest::MD5.hexdigest grammars
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/relaton_ccsds/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "relaton-ccsds"
|
7
|
+
spec.version = RelatonCcsds::VERSION
|
8
|
+
spec.authors = ["Ribose Inc."]
|
9
|
+
spec.email = ["open.source@ribose.com"]
|
10
|
+
|
11
|
+
spec.summary = "RelatonCcsds: retrive www.ccsds.org Standards"
|
12
|
+
spec.description = "RelatonCcsds: retrive www.ccsds.org Standards"
|
13
|
+
spec.homepage = "https://github.com/metanorma/relaton-ccsds"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
17
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
spec.required_ruby_version = ">= 2.7.0"
|
25
|
+
|
26
|
+
# Uncomment to register a new dependency of your gem
|
27
|
+
spec.add_dependency "mechanize", "~> 2.7"
|
28
|
+
spec.add_dependency "relaton-bib", "~> 1.14.13"
|
29
|
+
spec.add_dependency "relaton-index", "~> 0.2.0"
|
30
|
+
|
31
|
+
# For more information and examples about making a new gem, check out our
|
32
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: relaton-ccsds
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.14.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ribose Inc.
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-08-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: mechanize
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: relaton-bib
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.14.13
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.14.13
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: relaton-index
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.2.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.2.0
|
55
|
+
description: 'RelatonCcsds: retrive www.ccsds.org Standards'
|
56
|
+
email:
|
57
|
+
- open.source@ribose.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".github/workflows/rake.yml"
|
63
|
+
- ".github/workflows/release.yml"
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".rubocop.yml"
|
67
|
+
- ".vscode/launch.json"
|
68
|
+
- Gemfile
|
69
|
+
- README.adoc
|
70
|
+
- Rakefile
|
71
|
+
- bin/console
|
72
|
+
- bin/rspec
|
73
|
+
- bin/setup
|
74
|
+
- grammars/basicdoc.rng
|
75
|
+
- grammars/biblio-standoc.rng
|
76
|
+
- grammars/biblio.rng
|
77
|
+
- lib/relaton_ccsds.rb
|
78
|
+
- lib/relaton_ccsds/bibliographic_item.rb
|
79
|
+
- lib/relaton_ccsds/bibliography.rb
|
80
|
+
- lib/relaton_ccsds/config.rb
|
81
|
+
- lib/relaton_ccsds/data_fetcher.rb
|
82
|
+
- lib/relaton_ccsds/data_parser.rb
|
83
|
+
- lib/relaton_ccsds/hash_converter.rb
|
84
|
+
- lib/relaton_ccsds/hit.rb
|
85
|
+
- lib/relaton_ccsds/hit_collection.rb
|
86
|
+
- lib/relaton_ccsds/processor.rb
|
87
|
+
- lib/relaton_ccsds/util.rb
|
88
|
+
- lib/relaton_ccsds/version.rb
|
89
|
+
- lib/relaton_ccsds/xml_parser.rb
|
90
|
+
- relaton_ccsds.gemspec
|
91
|
+
homepage: https://github.com/metanorma/relaton-ccsds
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.7.0
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubygems_version: 3.3.26
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: 'RelatonCcsds: retrive www.ccsds.org Standards'
|
114
|
+
test_files: []
|