relaton-iso-bib 1.13.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,7 @@ end
21
21
  module RelatonIsoBib
22
22
  # Bibliographic item.
23
23
  class IsoBibliographicItem < RelatonBib::BibliographicItem
24
- TYPES = %w[
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
- # @param opts [Hash]
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
- # @return [Hash]
191
- def to_hash
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::TYPES.include?(doctype)
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::TYPES.join(', ')}"
235
+ warn "[relaton-iso-bib] Allowed doctypes are: #{self.class::DOCTYPES.join(', ')}"
215
236
  end
216
237
  end
217
238
 
@@ -1,3 +1,3 @@
1
1
  module RelatonIsoBib
2
- VERSION = "1.13.0".freeze
2
+ VERSION = "1.14.0".freeze
3
3
  end
@@ -36,5 +36,5 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency "simplecov"
37
37
 
38
38
  spec.add_dependency "isoics", "~> 0.1.6"
39
- spec.add_dependency "relaton-bib", "~> 1.13.0"
39
+ spec.add_dependency "relaton-bib", "~> 1.14.0"
40
40
  end
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.13.0
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-08-21 00:00:00.000000000 Z
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.13.0
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.13.0
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/isodoc.rng
146
- - grammars/isostandard.rng
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