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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: de41538113c775736c47d2c576b11e087fd965706cc356d14c29ec9b9ec49294
|
4
|
+
data.tar.gz: 211bd83661e30589ae435885afc1fac89a9b336c2e9b0abfa4bae75dfcf9722f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 602946077b688c1fbf035073d632a1d1abf2b1459261a40b72550b9b3bba7cdcd79bd9a3cbcff3188073ea5afeabee97396822c3b56fa3d1d1f47e4747fe3489
|
7
|
+
data.tar.gz: 450a9e0b4fa07ebcd2bdd75637423fda646ae5dd3899b9ef5fb4063eb6e42fa861997938bb0f9829e076c71616bc6a0249241684838dcbd214fd60093dff011a
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: rake
|
4
|
+
|
5
|
+
on:
|
6
|
+
push:
|
7
|
+
branches: [ master, main ]
|
8
|
+
tags: [ v* ]
|
9
|
+
pull_request:
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
rake:
|
13
|
+
uses: relaton/support/.github/workflows/rake.yml@master
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Auto-generated by Cimas: Do not edit it manually!
|
2
|
+
# See https://github.com/metanorma/cimas
|
3
|
+
name: release
|
4
|
+
|
5
|
+
on:
|
6
|
+
workflow_dispatch:
|
7
|
+
inputs:
|
8
|
+
next_version:
|
9
|
+
description: |
|
10
|
+
Next release version. Possible values: x.y.z, major, minor, patch (or pre|rc|etc).
|
11
|
+
Also, you can pass 'skip' to skip 'git tag' and do 'gem push' for the current version
|
12
|
+
required: true
|
13
|
+
default: 'skip'
|
14
|
+
repository_dispatch:
|
15
|
+
types: [ do-release ]
|
16
|
+
|
17
|
+
|
18
|
+
jobs:
|
19
|
+
release:
|
20
|
+
uses: relaton/support/.github/workflows/release.yml@master
|
21
|
+
with:
|
22
|
+
next_version: ${{ github.event.inputs.next_version }}
|
23
|
+
secrets:
|
24
|
+
rubygems-api-key: ${{ secrets.RELATON_CI_RUBYGEMS_API_KEY }}
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# This project follows the Ribose OSS style guide.
|
2
|
+
# https://github.com/riboseinc/oss-guides
|
3
|
+
# All project-specific additions and overrides should be specified in this file.
|
4
|
+
|
5
|
+
require: rubocop-rails
|
6
|
+
|
7
|
+
inherit_from:
|
8
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
9
|
+
AllCops:
|
10
|
+
TargetRubyVersion: 2.7
|
11
|
+
Rails:
|
12
|
+
Enabled: false
|
data/.vscode/launch.json
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
{
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
3
|
+
// Hover to view descriptions of existing attributes.
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
5
|
+
"version": "0.2.0",
|
6
|
+
"configurations": [
|
7
|
+
{
|
8
|
+
"name": "RSpec - all",
|
9
|
+
"type": "Ruby",
|
10
|
+
"request": "launch",
|
11
|
+
"program": "${workspaceRoot}/bin/rspec",
|
12
|
+
"args": [
|
13
|
+
"-I",
|
14
|
+
"${workspaceRoot}"
|
15
|
+
]
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"name": "RSpec - file only",
|
19
|
+
"type": "Ruby",
|
20
|
+
"request": "launch",
|
21
|
+
"program": "${workspaceRoot}/bin/rspec",
|
22
|
+
"args": [
|
23
|
+
"-I",
|
24
|
+
"${workspaceRoot}",
|
25
|
+
"${file}"
|
26
|
+
]
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"name": "RSpec - line only",
|
30
|
+
"type": "Ruby",
|
31
|
+
"request": "launch",
|
32
|
+
"program": "${workspaceRoot}/bin/rspec",
|
33
|
+
"args": [
|
34
|
+
"-I",
|
35
|
+
"${workspaceRoot}",
|
36
|
+
"${file}:${lineNumber}"
|
37
|
+
]
|
38
|
+
}
|
39
|
+
]
|
40
|
+
}
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in relaton-ccsds.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "equivalent-xml", "~> 0.6"
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "rubocop", "~> 1.21"
|
12
|
+
gem "rubocop-performance"
|
13
|
+
gem "rubocop-rails", "~> 2.12"
|
14
|
+
gem "simplecov", "~> 0.22"
|
15
|
+
gem "vcr", "~> 6.0"
|
16
|
+
gem "webmock", "~> 3.0"
|
data/README.adoc
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
= RelatonCcsds
|
2
|
+
|
3
|
+
RelatonCcsds is a Ruby gem that implements the https://github.com/relaton/relaton-models#bibliographic-item[BibliographicItem model].
|
4
|
+
|
5
|
+
You can use it to retrieve metadata of CCSDS Standards from https://public.ccsds.org/Publications/AllPubs.aspx, and access such metadata through the `RelatonCcsds::BibliographicItem` object.
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
[source,ruby]
|
12
|
+
----
|
13
|
+
gem 'relaton-ccsds'
|
14
|
+
----
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install relaton-ccsds
|
23
|
+
|
24
|
+
== Usage
|
25
|
+
|
26
|
+
=== Search for a standard using keywords
|
27
|
+
|
28
|
+
[source,ruby]
|
29
|
+
----
|
30
|
+
require 'relaton_ccsds'
|
31
|
+
=> true
|
32
|
+
|
33
|
+
hits = RelatonCcsds::Bibliography.search("CCSDS 230.2-G-1")
|
34
|
+
=> <RelatonCcsds::HitCollection:0x00000000001770 @ref=CCSDS 230.2-G-1 @fetched=false>
|
35
|
+
|
36
|
+
item = hits[0].fetch
|
37
|
+
=> #<RelatonCcsds::BibliographicItem:0x00000001135f6540
|
38
|
+
...
|
39
|
+
----
|
40
|
+
|
41
|
+
=== XML serialization
|
42
|
+
|
43
|
+
[source,ruby]
|
44
|
+
----
|
45
|
+
item.to_xml
|
46
|
+
=> "<bibitem id="CCSDS230.2-G-1" schema-version="v1.2.3">
|
47
|
+
<fetched>2023-08-25</fetched>
|
48
|
+
<title format="text/plain" language="en" script="Latn">Next Generation Uplink</title>
|
49
|
+
<uri type="pdf">https://public.ccsds.org/Pubs/230x2g1.pdf</uri>
|
50
|
+
<docidentifier type="CCSDS" primary="true">CCSDS 230.2-G-1</docidentifier>
|
51
|
+
...
|
52
|
+
</bibitem>"
|
53
|
+
----
|
54
|
+
With argument `bibdata: true` it outputs XML wrapped by `bibdata` element and adds flavour `ext` element.
|
55
|
+
[source,ruby]
|
56
|
+
----
|
57
|
+
item.to_xml bibdata: true
|
58
|
+
=> "<bibdata schema-version="v1.2.3">
|
59
|
+
<fetched>2023-08-25</fetched>
|
60
|
+
<title format="text/plain" language="en" script="Latn">Next Generation Uplink</title>
|
61
|
+
<uri type="pdf">https://public.ccsds.org/Pubs/230x2g1.pdf</uri>
|
62
|
+
...
|
63
|
+
<ext>
|
64
|
+
<doctype>report</doctype>
|
65
|
+
<editorialgroup>
|
66
|
+
<technical-committee>SLS-NGU</technical-committee>
|
67
|
+
</editorialgroup>
|
68
|
+
<technology-area>Space Link Services Area</technology-area>
|
69
|
+
</ext>
|
70
|
+
</bibdata>"
|
71
|
+
----
|
72
|
+
|
73
|
+
=== Typed links
|
74
|
+
|
75
|
+
All the CCSDS documents have PDF links. Some of them have additional DOC links. The gem provides a way to access these links through the `RelatonBib::TypedUri` object.
|
76
|
+
|
77
|
+
[source,ruby]
|
78
|
+
----
|
79
|
+
item.link
|
80
|
+
=> [#<RelatonBib::TypedUri:0x000000011420d950
|
81
|
+
@content=#<Addressable::URI:0xc1c URI:https://public.ccsds.org/Pubs/230x2g1.pdf>,
|
82
|
+
@language=nil,
|
83
|
+
@script=nil,
|
84
|
+
@type="pdf">]
|
85
|
+
|
86
|
+
RelatonCcsds::Bibliography.get("CCSDS 720.6-Y-1").link
|
87
|
+
[relaton-ccsd] (CCSDS 720.6-Y-1) fetching...
|
88
|
+
[relaton-ccsd] (CCSDS 720.6-Y-1) found `CCSDS 720.6-Y-1`.
|
89
|
+
=> [#<RelatonBib::TypedUri:0x0000000114183bb0
|
90
|
+
@content=#<Addressable::URI:0xca8 URI:https://public.ccsds.org/Pubs/720x6y1.pdf>,
|
91
|
+
@language=nil,
|
92
|
+
@script=nil,
|
93
|
+
@type="pdf">,
|
94
|
+
#<RelatonBib::TypedUri:0x0000000114183750
|
95
|
+
@content=#<Addressable::URI:0xcbc URI:https://public.ccsds.org/Pubs/720x6y1.doc>,
|
96
|
+
@language=nil,
|
97
|
+
@script=nil,
|
98
|
+
@type="doc">]
|
99
|
+
----
|
100
|
+
|
101
|
+
=== Get document by code and year
|
102
|
+
[source,ruby]
|
103
|
+
----
|
104
|
+
RelatonCcsds::Bibliography.get("CCSDS 230.2-G-1")
|
105
|
+
[relaton-ccsd] (CCSDS 230.2-G-1) fetching...
|
106
|
+
[relaton-ccsd] (CCSDS 230.2-G-1) found `CCSDS 230.2-G-1`.
|
107
|
+
=> #<RelatonCcsds::BibliographicItem:0x00000001135dade0
|
108
|
+
...
|
109
|
+
----
|
110
|
+
|
111
|
+
=== Create bibliographic item from XML
|
112
|
+
[source,ruby]
|
113
|
+
----
|
114
|
+
RelatonCcsds::XMLParser.from_xml File.read('spec/fixtures/ccsds_230_2-g-1.xml')
|
115
|
+
=> #<RelatonCcsds::BibliographicItem:0x00000001135fc1c0
|
116
|
+
...
|
117
|
+
----
|
118
|
+
|
119
|
+
=== Create bibliographic item from YAML
|
120
|
+
[source,ruby]
|
121
|
+
----
|
122
|
+
hash = YAML.load_file 'spec/fixtures/ccsds_230_2-g-1.yaml'
|
123
|
+
=> {"schema-version"=>"v1.2.3",
|
124
|
+
"id"=>"CCSDS230.2-G-1",
|
125
|
+
...
|
126
|
+
|
127
|
+
RelatonCcsds::BibliographicItem.from_hash hash
|
128
|
+
=> #<RelatonCcsds::BibliographicItem:0x00000001135ff780
|
129
|
+
...
|
130
|
+
----
|
131
|
+
|
132
|
+
=== Fetch data
|
133
|
+
|
134
|
+
This gem uses the https://public.ccsds.org/Publications/AllPubs.aspx as a data source.
|
135
|
+
|
136
|
+
The method `RelatonCcsds::DataFetcher.fetch(output: "data", format: "yaml")` fetches all the documents from the data source and saves them to the `./data` folder in YAML format.
|
137
|
+
Arguments:
|
138
|
+
|
139
|
+
- `output` - folder to save documents (default './data').
|
140
|
+
- `format` - the format in which the documents are saved. Possible formats are: `yaml`, `xml`, `bibxml` (default `yaml`).
|
141
|
+
|
142
|
+
[source,ruby]
|
143
|
+
----
|
144
|
+
RelatonCcsds::DataFetcher.fetch
|
145
|
+
Started at: 2023-08-25 22:02:06 -0400
|
146
|
+
(data/CCSDS-720-4-Y-1.yaml) file already exists. Trying to merge links ...
|
147
|
+
...
|
148
|
+
Done in: 20 sec.
|
149
|
+
=> nil
|
150
|
+
----
|
151
|
+
|
152
|
+
== Development
|
153
|
+
|
154
|
+
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.
|
155
|
+
|
156
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
157
|
+
|
158
|
+
== Contributing
|
159
|
+
|
160
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/relaton/relaton-ccsds.
|
161
|
+
|
162
|
+
== License
|
163
|
+
|
164
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "relaton/ccsds"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/rspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("rspec-core", "rspec")
|