relaton-cli 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +13 -0
- data/.hound.yml +3 -0
- data/.rubocop.yml +2 -7
- data/.travis.yml +5 -0
- data/Gemfile.lock +31 -24
- data/README.adoc +77 -36
- data/bin/rspec +29 -0
- data/exe/relaton +21 -0
- data/lib/relaton/bibcollection.rb +27 -38
- data/lib/relaton/bibdata.rb +81 -18
- data/lib/relaton/cli/_document.liquid +2 -2
- data/lib/relaton/cli/base_convertor.rb +94 -0
- data/lib/relaton/cli/command.rb +83 -0
- data/lib/relaton/cli/relaton_file.rb +153 -0
- data/lib/relaton/cli/version.rb +1 -1
- data/lib/relaton/cli/xml_convertor.rb +41 -0
- data/lib/relaton/cli/xml_to_html_renderer.rb +4 -14
- data/lib/relaton/cli/yaml_convertor.rb +59 -0
- data/lib/relaton/cli.rb +21 -3
- data/relaton-cli.gemspec +9 -7
- data/templates/_document.liquid +7 -2
- data/templates/_index.liquid +53 -0
- metadata +31 -18
- data/.rubocop.ribose.yml +0 -66
- data/.rubocop.tb.yml +0 -650
- data/exe/relaton-concatenate +0 -24
- data/exe/relaton-fetch +0 -41
- data/exe/relaton-metanorma-extract +0 -20
- data/exe/relaton-xml-html +0 -28
- data/exe/relaton-yaml-xml +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acaf3abbad33304c0ab6dfb6be03a86d2d90e7746b494ddbd739c6a30643691d
|
4
|
+
data.tar.gz: a1c604c89f7543d7b73596384b5d851aa382900e4895ed81bc8c27ad4b83fd59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f11878522fda0aa839d51f9a50407ae94965a67b8dabce4cc36b00601b563da3574ce9d4fda42ffdc2d257ce7e3d7e0159f92f8335928eac14d893c7f3452ae1
|
7
|
+
data.tar.gz: b618737bbc2bee1605ecc4541ccc6b99edc34e3cbb5668dbe6aca63d6c0e23e47ca519877491b4728f771b13e8b03d9b8be4246f7b3b257fd2870cdab7957695
|
data/.gitignore
ADDED
data/.hound.yml
ADDED
data/.rubocop.yml
CHANGED
@@ -3,13 +3,8 @@
|
|
3
3
|
# All project-specific additions and overrides should be specified in this file.
|
4
4
|
|
5
5
|
inherit_from:
|
6
|
-
|
7
|
-
- ".rubocop.tb.yml"
|
8
|
-
# Overrides from Ribose
|
9
|
-
- ".rubocop.ribose.yml"
|
6
|
+
- https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
|
10
7
|
AllCops:
|
11
|
-
|
12
|
-
StyleGuideCopsOnly: false
|
13
|
-
TargetRubyVersion: 2.5
|
8
|
+
TargetRubyVersion: 2.3
|
14
9
|
Rails:
|
15
10
|
Enabled: true
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
relaton-cli (0.1.
|
4
|
+
relaton-cli (0.1.4)
|
5
5
|
liquid
|
6
|
-
relaton (~> 0.
|
7
|
-
|
6
|
+
relaton (~> 0.3)
|
7
|
+
thor
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
@@ -16,43 +16,49 @@ GEM
|
|
16
16
|
json (>= 1.5.1)
|
17
17
|
byebug (10.0.2)
|
18
18
|
cnccs (0.1.3)
|
19
|
+
coderay (1.1.2)
|
19
20
|
diff-lcs (1.3)
|
20
21
|
equivalent-xml (0.6.0)
|
21
22
|
nokogiri (>= 1.4.3)
|
22
|
-
gb-agencies (0.0.
|
23
|
-
gbbib (0.
|
23
|
+
gb-agencies (0.0.5)
|
24
|
+
gbbib (0.4.1)
|
24
25
|
cnccs (~> 0.1.1)
|
25
26
|
gb-agencies (~> 0.0.1)
|
26
|
-
iso-bib-item (~> 0.
|
27
|
+
iso-bib-item (~> 0.4.2)
|
27
28
|
httpclient (2.8.3)
|
28
|
-
iecbib (0.1
|
29
|
+
iecbib (0.2.1)
|
29
30
|
addressable
|
30
|
-
iso-bib-item (~> 0.
|
31
|
-
ietfbib (0.4.
|
32
|
-
iso-bib-item (~> 0.
|
33
|
-
iso-bib-item (0.3
|
31
|
+
iso-bib-item (~> 0.4.2)
|
32
|
+
ietfbib (0.4.3)
|
33
|
+
iso-bib-item (~> 0.4.2)
|
34
|
+
iso-bib-item (0.4.3)
|
34
35
|
isoics (~> 0.1.6)
|
35
36
|
nokogiri (~> 1.8.4)
|
36
37
|
ruby_deep_clone (~> 0.8.0)
|
37
|
-
isobib (0.
|
38
|
+
isobib (0.4.1)
|
38
39
|
algoliasearch
|
39
|
-
|
40
|
+
iecbib (~> 0.2.1)
|
41
|
+
iso-bib-item (~> 0.4.2)
|
40
42
|
isoics (0.1.7)
|
41
43
|
json (2.1.0)
|
42
|
-
liquid (4.0.
|
44
|
+
liquid (4.0.1)
|
45
|
+
method_source (0.9.2)
|
43
46
|
mini_portile2 (2.3.0)
|
44
47
|
mixlib-shellout (2.4.0)
|
45
|
-
nokogiri (1.8.
|
48
|
+
nokogiri (1.8.5)
|
46
49
|
mini_portile2 (~> 2.3.0)
|
50
|
+
pry (0.12.2)
|
51
|
+
coderay (~> 1.1.0)
|
52
|
+
method_source (~> 0.9.0)
|
47
53
|
public_suffix (3.0.3)
|
48
54
|
rake (12.3.1)
|
49
|
-
relaton (0.
|
55
|
+
relaton (0.3.0)
|
50
56
|
algoliasearch
|
51
|
-
gbbib (~> 0.
|
52
|
-
iecbib (~> 0.
|
53
|
-
ietfbib (~> 0.4.
|
54
|
-
iso-bib-item (~> 0.
|
55
|
-
isobib (~> 0.
|
57
|
+
gbbib (~> 0.4.0)
|
58
|
+
iecbib (~> 0.2.0)
|
59
|
+
ietfbib (~> 0.4.2)
|
60
|
+
iso-bib-item (~> 0.4.2)
|
61
|
+
isobib (~> 0.4.0)
|
56
62
|
rspec (3.8.0)
|
57
63
|
rspec-core (~> 3.8.0)
|
58
64
|
rspec-expectations (~> 3.8.0)
|
@@ -63,7 +69,7 @@ GEM
|
|
63
69
|
rspec-its (~> 1.2)
|
64
70
|
rspec-core (3.8.0)
|
65
71
|
rspec-support (~> 3.8.0)
|
66
|
-
rspec-expectations (3.8.
|
72
|
+
rspec-expectations (3.8.2)
|
67
73
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
74
|
rspec-support (~> 3.8.0)
|
69
75
|
rspec-its (1.2.0)
|
@@ -74,7 +80,7 @@ GEM
|
|
74
80
|
rspec-support (~> 3.8.0)
|
75
81
|
rspec-support (3.8.0)
|
76
82
|
ruby_deep_clone (0.8.0)
|
77
|
-
|
83
|
+
thor (0.20.3)
|
78
84
|
|
79
85
|
PLATFORMS
|
80
86
|
ruby
|
@@ -83,6 +89,7 @@ DEPENDENCIES
|
|
83
89
|
bundler (~> 1.16)
|
84
90
|
byebug (~> 10.0)
|
85
91
|
equivalent-xml (~> 0.6)
|
92
|
+
pry
|
86
93
|
rake (~> 12.0)
|
87
94
|
relaton-cli!
|
88
95
|
rspec (~> 3.0)
|
@@ -90,4 +97,4 @@ DEPENDENCIES
|
|
90
97
|
rspec-core (~> 3.4)
|
91
98
|
|
92
99
|
BUNDLED WITH
|
93
|
-
1.
|
100
|
+
1.17.1
|
data/README.adoc
CHANGED
@@ -12,52 +12,67 @@ Please refer to https://github.com/riboseinc/relaton.
|
|
12
12
|
|
13
13
|
The following executables are included:
|
14
14
|
|
15
|
-
=== relaton
|
15
|
+
=== relaton concatenate
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
[source,console]
|
18
|
+
----
|
19
|
+
$ relaton concatenate Source-Directory Collection-File -t TITLE -g ORGANIZATION
|
20
|
+
----
|
20
21
|
|
21
|
-
Iterates through all the Relaton YAML files in
|
22
|
+
Iterates through all the Relaton YAML files in `Source-Directory`, and converts them in-place into Relaton XML.
|
22
23
|
|
23
|
-
Iterates through all the Relaton XML files in
|
24
|
-
and outputs to
|
24
|
+
Iterates through all the Relaton XML files in `Source-Directory` (including those just converted from Relaton YAML),
|
25
|
+
and outputs to `Collection-File` a `relaton-collection` document containing all the Relaton XML objects read in.
|
25
26
|
|
26
|
-
|
27
|
+
For each Relaton XML file, if a document file with the same base name is identified (i.e. an XML, HTML, PDF or DOC
|
28
|
+
file), a link to that file is inserted.
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
-
```
|
30
|
+
If the `TITLE` or `ORGANIZATION` options are given, they are added to the `Collection-File` output as the
|
31
|
+
title and author of the `relaton-collection` document.
|
31
32
|
|
32
|
-
|
33
|
+
=== relaton fetch
|
34
|
+
|
35
|
+
[source,console]
|
36
|
+
----
|
37
|
+
$ relaton fetch CODE -t TYPE -y YEAR
|
38
|
+
----
|
39
|
+
|
40
|
+
Fetch the Relaton XML entry corresponding to the document identifier `CODE`.
|
33
41
|
|
34
42
|
* `YEAR` is optional, and specifies the year of publication of the standard.
|
35
|
-
* `TYPE` specifies the standards class library to be used, that the identifier is part of; the recognised
|
43
|
+
* `TYPE` specifies the standards class library to be used, that the identifier is part of; the recognised
|
36
44
|
values for `TYPE` are `isobib`, `ietfbib`, `iecbib`, `gbbib`.
|
37
45
|
|
38
|
-
=== relaton
|
46
|
+
=== relaton extract
|
39
47
|
|
40
|
-
|
41
|
-
|
42
|
-
|
48
|
+
[source,console]
|
49
|
+
----
|
50
|
+
$ relaton extract Metanorma-XML-Directory Relaton-XML-Directory -x EXTENSION
|
51
|
+
----
|
43
52
|
|
44
53
|
Iterate through all the Metanorma XML files in `Metanorma-XML-Directory`, and extract the `bibdata`
|
45
54
|
element from each. Save the `bibdata` element for each file to `Relaton-XML-Directory`, as the Relaton XML
|
46
55
|
description for that file. If a document identifier is present in `bibdata`, it is used as the name of the
|
47
|
-
file; otherwise, the original file name is used.
|
56
|
+
file; otherwise, the original file name is used. The filename is suffixed with `EXTENSION`; by default,
|
57
|
+
`.rxl` is used.
|
48
58
|
|
49
|
-
|
59
|
+
[[relaton-xml2html]]
|
60
|
+
=== relaton xml2html
|
50
61
|
|
51
|
-
|
52
|
-
|
53
|
-
|
62
|
+
[source,console]
|
63
|
+
----
|
64
|
+
$ relaton xml2html <relaton-xml> <stylesheet> <html-template-dir>
|
65
|
+
----
|
54
66
|
|
55
67
|
Render a Relaton Collection XML as an HTML file. Used to generate an HTML index of standards.
|
56
68
|
|
57
69
|
* `relaton-xml` is the Relaton Collection XML file.
|
58
70
|
* `stylesheet` is the CSS stylesheet to be used to style the output. For the CSS styling of each bibliographic element, see below.
|
59
|
-
* `
|
60
|
-
|
71
|
+
* `html-template-dir` is a directory containing HTML Liquid Template files into which the bibliographic entries are to be inserted. There is one file for the overall file (`_index.liquid_`), and one file for the individual bibliographic entries (`_document.liquid`). A sample instance of this directory is available in the `templates` directory.
|
72
|
+
|
73
|
+
The HTML Template file `_document.liquid` recognises attributes of a bibliographic entry (`document`) which follow the naming convention of <<relaton-yaml,Relaton YAML>>; e.g. `document.html` is the HTML URI for the document.
|
74
|
+
|
75
|
+
The HTML Template file `_index.liquid` recognises the following parameters:
|
61
76
|
** `css`: where the CSS stylesheet `stylesheet` is injected
|
62
77
|
** `title`: the Title of the collection, `./relaton-collection/title` in `relaton-xml`
|
63
78
|
** `author`: the Author of the collection, `./relaton-collection/contributor[role/@type = 'author']/organization/name` in `relaton-xml`
|
@@ -65,7 +80,8 @@ Render a Relaton Collection XML as an HTML file. Used to generate an HTML index
|
|
65
80
|
|
66
81
|
Sample HTML output for a bibliographic entry:
|
67
82
|
|
68
|
-
|
83
|
+
[source,xml]
|
84
|
+
----
|
69
85
|
<div class="document">
|
70
86
|
<div class="doc-line">
|
71
87
|
<div class="doc-identifier">
|
@@ -108,26 +124,29 @@ Sample HTML output for a bibliographic entry:
|
|
108
124
|
</div>
|
109
125
|
</div>
|
110
126
|
</div>
|
111
|
-
|
127
|
+
----
|
112
128
|
|
113
|
-
|
129
|
+
[[relaton-yaml]]
|
130
|
+
=== relaton yaml2xml
|
114
131
|
|
115
|
-
|
116
|
-
|
117
|
-
|
132
|
+
[source,console]
|
133
|
+
----
|
134
|
+
$ relaton yaml2xml YAML -o OUTPUT-DIRECTORY -x RELATON_EXTENSION -p PREFIX -r LIBRARY
|
135
|
+
----
|
118
136
|
|
119
|
-
Convert a Relaton YAML file into a Relaton
|
137
|
+
Convert a Relaton YAML file (`filename.yaml`) into a Relaton XML file (`filename.xml`). If the Relaton YAML file specifies multiple bibliograph 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.
|
120
138
|
|
121
|
-
|
139
|
+
A Relaton Colleciton YAML file contains some initial metadata, and a list of metadata about each bibliographic entry. A Relaton YAML file describing an individual bibliographic entry is limited to metadata specific to that entry. The following illustrates the fields supported:
|
122
140
|
|
123
|
-
|
141
|
+
[source,yaml]
|
142
|
+
----
|
124
143
|
htmlstylesheet: ./index-style.css
|
125
144
|
root:
|
126
145
|
title: CalConnect Standards Registry
|
127
146
|
author: "CalConnect: The Calendaring and Scheduling Consortium"
|
128
147
|
items:
|
129
148
|
- technical_committee: TC VCARD
|
130
|
-
|
149
|
+
docidentifier: 18001
|
131
150
|
doctype: standard
|
132
151
|
title: "Date and time -- Representations for information interchange -- Part 1: Basic rules"
|
133
152
|
stage: Published
|
@@ -138,11 +157,33 @@ root:
|
|
138
157
|
doc: standards/csd-datetime-explict/csd-datetime-explict.doc
|
139
158
|
relaton: standards/csd-datetime-explict/cc-18001.xml
|
140
159
|
- technical_committee: TC PUBLISH
|
141
|
-
|
160
|
+
docidentifier: 10001
|
142
161
|
doctype: governance
|
143
162
|
title: "Standardization and publication"
|
144
163
|
stage: proposal
|
145
164
|
revdate: 2018-10-17
|
146
165
|
uri: standards/csd-standardization/csd-standardization.xml
|
147
|
-
|
166
|
+
agency: CalConnect
|
167
|
+
language: en
|
168
|
+
script: Latn
|
169
|
+
edition: 1
|
170
|
+
----
|
171
|
+
|
172
|
+
=== relaton xml2yaml
|
173
|
+
|
174
|
+
[source,console]
|
175
|
+
----
|
176
|
+
$ relaton xml2yaml XML -o OUTPUT-DIRECTORY -x RELATON_EXTENSION -p PREFIX -r LIBRARY
|
177
|
+
----
|
178
|
+
|
179
|
+
Convert a Relaton XML file (`filename.xml` or `filename.rxl`) into a Relaton YAML file (`filename.yaml`). If the Relaton XML file is a collection, and `OUTPUT-DIRECTORY` is nominated, also convert the file into a list of Relaton YAML 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 `.yaml`) 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.
|
180
|
+
|
181
|
+
|
182
|
+
=== relaton yaml2html
|
183
|
+
|
184
|
+
[source,console]
|
185
|
+
----
|
186
|
+
$ relaton yaml2xml YAML <stylesheet> <liquid-template-dir>
|
187
|
+
----
|
148
188
|
|
189
|
+
Render a Relaton YAML file as an HTML file. The stylesheet and liquid-template-dir directories are as for <<relaton-xml2html,relaton xml2html>>.
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
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
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 150) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/exe/relaton
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
#
|
4
|
+
# resolve bin path, ignoring symlinks
|
5
|
+
require "pathname"
|
6
|
+
bin_file = Pathname.new(__FILE__).realpath
|
7
|
+
|
8
|
+
# add self to libpath
|
9
|
+
$:.unshift File.expand_path("../../lib", bin_file)
|
10
|
+
|
11
|
+
# Fixes https://github.com/rubygems/rubygems/issues/1420
|
12
|
+
require "rubygems/specification"
|
13
|
+
|
14
|
+
class Gem::Specification
|
15
|
+
def this; self; end
|
16
|
+
end
|
17
|
+
|
18
|
+
require "relaton/cli"
|
19
|
+
|
20
|
+
Relaton::Cli.start(ARGV)
|
21
|
+
|
@@ -20,58 +20,33 @@ module Relaton
|
|
20
20
|
def initialize(options)
|
21
21
|
self.items = []
|
22
22
|
ATTRIBS.each do |k|
|
23
|
-
method = "#{k}="
|
24
23
|
value = options[k] || options[k.to_s]
|
25
|
-
puts "K #{method}"
|
26
|
-
puts value.inspect
|
27
|
-
|
28
24
|
self.send("#{k}=", value)
|
29
|
-
puts "SET! to #{self.send(k).inspect}"
|
30
25
|
end
|
31
|
-
|
32
|
-
# puts items.inspect
|
33
26
|
self.items = (self.items || []).inject([]) do |acc,item|
|
34
27
|
acc << if item.is_a?(::Relaton::Bibcollection) ||
|
35
28
|
item.is_a?(::Relaton::Bibdata)
|
36
|
-
|
37
29
|
item
|
38
30
|
else
|
39
|
-
# puts "item.inspect #{item.inspect}"
|
40
31
|
new_bib_item_class(item)
|
41
32
|
end
|
42
33
|
end
|
43
|
-
|
44
34
|
self
|
45
|
-
# byebug
|
46
35
|
end
|
47
36
|
|
48
|
-
|
49
|
-
|
37
|
+
# arbitrary number, must sort after all bib items
|
38
|
+
def doc_number
|
39
|
+
9999999
|
40
|
+
end
|
50
41
|
|
42
|
+
def self.from_xml(source)
|
51
43
|
title = source&.at(ns("./relaton-collection/title"))&.text
|
52
44
|
author = source&.at(ns("./relaton-collection/contributor[role/@type = 'author']/organization/name"))&.text
|
53
|
-
|
54
|
-
puts "!!!!!!!!!!"*3
|
55
|
-
puts "BC: title #{title}"
|
56
|
-
puts "BC: author #{author}"
|
57
|
-
puts "!!!!!!!!!!"*3
|
58
|
-
|
59
|
-
items = source.xpath(ns("./relaton-collection/relation")).map do |item|
|
60
|
-
puts "========="*3
|
61
|
-
puts "item #{item.to_s}"
|
45
|
+
items = source&.xpath(ns("./relaton-collection/relation"))&.map do |item|
|
62
46
|
klass = item.at(ns("./bibdata")) ? Bibdata : Bibcollection
|
63
|
-
klass.from_xml(item.at(ns("./bibdata")))
|
47
|
+
klass.from_xml(item.at(ns("./bibdata")) || item)
|
64
48
|
end
|
65
|
-
|
66
|
-
opts = {
|
67
|
-
title: title,
|
68
|
-
author: author,
|
69
|
-
items: items
|
70
|
-
}
|
71
|
-
|
72
|
-
puts "X"*38
|
73
|
-
puts opts.inspect
|
74
|
-
puts "X"*38
|
49
|
+
opts = { title: title, author: author, items: items }
|
75
50
|
new(opts)
|
76
51
|
end
|
77
52
|
|
@@ -84,6 +59,9 @@ module Relaton
|
|
84
59
|
end
|
85
60
|
|
86
61
|
def items_flattened
|
62
|
+
items.sort_by! do |b|
|
63
|
+
b.doc_number
|
64
|
+
end
|
87
65
|
|
88
66
|
items.inject([]) do |acc,item|
|
89
67
|
if item.is_a? ::Relaton::Bibcollection
|
@@ -92,14 +70,17 @@ module Relaton
|
|
92
70
|
acc << item
|
93
71
|
end
|
94
72
|
end
|
95
|
-
|
96
73
|
end
|
97
74
|
|
98
75
|
def to_xml
|
76
|
+
items.sort_by! do |b|
|
77
|
+
b.doc_number
|
78
|
+
end
|
79
|
+
|
99
80
|
collection_type = if doctype
|
100
81
|
"type=\"#{doctype}\""
|
101
82
|
else
|
102
|
-
'xmlns="
|
83
|
+
'xmlns="https://open.ribose.com/relaton-xml"'
|
103
84
|
end
|
104
85
|
|
105
86
|
ret = "<relaton-collection #{collection_type}>"
|
@@ -117,15 +98,23 @@ module Relaton
|
|
117
98
|
ret += "</relaton-collection>\n"
|
118
99
|
end
|
119
100
|
|
101
|
+
def to_yaml
|
102
|
+
to_h.to_yaml
|
103
|
+
end
|
104
|
+
|
120
105
|
def to_h
|
106
|
+
items.sort_by! do |b|
|
107
|
+
b.doc_number
|
108
|
+
end
|
109
|
+
|
121
110
|
a = ATTRIBS.inject({}) do |acc, k|
|
122
|
-
acc[k] = send(k)
|
111
|
+
acc[k.to_s] = send(k)
|
123
112
|
acc
|
124
113
|
end
|
125
114
|
|
126
|
-
a[
|
115
|
+
a["items"] = a["items"].map(&:to_h)
|
127
116
|
|
128
|
-
a
|
117
|
+
{ "root" => a }
|
129
118
|
end
|
130
119
|
|
131
120
|
end
|