relaton-cli 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/README.adoc +21 -22
- data/lib/relaton/cli/command.rb +7 -6
- data/lib/relaton/cli/relaton_file.rb +16 -5
- data/lib/relaton/cli/version.rb +1 -1
- metadata +2 -3
- data/Gemfile.lock +0 -128
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbb153837a43075460f32bbcc33fa18460868365f699dd6e2da57c01e1039066
|
4
|
+
data.tar.gz: 325431872002258b6d6f1d6d8f2c5ebfc674aadb06c8e08b23f08ed7031fe4ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b5d7221bf4951d058774df317617437de75648bfa1a5d720d2e130ab1df2f0ec503247a279ef0ee291603271282f69c866750d19406a1eca3e3010bb50b01c5
|
7
|
+
data.tar.gz: 40e035f13365c7664a7ebae2dd1ab302e264ab85cfa5b69e5a4c2210d257210c12f6b1639932a04e9a588e7f6076e4de926ee2821cbccf89340ce89661f0fdc0
|
data/docs/README.adoc
CHANGED
@@ -1,35 +1,33 @@
|
|
1
1
|
= Relaton CLI (relaton-cli): Relaton Command-line Interface
|
2
2
|
|
3
3
|
image:https://img.shields.io/gem/v/relaton-cli.svg["Gem Version", link="https://rubygems.org/gems/relaton-cli"]
|
4
|
-
image:https://
|
5
|
-
image:https://
|
4
|
+
image:https://github.com/relaton/relaton-cli/workflows/ubuntu/badge.svg["Build Status", link="https://github.com/relaton/relaton-cli/actions?workflow=ubuntu"]
|
5
|
+
image:https://github.com/relaton/relaton-cli/workflows/macos/badge.svg["Build Status", link="https://github.com/relaton/relaton-cli/actions?workflow=macos"]
|
6
|
+
image:https://github.com/relaton/relaton-cli/workflows/windows/badge.svg["Build Status", link="https://github.com/relaton/relaton-cli/actions?workflow=windows"]
|
6
7
|
image:https://codeclimate.com/github/metanorma/relaton-cli/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/metanorma/relaton-cli"]
|
7
8
|
|
8
9
|
Documentation in development.
|
9
10
|
|
10
|
-
Please refer to https://github.com/
|
11
|
+
Please refer to https://github.com/relaton/relaton.
|
11
12
|
|
12
|
-
==
|
13
|
+
== Commands
|
13
14
|
|
14
|
-
The following
|
15
|
+
The following commands are provided.
|
15
16
|
|
16
17
|
=== relaton concatenate
|
17
18
|
|
18
19
|
[source,console]
|
19
20
|
----
|
20
|
-
$ relaton concatenate Source-Directory Collection-File -t TITLE -g ORGANIZATION -n
|
21
|
+
$ relaton concatenate Source-Directory Relaton-Collection-File -t TITLE -g ORGANIZATION -n
|
21
22
|
----
|
22
23
|
|
23
|
-
Iterates through all the Relaton YAML
|
24
|
+
Iterates through all the Relaton files (YAML and XML) in `Source-Directory`, and concatenates them into a Relaton Collection file. The extension of the Collection file can be set using the `Relaton-Collection-File` file name (i.e, if it uses an extension of `yaml`, a Relaton YAML file will be created; if `rxl`, a Relaton XML file will be created, or via the `-x [ext]` (or `--extension`) option.
|
24
25
|
|
25
|
-
|
26
|
-
and outputs to `Collection-File` a `relaton-collection` document containing all the Relaton XML objects read in.
|
27
|
-
|
28
|
-
For each Relaton XML file, if a document file with the same base name is identified (i.e. an XML, HTML, PDF or DOC
|
26
|
+
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
|
29
27
|
file), a link to that file is inserted.
|
30
28
|
|
31
29
|
If the `TITLE` or `ORGANIZATION` options are given, they are added to the `Collection-File` output as the
|
32
|
-
title and author of the `
|
30
|
+
title and author of the `Relaton-Collection-File` document.
|
33
31
|
|
34
32
|
If the `-n` or `--new` option given then use the new Relaton YAML format https://github.com/relaton/relaton-bib/blob/master/docs/hash.adoc.
|
35
33
|
|
@@ -37,11 +35,11 @@ If the `-n` or `--new` option given then use the new Relaton YAML format https:/
|
|
37
35
|
|
38
36
|
[source,console]
|
39
37
|
----
|
40
|
-
$ relaton split Collection-File Relaton-File-Directory -x rxl -n
|
38
|
+
$ relaton split Relaton-Collection-File Relaton-File-Directory -x rxl -n
|
41
39
|
----
|
42
40
|
|
43
41
|
Splits a `Relaton-Collection-File` into multiple files in the `Relaton-File-Directory`, and it also
|
44
|
-
suports an
|
42
|
+
suports an additional `-x` or `--extension` options to use different extension.
|
45
43
|
|
46
44
|
If the `-n` or `--new` option given then use the new Relaton YAML format https://github.com/relaton/relaton-bib/blob/master/docs/hash.adoc.
|
47
45
|
|
@@ -217,9 +215,9 @@ Render a Relaton YAML file (`filename.yaml`) as an HTML file. The stylesheet and
|
|
217
215
|
$ relaton yaml2xmlnew <filename.yaml> -o OUTPUT-DIRECTORY -x RELATON_EXTENSION -p PREFIX -r LIBRARY
|
218
216
|
----
|
219
217
|
|
220
|
-
Convert a Relaton YAML file (`filename.yaml`) in a new format into a Relaton XML file (`filename.xml`). If the Relaton YAML file specifies multiple
|
218
|
+
Convert a Relaton YAML file (`filename.yaml`) in a new format into a Relaton XML file (`filename.xml`). If the Relaton YAML file specifies multiple bibliographic items, and `OUTPUT-DIRECTORY` is nominated, also convert the file into a list of Relaton XML files for each entry, stored in that directory. The document identifier is used as the name of each Relaton XML file; the Relaton XML filename is suffixed with `RELATON_EXTENSION` (default `.rxl`) and prefixed with `PREFIX` (default empty). Any libraries that need to be required for the conversion are specified in `LIBRARY` as a space-delimited list.
|
221
219
|
|
222
|
-
A Relaton
|
220
|
+
A Relaton Collection YAML file contains some initial metadata, and a list of metadata about each bibliographic entry:
|
223
221
|
|
224
222
|
[source,yaml]
|
225
223
|
----
|
@@ -228,11 +226,11 @@ root:
|
|
228
226
|
title: CalConnect Standards Registry
|
229
227
|
items:
|
230
228
|
- technical_committee: PUBLISH
|
231
|
-
docid:
|
229
|
+
docid:
|
232
230
|
type: CC
|
233
231
|
id: CC 36000
|
234
232
|
type: standard
|
235
|
-
title:
|
233
|
+
title:
|
236
234
|
type: main
|
237
235
|
content: Standardization documents -- Vocabulary
|
238
236
|
docstatus:
|
@@ -241,11 +239,11 @@ root:
|
|
241
239
|
type: issued
|
242
240
|
value: 2018-10-25
|
243
241
|
- technical_committee: DATETIME
|
244
|
-
docid:
|
242
|
+
docid:
|
245
243
|
type: CC
|
246
244
|
id: CC 34000
|
247
245
|
type: standard
|
248
|
-
title:
|
246
|
+
title:
|
249
247
|
type: main
|
250
248
|
content: Date and time -- Concepts and vocabulary
|
251
249
|
docstatus:
|
@@ -255,7 +253,7 @@ root:
|
|
255
253
|
value: 2018-10-25
|
256
254
|
----
|
257
255
|
|
258
|
-
A Relaton YAML file describing an individual bibliographic entry is limited to metadata specific to that entry. Flavor gems have
|
256
|
+
A Relaton YAML file describing an individual bibliographic entry is limited to metadata specific to that entry. Flavor gems have additional fields. The following illustrates the common fields supported by all flavor gems (see link:https://github.com/relaton/relaton-bib/blob/master/docs/hash.adoc#yaml[Relaton YAML]):
|
259
257
|
|
260
258
|
[source,yaml]
|
261
259
|
----
|
@@ -470,4 +468,5 @@ Convert a Relaton XML file (`filename.xml` or `filename.rxl`) into a Relaton YAM
|
|
470
468
|
$ relaton yaml2xmlnew <filename.yaml> [<stylesheet>] [<liquid-template-dir>]
|
471
469
|
----
|
472
470
|
|
473
|
-
Render a Relaton YAML file in a new format (`filename.yaml`) as an HTML file. The `stylesheet` and `liquid-template-dir` directories are as for <<relaton xml2html,relaton xml2html>>.
|
471
|
+
Render a Relaton YAML file in a new format (`filename.yaml`) as an HTML file. The `stylesheet` and `liquid-template-dir` directories are as for <<relaton xml2html,relaton xml2html>>.
|
472
|
+
|
data/lib/relaton/cli/command.rb
CHANGED
@@ -19,7 +19,7 @@ module Relaton
|
|
19
19
|
end
|
20
20
|
|
21
21
|
desc "extract Metanorma-XML-File / Directory Relaton-XML-Directory", "Extract Relaton XML from Metanorma XML file / directory"
|
22
|
-
option :extension, aliases: :x, desc: "File extension of Relaton XML files, defaults to 'rxl'"
|
22
|
+
option :extension, aliases: :x, default: "rxl", desc: "File extension of Relaton XML files, defaults to 'rxl'"
|
23
23
|
|
24
24
|
def extract(source_dir, outdir)
|
25
25
|
Relaton::Cli::RelatonFile.extract(source_dir, outdir, options)
|
@@ -29,13 +29,14 @@ module Relaton
|
|
29
29
|
option :title, aliases: :t, desc: "Title of resulting Relaton collection"
|
30
30
|
option :organization, aliases: :g, desc: "Organization owner of Relaton collection"
|
31
31
|
option :new, aliases: :n, type: :boolean, desc: "Use the new Relaton YAML format"
|
32
|
+
option :extension, aliases: :x, default: "rxl", desc: "File extension of destination Relaton file, defaults to 'rxl'"
|
32
33
|
|
33
34
|
def concatenate(source_dir, outfile)
|
34
35
|
Relaton::Cli::RelatonFile.concatenate(source_dir, outfile, options)
|
35
36
|
end
|
36
37
|
|
37
38
|
desc "split Relaton-Collection-File Relaton-XML-Directory", "Split a Relaton Collection into multiple files"
|
38
|
-
option :extension, aliases: :x, desc: "File extension of Relaton XML files, defaults to 'rxl'"
|
39
|
+
option :extension, aliases: :x, default: "rxl", desc: "File extension of Relaton XML files, defaults to 'rxl'"
|
39
40
|
option :new, aliases: :n, type: :boolean, desc: "Use the new Relaton YAML format"
|
40
41
|
|
41
42
|
def split(source, outdir)
|
@@ -43,7 +44,7 @@ module Relaton
|
|
43
44
|
end
|
44
45
|
|
45
46
|
desc "yaml2xml YAML", "Convert Relaton YAML into Relaton Collection XML or separate files"
|
46
|
-
option :extension, aliases: :x, desc: "File extension of Relaton XML files, defaults to 'rxl'"
|
47
|
+
option :extension, aliases: :x, default: "rxl", desc: "File extension of Relaton XML files, defaults to 'rxl'"
|
47
48
|
option :prefix, aliases: :p, desc: "Filename prefix of individual Relaton XML files, defaults to empty"
|
48
49
|
option :outdir, aliases: :o, desc: "Output to the specified directory with individual Relaton Bibdata XML files"
|
49
50
|
option :require, aliases: :r, type: :array, desc: "Require LIBRARY prior to execution"
|
@@ -54,7 +55,7 @@ module Relaton
|
|
54
55
|
end
|
55
56
|
|
56
57
|
desc "yaml2xmlnew YAML", "Convert Relaton YAML into Relaton Collection XML or separate files"
|
57
|
-
option :extension, aliases: :x, desc: "File extension of Relaton XML files, defaults to 'rxl'"
|
58
|
+
option :extension, aliases: :x, default: "rxl", desc: "File extension of Relaton XML files, defaults to 'rxl'"
|
58
59
|
option :prefix, aliases: :p, desc: "Filename prefix of individual Relaton XML files, defaults to empty"
|
59
60
|
option :outdir, aliases: :o, desc: "Output to the specified directory with individual Relaton Bibdata XML files"
|
60
61
|
option :require, aliases: :r, type: :array, desc: "Require LIBRARY prior to execution"
|
@@ -65,7 +66,7 @@ module Relaton
|
|
65
66
|
end
|
66
67
|
|
67
68
|
desc "xml2yaml XML", "Convert Relaton XML into Relaton Bibdata / Bibcollection YAML (and separate files)"
|
68
|
-
option :extension, aliases: :x, desc: "File extension of Relaton YAML files, defaults to 'yaml'"
|
69
|
+
option :extension, aliases: :x, default: "yaml", desc: "File extension of Relaton YAML files, defaults to 'yaml'"
|
69
70
|
option :prefix, aliases: :p, desc: "Filename prefix of Relaton XML files, defaults to empty"
|
70
71
|
option :outdir, aliases: :o, desc: "Output to the specified directory with individual Relaton Bibdata YAML files"
|
71
72
|
option :require, aliases: :r, type: :array, desc: "Require LIBRARY prior to execution"
|
@@ -76,7 +77,7 @@ module Relaton
|
|
76
77
|
end
|
77
78
|
|
78
79
|
desc "xml2yamlnew XML", "Convert Relaton XML into Relaton Bibdata / Bibcollection YAML (and separate files)"
|
79
|
-
option :extension, aliases: :x, desc: "File extension of Relaton YAML files, defaults to 'yaml'"
|
80
|
+
option :extension, aliases: :x, default: "yaml", desc: "File extension of Relaton YAML files, defaults to 'yaml'"
|
80
81
|
option :prefix, aliases: :p, desc: "Filename prefix of Relaton XML files, defaults to empty"
|
81
82
|
option :outdir, aliases: :o, desc: "Output to the specified directory with individual Relaton Bibdata YAML files"
|
82
83
|
option :require, aliases: :r, type: :array, desc: "Require LIBRARY prior to execution"
|
@@ -16,7 +16,7 @@ module Relaton
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def concatenate
|
19
|
-
|
19
|
+
concatenate_and_write_to_files
|
20
20
|
end
|
21
21
|
|
22
22
|
def split
|
@@ -128,7 +128,7 @@ module Relaton
|
|
128
128
|
bibdata = Relaton::Bibdata.from_xml(bib.root)
|
129
129
|
build_bibdata_relaton(bibdata, file)
|
130
130
|
|
131
|
-
write_to_file(bibdata.
|
131
|
+
write_to_file(bibdata.send(output_type), outdir, build_filename(file))
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
@@ -147,6 +147,10 @@ module Relaton
|
|
147
147
|
end.compact
|
148
148
|
end
|
149
149
|
|
150
|
+
def concatenate_and_write_to_files
|
151
|
+
write_to_file(bibcollection.send(output_type))
|
152
|
+
end
|
153
|
+
|
150
154
|
def split_and_write_to_files
|
151
155
|
output_dir = outdir || build_dirname(source)
|
152
156
|
|
@@ -164,9 +168,16 @@ module Relaton
|
|
164
168
|
end
|
165
169
|
end
|
166
170
|
|
167
|
-
def output_type
|
168
|
-
|
169
|
-
|
171
|
+
def output_type(ext=options[:extension])
|
172
|
+
case ext
|
173
|
+
when "rxl", "xml"
|
174
|
+
:to_xml
|
175
|
+
when "yml", "yaml"
|
176
|
+
:to_yaml
|
177
|
+
else
|
178
|
+
puts "The given extension of '#{ext}' is not supported."
|
179
|
+
:to_xml
|
180
|
+
end
|
170
181
|
end
|
171
182
|
|
172
183
|
def bibdata_instance(document, file)
|
data/lib/relaton/cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -210,7 +210,6 @@ files:
|
|
210
210
|
- ".rubocop.yml"
|
211
211
|
- CHANGELOG.md
|
212
212
|
- Gemfile
|
213
|
-
- Gemfile.lock
|
214
213
|
- LICENSE
|
215
214
|
- Rakefile
|
216
215
|
- bin/console
|
data/Gemfile.lock
DELETED
@@ -1,128 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
relaton-cli (0.4.2)
|
5
|
-
liquid
|
6
|
-
relaton (~> 0.6.0)
|
7
|
-
thor
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
addressable (2.7.0)
|
13
|
-
public_suffix (>= 2.0.2, < 5.0)
|
14
|
-
byebug (10.0.2)
|
15
|
-
cnccs (0.1.5)
|
16
|
-
coderay (1.1.2)
|
17
|
-
debase (0.2.3)
|
18
|
-
debase-ruby_core_source (>= 0.10.2)
|
19
|
-
debase-ruby_core_source (0.10.5)
|
20
|
-
diff-lcs (1.3)
|
21
|
-
docile (1.3.2)
|
22
|
-
equivalent-xml (0.6.0)
|
23
|
-
nokogiri (>= 1.4.3)
|
24
|
-
faraday (0.17.1)
|
25
|
-
multipart-post (>= 1.2, < 3)
|
26
|
-
gb-agencies (0.0.6)
|
27
|
-
isoics (0.1.8)
|
28
|
-
json (2.2.0)
|
29
|
-
liquid (4.0.3)
|
30
|
-
method_source (0.9.2)
|
31
|
-
mini_portile2 (2.4.0)
|
32
|
-
mixlib-shellout (2.4.4)
|
33
|
-
multipart-post (2.1.1)
|
34
|
-
nokogiri (1.10.7)
|
35
|
-
mini_portile2 (~> 2.4.0)
|
36
|
-
pry (0.12.2)
|
37
|
-
coderay (~> 1.1.0)
|
38
|
-
method_source (~> 0.9.0)
|
39
|
-
public_suffix (4.0.1)
|
40
|
-
rake (12.3.3)
|
41
|
-
relaton (0.6.2)
|
42
|
-
relaton-calconnect (~> 0.2.0)
|
43
|
-
relaton-gb (~> 0.7.0)
|
44
|
-
relaton-iec (~> 0.5.0)
|
45
|
-
relaton-ietf (~> 0.7.0)
|
46
|
-
relaton-iso (~> 0.7.0)
|
47
|
-
relaton-itu (~> 0.4.0)
|
48
|
-
relaton-nist (~> 0.4.0)
|
49
|
-
relaton-ogc (~> 0.2.0)
|
50
|
-
relaton-bib (0.4.1)
|
51
|
-
addressable
|
52
|
-
nokogiri
|
53
|
-
relaton-calconnect (0.2.1)
|
54
|
-
faraday
|
55
|
-
relaton-iso-bib (~> 0.4.0)
|
56
|
-
relaton-gb (0.7.1)
|
57
|
-
cnccs (~> 0.1.1)
|
58
|
-
gb-agencies (~> 0.0.1)
|
59
|
-
relaton-iso-bib (~> 0.4.0)
|
60
|
-
relaton-iec (0.5.1)
|
61
|
-
addressable
|
62
|
-
relaton-iso-bib (~> 0.4.0)
|
63
|
-
relaton-ietf (0.7.2)
|
64
|
-
relaton-bib (~> 0.4.0)
|
65
|
-
relaton-iso (0.7.1)
|
66
|
-
relaton-iec (~> 0.5.0)
|
67
|
-
relaton-iso-bib (~> 0.4.0)
|
68
|
-
relaton-iso-bib (0.4.1)
|
69
|
-
isoics (~> 0.1.6)
|
70
|
-
relaton-bib (~> 0.4.0)
|
71
|
-
ruby_deep_clone (~> 0.8.0)
|
72
|
-
relaton-itu (0.4.1)
|
73
|
-
relaton-iso-bib (~> 0.4.0)
|
74
|
-
relaton-nist (0.4.1)
|
75
|
-
relaton-bib (~> 0.4.0)
|
76
|
-
rubyzip
|
77
|
-
relaton-ogc (0.2.1)
|
78
|
-
faraday
|
79
|
-
relaton-iso-bib (~> 0.4.0)
|
80
|
-
rspec (3.8.0)
|
81
|
-
rspec-core (~> 3.8.0)
|
82
|
-
rspec-expectations (~> 3.8.0)
|
83
|
-
rspec-mocks (~> 3.8.0)
|
84
|
-
rspec-command (1.0.3)
|
85
|
-
mixlib-shellout (~> 2.0)
|
86
|
-
rspec (~> 3.2)
|
87
|
-
rspec-its (~> 1.2)
|
88
|
-
rspec-core (3.8.2)
|
89
|
-
rspec-support (~> 3.8.0)
|
90
|
-
rspec-expectations (3.8.4)
|
91
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
92
|
-
rspec-support (~> 3.8.0)
|
93
|
-
rspec-its (1.3.0)
|
94
|
-
rspec-core (>= 3.0.0)
|
95
|
-
rspec-expectations (>= 3.0.0)
|
96
|
-
rspec-mocks (3.8.1)
|
97
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
98
|
-
rspec-support (~> 3.8.0)
|
99
|
-
rspec-support (3.8.2)
|
100
|
-
ruby-debug-ide (0.7.0)
|
101
|
-
rake (>= 0.8.1)
|
102
|
-
ruby_deep_clone (0.8.0)
|
103
|
-
rubyzip (2.0.0)
|
104
|
-
simplecov (0.17.0)
|
105
|
-
docile (~> 1.1)
|
106
|
-
json (>= 1.8, < 3)
|
107
|
-
simplecov-html (~> 0.10.0)
|
108
|
-
simplecov-html (0.10.2)
|
109
|
-
thor (0.20.3)
|
110
|
-
|
111
|
-
PLATFORMS
|
112
|
-
ruby
|
113
|
-
|
114
|
-
DEPENDENCIES
|
115
|
-
byebug (~> 10.0)
|
116
|
-
debase
|
117
|
-
equivalent-xml (~> 0.6)
|
118
|
-
pry
|
119
|
-
rake (~> 12.0)
|
120
|
-
relaton-cli!
|
121
|
-
rspec (~> 3.0)
|
122
|
-
rspec-command (~> 1.0.3)
|
123
|
-
rspec-core (~> 3.4)
|
124
|
-
ruby-debug-ide
|
125
|
-
simplecov
|
126
|
-
|
127
|
-
BUNDLED WITH
|
128
|
-
2.0.2
|