relaton-iso-bib 0.9.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/grammars/basicdoc.rng +12 -56
- data/grammars/biblio.rng +144 -49
- data/grammars/isodoc.rng +592 -29
- data/grammars/isostandard.rng +145 -472
- data/lib/relaton_iso_bib/iso_bibliographic_item.rb +9 -4
- data/lib/relaton_iso_bib/version.rb +1 -1
- data/lib/relaton_iso_bib/xml_parser.rb +10 -17
- data/relaton_iso_bib.gemspec +5 -4
- metadata +4 -4
@@ -23,9 +23,9 @@ module RelatonIsoBib
|
|
23
23
|
# Bibliographic item.
|
24
24
|
class IsoBibliographicItem < RelatonBib::BibliographicItem
|
25
25
|
TYPES = %w[
|
26
|
-
standard
|
27
26
|
international-standard technical-specification technical-report
|
28
27
|
publicly-available-specification international-workshop-agreement guide
|
28
|
+
amendment technical-corrigendum
|
29
29
|
].freeze
|
30
30
|
|
31
31
|
# @return [RelatonIsoBib::StructuredIdentifier]
|
@@ -35,7 +35,7 @@ module RelatonIsoBib
|
|
35
35
|
# @return [Array<RelatonIsoBib::TypedTitleString>]
|
36
36
|
|
37
37
|
# @return [String, NilClass]
|
38
|
-
attr_reader :doctype
|
38
|
+
attr_reader :doctype, :stagename
|
39
39
|
|
40
40
|
# @return [RelatonIsoBib::EditorialGroup]
|
41
41
|
attr_reader :editorialgroup
|
@@ -67,6 +67,7 @@ module RelatonIsoBib
|
|
67
67
|
# @param validity [RelatonBib:Validity, NilClass]
|
68
68
|
# @param docid [Array<RelatonBib::DocumentIdentifier>]
|
69
69
|
# @param structuredidentifier [RelatonIsoBib::StructuredIdentifier]
|
70
|
+
# @param stagename [String, NilClass]
|
70
71
|
#
|
71
72
|
# @param title [Array<Hash>]
|
72
73
|
# @option title [String] :title_intro
|
@@ -134,7 +135,7 @@ module RelatonIsoBib
|
|
134
135
|
%i[id docnumber language script docstatus date abstract contributor
|
135
136
|
edition version relation biblionote series medium place copyright
|
136
137
|
link fetched docid formattedref extent accesslocation classification
|
137
|
-
validity].include? k
|
138
|
+
validity keyword].include? k
|
138
139
|
end
|
139
140
|
super super_args
|
140
141
|
|
@@ -158,6 +159,7 @@ module RelatonIsoBib
|
|
158
159
|
@structuredidentifier = args[:structuredidentifier]
|
159
160
|
@doctype ||= args[:doctype]
|
160
161
|
@ics = args.fetch(:ics, []).map { |i| i.is_a?(Hash) ? Ics.new(i) : i }
|
162
|
+
@stagename = args[:stagename]
|
161
163
|
@id_attribute = true
|
162
164
|
end
|
163
165
|
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity
|
@@ -243,7 +245,8 @@ module RelatonIsoBib
|
|
243
245
|
end
|
244
246
|
super builder, **opts do |b|
|
245
247
|
if opts[:bibdata] && (doctype || respond_to?(:committee) && committee ||
|
246
|
-
editorialgroup || ics.any? || structuredidentifier ||
|
248
|
+
editorialgroup || ics.any? || structuredidentifier || stagename ||
|
249
|
+
block_given?)
|
247
250
|
b.ext do
|
248
251
|
b.doctype doctype if doctype
|
249
252
|
b.docsubtype docsubtype if respond_to?(:docsubtype) && docsubtype
|
@@ -255,6 +258,7 @@ module RelatonIsoBib
|
|
255
258
|
end
|
256
259
|
ics.each { |i| i.to_xml b }
|
257
260
|
structuredidentifier&.to_xml b
|
261
|
+
b.stagename stagename if stagename
|
258
262
|
yield b if block_given?
|
259
263
|
end
|
260
264
|
end
|
@@ -268,6 +272,7 @@ module RelatonIsoBib
|
|
268
272
|
hash["ics"] = single_element_array(ics) if ics&.any?
|
269
273
|
hash["structuredidentifier"] = structuredidentifier.to_hash if structuredidentifier
|
270
274
|
hash["doctype"] = doctype if doctype
|
275
|
+
hash["stagename"] = stagename if stagename
|
271
276
|
hash
|
272
277
|
end
|
273
278
|
|
@@ -3,20 +3,6 @@ require "nokogiri"
|
|
3
3
|
module RelatonIsoBib
|
4
4
|
class XMLParser < RelatonBib::XMLParser
|
5
5
|
class << self
|
6
|
-
# Override RelatonBib::XMLParser.form_xml method.
|
7
|
-
# @param xml [String]
|
8
|
-
# @return [RelatonIsoBib::IsoBibliographicItem]
|
9
|
-
def from_xml(xml)
|
10
|
-
doc = Nokogiri::XML(xml)
|
11
|
-
doc.remove_namespaces!
|
12
|
-
isoitem = doc.at "/bibitem|/bibdata"
|
13
|
-
if isoitem
|
14
|
-
IsoBibliographicItem.new item_data(isoitem)
|
15
|
-
else
|
16
|
-
warn "[relato-iso-bib] can't find bibitem or bibdata element in the XML"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
6
|
private
|
21
7
|
|
22
8
|
# Override RelatonBib::XMLParser.item_data method.
|
@@ -31,9 +17,17 @@ module RelatonIsoBib
|
|
31
17
|
data[:editorialgroup] = fetch_editorialgroup ext
|
32
18
|
data[:ics] = fetch_ics ext
|
33
19
|
data[:structuredidentifier] = fetch_structuredidentifier ext
|
20
|
+
data[:stagename] = ext.at("./stagename")&.text
|
34
21
|
data
|
35
22
|
end
|
36
23
|
|
24
|
+
# override RelatonBib::BibliographicItem.bib_item method
|
25
|
+
# @param item_hash [Hash]
|
26
|
+
# @return [RelatonIsoBib::IsoBibliographicItem]
|
27
|
+
def bib_item(item_hash)
|
28
|
+
IsoBibliographicItem.new item_hash
|
29
|
+
end
|
30
|
+
|
37
31
|
# @param ext [Nokogiri::XML::Element]
|
38
32
|
# @return [RelatonIsoBib::StructuredIdentifier]
|
39
33
|
def fetch_structuredidentifier(ext)
|
@@ -77,9 +71,8 @@ module RelatonIsoBib
|
|
77
71
|
sc = eg&.xpath("subcommittee")&.map { |s| iso_subgroup(s) }
|
78
72
|
wg = eg&.xpath("workgroup")&.map { |w| iso_subgroup(w) }
|
79
73
|
sr = eg&.at "secretariat"
|
80
|
-
EditorialGroup.new(
|
81
|
-
|
82
|
-
)
|
74
|
+
EditorialGroup.new(technical_committee: tc, subcommittee: sc,
|
75
|
+
workgroup: wg, secretariat: sr&.text)
|
83
76
|
end
|
84
77
|
|
85
78
|
# @param com [Nokogiri::XML::Element]
|
data/relaton_iso_bib.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
lib = File.expand_path("
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
require "relaton_iso_bib/version"
|
6
6
|
|
@@ -16,8 +16,9 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.license = "BSD-2-Clause"
|
17
17
|
|
18
18
|
# Specify which files should be added to the gem when it is released.
|
19
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added
|
20
|
-
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added
|
20
|
+
# into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
21
22
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
23
|
end
|
23
24
|
spec.bindir = "exe"
|
@@ -35,5 +36,5 @@ Gem::Specification.new do |spec|
|
|
35
36
|
spec.add_development_dependency "simplecov"
|
36
37
|
|
37
38
|
spec.add_dependency "isoics", "~> 0.1.6"
|
38
|
-
spec.add_dependency "relaton-bib", "~>
|
39
|
+
spec.add_dependency "relaton-bib", "~> 1.1.0"
|
39
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:
|
4
|
+
version: 1.1.1
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: debase
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 1.1.0
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 1.1.0
|
153
153
|
description: 'RelatonIsoBib: Ruby ISOXMLDOC impementation.'
|
154
154
|
email:
|
155
155
|
- open.source@ribose.com
|