relaton-iso-bib 1.16.1 → 1.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.adoc +13 -4
- data/grammars/basicdoc.rng +18 -2
- data/grammars/biblio.rng +1 -0
- data/lib/relaton_iso_bib/document_type.rb +32 -0
- data/lib/relaton_iso_bib/hash_converter.rb +47 -42
- data/lib/relaton_iso_bib/iso_bibliographic_item.rb +7 -29
- data/lib/relaton_iso_bib/version.rb +1 -1
- data/lib/relaton_iso_bib.rb +1 -0
- data/relaton_iso_bib.gemspec +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c20b36a2a29b65da5e78b52c28b6f67ad8b219a73f932121d845cf7a1299e1e6
|
4
|
+
data.tar.gz: b3d573c7dea77922baf318b9c291f2572b74118fb677c33fa71e469db5ad46a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d61d22e7b2cb5077541d9b67cc6f1c07c92512788f6ee400fec0789b2af832dd2f069e72d6c1a20d7e3da72f665571e1e776dad3423b82edcaf8db6523e6a6f7
|
7
|
+
data.tar.gz: 8901e4722edb16249d04cf4dc49a1d1a6ec8bef9276854a89bacedd47c1fe0db523260b66d9577bd3ce50354760c2fe09308a28e3e5e151d4b1c06914bfd631b
|
data/README.adoc
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
= RelatonIsoBib
|
2
2
|
|
3
3
|
image:https://img.shields.io/gem/v/relaton-iso-bib.svg["Gem Version", link="https://rubygems.org/gems/relaton-iso-bib"]
|
4
|
-
image:https://github.com/relaton/relaton-iso-bib/workflows/
|
5
|
-
image:https://github.com/relaton/relaton-iso-bib/workflows/windows/badge.svg["Build Status (Windows)", link="https://github.com/relaton/relaton-iso-bib/actions?workflow=windows"]
|
6
|
-
image:https://github.com/relaton/relaton-iso-bib/workflows/ubuntu/badge.svg["Build Status (Ubuntu)", link="https://github.com/relaton/relaton-iso-bib/actions?workflow=ubuntu"]
|
4
|
+
image:https://github.com/relaton/relaton-iso-bib/workflows/rake/badge.svg["Build Status (macOS)", link="https://github.com/relaton/relaton-iso-bib/actions?workflow=rake"]
|
7
5
|
image:https://codeclimate.com/github/relaton/relaton-iso-bib/badges/gpa.svg["Code Climate", link="https://codeclimate.com/github/relaton/relaton-iso-bib"]
|
8
6
|
image:https://img.shields.io/github/issues-pr-raw/relaton/relaton-iso-bib.svg["Pull Requests", link="https://github.com/relaton/relaton-iso-bib/pulls"]
|
9
7
|
image:https://img.shields.io/github/commits-since/relaton/relaton-iso-bib/latest.svg["Commits since latest",link="https://github.com/relaton/relaton-iso-bib/releases"]
|
@@ -29,13 +27,24 @@ Or install it yourself as:
|
|
29
27
|
|
30
28
|
== Usage
|
31
29
|
|
32
|
-
===
|
30
|
+
=== Configuration
|
31
|
+
|
32
|
+
Configuration is optional. The available option is `logger` which is a `Logger` instance. By default, the logger is `Logger.new($stderr)` with `Logger::WARN` level. To change the logger level, use `RelatonIsoBib.configure` block.
|
33
33
|
|
34
34
|
[source,ruby]
|
35
35
|
----
|
36
36
|
require 'relaton_iso_bib'
|
37
37
|
=> true
|
38
38
|
|
39
|
+
RelatonIsoBib.configure do |config|
|
40
|
+
config.logger.level = Logger::DEBUG
|
41
|
+
end
|
42
|
+
----
|
43
|
+
|
44
|
+
=== Create ISO bibliographic item
|
45
|
+
|
46
|
+
[source,ruby]
|
47
|
+
----
|
39
48
|
hash = YAML.load_file "spec/examples/iso_bib_item.yml"
|
40
49
|
=> {
|
41
50
|
"schema-version"=>"v1.0.0",
|
data/grammars/basicdoc.rng
CHANGED
@@ -346,6 +346,8 @@
|
|
346
346
|
<ref name="keyword"/>
|
347
347
|
<ref name="xref"/>
|
348
348
|
<ref name="hyperlink"/>
|
349
|
+
<ref name="index"/>
|
350
|
+
<ref name="index-xref"/>
|
349
351
|
</choice>
|
350
352
|
</oneOrMore>
|
351
353
|
</element>
|
@@ -623,6 +625,8 @@
|
|
623
625
|
<ref name="eref"/>
|
624
626
|
<ref name="xref"/>
|
625
627
|
<ref name="hyperlink"/>
|
628
|
+
<ref name="index"/>
|
629
|
+
<ref name="index-xref"/>
|
626
630
|
</choice>
|
627
631
|
</zeroOrMore>
|
628
632
|
</element>
|
@@ -636,6 +640,8 @@
|
|
636
640
|
<ref name="eref"/>
|
637
641
|
<ref name="xref"/>
|
638
642
|
<ref name="hyperlink"/>
|
643
|
+
<ref name="index"/>
|
644
|
+
<ref name="index-xref"/>
|
639
645
|
</choice>
|
640
646
|
</zeroOrMore>
|
641
647
|
</element>
|
@@ -648,6 +654,8 @@
|
|
648
654
|
<ref name="eref"/>
|
649
655
|
<ref name="xref"/>
|
650
656
|
<ref name="hyperlink"/>
|
657
|
+
<ref name="index"/>
|
658
|
+
<ref name="index-xref"/>
|
651
659
|
</choice>
|
652
660
|
</zeroOrMore>
|
653
661
|
</element>
|
@@ -655,7 +663,11 @@
|
|
655
663
|
<define name="keyword">
|
656
664
|
<element name="keyword">
|
657
665
|
<zeroOrMore>
|
658
|
-
<
|
666
|
+
<choice>
|
667
|
+
<ref name="PureTextElement"/>
|
668
|
+
<ref name="index"/>
|
669
|
+
<ref name="index-xref"/>
|
670
|
+
</choice>
|
659
671
|
</zeroOrMore>
|
660
672
|
</element>
|
661
673
|
</define>
|
@@ -676,7 +688,11 @@
|
|
676
688
|
<define name="strike">
|
677
689
|
<element name="strike">
|
678
690
|
<zeroOrMore>
|
679
|
-
<
|
691
|
+
<choice>
|
692
|
+
<ref name="PureTextElement"/>
|
693
|
+
<ref name="index"/>
|
694
|
+
<ref name="index-xref"/>
|
695
|
+
</choice>
|
680
696
|
</zeroOrMore>
|
681
697
|
</element>
|
682
698
|
</define>
|
data/grammars/biblio.rng
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
module RelatonIsoBib
|
2
|
+
class DocumentType < RelatonBib::DocumentType
|
3
|
+
DOCTYPES = %w[
|
4
|
+
international-standard technical-specification technical-report
|
5
|
+
publicly-available-specification international-workshop-agreement guide
|
6
|
+
amendment technical-corrigendum directive
|
7
|
+
].freeze
|
8
|
+
|
9
|
+
#
|
10
|
+
# Create a new DocumentType object.
|
11
|
+
#
|
12
|
+
# @param [String] type document type
|
13
|
+
# @param [String, nil] abbreviation type abbreviation
|
14
|
+
#
|
15
|
+
def initialize(type:, abbreviation: nil)
|
16
|
+
check_doctype type
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Check if type is valid.
|
22
|
+
#
|
23
|
+
# @param [String] type document type
|
24
|
+
#
|
25
|
+
def check_doctype(type)
|
26
|
+
unless DOCTYPES.include? type
|
27
|
+
Util.warn "WARNING: invalid doctype: `#{type}`"
|
28
|
+
Util.warn "Allowed doctypes are: `#{DOCTYPES.join('`, `')}`"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,52 +1,57 @@
|
|
1
1
|
module RelatonIsoBib
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
#
|
7
|
-
# Ovverides superclass's method
|
8
|
-
#
|
9
|
-
# @param item [Hash]
|
10
|
-
# @retirn [RelatonIsoBib::IsoBibliographicItem]
|
11
|
-
def bib_item(item)
|
12
|
-
IsoBibliographicItem.new(**item)
|
13
|
-
end
|
2
|
+
module HashConverter
|
3
|
+
include RelatonBib::HashConverter
|
4
|
+
extend self
|
14
5
|
|
15
|
-
|
16
|
-
# Ovverides superclass's method
|
17
|
-
#
|
18
|
-
# @param title [Hash]
|
19
|
-
# @return [RelatonBib::TypedTitleString]
|
20
|
-
def typed_title_strig(title)
|
21
|
-
RelatonBib::TypedTitleString.new(**title)
|
22
|
-
end
|
6
|
+
private
|
23
7
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
workgroup: RelatonBib.array(eg[:workgroup]),
|
33
|
-
secretariat: eg[:secretariat],
|
34
|
-
)
|
35
|
-
end
|
8
|
+
#
|
9
|
+
# Ovverides superclass's method
|
10
|
+
#
|
11
|
+
# @param item [Hash]
|
12
|
+
# @retirn [RelatonIsoBib::IsoBibliographicItem]
|
13
|
+
def bib_item(item)
|
14
|
+
IsoBibliographicItem.new(**item)
|
15
|
+
end
|
36
16
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
17
|
+
#
|
18
|
+
# Ovverides superclass's method
|
19
|
+
#
|
20
|
+
# @param title [Hash]
|
21
|
+
# @return [RelatonBib::TypedTitleString]
|
22
|
+
def typed_title_strig(title)
|
23
|
+
RelatonBib::TypedTitleString.new(**title)
|
24
|
+
end
|
43
25
|
|
44
|
-
|
45
|
-
|
46
|
-
|
26
|
+
# @param ret [Hash]
|
27
|
+
def editorialgroup_hash_to_bib(ret)
|
28
|
+
eg = ret[:editorialgroup]
|
29
|
+
return unless eg
|
47
30
|
|
48
|
-
|
31
|
+
ret[:editorialgroup] = EditorialGroup.new(
|
32
|
+
technical_committee: RelatonBib.array(eg[:technical_committee]),
|
33
|
+
subcommittee: RelatonBib.array(eg[:subcommittee]),
|
34
|
+
workgroup: RelatonBib.array(eg[:workgroup]),
|
35
|
+
secretariat: eg[:secretariat],
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @param ret [Hash]
|
40
|
+
def ics_hash_to_bib(ret)
|
41
|
+
ret[:ics] = RelatonBib.array(ret[:ics]).map do |ics|
|
42
|
+
Ics.new(ics[:code] || ics)
|
49
43
|
end
|
50
44
|
end
|
45
|
+
|
46
|
+
# @param ret [Hash]
|
47
|
+
def structuredidentifier_hash_to_bib(ret)
|
48
|
+
return unless ret[:structuredidentifier]
|
49
|
+
|
50
|
+
ret[:structuredidentifier] = RelatonIsoBib::StructuredIdentifier.new(**ret[:structuredidentifier])
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_doctype(**args)
|
54
|
+
DocumentType.new(**args)
|
55
|
+
end
|
51
56
|
end
|
52
57
|
end
|
@@ -18,22 +18,16 @@ end
|
|
18
18
|
module RelatonIsoBib
|
19
19
|
# Bibliographic item.
|
20
20
|
class IsoBibliographicItem < RelatonBib::BibliographicItem
|
21
|
-
DOCTYPES = %w[
|
22
|
-
international-standard technical-specification technical-report
|
23
|
-
publicly-available-specification international-workshop-agreement guide
|
24
|
-
amendment technical-corrigendum directive
|
25
|
-
].freeze
|
26
|
-
|
27
21
|
SUBDOCTYPES = %w[specification method-of-test vocabulary code-of-practice].freeze
|
28
22
|
|
29
23
|
# @return [RelatonIsoBib::StructuredIdentifier]
|
30
24
|
attr_reader :structuredidentifier
|
31
25
|
|
32
|
-
#
|
33
|
-
|
26
|
+
# @return [String, nil]
|
27
|
+
attr_reader :stagename
|
34
28
|
|
35
|
-
#
|
36
|
-
|
29
|
+
# @!attribute [r] subdoctype
|
30
|
+
# @return [RelatonIsoBib::DocumentType]
|
37
31
|
|
38
32
|
# @return [Boolean, nil]
|
39
33
|
attr_reader :horizontal
|
@@ -64,18 +58,13 @@ module RelatonIsoBib
|
|
64
58
|
# @param classification [RelatonBib::Classification, NilClass]
|
65
59
|
# @param validity [RelatonBib:Validity, NilClass]
|
66
60
|
# @param docid [Array<RelatonBib::DocumentIdentifier>]
|
67
|
-
# @param doctype [
|
61
|
+
# @param doctype [RelatonIsoBib::DocumentType]
|
68
62
|
# @param subdoctype [String, nil]
|
69
63
|
# @param horizontal [Boolean, nil]
|
70
64
|
# @param structuredidentifier [RelatonIsoBib::StructuredIdentifier]
|
71
65
|
# @param stagename [String, NilClass]
|
72
66
|
#
|
73
|
-
# @param title [Array<Hash
|
74
|
-
# @option title [String] :title_intro
|
75
|
-
# @option title [String] :title_main
|
76
|
-
# @option title [String] :title_part
|
77
|
-
# @option title [String] :language
|
78
|
-
# @option title [String] :script
|
67
|
+
# @param title [Array<Hash, RelatonBib::TypedTitleString>, RelatonBib::TypedTitleStringCollection]
|
79
68
|
#
|
80
69
|
# @param editorialgroup [Hash, RelatonIsoBib::EditorialGroup]
|
81
70
|
# @option workgrpup [String] :name
|
@@ -128,8 +117,6 @@ module RelatonIsoBib
|
|
128
117
|
#
|
129
118
|
# @raise [ArgumentError]
|
130
119
|
def initialize(**args)
|
131
|
-
check_doctype args[:doctype]
|
132
|
-
|
133
120
|
args[:type] ||= "standard"
|
134
121
|
arg_names = %i[
|
135
122
|
id title docnumber language script docstatus date abstract contributor
|
@@ -183,7 +170,7 @@ module RelatonIsoBib
|
|
183
170
|
if block_given? then yield b
|
184
171
|
elsif opts[:bibdata] && has_ext_attrs?
|
185
172
|
ext = b.ext do
|
186
|
-
|
173
|
+
doctype.to_xml b if doctype
|
187
174
|
b.subdoctype subdoctype if subdoctype
|
188
175
|
b.horizontal horizontal unless horizontal.nil?
|
189
176
|
editorialgroup&.to_xml b
|
@@ -224,15 +211,6 @@ module RelatonIsoBib
|
|
224
211
|
|
225
212
|
private
|
226
213
|
|
227
|
-
# @param doctype [String]
|
228
|
-
# @raise ArgumentError
|
229
|
-
def check_doctype(doctype)
|
230
|
-
if doctype && !self.class::DOCTYPES.include?(doctype)
|
231
|
-
Util.warn "WARNING: invalid doctype: #{doctype}"
|
232
|
-
Util.warn "Allowed doctypes are: #{self.class::DOCTYPES.join(', ')}"
|
233
|
-
end
|
234
|
-
end
|
235
|
-
|
236
214
|
def makeid(id, attribute, _delim = "") # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
|
237
215
|
return nil if attribute && !@id_attribute
|
238
216
|
|
data/lib/relaton_iso_bib.rb
CHANGED
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.17.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: 2023-
|
11
|
+
date: 2023-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: isoics
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.17.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: 1.17.0
|
41
41
|
description: 'RelatonIsoBib: Ruby ISOXMLDOC impementation.'
|
42
42
|
email:
|
43
43
|
- open.source@ribose.com
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- grammars/relaton-iso.rng
|
65
65
|
- lib/relaton_iso_bib.rb
|
66
66
|
- lib/relaton_iso_bib/config.rb
|
67
|
+
- lib/relaton_iso_bib/document_type.rb
|
67
68
|
- lib/relaton_iso_bib/editorial_group.rb
|
68
69
|
- lib/relaton_iso_bib/hash_converter.rb
|
69
70
|
- lib/relaton_iso_bib/ics.rb
|