relaton-cli 0.9.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/docs/README.adoc +2 -1
- data/lib/relaton/cli/command.rb +12 -11
- data/lib/relaton/cli/relaton_file.rb +10 -6
- data/lib/relaton/cli/version.rb +1 -1
- data/lib/relaton/cli/xml_to_html_renderer.rb +1 -1
- data/relaton-cli.gemspec +2 -3
- data/templates/_document.liquid +9 -4
- metadata +4 -6
- data/lib/relaton/cli/_document.liquid +0 -82
- data/lib/relaton/cli/_index.liquid +0 -53
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2519a76d53e13022ef3f2da8010ee1bd1667e12e614763851a7a9e0a61c41e0
|
4
|
+
data.tar.gz: b4e920db6ded4e1fccec77497fee98a1b9b34172ffaad33a00fb3ff69f714ce6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15b49542f88b8248a9177493670c91ee60107f67c432a785bda4b9c115ffd149cf6c5f3a72363f560e35cc1d0df1bf223ef339388de65e8b84d0b8882a5bcfce
|
7
|
+
data.tar.gz: 24427ff9a3fb6ef259e0d0b032815cece68e87afe9d48d1acb486b59d29e898796a5ddf7decb77f3f7caaeeefa886f6d4b5158de95a78c4784eb6102474fe7b4
|
data/.rubocop.yml
CHANGED
data/docs/README.adoc
CHANGED
@@ -43,12 +43,13 @@ suports an additional `-x` or `--extension` options to use different extension.
|
|
43
43
|
|
44
44
|
[source,console]
|
45
45
|
----
|
46
|
-
$ relaton fetch CODE -t TYPE -y YEAR
|
46
|
+
$ relaton fetch CODE -t TYPE -f FORMAT -y YEAR
|
47
47
|
----
|
48
48
|
|
49
49
|
Fetch the Relaton XML entry corresponding to the document identifier `CODE`.
|
50
50
|
|
51
51
|
* `YEAR` is optional, and specifies the year of publication of the standard.
|
52
|
+
* `FORMAT` is optional, and specifies the output format; the recognised values for `FORMAT` are `xml` (default), `bibtex`.
|
52
53
|
* `TYPE` specifies the standards class library to be used, that the identifier is part of; the recognised
|
53
54
|
values for `TYPE` are `isobib`, `ietfbib`, `iecbib`, `gbbib`.
|
54
55
|
|
data/lib/relaton/cli/command.rb
CHANGED
@@ -8,6 +8,7 @@ module Relaton
|
|
8
8
|
class Command < Thor
|
9
9
|
desc "fetch CODE", "Fetch Relaton XML for Standard identifier CODE"
|
10
10
|
option :type, aliases: :t, required: true, desc: "Type of standard to get bibliographic entry for"
|
11
|
+
option :format, aliases: :f, desc: "Output format (xml, bibtex). Default xml."
|
11
12
|
option :year, aliases: :y, type: :numeric, desc: "Year the standard was published"
|
12
13
|
|
13
14
|
def fetch(code)
|
@@ -72,16 +73,7 @@ module Relaton
|
|
72
73
|
Relaton::Cli::XMLConvertor.to_html(file, style, template)
|
73
74
|
end
|
74
75
|
|
75
|
-
|
76
|
-
# option :stylesheet, aliases: :s, desc: "Stylesheet file path for rendering HTML index"
|
77
|
-
# option :templatedir, aliases: :t, desc: "Liquid template directory for rendering Relaton items and collection"
|
78
|
-
# option :overwrite, aliases: :f, type: :boolean, default: false, desc: "Overwrite the existing file"
|
79
|
-
|
80
|
-
# def yaml2html(file, style = nil, template = nil)
|
81
|
-
# Relaton::Cli::YAMLConvertor.to_html(file, style, template)
|
82
|
-
# end
|
83
|
-
|
84
|
-
desc "yaml2htmlnew RELATON-INDEX-YAML", "Concatenate Relaton Collection YAML into HTML"
|
76
|
+
desc "yaml2html RELATON-INDEX-YAML", "Concatenate Relaton Collection YAML into HTML"
|
85
77
|
option :stylesheet, aliases: :s, desc: "Stylesheet file path for rendering HTML index"
|
86
78
|
option :templatedir, aliases: :t, desc: "Liquid template directory for rendering Relaton items and collection"
|
87
79
|
option :overwrite, aliases: :f, type: :boolean, default: false, desc: "Overwrite the existing file"
|
@@ -92,10 +84,19 @@ module Relaton
|
|
92
84
|
|
93
85
|
private
|
94
86
|
|
87
|
+
# @param code [String]
|
88
|
+
# @param options [Hash]
|
89
|
+
# @option options [String] :type
|
90
|
+
# @option options [String, NilClass] :format
|
91
|
+
# @option options [Integer, NilClass] :year
|
95
92
|
def fetch_document(code, options)
|
96
93
|
if registered_types.include?(options[:type])
|
97
94
|
doc = Cli.relaton.fetch(code, options[:year]&.to_s)
|
98
|
-
|
95
|
+
if doc
|
96
|
+
options[:format] == "bibtex" ? doc.to_bibtex : doc.to_xml
|
97
|
+
else
|
98
|
+
"No matching bibliographic entry found"
|
99
|
+
end
|
99
100
|
end
|
100
101
|
rescue RelatonBib::RequestError => e
|
101
102
|
e.message
|
@@ -137,15 +137,19 @@ module Relaton
|
|
137
137
|
def concatenate_files
|
138
138
|
xml_files = [convert_rxl_to_xml, convert_yamls_to_xml, convert_xml_to_xml]
|
139
139
|
|
140
|
-
xml_files.flatten.
|
140
|
+
xml_files.flatten.reduce([]) do |mem, xml|
|
141
141
|
doc = nokogiri_document(xml[:content])
|
142
|
-
if (
|
142
|
+
if (refs = doc.xpath("//rfc//reference")).any?
|
143
143
|
require "relaton_ietf/scrapper"
|
144
|
-
|
145
|
-
|
146
|
-
|
144
|
+
mem + refs.map do |rfc|
|
145
|
+
ietf = RelatonIetf::Scrapper.fetch_rfc rfc
|
146
|
+
d = nokogiri_document ietf.to_xml(bibdata: true)
|
147
|
+
bibdata_instance(d, xml[:file])
|
148
|
+
end
|
149
|
+
elsif doc&.root&.name == "bibdata"
|
150
|
+
mem << bibdata_instance(doc, xml[:file])
|
151
|
+
else mem
|
147
152
|
end
|
148
|
-
bibdata_instance(doc, xml[:file]) if doc&.root&.name == "bibdata"
|
149
153
|
end.compact
|
150
154
|
end
|
151
155
|
|
data/lib/relaton/cli/version.rb
CHANGED
data/relaton-cli.gemspec
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path("../lib", __FILE__)
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require "relaton/cli/version"
|
5
4
|
|
@@ -35,7 +34,7 @@ Gem::Specification.new do |spec|
|
|
35
34
|
spec.add_development_dependency "simplecov"
|
36
35
|
|
37
36
|
spec.add_runtime_dependency "liquid"
|
38
|
-
spec.add_runtime_dependency "relaton", "~>
|
37
|
+
spec.add_runtime_dependency "relaton", "~> 1.1.0"
|
39
38
|
spec.add_runtime_dependency "thor"
|
40
39
|
# spec.add_runtime_dependency 'byebug'
|
41
40
|
end
|
data/templates/_document.liquid
CHANGED
@@ -32,12 +32,17 @@
|
|
32
32
|
</h{{ depth | plus: 1 }}>
|
33
33
|
</div>
|
34
34
|
|
35
|
-
<div class="doc-info {{ document.docstatus.stage | downcase }}">
|
36
|
-
<div class="doc-stage {{ document.docstatus.stage | downcase }}">
|
37
|
-
{{ document.docstatus.stage }}
|
35
|
+
<div class="doc-info {{ document.docstatus.stage.value | downcase }}">
|
36
|
+
<div class="doc-stage {{ document.docstatus.stage.value | downcase }}">
|
37
|
+
{{ document.docstatus.stage.abbreviation }}
|
38
|
+
{% if document.docstatus.substage %}
|
39
|
+
{{ document.docstatus.stage.value }}.{{ document.docstatus.substage.value }}
|
40
|
+
{% else %}
|
41
|
+
{{ document.docstatus.stage.value }}
|
42
|
+
{% endif %}
|
38
43
|
</div>
|
39
44
|
<div class="doc-dates">
|
40
|
-
{% unless document.docstatus.stage == "published" %}
|
45
|
+
{% unless document.docstatus.stage.value == "published" %}
|
41
46
|
<div class="doc-updated">
|
42
47
|
{% else %}
|
43
48
|
<div class="doc-published">
|
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:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
173
|
+
version: 1.1.0
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
180
|
+
version: 1.1.0
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: thor
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -223,8 +223,6 @@ files:
|
|
223
223
|
- lib/relaton/bibcollection.rb
|
224
224
|
- lib/relaton/bibdata.rb
|
225
225
|
- lib/relaton/cli.rb
|
226
|
-
- lib/relaton/cli/_document.liquid
|
227
|
-
- lib/relaton/cli/_index.liquid
|
228
226
|
- lib/relaton/cli/base_convertor.rb
|
229
227
|
- lib/relaton/cli/command.rb
|
230
228
|
- lib/relaton/cli/relaton_file.rb
|
@@ -1,82 +0,0 @@
|
|
1
|
-
{%- if document.items.size > 0 -%}
|
2
|
-
<div class="doc-section">
|
3
|
-
{%- else -%}
|
4
|
-
<div class="document">
|
5
|
-
{%- endif -%}
|
6
|
-
|
7
|
-
<div class="doc-line">
|
8
|
-
<div class="doc-identifier">
|
9
|
-
<h{{ depth }}>
|
10
|
-
{% if document.html == "" %}
|
11
|
-
{{ document.docid.id }}
|
12
|
-
{% else %}
|
13
|
-
<a href="{{ document.html }}">{{ document.docid.id }}</a>
|
14
|
-
{% endif %}
|
15
|
-
</h{{ depth }}>
|
16
|
-
</div>
|
17
|
-
|
18
|
-
<div class="doc-type-wrap">
|
19
|
-
<div class="doc-type {{ document.type | downcase | split: " " | join: "-" }}">
|
20
|
-
{{ document.type }}
|
21
|
-
</div>
|
22
|
-
</div>
|
23
|
-
</div>
|
24
|
-
|
25
|
-
<div class="doc-title">
|
26
|
-
<h{{ depth | plus: 1 }}>
|
27
|
-
{% if document.html == blank or document.html == nil %}
|
28
|
-
{{ document.title }}
|
29
|
-
{% else %}
|
30
|
-
<a href="{{ document.html }}">{{ document.title }}</a>
|
31
|
-
{% endif %}
|
32
|
-
</h{{ depth | plus: 1 }}>
|
33
|
-
</div>
|
34
|
-
|
35
|
-
<div class="doc-info {{ document.docstatus.stage | downcase }}">
|
36
|
-
<div class="doc-stage {{ document.docstatus.stage | downcase }}">
|
37
|
-
{{ document.docstatus.stage }}
|
38
|
-
</div>
|
39
|
-
<div class="doc-dates">
|
40
|
-
{% unless document.docstatus.stage == "published" %}
|
41
|
-
<div class="doc-updated">
|
42
|
-
{% else %}
|
43
|
-
<div class="doc-published">
|
44
|
-
{% endunless %}
|
45
|
-
{{ document.revdate }}
|
46
|
-
</div>
|
47
|
-
</div>
|
48
|
-
</div>
|
49
|
-
|
50
|
-
<div class="doc-bib">
|
51
|
-
<div class="doc-bib-relaton">
|
52
|
-
<a href="{{ document.relaton }}">Relaton XML</a>
|
53
|
-
</div>
|
54
|
-
</div>
|
55
|
-
|
56
|
-
<div class="doc-access">
|
57
|
-
{% unless document.html == blank or document.html == nil %}
|
58
|
-
<div class="doc-access-button-html">
|
59
|
-
<a href="{{ document.html }}">HTML</a>
|
60
|
-
</div>
|
61
|
-
{% endunless %}
|
62
|
-
{% unless document.pdf == blank or document.pdf == nil %}
|
63
|
-
<div class="doc-access-button-pdf">
|
64
|
-
<a href="{{ document.pdf }}">PDF</a>
|
65
|
-
</div>
|
66
|
-
{% endunless %}
|
67
|
-
{% unless document.doc == blank or document.doc == nil %}
|
68
|
-
<div class="doc-access-button-doc">
|
69
|
-
<a href="{{ document.doc }}">Word</a>
|
70
|
-
</div>
|
71
|
-
{% endunless %}
|
72
|
-
{% unless document.xml == blank or document.xml == nil %}
|
73
|
-
<div class="doc-access-button-xml">
|
74
|
-
<a href="{{ document.xml }}">XML</a>
|
75
|
-
</div>
|
76
|
-
{% endunless %}
|
77
|
-
</div>
|
78
|
-
</div>
|
79
|
-
|
80
|
-
{%- if document.items.size > 0 -%}
|
81
|
-
{%- include 'document' for document.items -%}
|
82
|
-
{%- endif -%}
|
@@ -1,53 +0,0 @@
|
|
1
|
-
<!DOCTYPE HTML>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>{{ title }}</title>
|
5
|
-
<style>
|
6
|
-
<!--
|
7
|
-
{{ css }}
|
8
|
-
-->
|
9
|
-
</style>
|
10
|
-
<meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
|
11
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript"></script>
|
12
|
-
<script src="https://cdn.rawgit.com/jgallen23/toc/0.3.2/dist/toc.min.js" type="text/javascript"></script>
|
13
|
-
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i|Space+Mono:400,700|Overpass:300,300i,600,900|Ek+Mukta:200" rel="stylesheet" type="text/css"/>
|
14
|
-
<link href="https://use.fontawesome.com/releases/v5.0.8/css/solid.css" integrity="sha384-v2Tw72dyUXeU3y4aM2Y0tBJQkGfplr39mxZqlTBDUZAb9BGoC40+rdFCG0m10lXk" crossorigin="anonymous"/>
|
15
|
-
<link href="https://use.fontawesome.com/releases/v5.0.8/css/fontawesome.css" integrity="sha384-q3jl8XQu1OpdLgGFvNRnPdj5VIlCvgsDQTQB6owSOHWlAurxul7f+JpUOVdAiJ5P" crossorigin="anonymous"/>
|
16
|
-
</head>
|
17
|
-
<body>
|
18
|
-
<header>
|
19
|
-
<div id="topbar-inner">
|
20
|
-
<div id="title-bar"><span>{{ author }}</span></div>
|
21
|
-
</div>
|
22
|
-
<div class="title-section">
|
23
|
-
<div class="coverpage">
|
24
|
-
<div class="wrapper-top">
|
25
|
-
<div class="coverpage-doc-identity">
|
26
|
-
<div class="coverpage-title"><span class="title-first">{{ title }}</span></div>
|
27
|
-
</div>
|
28
|
-
</div>
|
29
|
-
</div>
|
30
|
-
</div>
|
31
|
-
</header>
|
32
|
-
<main class="main-section">
|
33
|
-
{% include 'document' for documents %}
|
34
|
-
</main>
|
35
|
-
<footer>
|
36
|
-
<div class="copyright">
|
37
|
-
<p class="year">© {{ author }}</p>
|
38
|
-
<p class="message">All rights reserved. Unless otherwise specified, no part of this publication may be reproduced or utilized otherwise in any form or by any means, electronic or mechanical, including photocopying, or posting on the internet or an intranet, without prior written permission.</p>
|
39
|
-
</div>
|
40
|
-
</footer>
|
41
|
-
<script>
|
42
|
-
$(document).ready(function() {
|
43
|
-
$('[id^=toc]').each(function () {
|
44
|
-
var currentToc = $(this);
|
45
|
-
var url = window.location.href;
|
46
|
-
currentToc.wrap("<a href='" + url + "#" + currentToc.attr("id") + "' <\/a>");
|
47
|
-
});
|
48
|
-
});
|
49
|
-
anchors.options = { placement: 'left' };
|
50
|
-
anchors.add('h1, h2, h3, h4');
|
51
|
-
</script>
|
52
|
-
</body>
|
53
|
-
</html>
|