relaton-iso-bib 1.12.1 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +0 -1
- data/.github/workflows/release.yml +22 -0
- data/README.adoc +227 -243
- data/grammars/basicdoc.rng +3 -27
- data/grammars/biblio-standoc.rng +164 -0
- data/grammars/biblio.rng +90 -24
- data/grammars/relaton-iso-compile.rng +11 -0
- data/grammars/relaton-iso.rng +225 -0
- data/lib/relaton_iso_bib/editorial_group.rb +2 -2
- data/lib/relaton_iso_bib/iso_bibliographic_item.rb +32 -11
- data/lib/relaton_iso_bib/structured_identifier.rb +14 -14
- data/lib/relaton_iso_bib/version.rb +1 -1
- data/relaton_iso_bib.gemspec +1 -1
- metadata +8 -7
- data/grammars/isodoc.rng +0 -2781
- data/grammars/isostandard.rng +0 -514
- data/grammars/reqt.rng +0 -223
@@ -32,7 +32,7 @@ module RelatonIsoBib
|
|
32
32
|
# @option workgroup [String] :type
|
33
33
|
# @option workgroup [Integer] :number
|
34
34
|
#
|
35
|
-
# @param secretariat [String,
|
35
|
+
# @param secretariat [String, nil]
|
36
36
|
def initialize(technical_committee:, **args) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/AbcSize
|
37
37
|
@technical_committee = technical_committee.map do |tc|
|
38
38
|
tc.is_a?(Hash) ? RelatonBib::WorkGroup.new(**tc) : tc
|
@@ -58,7 +58,7 @@ module RelatonIsoBib
|
|
58
58
|
|
59
59
|
builder.editorialgroup do
|
60
60
|
technical_committee.each do |tc|
|
61
|
-
builder.send("technical-committee") { tc.to_xml builder }
|
61
|
+
builder.send(:"technical-committee") { tc.to_xml builder }
|
62
62
|
end
|
63
63
|
subcommittee.each do |sc|
|
64
64
|
builder.subcommittee { sc.to_xml builder }
|
@@ -21,7 +21,7 @@ end
|
|
21
21
|
module RelatonIsoBib
|
22
22
|
# Bibliographic item.
|
23
23
|
class IsoBibliographicItem < RelatonBib::BibliographicItem
|
24
|
-
|
24
|
+
DOCTYPES = %w[
|
25
25
|
international-standard technical-specification technical-report
|
26
26
|
publicly-available-specification international-workshop-agreement guide
|
27
27
|
amendment technical-corrigendum directive
|
@@ -133,17 +133,16 @@ module RelatonIsoBib
|
|
133
133
|
def initialize(**args)
|
134
134
|
check_doctype args[:doctype]
|
135
135
|
|
136
|
+
args[:type] ||= "standard"
|
136
137
|
arg_names = %i[
|
137
138
|
id title docnumber language script docstatus date abstract contributor
|
138
139
|
edition version relation biblionote series medium place copyright link
|
139
140
|
fetched docid formattedref extent accesslocation classification validity
|
140
|
-
editorialgroup doctype keyword
|
141
|
+
editorialgroup doctype keyword type
|
141
142
|
]
|
142
143
|
super_args = args.select { |k| arg_names.include? k }
|
143
144
|
super(**super_args)
|
144
145
|
|
145
|
-
@type = args[:type] || "standard"
|
146
|
-
|
147
146
|
if args[:editorialgroup]
|
148
147
|
@editorialgroup = if args[:editorialgroup].is_a?(Hash)
|
149
148
|
EditorialGroup.new(**args[:editorialgroup])
|
@@ -162,16 +161,31 @@ module RelatonIsoBib
|
|
162
161
|
@id_attribute = true
|
163
162
|
end
|
164
163
|
|
165
|
-
#
|
164
|
+
#
|
165
|
+
# Fetch the flavour schema version
|
166
|
+
#
|
167
|
+
# @return [String] flavour schema version
|
168
|
+
#
|
169
|
+
def ext_schema
|
170
|
+
@ext_schema ||= schema_versions["relaton-model-iso"]
|
171
|
+
end
|
172
|
+
|
173
|
+
#
|
174
|
+
# Render the document as an XML string.
|
175
|
+
#
|
176
|
+
# @param opts [Hash] options
|
166
177
|
# @option opts [Nokogiri::XML::Builder] :builder XML builder
|
167
|
-
# @option opts [Boolean] :bibdata
|
178
|
+
# @option opts [Boolean] :bibdata if true, bibdata element is created
|
179
|
+
# @option opts [Boolean] :embedded if true the document is embedded in another document
|
168
180
|
# @option opts [String] :lang language
|
181
|
+
#
|
169
182
|
# @return [String] XML
|
183
|
+
#
|
170
184
|
def to_xml(**opts)
|
171
185
|
super(**opts) do |b|
|
172
186
|
if block_given? then yield b
|
173
187
|
elsif opts[:bibdata] && has_ext_attrs?
|
174
|
-
b.ext do
|
188
|
+
ext = b.ext do
|
175
189
|
b.doctype doctype if doctype
|
176
190
|
b.subdoctype subdoctype if subdoctype
|
177
191
|
b.horizontal horizontal unless horizontal.nil?
|
@@ -180,6 +194,7 @@ module RelatonIsoBib
|
|
180
194
|
structuredidentifier&.to_xml b
|
181
195
|
b.stagename stagename if stagename
|
182
196
|
end
|
197
|
+
ext["schema-version"] = ext_schema unless opts[:embedded]
|
183
198
|
end
|
184
199
|
end
|
185
200
|
end
|
@@ -187,8 +202,14 @@ module RelatonIsoBib
|
|
187
202
|
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
188
203
|
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
189
204
|
|
190
|
-
#
|
191
|
-
|
205
|
+
#
|
206
|
+
# Render the document as HASH
|
207
|
+
#
|
208
|
+
# @param embedded [Boolean] true if the bibitem is embedded in another bibitem
|
209
|
+
#
|
210
|
+
# @return [Hash] the document as HAS
|
211
|
+
#
|
212
|
+
def to_hash(embedded: false)
|
192
213
|
hash = super
|
193
214
|
hash["horizontal"] = horizontal unless horizontal.nil?
|
194
215
|
hash["stagename"] = stagename if stagename
|
@@ -209,9 +230,9 @@ module RelatonIsoBib
|
|
209
230
|
# @param doctype [String]
|
210
231
|
# @raise ArgumentError
|
211
232
|
def check_doctype(doctype)
|
212
|
-
if doctype && !self.class::
|
233
|
+
if doctype && !self.class::DOCTYPES.include?(doctype)
|
213
234
|
warn "[relaton-iso-bib] WARNING: invalid doctype: #{doctype}"
|
214
|
-
warn "[relaton-iso-bib] Allowed doctypes are: #{self.class::
|
235
|
+
warn "[relaton-iso-bib] Allowed doctypes are: #{self.class::DOCTYPES.join(', ')}"
|
215
236
|
end
|
216
237
|
end
|
217
238
|
|
@@ -1,26 +1,26 @@
|
|
1
1
|
module RelatonIsoBib
|
2
2
|
# Document structured identifier.
|
3
3
|
class StructuredIdentifier
|
4
|
-
# @return [Integer,
|
4
|
+
# @return [Integer, nil]
|
5
5
|
attr_reader :tc_document_number
|
6
6
|
|
7
7
|
# @return [String]
|
8
8
|
attr_reader :project_number
|
9
9
|
|
10
|
-
# @return [Integer,
|
10
|
+
# @return [Integer, nil]
|
11
11
|
attr_reader :part
|
12
12
|
|
13
|
-
# @return [Integer,
|
13
|
+
# @return [Integer, nil]
|
14
14
|
attr_reader :subpart
|
15
15
|
|
16
|
-
# @return [String,
|
16
|
+
# @return [String, nil]
|
17
17
|
attr_reader :type
|
18
18
|
|
19
|
-
# @param tc_document_number [Integer,
|
19
|
+
# @param tc_document_number [Integer, nil]
|
20
20
|
# @param project_number [String]
|
21
|
-
# @param part [String,
|
22
|
-
# @param subpart [String,
|
23
|
-
# @param type [String,
|
21
|
+
# @param part [String, nil]
|
22
|
+
# @param subpart [String, nil]
|
23
|
+
# @param type [String, nil]
|
24
24
|
def initialize(**args)
|
25
25
|
@tc_document_number = args[:tc_document_number]
|
26
26
|
@project_number = args[:project_number]
|
@@ -50,7 +50,7 @@ module RelatonIsoBib
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def all_parts
|
53
|
-
@project_number = @project_number
|
53
|
+
@project_number = "#{@project_number} (all parts)"
|
54
54
|
end
|
55
55
|
|
56
56
|
def id
|
@@ -58,20 +58,20 @@ module RelatonIsoBib
|
|
58
58
|
end
|
59
59
|
|
60
60
|
# @param builder [Nokogiri::XML::Builder]
|
61
|
-
def to_xml(builder)
|
61
|
+
def to_xml(builder) # rubocop:disable Metrics/AbcSize
|
62
62
|
xml = builder.structuredidentifier do
|
63
|
-
pn = builder.send "project-number", project_number
|
63
|
+
pn = builder.send :"project-number", project_number
|
64
64
|
pn[:part] = part if part
|
65
65
|
pn[:subpart] = subpart if subpart
|
66
66
|
if tc_document_number
|
67
|
-
builder.send "tc-document-number", tc_document_number
|
67
|
+
builder.send :"tc-document-number", tc_document_number
|
68
68
|
end
|
69
69
|
end
|
70
70
|
xml[:type] = type if type
|
71
71
|
end
|
72
72
|
|
73
73
|
# @return [Hash]
|
74
|
-
def to_hash
|
74
|
+
def to_hash # rubocop:disable Metrics/AbcSize
|
75
75
|
hash = {}
|
76
76
|
hash["tc_document_number"] = tc_document_number if tc_document_number
|
77
77
|
hash["project_number"] = project_number if project_number
|
@@ -84,7 +84,7 @@ module RelatonIsoBib
|
|
84
84
|
# @param prefix [String]
|
85
85
|
# @return [String]
|
86
86
|
def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength
|
87
|
-
pref = prefix.empty? ? prefix : prefix
|
87
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
88
88
|
pref += "structured_identifier"
|
89
89
|
out = ""
|
90
90
|
if tc_document_number
|
data/relaton_iso_bib.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-iso-bib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.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: 2022-
|
11
|
+
date: 2022-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: equivalent-xml
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 1.
|
117
|
+
version: 1.14.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 1.
|
124
|
+
version: 1.14.0
|
125
125
|
description: 'RelatonIsoBib: Ruby ISOXMLDOC impementation.'
|
126
126
|
email:
|
127
127
|
- open.source@ribose.com
|
@@ -130,6 +130,7 @@ extensions: []
|
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
132
|
- ".github/workflows/rake.yml"
|
133
|
+
- ".github/workflows/release.yml"
|
133
134
|
- ".gitignore"
|
134
135
|
- ".rspec"
|
135
136
|
- ".rubocop.yml"
|
@@ -141,10 +142,10 @@ files:
|
|
141
142
|
- bin/rspec
|
142
143
|
- bin/setup
|
143
144
|
- grammars/basicdoc.rng
|
145
|
+
- grammars/biblio-standoc.rng
|
144
146
|
- grammars/biblio.rng
|
145
|
-
- grammars/
|
146
|
-
- grammars/
|
147
|
-
- grammars/reqt.rng
|
147
|
+
- grammars/relaton-iso-compile.rng
|
148
|
+
- grammars/relaton-iso.rng
|
148
149
|
- lib/relaton_iso_bib.rb
|
149
150
|
- lib/relaton_iso_bib/editorial_group.rb
|
150
151
|
- lib/relaton_iso_bib/hash_converter.rb
|