relaton-cli 1.20.6 → 2.0.0.pre.alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile +1 -0
- data/docs/README.adoc +169 -255
- data/lib/relaton/bibdata.rb +10 -10
- data/lib/relaton/cli/command.rb +4 -4
- data/lib/relaton/cli/relaton_file.rb +6 -6
- data/lib/relaton/cli/subcommand_collection.rb +22 -4
- data/lib/relaton/cli/util.rb +1 -1
- data/lib/relaton/cli/version.rb +1 -1
- data/lib/relaton/cli/xml_to_html_renderer.rb +7 -6
- data/lib/relaton/cli/yaml_convertor.rb +9 -7
- data/lib/relaton/cli.rb +9 -11
- data/relaton-cli.gemspec +2 -2
- data/templates/_document.liquid +11 -12
- metadata +7 -10
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78896ea0b02f8711ab4eea67a5d74909137f45a42a7d0785c68ae8db0756dcbb
|
|
4
|
+
data.tar.gz: e8db97ab8e36651275173de95ce88d59979931b8fc44d6d563a23736201c86c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4c4f1ea97e4ce93484b2923529645c828cc9d5c0b9bf0e4563b554a962bb7e11e58491ed589155366257410f33868df6e56db83bebb5d4ebef082e35c78c895
|
|
7
|
+
data.tar.gz: b89d0b397640e7fe3bd7a4866559723ee1aebf85390be44ad09b756e2f51722972b29b8c0382a74e605d464afe15daa7c8e9f016063cc16a9e8e95f5babe0b0b
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/docs/README.adoc
CHANGED
|
@@ -1,42 +1,37 @@
|
|
|
1
|
-
= Relaton CLI
|
|
1
|
+
= Relaton CLI: Command-line Interface for Bibliographic References
|
|
2
2
|
|
|
3
3
|
image:https://img.shields.io/gem/v/relaton-cli.svg["Gem Version", link="https://rubygems.org/gems/relaton-cli"]
|
|
4
4
|
image:https://github.com/relaton/relaton-cli/workflows/rake/badge.svg["Build Status", link="https://github.com/relaton/relaton-cli/actions?workflow=rake"]
|
|
5
|
-
// image:https://codeclimate.com/github/metanorma/relaton-cli/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/relaton-cli"]
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
Relaton CLI is a command-line tool for fetching, converting, and managing
|
|
7
|
+
bibliographic references to standards (ISO, IEC, IETF, NIST, IEEE, and many
|
|
8
|
+
more). It is part of the https://github.com/relaton[Relaton] /
|
|
9
|
+
https://www.metanorma.org[Metanorma] ecosystem.
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
== Installation
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
Add to your `Gemfile`:
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
[source,ruby]
|
|
16
|
+
----
|
|
17
|
+
gem "relaton-cli"
|
|
18
|
+
----
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
Or install directly:
|
|
17
21
|
|
|
18
22
|
[source,console]
|
|
19
23
|
----
|
|
20
|
-
$
|
|
24
|
+
$ gem install relaton-cli
|
|
21
25
|
----
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
For each Relaton input file in the `Source-Directory`, if a document file with the same base name is identified (i.e. an XML, HTML, PDF or DOC
|
|
26
|
-
file) a link to that file is inserted.
|
|
27
|
+
== Requirements
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
title and author of the `Relaton-Collection-File` document.
|
|
29
|
+
* Ruby >= 3.2.0
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
[source,console]
|
|
34
|
-
----
|
|
35
|
-
$ relaton split Relaton-Collection-File Relaton-File-Directory -x rxl
|
|
36
|
-
----
|
|
31
|
+
== Usage
|
|
37
32
|
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
Each command supports a `--verbose` (short form `-v`) option to include
|
|
34
|
+
warnings in the output.
|
|
40
35
|
|
|
41
36
|
=== relaton fetch
|
|
42
37
|
|
|
@@ -47,11 +42,12 @@ $ relaton fetch CODE -t TYPE -f FORMAT -y YEAR -r RETRIES --all-parts --keep-yea
|
|
|
47
42
|
|
|
48
43
|
Fetch the Relaton XML entry corresponding to the document identifier `CODE`.
|
|
49
44
|
|
|
50
|
-
|
|
51
|
-
* `
|
|
52
|
-
* `
|
|
45
|
+
[[relaton-fetch-types]]
|
|
46
|
+
* `TYPE` is optional and specifies the standards class library to use. Recognized values for `TYPE` are: `3GPP`, `BIPM`, `CCTF`, `CCDS`, `CGPM`, `CIPM`, `JCRB`, `JCGM`, `BSI`, `BS`, `PD`, `CC`, `CCSDS`, `CEN`, `EN`, `ENV`, `CWA`, `HD`, `CR`, `CIE`, `DOI`, `ECMA`, `ETSI`, `CN`, `GB`, `GB/T`, `GB/Z`, `IANA`, `IEC`, `CISPR`, `IEV`, `IEEE`, `ANSI`, `NACE`, `AIEE`, `ASA`, `IRE`, `IETF`, `RFC`, `BCP`, `FYI`, `STD`, `I-D`, `IHO`, `ISBN`, `ISO`, `ISO/IEC`, `ITU`, `JIS`, `TR`, `NIST`, `NBS`, `NISTGCR`, `ITL Bulletin`, `JPCRD`, `NISTIR`, `CSRC`, `FIPS`, `OASIS`, `OGC`, `OMG`, `UN`, `W3C`, `XEP`, `PLATEAU`.
|
|
47
|
+
* `FORMAT` is optional. Recognized values are `xml` (default), `yaml`, `bibtex`.
|
|
48
|
+
* `YEAR` is optional and specifies the year of publication.
|
|
53
49
|
* `RETRIES` is optional, number of network retries (default 1).
|
|
54
|
-
* `--all-parts` fetch all parts.
|
|
50
|
+
* `--all-parts` fetch all parts of the standard.
|
|
55
51
|
* `--keep-year` undated reference should return an actual reference with year.
|
|
56
52
|
* `--no-cache` do not use cache.
|
|
57
53
|
* `--publication-date-before DATE` fetch only documents published before the specified date. Accepted formats: `YYYY`, `YYYY-MM`, `YYYY-MM-DD`.
|
|
@@ -64,7 +60,7 @@ Fetch the Relaton XML entry corresponding to the document identifier `CODE`.
|
|
|
64
60
|
$ relaton fetch-data DATASET -o DIR -f FORMAT
|
|
65
61
|
----
|
|
66
62
|
|
|
67
|
-
Fetch all
|
|
63
|
+
Fetch all documents from a `DATASET` source and save them to folder `DIR` in format `FORMAT`.
|
|
68
64
|
|
|
69
65
|
The following datasets are available:
|
|
70
66
|
|
|
@@ -72,18 +68,18 @@ The following datasets are available:
|
|
|
72
68
|
* `cie-techstreet` - https://www.techstreet.com/cie/searches/31156444
|
|
73
69
|
* `calconnect-org` - https://standards.calconnect.org/relaton/index.yaml
|
|
74
70
|
* `ogc-naming-authority` - https://raw.githubusercontent.com/opengeospatial/NamingAuthority/master/incubation/bibliography/bibliography.json
|
|
75
|
-
* `ieee-rawbib` - looks for the IEEE dataset in the local `./ieee-rawbib` directory. The dataset
|
|
71
|
+
* `ieee-rawbib` - looks for the IEEE dataset in the local `./ieee-rawbib` directory. The dataset can be downloaded from https://github.com/ietf-ribose/ieee-rawbib
|
|
76
72
|
* `w3c-rdf` - http://www.w3.org/2002/01/tr-automation/tr.rdf
|
|
77
|
-
* `w3c-tr-archive` - looks for the W3C archive dataset in local `./w3c-tr-archive` directory. The dataset
|
|
73
|
+
* `w3c-tr-archive` - looks for the W3C archive dataset in local `./w3c-tr-archive` directory. The dataset can be downloaded from https://github.com/relaton/w3c-tr-archive
|
|
78
74
|
* `iana-registries` - https://github.com/ietf-ribose/iana-registries
|
|
79
75
|
* `status-smg-3GPP` - updates previously downloaded data if a new archive is available in ftp://www.3gpp.org/Information/Databases/
|
|
80
76
|
* `status-smg-3GPP-force` - download data from the latest archive in ftp://www.3gpp.org/Information/Databases/
|
|
81
77
|
* `ietf-rfcsubseries` - https://www.rfc-editor.org/rfc-index.xml (`<bcp-entry>`, `<fyi-entry>`, `<std-entry>`)
|
|
82
|
-
* `ietf-internet-drafts` - looks for the Internet-Drafts dataset in the local `./bibxml-ids` directory. The dataset
|
|
78
|
+
* `ietf-internet-drafts` - looks for the Internet-Drafts dataset in the local `./bibxml-ids` directory. The dataset can be downloaded using `rsync -avcizxL rsync.ietf.org::bibxml-ids ./bibxml-ids`.
|
|
83
79
|
* `ietf-rfc-entries` - https://www.rfc-editor.org/rfc-index.xml (`<rfc-entry>`)
|
|
84
80
|
* `oasis-open` - https://www.oasis-open.org/standards/
|
|
85
|
-
* `bipm-data-outcomes` - looks for the BIPM dataset in the local `./bipm-data-outcomes` directory. The dataset
|
|
86
|
-
* `si-brochure` - looks for the SI-Brochure dataset in the local `./bipm-si-
|
|
81
|
+
* `bipm-data-outcomes` - looks for the BIPM dataset in the local `./bipm-data-outcomes` directory. The dataset can be downloaded from https://github.com/metanorma/bipm-data-outcomes
|
|
82
|
+
* `si-brochure` - looks for the SI-Brochure dataset in the local `./bipm-si-brochure` directory. The dataset can be downloaded from https://github.com/metanorma/bipm-si-brochure
|
|
87
83
|
* `ecma-standards` - https://www.ecma-international.org/publications/standards/
|
|
88
84
|
* `itu-r` - https://extranet.itu.int/brdocsearch
|
|
89
85
|
* `ccsds` - https://public.ccsds.org/Publications/AllPubs.aspx
|
|
@@ -95,7 +91,7 @@ The following datasets are available:
|
|
|
95
91
|
Options:
|
|
96
92
|
|
|
97
93
|
* `DIR` - folder name to store documents (default `./data`).
|
|
98
|
-
* `FORMAT` - format
|
|
94
|
+
* `FORMAT` - output format: `yaml` (default), `xml`, `bibxml`.
|
|
99
95
|
|
|
100
96
|
=== relaton extract
|
|
101
97
|
|
|
@@ -104,89 +100,39 @@ Options:
|
|
|
104
100
|
$ relaton extract Metanorma-XML-Directory Relaton-XML-Directory -x EXTENSION
|
|
105
101
|
----
|
|
106
102
|
|
|
107
|
-
Iterate through all
|
|
108
|
-
element from each. Save the `bibdata` element for each file to `Relaton-XML-Directory`, as the Relaton XML
|
|
109
|
-
description for that file. If a document identifier is present in `bibdata`, it is used as the name of the
|
|
110
|
-
file; otherwise, the original file name is used. The filename is suffixed with `EXTENSION`; by default,
|
|
111
|
-
`.rxl` is used.
|
|
103
|
+
Iterate through all Metanorma XML files in `Metanorma-XML-Directory` and extract the `bibdata` element from each. Save the `bibdata` element to `Relaton-XML-Directory` as the Relaton XML description for that file. If a document identifier is present in `bibdata`, it is used as the filename; otherwise, the original filename is used. The filename is suffixed with `EXTENSION` (default `.rxl`).
|
|
112
104
|
|
|
113
|
-
|
|
114
|
-
=== relaton xml2html
|
|
105
|
+
=== relaton concatenate
|
|
115
106
|
|
|
116
107
|
[source,console]
|
|
117
108
|
----
|
|
118
|
-
$ relaton
|
|
109
|
+
$ relaton concatenate Source-Directory Relaton-Collection-File -t TITLE -g ORGANIZATION
|
|
119
110
|
----
|
|
120
111
|
|
|
121
|
-
|
|
112
|
+
Iterate through all Relaton files (YAML and XML) in `Source-Directory` and concatenate them into a Relaton Collection file. The extension of the Collection file can be set via the filename (e.g., `.yaml` for YAML, `.rxl` for XML) or using the `-x` (`--extension`) option.
|
|
122
113
|
|
|
123
|
-
|
|
124
|
-
* `stylesheet` is the CSS stylesheet to be used to style the output. For the CSS styling of each bibliographic element, see below.
|
|
125
|
-
* `html-template-dir` is a directory containing HTML Liquid Template files into which the bibliographic entries are to be inserted.
|
|
126
|
-
There are two templates necessary:
|
|
114
|
+
For each Relaton input file in `Source-Directory`, if a document file with the same base name is identified (XML, HTML, PDF, or DOC), a link to that file is inserted.
|
|
127
115
|
|
|
128
|
-
|
|
116
|
+
If `TITLE` or `ORGANIZATION` options are given, they are added to the output as the title and author of the collection.
|
|
129
117
|
|
|
130
|
-
|
|
131
|
-
*** `css`: where the CSS stylesheet `stylesheet` is injected
|
|
132
|
-
*** `title`: the Title of the collection, `./relaton-collection/title` in `relaton-xml`
|
|
133
|
-
*** `author`: the Author of the collection, `./relaton-collection/contributor[role/@type = 'author']/organization/name` in `relaton-xml`
|
|
134
|
-
*** `content`: the list of resources generated by the script
|
|
118
|
+
=== relaton split
|
|
135
119
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
<div class="doc-identifier">
|
|
149
|
-
<h2>
|
|
150
|
-
<a href="http://calconnect.org/pubdocs/CD0507%20CalDAV%20Use%20Cases%20V1.0.html">CC/R 3101</a>
|
|
151
|
-
</h2>
|
|
152
|
-
</div>
|
|
153
|
-
<div class="doc-type-wrap">
|
|
154
|
-
<div class="doc-type report">report</div>
|
|
155
|
-
</div>
|
|
156
|
-
</div>
|
|
157
|
-
<div class="doc-title">
|
|
158
|
-
<h3>
|
|
159
|
-
<a href="http://calconnect.org/pubdocs/CD0507%20CalDAV%20Use%20Cases%20V1.0.html">CalConnect XLIII -- Position on the European Union daylight-savings timezone change</a>
|
|
160
|
-
</h3>
|
|
161
|
-
</div>
|
|
162
|
-
<div class="doc-info cancelled">
|
|
163
|
-
<div class="doc-stage cancelled">cancelled</div>
|
|
164
|
-
<div class="doc-dates">
|
|
165
|
-
<div class="doc-updated">2019-10-17</div>
|
|
166
|
-
</div>
|
|
167
|
-
</div>
|
|
168
|
-
<div class="doc-bib">
|
|
169
|
-
<div class="doc-bib-relaton">
|
|
170
|
-
<a href="csd/cc-r-3101.xml">Relaton XML</a>
|
|
171
|
-
</div>
|
|
172
|
-
</div>
|
|
173
|
-
<div class="doc-access">
|
|
174
|
-
<div class="doc-access-button-html">
|
|
175
|
-
<a href="http://calconnect.org/pubdocs/CD0507%20CalDAV%20Use%20Cases%20V1.0.html">HTML</a>
|
|
176
|
-
</div>
|
|
177
|
-
<div class="doc-access-button-pdf">
|
|
178
|
-
<a href="http://calconnect.org/pubdocs/CD0507%20CalDAV%20Use%20Cases%20V1.0.pdf">PDF</a>
|
|
179
|
-
</div>
|
|
180
|
-
<div class="doc-access-button-doc">
|
|
181
|
-
<a href="http://calconnect.org/pubdocs/CD0507%20CalDAV%20Use%20Cases%20V1.0.doc">Word</a>
|
|
182
|
-
</div>
|
|
183
|
-
<div class="doc-access-button-xml">
|
|
184
|
-
<a href="http://calconnect.org/pubdocs/CD0507%20CalDAV%20Use%20Cases%20V1.0.xml">XML</a>
|
|
185
|
-
</div>
|
|
186
|
-
</div>
|
|
187
|
-
</div>
|
|
120
|
+
[source,console]
|
|
121
|
+
----
|
|
122
|
+
$ relaton split Relaton-Collection-File Relaton-File-Directory -x rxl
|
|
123
|
+
----
|
|
124
|
+
|
|
125
|
+
Split a `Relaton-Collection-File` into multiple files in `Relaton-File-Directory`. Supports the `-x` (`--extension`) option to set the file extension.
|
|
126
|
+
|
|
127
|
+
=== relaton convert
|
|
128
|
+
|
|
129
|
+
[source,console]
|
|
130
|
+
----
|
|
131
|
+
$ relaton convert XML -f FORMAT -o OUTPUT-FILE
|
|
188
132
|
----
|
|
189
133
|
|
|
134
|
+
Convert a Relaton XML document into YAML, AsciiBib, or BibTeX format. Allowed `--format` values are `yaml`, `asciibib`, `bibtex`. If `--output` is omitted, a new file is created in the same folder with the appropriate extension.
|
|
135
|
+
|
|
190
136
|
=== relaton yaml2xml
|
|
191
137
|
|
|
192
138
|
[source,console]
|
|
@@ -194,48 +140,48 @@ Sample HTML output for a bibliographic entry:
|
|
|
194
140
|
$ relaton yaml2xml YAML -o OUTPUT-DIRECTORY -x RELATON_EXTENSION -p PREFIX -r LIBRARY
|
|
195
141
|
----
|
|
196
142
|
|
|
197
|
-
Convert a Relaton YAML file
|
|
143
|
+
Convert a Relaton YAML file into Relaton Collection XML or separate files. If the YAML file specifies multiple bibliographic items and `OUTPUT-DIRECTORY` is given, also convert into individual Relaton XML files per entry. The document identifier is used as the filename, suffixed with `RELATON_EXTENSION` (default `.rxl`) and prefixed with `PREFIX` (default empty). Libraries required for conversion are specified in `LIBRARY` as a space-delimited list.
|
|
198
144
|
|
|
199
145
|
[[relaton-yaml]]
|
|
200
|
-
A Relaton Collection YAML file contains
|
|
146
|
+
A Relaton Collection YAML file contains initial metadata and a list of bibliographic entries:
|
|
201
147
|
|
|
202
148
|
[source,yaml]
|
|
203
149
|
----
|
|
204
150
|
root:
|
|
205
|
-
author: The Calendaring and Scheduling Consortium
|
|
206
151
|
title: CalConnect Standards Registry
|
|
152
|
+
author: The Calendaring and Scheduling Consortium
|
|
207
153
|
items:
|
|
208
|
-
-
|
|
209
|
-
docid:
|
|
210
|
-
type: CC
|
|
211
|
-
id: CC 36000
|
|
212
|
-
primary: true
|
|
154
|
+
- id: CC36000
|
|
213
155
|
type: standard
|
|
214
156
|
title:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
157
|
+
- content: Standardization documents -- Vocabulary
|
|
158
|
+
docidentifier:
|
|
159
|
+
- type: CC
|
|
160
|
+
content: CC 36000
|
|
161
|
+
primary: true
|
|
219
162
|
date:
|
|
220
|
-
type: issued
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
primary: true
|
|
163
|
+
- type: issued
|
|
164
|
+
at: '2018-10-25'
|
|
165
|
+
status:
|
|
166
|
+
stage:
|
|
167
|
+
content: proposal
|
|
168
|
+
- id: CC34000
|
|
227
169
|
type: standard
|
|
228
170
|
title:
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
171
|
+
- content: Date and time -- Concepts and vocabulary
|
|
172
|
+
docidentifier:
|
|
173
|
+
- type: CC
|
|
174
|
+
content: CC 34000
|
|
175
|
+
primary: true
|
|
233
176
|
date:
|
|
234
|
-
type: issued
|
|
235
|
-
|
|
177
|
+
- type: issued
|
|
178
|
+
at: '2018-10-25'
|
|
179
|
+
status:
|
|
180
|
+
stage:
|
|
181
|
+
content: proposal
|
|
236
182
|
----
|
|
237
183
|
|
|
238
|
-
A Relaton YAML file describing an individual bibliographic entry is limited to metadata specific to that entry.
|
|
184
|
+
A Relaton YAML file describing an individual bibliographic entry is limited to metadata specific to that entry. The link:https://github.com/relaton/relaton-bib/blob/master/docs/hash.adoc#yaml[Relaton YAML] illustrates the common fields supported by all flavor gems.
|
|
239
185
|
|
|
240
186
|
=== relaton xml2yaml
|
|
241
187
|
|
|
@@ -244,65 +190,53 @@ A Relaton YAML file describing an individual bibliographic entry is limited to m
|
|
|
244
190
|
$ relaton xml2yaml XML -o OUTPUT-DIRECTORY -x RELATON_EXTENSION -p PREFIX -r LIBRARY
|
|
245
191
|
----
|
|
246
192
|
|
|
247
|
-
Convert a Relaton XML file
|
|
193
|
+
Convert a Relaton XML file into Relaton YAML. If the XML file is a collection and `OUTPUT-DIRECTORY` is given, also produce individual YAML files per entry. The document identifier is used as the filename, suffixed with `RELATON_EXTENSION` (default `.yaml`) and prefixed with `PREFIX` (default empty). Libraries required for conversion are specified in `LIBRARY` as a space-delimited list.
|
|
248
194
|
|
|
249
|
-
|
|
195
|
+
[[relaton-xml2html]]
|
|
196
|
+
=== relaton xml2html
|
|
250
197
|
|
|
251
198
|
[source,console]
|
|
252
199
|
----
|
|
253
|
-
$ relaton
|
|
200
|
+
$ relaton xml2html <relaton-xml> [<stylesheet>] [<html-template-dir>]
|
|
254
201
|
----
|
|
255
202
|
|
|
256
|
-
Render a Relaton
|
|
203
|
+
Render a Relaton Collection XML as an HTML file. Used to generate an HTML index of standards.
|
|
257
204
|
|
|
258
|
-
|
|
205
|
+
* `relaton-xml` is the Relaton Collection XML file.
|
|
206
|
+
* `stylesheet` is the CSS stylesheet to style the output.
|
|
207
|
+
* `html-template-dir` is a directory containing HTML Liquid Template files. Two templates are required:
|
|
208
|
+
|
|
209
|
+
** Index template (`_index.liquid`) -- recognizes the following parameters:
|
|
210
|
+
*** `css`: the CSS stylesheet content
|
|
211
|
+
*** `title`: the collection title from `./relaton-collection/title`
|
|
212
|
+
*** `author`: the collection author from `./relaton-collection/contributor[role/@type = 'author']/organization/name`
|
|
213
|
+
*** `content`: the list of resources generated by the script
|
|
259
214
|
|
|
260
|
-
|
|
215
|
+
** Individual entry template (`_document.liquid`) -- recognizes attributes of a bibliographic entry (`document`) following the naming convention of <<relaton-yaml,Relaton YAML>>; e.g. `document.html` is the HTML URI for the document.
|
|
216
|
+
|
|
217
|
+
The default stylesheet and templates are provided in the `templates` directory.
|
|
218
|
+
|
|
219
|
+
=== relaton yaml2html
|
|
220
|
+
|
|
221
|
+
[source,console]
|
|
261
222
|
----
|
|
262
|
-
$ relaton
|
|
223
|
+
$ relaton yaml2html YAML [<stylesheet>] [<liquid-template-dir>]
|
|
263
224
|
----
|
|
264
225
|
|
|
265
|
-
|
|
226
|
+
Render a Relaton YAML file as an HTML file. The `stylesheet` and `liquid-template-dir` parameters are as for <<relaton-xml2html,relaton xml2html>>.
|
|
266
227
|
|
|
267
228
|
=== relaton version
|
|
229
|
+
|
|
230
|
+
[source,console]
|
|
268
231
|
----
|
|
269
232
|
$ relaton version
|
|
270
|
-
CLI => 1.17.2
|
|
271
|
-
relaton => 1.17.2
|
|
272
|
-
relaton-bib => 1.17.2
|
|
273
|
-
relaton-iso-bib => 1.17.0
|
|
274
|
-
relaton-gb => 1.17.0
|
|
275
|
-
relaton-iec => 1.17.0
|
|
276
|
-
relaton-ietf => 1.17.0
|
|
277
|
-
relaton-iso => 1.17.0
|
|
278
|
-
relaton-itu => 1.17.0
|
|
279
|
-
relaton-nist => 1.17.0
|
|
280
|
-
relaton-ogc => 1.17.1
|
|
281
|
-
relaton-calconnect => 1.17.0
|
|
282
|
-
relaton-omg => 1.17.0
|
|
283
|
-
relaton-un => 1.17.0
|
|
284
|
-
relaton-w3c => 1.17.2
|
|
285
|
-
relaton-ieee => 1.17.0
|
|
286
|
-
relaton-iho => 1.17.0
|
|
287
|
-
relaton-bipm => 1.17.0
|
|
288
|
-
relaton-ecma => 1.17.0
|
|
289
|
-
relaton-cie => 1.17.0
|
|
290
|
-
relaton-bsi => 1.17.0
|
|
291
|
-
relaton-cen => 1.17.0
|
|
292
|
-
relaton-iana => 1.17.0
|
|
293
|
-
relaton-3gpp => 1.17.0
|
|
294
|
-
relaton-oasis => 1.17.0
|
|
295
|
-
relaton-doi => 1.17.0
|
|
296
|
-
relaton-jis => 1.17.0
|
|
297
|
-
relaton-xsf => 1.17.0
|
|
298
|
-
relaton-ccsds => 1.17.0
|
|
299
|
-
relaton-etsi => 1.17.0
|
|
300
|
-
relaton-isbn => 1.17.0
|
|
301
233
|
----
|
|
302
234
|
|
|
235
|
+
Display version information for the CLI and all installed Relaton libraries.
|
|
236
|
+
|
|
303
237
|
=== relaton collection
|
|
304
238
|
|
|
305
|
-
The `relaton collection`
|
|
239
|
+
The `relaton collection` command provides subcommands for collection manipulation.
|
|
306
240
|
|
|
307
241
|
==== relaton collection create
|
|
308
242
|
|
|
@@ -311,8 +245,9 @@ $ relaton collection create COLLECTION -d DIRECTORY --author AUTHOR --title TITL
|
|
|
311
245
|
----
|
|
312
246
|
|
|
313
247
|
Create a new empty collection with the name `COLLECTION`.
|
|
314
|
-
|
|
315
|
-
* `
|
|
248
|
+
|
|
249
|
+
* `DIRECTORY` - optional path to a directory with collections. Default: `$HOME/.relaton/collections`.
|
|
250
|
+
* `AUTHOR`, `TITLE`, and `DOCTYPE` are optional metadata.
|
|
316
251
|
|
|
317
252
|
==== relaton collection info
|
|
318
253
|
|
|
@@ -320,8 +255,9 @@ Create a new empty collection with the name `COLLECTION`.
|
|
|
320
255
|
$ relaton collection info COLLECTION -d DIRECTORY
|
|
321
256
|
----
|
|
322
257
|
|
|
323
|
-
Show information about `COLLECTION` (number of items, file size
|
|
324
|
-
|
|
258
|
+
Show information about `COLLECTION` (number of items, file size, last updated, name, metadata).
|
|
259
|
+
|
|
260
|
+
* `DIRECTORY` - optional path to a directory with collections. Default: `$HOME/.relaton/collections`.
|
|
325
261
|
|
|
326
262
|
==== relaton collection list
|
|
327
263
|
|
|
@@ -330,8 +266,9 @@ $ relaton collection list -d DIRECTORY -e
|
|
|
330
266
|
----
|
|
331
267
|
|
|
332
268
|
List all collections.
|
|
333
|
-
|
|
334
|
-
*
|
|
269
|
+
|
|
270
|
+
* `DIRECTORY` - optional path to a directory with collections. Default: `$HOME/.relaton/collections`.
|
|
271
|
+
* `-e` - when set, list the document ID of each entry.
|
|
335
272
|
|
|
336
273
|
==== relaton collection get
|
|
337
274
|
|
|
@@ -339,12 +276,12 @@ List all collections.
|
|
|
339
276
|
$ relaton collection get CODE -c COLLECTION -d DIRECTORY -f FORMAT -o FILE
|
|
340
277
|
----
|
|
341
278
|
|
|
342
|
-
Get a document
|
|
279
|
+
Get a document matching `CODE` from `COLLECTION`.
|
|
343
280
|
|
|
344
|
-
* `COLLECTION` - optional name of a collection. If
|
|
345
|
-
* `DIRECTORY` - optional
|
|
346
|
-
* `FORMAT` - optional. If
|
|
347
|
-
* `FILE`
|
|
281
|
+
* `COLLECTION` - optional name of a collection. If omitted, fetches the first match across all collections in `DIRECTORY`.
|
|
282
|
+
* `DIRECTORY` - optional path to a directory with collections. Default: `$HOME/.relaton/collections`.
|
|
283
|
+
* `FORMAT` - optional. If omitted, output is in human-readable form. Allowed values: `abb` (AsciiBib), `xml` (XML).
|
|
284
|
+
* `FILE` - optional. Save the document with the given filename. The file extension (`abb`, `xml`) defines the output format.
|
|
348
285
|
|
|
349
286
|
==== relaton collection find
|
|
350
287
|
|
|
@@ -354,8 +291,8 @@ $ relaton collection find TEXT -c COLLECTION -d DIRECTORY
|
|
|
354
291
|
|
|
355
292
|
Full-text search through a collection or all collections.
|
|
356
293
|
|
|
357
|
-
* `COLLECTION` - optional name of a collection. If
|
|
358
|
-
* `DIRECTORY` - optional
|
|
294
|
+
* `COLLECTION` - optional name of a collection. If omitted, searches across all collections.
|
|
295
|
+
* `DIRECTORY` - optional path to a directory with collections. Default: `$HOME/.relaton/collections`.
|
|
359
296
|
|
|
360
297
|
==== relaton collection fetch
|
|
361
298
|
|
|
@@ -363,12 +300,12 @@ Full-text search through a collection or all collections.
|
|
|
363
300
|
$ relaton collection fetch CODE -t TYPE -y YEAR -c COLLECTION -d DIRECTORY --publication-date-before DATE --publication-date-after DATE
|
|
364
301
|
----
|
|
365
302
|
|
|
366
|
-
Fetch the Relaton
|
|
303
|
+
Fetch the Relaton entry for document identifier `CODE` and save it into `COLLECTION`.
|
|
367
304
|
|
|
368
|
-
* `TYPE` specifies the standards class library
|
|
369
|
-
* `YEAR`
|
|
370
|
-
* `COLLECTION` -
|
|
371
|
-
* `DIRECTORY` - optional
|
|
305
|
+
* `TYPE` - specifies the standards class library. See <<relaton-fetch-types,recognized TYPE values>>.
|
|
306
|
+
* `YEAR` - optional year of publication.
|
|
307
|
+
* `COLLECTION` - name of a collection (required).
|
|
308
|
+
* `DIRECTORY` - optional path to a directory with collections. Default: `$HOME/.relaton/collections`.
|
|
372
309
|
* `--publication-date-before DATE` fetch only documents published before the specified date. Accepted formats: `YYYY`, `YYYY-MM`, `YYYY-MM-DD`.
|
|
373
310
|
* `--publication-date-after DATE` fetch only documents published after the specified date. Accepted formats: `YYYY`, `YYYY-MM`, `YYYY-MM-DD`.
|
|
374
311
|
|
|
@@ -380,7 +317,7 @@ $ relaton collection export COLLECTION -d DIRECTORY
|
|
|
380
317
|
|
|
381
318
|
Export `COLLECTION` into an XML file.
|
|
382
319
|
|
|
383
|
-
* `DIRECTORY` - optional
|
|
320
|
+
* `DIRECTORY` - optional path to a directory with collections. Default: `$HOME/.relaton/collections`.
|
|
384
321
|
|
|
385
322
|
==== relaton collection import
|
|
386
323
|
|
|
@@ -388,111 +325,88 @@ Export `COLLECTION` into an XML file.
|
|
|
388
325
|
$ relaton collection import FILE -c COLLECTION -d DIRECTORY
|
|
389
326
|
----
|
|
390
327
|
|
|
391
|
-
Import document or collection from XML `FILE` into `COLLECTION`.
|
|
328
|
+
Import a document or collection from XML `FILE` into `COLLECTION`.
|
|
392
329
|
|
|
393
|
-
* `COLLECTION` - optional. If
|
|
394
|
-
* `DIRECTORY` - optional
|
|
330
|
+
* `COLLECTION` - optional. If the collection does not exist, it will be created.
|
|
331
|
+
* `DIRECTORY` - optional path to a directory with collections. Default: `$HOME/.relaton/collections`.
|
|
395
332
|
|
|
396
|
-
===
|
|
333
|
+
=== Database manipulation
|
|
397
334
|
|
|
398
|
-
====
|
|
335
|
+
==== relaton db create
|
|
399
336
|
|
|
400
337
|
----
|
|
401
338
|
$ relaton db create DIR
|
|
402
339
|
----
|
|
403
340
|
|
|
404
|
-
|
|
341
|
+
Create a new cache database in directory `DIR` (optional, default: `$HOME/.relaton/cache`). If the target directory exists, it will be used as a database.
|
|
405
342
|
|
|
406
|
-
|
|
407
|
-
$ relaton db create
|
|
408
|
-
[relaton-cli] Database is in `/Users/user/.relaton/cache`
|
|
409
|
-
|
|
410
|
-
$ relaton db create cachedb
|
|
411
|
-
[relaton-cli] Database is in `/Users/user/RubyProjects/relaton-cli/cachedb`
|
|
412
|
-
----
|
|
413
|
-
|
|
414
|
-
==== Move database
|
|
343
|
+
==== relaton db mv
|
|
415
344
|
|
|
416
345
|
----
|
|
417
346
|
$ relaton db mv DIR
|
|
418
347
|
----
|
|
419
348
|
|
|
420
|
-
Move
|
|
349
|
+
Move the cache database to a new directory `DIR`.
|
|
421
350
|
|
|
422
|
-
|
|
423
|
-
$ relaton db mv cache_dir
|
|
424
|
-
[relaton-cli] Database is moved to `/Users/user/RubyProjects/relaton-cli/cache_dir`
|
|
425
|
-
----
|
|
426
|
-
|
|
427
|
-
==== Clear database
|
|
428
|
-
|
|
429
|
-
Delete all entries from a cache DB.
|
|
351
|
+
==== relaton db clear
|
|
430
352
|
|
|
431
353
|
----
|
|
432
354
|
$ relaton db clear
|
|
433
355
|
----
|
|
434
356
|
|
|
435
|
-
|
|
357
|
+
Delete all entries from the cache database.
|
|
358
|
+
|
|
359
|
+
==== relaton db fetch
|
|
436
360
|
|
|
437
361
|
----
|
|
438
|
-
$ relaton db fetch -t TYPE -f FORMAT -y YEAR
|
|
362
|
+
$ relaton db fetch CODE -t TYPE -f FORMAT -y YEAR --publication-date-before DATE --publication-date-after DATE
|
|
439
363
|
----
|
|
440
364
|
|
|
441
|
-
Fetch an entry from
|
|
442
|
-
|
|
443
|
-
==== Fetch all
|
|
365
|
+
Fetch an entry from the cache database. Arguments are the same as for `relaton fetch`.
|
|
444
366
|
|
|
445
|
-
|
|
367
|
+
==== relaton db fetch_all
|
|
446
368
|
|
|
447
369
|
----
|
|
448
370
|
$ relaton db fetch_all TEXT -e EDITION -y YEAR -f FORMAT
|
|
449
371
|
----
|
|
450
372
|
|
|
451
|
-
|
|
452
|
-
* `EDITION` (optional) filter documents with a certain edition
|
|
453
|
-
* `YEAR` (optional) filter documents by a year
|
|
454
|
-
* `FORMAT` (optional) specifies the output format. Recognized values are `xml` (default), yaml, `bibtex`.
|
|
373
|
+
Fetch all entries from the cache database.
|
|
455
374
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
$ relaton db fetch_all 'Procedures for the technical work'
|
|
462
|
-
<bibitem id="ISO/IECDIR1" type="international-standard">
|
|
463
|
-
<fetched>2021-04-01</fetched>
|
|
464
|
-
<title type="title-main" format="text/plain" language="en" script="Latn">Procedures for the technical work</title>
|
|
465
|
-
...
|
|
466
|
-
|
|
467
|
-
$ relaton db fetch_all -e 3
|
|
468
|
-
<bibitem id="ISO2146-2010" type="standard">
|
|
469
|
-
...
|
|
470
|
-
<edition>3</edition>
|
|
471
|
-
...
|
|
472
|
-
|
|
473
|
-
$ relaton db fetch_all -e 8 -y 2018
|
|
474
|
-
<bibitem id="ISO/IECDIR2IEC" type="international-standard">
|
|
475
|
-
<fetched>2021-04-01</fetched>
|
|
476
|
-
<title type="title-main" format="text/plain" language="en" script="Latn">Principles and rules for the structure and drafting of ISO and IEC documents</title>
|
|
477
|
-
<uri type="obp">https://www.iec.ch/members_experts/refdocs/iec/isoiecdir2%7Bed8.0.RLV%7Den.pdf</uri>
|
|
478
|
-
<docidentifier type="ISO" primary="true">ISO/IEC DIR 2 IEC</docidentifier>
|
|
479
|
-
<date type="published">
|
|
480
|
-
<on>2018-05-01</on>
|
|
481
|
-
</date>
|
|
482
|
-
<edition>8</edition>
|
|
483
|
-
...
|
|
484
|
-
----
|
|
375
|
+
* `TEXT` - optional, search for a specific string.
|
|
376
|
+
* `EDITION` - optional, filter documents by edition.
|
|
377
|
+
* `YEAR` - optional, filter documents by year.
|
|
378
|
+
* `FORMAT` - optional output format: `xml` (default), `yaml`, `bibtex`.
|
|
485
379
|
|
|
486
|
-
====
|
|
380
|
+
==== relaton db doctype
|
|
487
381
|
|
|
488
382
|
----
|
|
489
383
|
$ relaton db doctype REF
|
|
490
384
|
----
|
|
491
385
|
|
|
492
|
-
|
|
386
|
+
Detect and display the document type from reference `REF`.
|
|
493
387
|
|
|
494
388
|
----
|
|
495
389
|
$ relaton db doctype 'CN(GB/T 1.1)'
|
|
496
390
|
Chinese Standard
|
|
497
391
|
GB/T 1.1
|
|
498
392
|
----
|
|
393
|
+
|
|
394
|
+
== Development
|
|
395
|
+
|
|
396
|
+
[source,console]
|
|
397
|
+
----
|
|
398
|
+
$ bundle install
|
|
399
|
+
$ bundle exec rspec
|
|
400
|
+
$ bundle exec rubocop
|
|
401
|
+
----
|
|
402
|
+
|
|
403
|
+
== Contributing
|
|
404
|
+
|
|
405
|
+
Open an issue or pull request at https://github.com/relaton/relaton-cli.
|
|
406
|
+
|
|
407
|
+
This gem is developed, maintained, and funded by
|
|
408
|
+
https://www.ribose.com[Ribose Inc.]
|
|
409
|
+
|
|
410
|
+
== License
|
|
411
|
+
|
|
412
|
+
BSD 2-Clause. See link:../LICENSE[LICENSE] for details.
|
data/lib/relaton/bibdata.rb
CHANGED
|
@@ -13,7 +13,7 @@ module Relaton
|
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def docidentifier
|
|
16
|
-
@bibitem.docidentifier.first&.
|
|
16
|
+
@bibitem.docidentifier.first&.content&.to_s
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
# def doctype
|
|
@@ -50,10 +50,9 @@ module Relaton
|
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
def to_h
|
|
53
|
-
URL_TYPES.
|
|
53
|
+
URL_TYPES.each_with_object(YAML.safe_load(@bibitem.to_yaml)) do |t, h|
|
|
54
54
|
value = send t
|
|
55
|
-
h[t.to_s] = value
|
|
56
|
-
h
|
|
55
|
+
h[t.to_s] = value if value
|
|
57
56
|
end
|
|
58
57
|
end
|
|
59
58
|
|
|
@@ -68,19 +67,20 @@ module Relaton
|
|
|
68
67
|
if @bibitem.respond_to?(meth)
|
|
69
68
|
@bibitem.send meth, *args
|
|
70
69
|
elsif URL_TYPES.include? meth
|
|
71
|
-
|
|
70
|
+
source = (@bibitem.source || []).detect do |l|
|
|
72
71
|
l.type == meth.to_s || (meth == :uri && l.type.nil?)
|
|
73
72
|
end
|
|
74
|
-
|
|
73
|
+
source&.content&.to_s
|
|
75
74
|
elsif URL_TYPES.include? meth.match(/^\w+(?==)/).to_s.to_sym
|
|
76
75
|
/^(?<type>\w+)/ =~ meth
|
|
77
|
-
|
|
76
|
+
@bibitem.source ||= []
|
|
77
|
+
source = @bibitem.source.detect do |l|
|
|
78
78
|
l.type == type || (type == "uri" && l.type.nil?)
|
|
79
79
|
end
|
|
80
|
-
if
|
|
81
|
-
|
|
80
|
+
if source
|
|
81
|
+
source.content = args[0]
|
|
82
82
|
else
|
|
83
|
-
@bibitem.
|
|
83
|
+
@bibitem.source << Relaton::Bib::Uri.new(type: type, content: args[0])
|
|
84
84
|
end
|
|
85
85
|
else
|
|
86
86
|
super
|
data/lib/relaton/cli/command.rb
CHANGED
|
@@ -140,7 +140,7 @@ module Relaton
|
|
|
140
140
|
xml = Nokogiri::XML(File.read(file, encoding: "UTF-8"))
|
|
141
141
|
item = Relaton::Cli.parse_xml xml
|
|
142
142
|
result = if /yaml|yml/.match?(options[:format])
|
|
143
|
-
item.
|
|
143
|
+
item.to_yaml
|
|
144
144
|
else item.send "to_#{options[:format]}"
|
|
145
145
|
end
|
|
146
146
|
ext = case options[:format]
|
|
@@ -226,16 +226,16 @@ module Relaton
|
|
|
226
226
|
return "No matching bibliographic entry found" unless doc
|
|
227
227
|
|
|
228
228
|
serialize doc, options[:format]
|
|
229
|
-
rescue
|
|
229
|
+
rescue Relaton::RequestError => e
|
|
230
230
|
e.message
|
|
231
231
|
end
|
|
232
232
|
|
|
233
|
-
# @param doc [
|
|
233
|
+
# @param doc [Relaton::Bib::ItemData]
|
|
234
234
|
# @param format [String]
|
|
235
235
|
# @return [String]
|
|
236
236
|
def serialize(doc, format)
|
|
237
237
|
case format
|
|
238
|
-
when "yaml", "yml" then doc.
|
|
238
|
+
when "yaml", "yml" then doc.to_yaml
|
|
239
239
|
when "bibtex" then doc.to_bibtex
|
|
240
240
|
else doc.to_xml bibdata: true
|
|
241
241
|
end
|
|
@@ -119,15 +119,15 @@ module Relaton
|
|
|
119
119
|
if (bib = xml.at("//bibdata"))
|
|
120
120
|
bib = nokogiri_document(bib.to_xml)
|
|
121
121
|
elsif (rfc = xml.at("//rfc"))
|
|
122
|
-
require "
|
|
123
|
-
ietf
|
|
122
|
+
require "relaton/ietf"
|
|
123
|
+
require "relaton/ietf/bibxml_parser"
|
|
124
|
+
ietf = Relaton::Ietf::BibXMLParser.parse_rfc rfc.to_xml
|
|
124
125
|
bib = nokogiri_document(ietf.to_xml(bibdata: true))
|
|
125
126
|
else
|
|
126
127
|
next
|
|
127
128
|
end
|
|
128
129
|
|
|
129
130
|
bib.remove_namespaces!
|
|
130
|
-
bib.root.add_namespace(nil, "xmlns")
|
|
131
131
|
|
|
132
132
|
bibdata = Relaton::Bibdata.from_xml(bib.root)
|
|
133
133
|
if bibdata
|
|
@@ -147,8 +147,9 @@ module Relaton
|
|
|
147
147
|
xml_files.flatten.reduce([]) do |mem, xml|
|
|
148
148
|
doc = nokogiri_document(xml[:content])
|
|
149
149
|
if (rfc = doc.at("/rfc"))
|
|
150
|
-
require "
|
|
151
|
-
ietf
|
|
150
|
+
require "relaton/ietf"
|
|
151
|
+
require "relaton/ietf/bibxml_parser"
|
|
152
|
+
ietf = Relaton::Ietf::BibXMLParser.parse_rfc rfc.to_xml
|
|
152
153
|
d = nokogiri_document ietf.to_xml(bibdata: true)
|
|
153
154
|
mem << bibdata_instance(d, xml[:file])
|
|
154
155
|
elsif %w[bibitem bibdata].include? doc&.root&.name
|
|
@@ -231,7 +232,6 @@ module Relaton
|
|
|
231
232
|
# @return [Nokogiri::XML::Document]
|
|
232
233
|
def clean_nokogiri_document(document)
|
|
233
234
|
document.remove_namespaces!
|
|
234
|
-
document.root.add_namespace(nil, "xmlns")
|
|
235
235
|
nokogiri_document(document.to_xml)
|
|
236
236
|
end
|
|
237
237
|
|
|
@@ -144,11 +144,13 @@ module Relaton
|
|
|
144
144
|
collfile = File.join directory, options[:collection]
|
|
145
145
|
coll = read_collection collfile
|
|
146
146
|
xml = Nokogiri::XML File.read(file, encoding: "UTF-8")
|
|
147
|
+
xml.remove_namespaces!
|
|
147
148
|
if xml.at "relaton-collection"
|
|
149
|
+
imported = import_collection(xml)
|
|
148
150
|
if coll
|
|
149
|
-
coll <<
|
|
151
|
+
coll << imported
|
|
150
152
|
else
|
|
151
|
-
coll =
|
|
153
|
+
coll = imported
|
|
152
154
|
end
|
|
153
155
|
else
|
|
154
156
|
coll ||= Relaton::Bibcollection.new({})
|
|
@@ -169,6 +171,22 @@ module Relaton
|
|
|
169
171
|
|
|
170
172
|
private
|
|
171
173
|
|
|
174
|
+
# Parse a namespace-free collection XML document.
|
|
175
|
+
# Bibcollection.from_xml expects namespaced docs (via apply_namespace),
|
|
176
|
+
# so we use plain XPath on the namespace-stripped document instead.
|
|
177
|
+
def import_collection(xml)
|
|
178
|
+
title = xml.at("relaton-collection/title")&.text
|
|
179
|
+
author = xml.at_xpath(
|
|
180
|
+
"./relaton-collection/contributor[role/@type='author']"\
|
|
181
|
+
"/organization/name",
|
|
182
|
+
)&.text
|
|
183
|
+
items = xml.xpath("relaton-collection/relation").map do |rel|
|
|
184
|
+
el = rel.at("bibdata") || rel.at("bibitem")
|
|
185
|
+
Relaton::Bibdata.from_xml(el || rel)
|
|
186
|
+
end.compact
|
|
187
|
+
Relaton::Bibcollection.new(title: title, author: author, items: items)
|
|
188
|
+
end
|
|
189
|
+
|
|
172
190
|
# @return [String]
|
|
173
191
|
def directory
|
|
174
192
|
options.fetch :dir, File.join(Dir.home, ".relaton/collections")
|
|
@@ -231,9 +249,9 @@ module Relaton
|
|
|
231
249
|
# @param item [Relaton::Bibdata]
|
|
232
250
|
def puts_human_readable_item(item) # rubocop:disable Metrics/AbcSize
|
|
233
251
|
puts "Document identifier: #{item.docidentifier}"
|
|
234
|
-
puts "Title: #{item.title.first.
|
|
252
|
+
puts "Title: #{item.title.first.content}"
|
|
235
253
|
puts "Status: #{item.status.stage}"
|
|
236
|
-
item.date.each { |d| puts "Date #{d.type}: #{d.
|
|
254
|
+
item.date.each { |d| puts "Date #{d.type}: #{d.at || d.from}" }
|
|
237
255
|
end
|
|
238
256
|
end
|
|
239
257
|
end
|
data/lib/relaton/cli/util.rb
CHANGED
data/lib/relaton/cli/version.rb
CHANGED
|
@@ -90,12 +90,13 @@ module Relaton::Cli
|
|
|
90
90
|
elsif value.is_a?(Hash) then v = value["content"]
|
|
91
91
|
else v = value
|
|
92
92
|
end
|
|
93
|
-
when "
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
when "docidentifier"
|
|
94
|
+
did = if value.is_a?(Array)
|
|
95
|
+
value.detect { |d| (d["id"] || d["content"]).to_s !~ /^(http|https):\/\// } ||
|
|
96
|
+
value.first
|
|
97
|
+
else value
|
|
98
|
+
end
|
|
99
|
+
v = did
|
|
99
100
|
else v = value
|
|
100
101
|
end
|
|
101
102
|
[key.to_s, empty2nil(v)]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "yaml"
|
|
2
2
|
require "relaton/cli/base_convertor"
|
|
3
|
-
require "
|
|
3
|
+
require "relaton/bib"
|
|
4
4
|
|
|
5
5
|
module Relaton
|
|
6
6
|
module Cli
|
|
@@ -33,13 +33,15 @@ module Relaton
|
|
|
33
33
|
# @return [RelatonBib::BibliographicItem,
|
|
34
34
|
# RelatonIso::IsoBiblioraphicItem]
|
|
35
35
|
def convert_single_file(content)
|
|
36
|
-
flavor = content.dig("ext", "flavor") || doctype(content["
|
|
36
|
+
flavor = content.dig("ext", "flavor") || doctype(content["docidentifier"])
|
|
37
37
|
if (processor = Registry.instance.by_type(flavor))
|
|
38
|
-
|
|
38
|
+
begin
|
|
39
|
+
processor.from_yaml content.to_yaml
|
|
40
|
+
rescue RuntimeError
|
|
41
|
+
Relaton::Bib::Item.from_yaml(content.to_yaml)
|
|
42
|
+
end
|
|
39
43
|
else
|
|
40
|
-
|
|
41
|
-
**RelatonBib::HashConverter::hash_to_bib(content)
|
|
42
|
-
)
|
|
44
|
+
Relaton::Bib::Item.from_yaml(content.to_yaml)
|
|
43
45
|
end
|
|
44
46
|
end
|
|
45
47
|
|
|
@@ -51,7 +53,7 @@ module Relaton
|
|
|
51
53
|
did = docid.is_a?(Array) ? docid.fetch(0) : docid
|
|
52
54
|
return unless did
|
|
53
55
|
|
|
54
|
-
did["type"] || did.fetch("
|
|
56
|
+
did["type"] || did.fetch("content")&.match(/^\w+/)&.to_s
|
|
55
57
|
end
|
|
56
58
|
end
|
|
57
59
|
|
data/lib/relaton/cli.rb
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require "fileutils"
|
|
1
2
|
require "thor"
|
|
2
3
|
require "thor/hollaback"
|
|
3
4
|
require_relative "cli/version"
|
|
@@ -19,6 +20,7 @@ module Relaton
|
|
|
19
20
|
# @return [Relaton::Db]
|
|
20
21
|
def db(dir)
|
|
21
22
|
if dir
|
|
23
|
+
FileUtils.mkdir_p File.dirname(DBCONF)
|
|
22
24
|
File.write DBCONF, dir, encoding: "UTF-8"
|
|
23
25
|
@db = Relaton::Db.new dir, nil
|
|
24
26
|
else
|
|
@@ -39,19 +41,14 @@ module Relaton
|
|
|
39
41
|
|
|
40
42
|
class << self
|
|
41
43
|
def version
|
|
42
|
-
require "
|
|
43
|
-
require "relaton_iso_bib"
|
|
44
|
+
require "relaton/bib"
|
|
44
45
|
registry = Relaton::Registry.instance
|
|
45
46
|
puts "CLI => #{Relaton::Cli::VERSION}"
|
|
46
|
-
puts "relaton => #{
|
|
47
|
-
puts "relaton-bib => #{
|
|
48
|
-
puts "relaton-iso-bib => #{RelatonIsoBib::VERSION}"
|
|
47
|
+
puts "relaton => #{Gem.loaded_specs['relaton'].version}"
|
|
48
|
+
puts "relaton-bib => #{Gem.loaded_specs['relaton-bib'].version}"
|
|
49
49
|
registry.processors.each_key do |k|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
klass = "#{klass}::VERSION"
|
|
53
|
-
version = Kernel.const_get(klass)
|
|
54
|
-
puts "#{k.to_s.sub('_', '-')} => #{version}"
|
|
50
|
+
name = k.to_s.sub("_", "-")
|
|
51
|
+
puts "#{name} => #{Gem.loaded_specs[name].version}"
|
|
55
52
|
end
|
|
56
53
|
end
|
|
57
54
|
|
|
@@ -76,10 +73,11 @@ module Relaton
|
|
|
76
73
|
# @return [RelatonBib::BibliographicItem,
|
|
77
74
|
# RelatonIsoBib::IsoBibliongraphicItem]
|
|
78
75
|
def parse_xml(doc)
|
|
76
|
+
doc.remove_namespaces! if doc.respond_to?(:remove_namespaces!)
|
|
79
77
|
if (proc = Cli.processor(doc))
|
|
80
78
|
proc.from_xml(doc.to_s)
|
|
81
79
|
else
|
|
82
|
-
|
|
80
|
+
Relaton::Bib::Item.from_xml(doc.to_s) rescue nil
|
|
83
81
|
end
|
|
84
82
|
end
|
|
85
83
|
|
data/relaton-cli.gemspec
CHANGED
|
@@ -20,10 +20,10 @@ Gem::Specification.new do |spec|
|
|
|
20
20
|
spec.bindir = "exe"
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
22
22
|
spec.require_paths = ["lib"]
|
|
23
|
-
spec.required_ruby_version = ">= 3.
|
|
23
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.2.0")
|
|
24
24
|
|
|
25
25
|
spec.add_runtime_dependency "liquid", "~> 5"
|
|
26
|
-
spec.add_runtime_dependency "relaton", "~>
|
|
26
|
+
spec.add_runtime_dependency "relaton", "~> 2.0.0-alpha.1"
|
|
27
27
|
spec.add_runtime_dependency "thor"
|
|
28
28
|
spec.add_runtime_dependency "thor-hollaback"
|
|
29
29
|
|
data/templates/_document.liquid
CHANGED
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
<div class="doc-identifier">
|
|
21
21
|
<h{{ depth }}>
|
|
22
22
|
{% if default_link %}
|
|
23
|
-
<a href="{{ default_link }}">{{ document.
|
|
23
|
+
<a href="{{ default_link }}">{{ document.docidentifier.content }}</a>
|
|
24
24
|
{% else %}
|
|
25
|
-
{{ document.
|
|
25
|
+
{{ document.docidentifier.content }}
|
|
26
26
|
{% endif %}
|
|
27
27
|
</h{{ depth }}>
|
|
28
28
|
</div>
|
|
29
29
|
|
|
30
30
|
<div class="doc-type-wrap">
|
|
31
|
-
<div class="doc-type {{ document.doctype.
|
|
32
|
-
{{ document.doctype.
|
|
31
|
+
<div class="doc-type {{ document.ext.doctype.content | downcase | split: " " | join: "-" }}">
|
|
32
|
+
{{ document.ext.doctype.content }}
|
|
33
33
|
</div>
|
|
34
34
|
</div>
|
|
35
35
|
|
|
@@ -50,18 +50,17 @@
|
|
|
50
50
|
</h{{ depth | plus: 1 }}>
|
|
51
51
|
</div>
|
|
52
52
|
|
|
53
|
-
{% if document.
|
|
54
|
-
<div class="doc-info {{ document.
|
|
55
|
-
<div class="doc-stage {{ document.
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
{{ document.docstatus.stage.value }}.{{ document.docstatus.substage.value }}
|
|
53
|
+
{% if document.status %}
|
|
54
|
+
<div class="doc-info {{ document.status.stage.content | downcase }}">
|
|
55
|
+
<div class="doc-stage {{ document.status.stage.content | downcase }}">
|
|
56
|
+
{% if document.status.substage %}
|
|
57
|
+
{{ document.status.stage.content }}.{{ document.status.substage.content }}
|
|
59
58
|
{% else %}
|
|
60
|
-
{{ document.
|
|
59
|
+
{{ document.status.stage.content }}
|
|
61
60
|
{% endif %}
|
|
62
61
|
</div>
|
|
63
62
|
<div class="doc-dates">
|
|
64
|
-
{% unless document.
|
|
63
|
+
{% unless document.status.stage.content == "published" %}
|
|
65
64
|
<div class="doc-updated">
|
|
66
65
|
{% else %}
|
|
67
66
|
<div class="doc-published">
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: relaton-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0.pre.alpha.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: liquid
|
|
@@ -30,14 +29,14 @@ dependencies:
|
|
|
30
29
|
requirements:
|
|
31
30
|
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
32
|
+
version: 2.0.0.pre.alpha.1
|
|
34
33
|
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
39
|
+
version: 2.0.0.pre.alpha.1
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
41
|
name: thor
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -87,8 +86,8 @@ executables:
|
|
|
87
86
|
- relaton
|
|
88
87
|
extensions: []
|
|
89
88
|
extra_rdoc_files:
|
|
90
|
-
- docs/README.adoc
|
|
91
89
|
- LICENSE
|
|
90
|
+
- docs/README.adoc
|
|
92
91
|
files:
|
|
93
92
|
- ".github/workflows/rake.yml"
|
|
94
93
|
- ".github/workflows/release.yml"
|
|
@@ -132,7 +131,6 @@ homepage: https://github.com/metanorma/relaton-cli
|
|
|
132
131
|
licenses:
|
|
133
132
|
- BSD-2-Clause
|
|
134
133
|
metadata: {}
|
|
135
|
-
post_install_message:
|
|
136
134
|
rdoc_options: []
|
|
137
135
|
require_paths:
|
|
138
136
|
- lib
|
|
@@ -140,15 +138,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
140
138
|
requirements:
|
|
141
139
|
- - ">="
|
|
142
140
|
- !ruby/object:Gem::Version
|
|
143
|
-
version: 3.
|
|
141
|
+
version: 3.2.0
|
|
144
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
143
|
requirements:
|
|
146
144
|
- - ">="
|
|
147
145
|
- !ruby/object:Gem::Version
|
|
148
146
|
version: '0'
|
|
149
147
|
requirements: []
|
|
150
|
-
rubygems_version: 3.
|
|
151
|
-
signing_key:
|
|
148
|
+
rubygems_version: 3.6.9
|
|
152
149
|
specification_version: 4
|
|
153
150
|
summary: Relaton Command-line Interface
|
|
154
151
|
test_files: []
|