iso-bib-item 0.1.11 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +10 -1
- data/README.adoc +1 -0
- data/lib/iso_bib_item/bibliographic_date.rb +15 -3
- data/lib/iso_bib_item/bibliographic_item.rb +10 -5
- data/lib/iso_bib_item/document_relation_collection.rb +4 -3
- data/lib/iso_bib_item/from_xml.rb +131 -16
- data/lib/iso_bib_item/iso_bibliographic_item.rb +39 -18
- data/lib/iso_bib_item/iso_document_status.rb +49 -30
- data/lib/iso_bib_item/iso_project_group.rb +34 -7
- data/lib/iso_bib_item/organization.rb +2 -1
- data/lib/iso_bib_item/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fa989f9c13fbb68e055a71c3e69b85c1aaaa2659ab20065bd3b07ac24154e47
|
4
|
+
data.tar.gz: 953d20175ece7b483a185dbd48028f03f99dafd39fa0d7467e7feebe202c5aa6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca6ac6fc0f254f5932c4c2a1704e628e7aeab626804def141c900d9d778b195683c261074ac2ecd3652fef5ea394f82f2476f8c2d866b6ddb6aa54cc807def9d
|
7
|
+
data.tar.gz: e984e55d216273d9b5db76e71135e33b02ea04e9cef07a5ac9651f0a326dc1646b0e6bcec4313f7bc59bd90deac41de5ea8053bda957266f4f93d8db6c65e47f
|
data/.travis.yml
CHANGED
data/README.adoc
CHANGED
@@ -23,9 +23,9 @@ module IsoBibItem
|
|
23
23
|
def initialize(type:, on: nil, from: nil, to: nil)
|
24
24
|
raise ArgumentError, 'expected :on or :form argument' unless on || from
|
25
25
|
@type = type
|
26
|
-
@on =
|
27
|
-
@from =
|
28
|
-
@to =
|
26
|
+
@on = parse_date on
|
27
|
+
@from = parse_date from
|
28
|
+
@to = parse_date to
|
29
29
|
end
|
30
30
|
|
31
31
|
# rubocop:disable Metric/AbcSize
|
@@ -43,5 +43,17 @@ module IsoBibItem
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
# rubocop:enable Metric/AbcSize
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
# @params date [String] 'yyyy' or 'yyyy-mm'
|
50
|
+
def parse_date(date)
|
51
|
+
return unless date
|
52
|
+
if date =~ /\d{4}/
|
53
|
+
Time.strptime date, '%Y'
|
54
|
+
else
|
55
|
+
Time.strptime date, '%Y-%m'
|
56
|
+
end
|
57
|
+
end
|
46
58
|
end
|
47
59
|
end
|
@@ -59,7 +59,9 @@ module IsoBibItem
|
|
59
59
|
# @param from [String] date
|
60
60
|
# @param to [String] date
|
61
61
|
def initialize(owner:, from:, to: nil)
|
62
|
-
@owner =
|
62
|
+
@owner = if owner.is_a?(Hash)
|
63
|
+
ContributionInfo.new entity: Organization.new(owner)
|
64
|
+
else owner end
|
63
65
|
@from = Time.strptime(from, '%Y') unless from.empty?
|
64
66
|
@to = Time.parse(to) if to
|
65
67
|
end
|
@@ -169,18 +171,21 @@ module IsoBibItem
|
|
169
171
|
d.is_a?(Hash) ? BibliographicDate.new(d) : d
|
170
172
|
end
|
171
173
|
@contributors = (args[:contributors] || []).map do |c|
|
172
|
-
|
173
|
-
|
174
|
+
if c.is_a? Hash
|
175
|
+
e = c[:entity].is_a?(Hash) ? Organization.new(c[:entity]) : c[:entity]
|
176
|
+
ContributionInfo.new(entity: e, role: c[:roles])
|
177
|
+
else c
|
178
|
+
end
|
174
179
|
end
|
175
180
|
@notes = []
|
176
181
|
@language = args[:language]
|
177
182
|
@script = args[:script]
|
178
183
|
@status = args[:docstatus]
|
179
184
|
@abstract = (args[:abstract] || []).map do |a|
|
180
|
-
FormattedString.new(a)
|
185
|
+
a.is_a?(Hash) ? FormattedString.new(a) : a
|
181
186
|
end
|
182
187
|
@relations = DocRelationCollection.new(args[:relations] || [])
|
183
|
-
@link = args[:link].map { |s| TypedUri.new(s) }
|
188
|
+
@link = args[:link].map { |s| s.is_a?(Hash) ? TypedUri.new(s) : s }
|
184
189
|
@series = args[:series]
|
185
190
|
end
|
186
191
|
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
@@ -67,7 +67,7 @@ module IsoBibItem
|
|
67
67
|
|
68
68
|
# @param type [String]
|
69
69
|
# @param identifier [String]
|
70
|
-
def initialize(type:, identifier:, url
|
70
|
+
def initialize(type:, identifier:, url: nil, bib_locality: [], bibitem: nil)
|
71
71
|
type = "obsoletes" if type == "Now withdrawn"
|
72
72
|
@type = type
|
73
73
|
@identifier = identifier
|
@@ -76,12 +76,13 @@ module IsoBibItem
|
|
76
76
|
@bibitem = bibitem
|
77
77
|
end
|
78
78
|
|
79
|
+
# @param builder [Nokogiri::XML::Builder]
|
79
80
|
def to_xml(builder)
|
80
81
|
builder.relation(type: type) do
|
81
82
|
if @bibitem.nil?
|
82
83
|
builder.bibitem do
|
83
84
|
builder.formattedref identifier
|
84
|
-
builder.docidentifier identifier
|
85
|
+
# builder.docidentifier identifier
|
85
86
|
end
|
86
87
|
else
|
87
88
|
@bibitem.to_xml(builder, {})
|
@@ -95,7 +96,7 @@ module IsoBibItem
|
|
95
96
|
class DocRelationCollection < Array
|
96
97
|
# @param [Array<Hash{type=>String, identifier=>String}>]
|
97
98
|
def initialize(relations)
|
98
|
-
super relations.map { |r| DocumentRelation.new(r) }
|
99
|
+
super relations.map { |r| r.is_a?(Hash) ? DocumentRelation.new(r) : r }
|
99
100
|
end
|
100
101
|
|
101
102
|
# @return [Array<IsoBibItem::DocumentRelation>]
|
@@ -1,27 +1,142 @@
|
|
1
1
|
require 'nokogiri'
|
2
|
+
|
2
3
|
module IsoBibItem
|
3
4
|
class << self
|
4
|
-
def from_xml(
|
5
|
-
|
6
|
-
IsoBibliographicItem.new(
|
7
|
-
=begin
|
5
|
+
def from_xml(xml)
|
6
|
+
doc = Nokogiri::XML(xml)
|
7
|
+
IsoBibliographicItem.new(
|
8
8
|
docid: fetch_docid(doc),
|
9
|
-
edition: edition,
|
10
|
-
language:
|
11
|
-
script:
|
12
|
-
titles:
|
13
|
-
type:
|
14
|
-
docstatus: fetch_status(doc
|
9
|
+
edition: doc.at('/bibitem/edition')&.text,
|
10
|
+
language: doc.xpath('/bibitem/language').map(&:text),
|
11
|
+
script: doc.xpath('/bibitem/script').map(&:text),
|
12
|
+
titles: fetch_titles(doc),
|
13
|
+
type: doc.at('bibitem')&.attr(:type),
|
14
|
+
docstatus: fetch_status(doc),
|
15
15
|
ics: fetch_ics(doc),
|
16
16
|
dates: fetch_dates(doc),
|
17
|
-
contributors: fetch_contributors(
|
17
|
+
contributors: fetch_contributors(doc),
|
18
18
|
workgroup: fetch_workgroup(doc),
|
19
|
-
abstract:
|
20
|
-
copyright: fetch_copyright(
|
21
|
-
link:
|
19
|
+
abstract: fetch_abstract(doc),
|
20
|
+
copyright: fetch_copyright(doc),
|
21
|
+
link: fetch_link(doc),
|
22
22
|
relations: fetch_relations(doc)
|
23
|
-
|
24
|
-
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def fetch_docid(doc)
|
29
|
+
did = doc.at('/bibitem/docidentifier')
|
30
|
+
return unless did
|
31
|
+
id = did.text.match(/(?<project>\d+)(?<hyphen>-)?(?(<hyphen>)(?<part>\d*))/)
|
32
|
+
IsoBibItem::IsoDocumentId.new project_number: id[:project],
|
33
|
+
part_number: id[:part]
|
34
|
+
end
|
35
|
+
|
36
|
+
def fetch_titles(doc)
|
37
|
+
doc.xpath('/bibitem/title').map do |t|
|
38
|
+
titl = t.text.split ' -- '
|
39
|
+
case titl.size
|
40
|
+
when 0
|
41
|
+
intro, main, part = nil, "", nil
|
42
|
+
when 1
|
43
|
+
intro, main, part = nil, titl[0], nil
|
44
|
+
when 2
|
45
|
+
if /^(Part|Partie) \d+:/.match? titles[1]
|
46
|
+
intro, main, part = nil, titl[0], titles[1]
|
47
|
+
else
|
48
|
+
intro, main, part = titl[0], titl[1], nil
|
49
|
+
end
|
50
|
+
when 3
|
51
|
+
intro, main, part = titl[0], titl[1], titl[2]
|
52
|
+
else
|
53
|
+
intro, main, part = titl[0], titl[1], titl[2..-1]&.join(" -- ")
|
54
|
+
end
|
55
|
+
IsoLocalizedTitle.new(title_intro: intro, title_main: main,
|
56
|
+
title_part: part, language: t[:language],
|
57
|
+
script: t[:script])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def fetch_status(doc)
|
62
|
+
status = doc.at('/bibitem/status')
|
63
|
+
stage = status&.at('stage')&.text
|
64
|
+
substage = status&.at('substage')&.text
|
65
|
+
iteration = status&.at('iterarion')&.text&.to_i
|
66
|
+
IsoDocumentStatus.new(status: status&.text, stage: stage,
|
67
|
+
substage: substage, iteration: iteration)
|
68
|
+
end
|
69
|
+
|
70
|
+
def fetch_ics(doc)
|
71
|
+
doc.xpath('/bibitem/ics/code').map { |ics| Ics.new ics.text }
|
72
|
+
end
|
73
|
+
|
74
|
+
def fetch_dates(doc)
|
75
|
+
doc.xpath('/bibitem/date').map do |d|
|
76
|
+
BibliographicDate.new(type: d[:type], on: d.at('on')&.text,
|
77
|
+
from: d.at('from')&.text,
|
78
|
+
to: d.at('to')&.text)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def fetch_contributors(doc)
|
83
|
+
doc.xpath('/bibitem/contributor').map do |c|
|
84
|
+
o = c.at 'organization'
|
85
|
+
org = Organization.new(name: o.at('name')&.text,
|
86
|
+
abbreviation: o.at('abbreviation')&.text,
|
87
|
+
url: o.at('uri')&.text)
|
88
|
+
ContributionInfo.new entity: org, role: [c.at('role')[:type]]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# @TODO Organization doesn't recreated
|
93
|
+
def fetch_workgroup(doc)
|
94
|
+
eg = doc.at('/bibitem/editorialgroup')
|
95
|
+
tc = eg.at('technical_committee')
|
96
|
+
sc = eg.at('subcommittee')
|
97
|
+
scom = sc && iso_subgroup(cs)
|
98
|
+
wg = eg.at('workgroup')
|
99
|
+
wgrp = wg && iso_subgroup(wg)
|
100
|
+
IsoProjectGroup.new(technical_committee: iso_subgroup(tc),
|
101
|
+
subcommittee: scom, workgroup: wgrp)
|
102
|
+
end
|
103
|
+
|
104
|
+
def iso_subgroup(com)
|
105
|
+
IsoSubgroup.new(name: com.text, type: com[:type],
|
106
|
+
number: com[:number].to_i)
|
107
|
+
end
|
108
|
+
|
109
|
+
def fetch_abstract(doc)
|
110
|
+
doc.xpath('/bibitem/abstract').map do |a|
|
111
|
+
FormattedString.new(content: a.text, language: a[:language],
|
112
|
+
script: a[:script], type: a[:format])
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def fetch_copyright(doc)
|
117
|
+
cp = doc.at('/bibitem/copyright')
|
118
|
+
org = cp.at('owner/organization')
|
119
|
+
name = org.at('name').text
|
120
|
+
abbr = org.at('abbreviation').text
|
121
|
+
url = org.at('uri')&.text
|
122
|
+
entity = Organization.new(name: name, abbreviation: abbr, url: url)
|
123
|
+
from = cp.at('from').text
|
124
|
+
to = cp.at('to')&.text
|
125
|
+
owner = ContributionInfo.new entity: entity
|
126
|
+
CopyrightAssociation.new(owner: owner, from: from, to: to)
|
127
|
+
end
|
128
|
+
|
129
|
+
def fetch_link(doc)
|
130
|
+
doc.xpath('/bibitem/uri').map do |l|
|
131
|
+
TypedUri.new type: l[:type], content: l.text
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def fetch_relations(doc)
|
136
|
+
doc.xpath('/bibitem/relation').map do |r|
|
137
|
+
DocumentRelation.new(type: r[:type],
|
138
|
+
identifier: r.at('bibitem/formattedref').text)
|
139
|
+
end
|
25
140
|
end
|
26
141
|
end
|
27
142
|
end
|
@@ -58,7 +58,12 @@ module IsoBibItem
|
|
58
58
|
# @param field [Integer]
|
59
59
|
# @param group [Integer]
|
60
60
|
# @param subgroup [Integer]
|
61
|
-
def initialize(field
|
61
|
+
def initialize(code = nil, field: nil, group: nil, subgroup: nil)
|
62
|
+
unless code || field
|
63
|
+
raise ArgumentError, "wrong arguments (should be string or { fieldcode: [String] }"
|
64
|
+
end
|
65
|
+
|
66
|
+
field, group, subgroup = code.split '.' if code
|
62
67
|
super fieldcode: field, groupcode: group, subgroupcode: subgroup
|
63
68
|
end
|
64
69
|
|
@@ -70,6 +75,8 @@ module IsoBibItem
|
|
70
75
|
end
|
71
76
|
end
|
72
77
|
|
78
|
+
# rubocop:disable Metrics/ClassLength
|
79
|
+
|
73
80
|
# Bibliographic item.
|
74
81
|
class IsoBibliographicItem < BibliographicItem
|
75
82
|
# @return [IsoBibItem::IsoDocumentId]
|
@@ -93,9 +100,8 @@ module IsoBibItem
|
|
93
100
|
# @return [Array<IsoBibItem::Ics>]
|
94
101
|
attr_reader :ics
|
95
102
|
|
96
|
-
#
|
97
|
-
|
98
|
-
# @param docid [Hash{project_number=>Integer, part_number=>Integer}]
|
103
|
+
# @param docid [Hash{project_number=>Integer, part_number=>Integer},
|
104
|
+
# IsoBibItem::IsoDocumentId]
|
99
105
|
# @param titles [Array<Hash{title_intro=>String, title_main=>String,
|
100
106
|
# title_part=>String, language=>String, script=>String}>]
|
101
107
|
# @param edition [String]
|
@@ -114,7 +120,7 @@ module IsoBibItem
|
|
114
120
|
# abbreviation=>String}, roles=>Array<String>}>]
|
115
121
|
# @param copyright [Hash{owner=>Hash{name=>String, abbreviation=>String,
|
116
122
|
# url=>String}, form=>String, to=>String}]
|
117
|
-
# @param link [Array<Hash{type=>String, content=>String}>]
|
123
|
+
# @param link [Array<Hash{type=>String, content=>String}, IsoBibItem::TypedUri>]
|
118
124
|
# @param relations [Array<Hash{type=>String, identifier=>String}>]
|
119
125
|
def initialize(**args)
|
120
126
|
super_args = args.select do |k|
|
@@ -123,24 +129,36 @@ module IsoBibItem
|
|
123
129
|
].include? k
|
124
130
|
end
|
125
131
|
super(super_args)
|
126
|
-
@docidentifier =
|
127
|
-
|
128
|
-
|
129
|
-
@
|
130
|
-
@
|
131
|
-
|
132
|
-
|
133
|
-
@
|
134
|
-
@
|
132
|
+
@docidentifier = if args[:docid].is_a?(Hash)
|
133
|
+
IsoDocumentId.new(args[:docid])
|
134
|
+
else args[:docid] end
|
135
|
+
@edition = args[:edition]
|
136
|
+
@title = args[:titles].map do |t|
|
137
|
+
t.is_a?(Hash) ? IsoLocalizedTitle.new(t) : t
|
138
|
+
end
|
139
|
+
@type = args[:type]
|
140
|
+
@status = if args[:docstatus].is_a?(Hash)
|
141
|
+
IsoDocumentStatus.new(args[:docstatus])
|
142
|
+
else args[:docstatus] end
|
143
|
+
if args[:workgroup]
|
144
|
+
@workgroup = if args[:workgroup].is_a?(Hash)
|
145
|
+
IsoProjectGroup.new(args[:workgroup])
|
146
|
+
else args[:workgroup] end
|
147
|
+
end
|
148
|
+
@ics = args[:ics].map { |i| i.is_a?(Hash) ? Ics.new(i) : i }
|
149
|
+
if args[:copyright]
|
150
|
+
@copyright = if args[:copyright].is_a?(Hash)
|
151
|
+
CopyrightAssociation.new args[:copyright]
|
152
|
+
else args[:copyright] end
|
153
|
+
end
|
154
|
+
@link = args[:link].map { |s| s.is_a?(Hash) ? TypedUri.new(s) : s }
|
135
155
|
@id_attribute = true
|
136
156
|
end
|
137
|
-
|
138
|
-
|
157
|
+
|
139
158
|
def disable_id_attribute
|
140
159
|
@id_attribute = false
|
141
160
|
end
|
142
|
-
|
143
|
-
# convert ISO nnn-1 reference into an All Parts reference:
|
161
|
+
|
144
162
|
# remove title part components and abstract
|
145
163
|
def to_all_parts
|
146
164
|
#me = Duplicate.duplicate(self)
|
@@ -208,6 +226,7 @@ module IsoBibItem
|
|
208
226
|
|
209
227
|
private
|
210
228
|
|
229
|
+
# @return [Array<IsoBibItem::ContributionInfo>]
|
211
230
|
def publishers
|
212
231
|
@contributors.select do |c|
|
213
232
|
c.role.select { |r| r.type == 'publisher' }.any?
|
@@ -251,6 +270,7 @@ module IsoBibItem
|
|
251
270
|
status.to_xml builder
|
252
271
|
copyright&.to_xml builder
|
253
272
|
relations.each { |r| r.to_xml builder }
|
273
|
+
workgroup.to_xml builder
|
254
274
|
if opts[:note]
|
255
275
|
builder.note("ISO DATE: #{opts[:note]}", format: 'text/plain')
|
256
276
|
end
|
@@ -260,4 +280,5 @@ module IsoBibItem
|
|
260
280
|
end
|
261
281
|
end
|
262
282
|
end
|
283
|
+
# rubocop:enable Metrics/ClassLength
|
263
284
|
end
|
@@ -4,43 +4,62 @@ require 'iso_bib_item/document_status'
|
|
4
4
|
require 'iso_bib_item/localized_string'
|
5
5
|
|
6
6
|
module IsoBibItem
|
7
|
-
module IsoDocumentStageCodes
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
7
|
+
# module IsoDocumentStageCodes
|
8
|
+
# PREELIMINARY = '00'
|
9
|
+
# PROPOSAL = '10'
|
10
|
+
# PREPARATORY = '20'
|
11
|
+
# COMMITTE = '30'
|
12
|
+
# ENQUIRY = '40'
|
13
|
+
# APPROVAL = '50'
|
14
|
+
# PUBLICATION = '60'
|
15
|
+
# REVIEW = '90'
|
16
|
+
# WITHDRAWAL = '95'
|
17
|
+
# end
|
18
18
|
|
19
|
-
module IsoDocumentSubstageCodes
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
19
|
+
# module IsoDocumentSubstageCodes
|
20
|
+
# REGISTRATION = '00'
|
21
|
+
# START_OF_MAIN_ACTION = '20'
|
22
|
+
# COMPLETION_OF_MAIN_ACTION = '60'
|
23
|
+
# REPEAT_AN_EARLIER_PHASE = '92'
|
24
|
+
# REPEAT_CURRENT_PHASE = '92'
|
25
|
+
# ABADON = '98'
|
26
|
+
# PROCEED = '99'
|
27
|
+
# end
|
28
28
|
|
29
29
|
# ISO Document status.
|
30
30
|
class IsoDocumentStatus < DocumentStatus
|
31
|
-
# @return [
|
32
|
-
|
31
|
+
# @return [String, NilClass]
|
32
|
+
attr_reader :stage
|
33
|
+
|
34
|
+
# @return [String, NilClass]
|
35
|
+
attr_reader :substage
|
33
36
|
|
34
|
-
# @return [
|
35
|
-
|
37
|
+
# @return [Integer, NilClass]
|
38
|
+
attr_reader :iteration
|
36
39
|
|
37
|
-
# @param status [String]
|
38
|
-
# @param stage [
|
39
|
-
# @param substage [
|
40
|
-
|
40
|
+
# @param status [String, NilClass]
|
41
|
+
# @param stage [String, NilClass]
|
42
|
+
# @param substage [String, NilClass]
|
43
|
+
# @param iteration [Integer, NilClass]
|
44
|
+
def initialize(status: nil, stage: nil, substage: nil, iteration: nil)
|
45
|
+
raise ArgumentError, 'status or stage is required' unless status || stage
|
41
46
|
super LocalizedString.new(status)
|
42
|
-
@stage
|
43
|
-
@substage
|
47
|
+
@stage = stage
|
48
|
+
@substage = substage
|
49
|
+
@iteration = iteration
|
50
|
+
end
|
51
|
+
|
52
|
+
# @param builder [Nkogiri::XML::Builder]
|
53
|
+
def to_xml(builder)
|
54
|
+
if stage
|
55
|
+
builder.status do
|
56
|
+
builder.stage stage
|
57
|
+
builder.substage substage if substage
|
58
|
+
builder.iteration iteration if iteration
|
59
|
+
end
|
60
|
+
else
|
61
|
+
super
|
62
|
+
end
|
44
63
|
end
|
45
64
|
end
|
46
65
|
end
|
@@ -4,14 +4,14 @@ require 'iso_bib_item/organization'
|
|
4
4
|
|
5
5
|
module IsoBibItem
|
6
6
|
# ISO project group.
|
7
|
-
class IsoProjectGroup
|
7
|
+
class IsoProjectGroup
|
8
8
|
# @return [IsoBibItem::IsoSubgroup]
|
9
9
|
attr_reader :technical_committee
|
10
10
|
|
11
|
-
# @return [IsoBibItem::
|
11
|
+
# @return [IsoBibItem::IsoSubgroup]
|
12
12
|
attr_reader :subcommittee
|
13
13
|
|
14
|
-
# @return [IsoBibItem::
|
14
|
+
# @return [IsoBibItem::IsoSubgroup]
|
15
15
|
attr_reader :workgroup
|
16
16
|
|
17
17
|
# @return [String]
|
@@ -21,10 +21,30 @@ module IsoBibItem
|
|
21
21
|
# @param url [String]
|
22
22
|
# @param technical_commite [Hash{name=>String, type=>String,
|
23
23
|
# number=>Integer}]
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
# @param subcommittee [IsoBibItem::IsoSubgroup]
|
25
|
+
# @param workgroup [IsoBibItem::IsoSubgroup]
|
26
|
+
# @param secretariat [String]
|
27
|
+
def initialize(technical_committee:, **args)
|
28
|
+
@technical_committee = if technical_committee.is_a? Hash
|
29
|
+
IsoSubgroup.new(technical_committee)
|
30
|
+
else technical_committee end
|
31
|
+
@subcommittee = args[:subcommittee]
|
32
|
+
@workgroup = args[:workgroup]
|
33
|
+
@secretariat = args[:secretariat]
|
27
34
|
end
|
35
|
+
|
36
|
+
# rubocop:disable Metrics/AbcSize
|
37
|
+
|
38
|
+
# @param builder [Nokogiri::XML::Builder]
|
39
|
+
def to_xml(builder)
|
40
|
+
builder.editorialgroup do
|
41
|
+
builder.technical_committee { technical_committee.to_xml builder }
|
42
|
+
builder.subcommittee { subcommittee.to_xml builder } if subcommittee
|
43
|
+
builder.workgroup { workgroup.to_xml builder } if workgroup
|
44
|
+
builder.secretariat secretariat if secretariat
|
45
|
+
end
|
46
|
+
end
|
47
|
+
# rubocop:enable Metrics/AbcSize
|
28
48
|
end
|
29
49
|
|
30
50
|
# ISO subgroup.
|
@@ -41,10 +61,17 @@ module IsoBibItem
|
|
41
61
|
# @param name [String]
|
42
62
|
# @param type [String]
|
43
63
|
# @param number [Integer]
|
44
|
-
def initialize(name:, type
|
64
|
+
def initialize(name:, type: nil, number: nil)
|
45
65
|
@name = name
|
46
66
|
@type = type
|
47
67
|
@number = number
|
48
68
|
end
|
69
|
+
|
70
|
+
# @param builder [Nokogiri::XML::Builder]
|
71
|
+
def to_xml(builder)
|
72
|
+
builder.parent[:number] = number if number
|
73
|
+
builder.parent[:type] = type if type
|
74
|
+
builder.text name
|
75
|
+
end
|
49
76
|
end
|
50
77
|
end
|
@@ -42,6 +42,7 @@ module IsoBibItem
|
|
42
42
|
# @param name [String]
|
43
43
|
# @param abbreviation [String]
|
44
44
|
# @param url [String]
|
45
|
+
# @TODO identifier
|
45
46
|
def initialize(name:, abbreviation: nil, url: nil)
|
46
47
|
super(url: url)
|
47
48
|
@name = LocalizedString.new name
|
@@ -49,7 +50,7 @@ module IsoBibItem
|
|
49
50
|
@identifiers = []
|
50
51
|
end
|
51
52
|
|
52
|
-
# @
|
53
|
+
# @param builder [Nokogiri::XML::Builder]
|
53
54
|
def to_xml(builder)
|
54
55
|
builder.organization do
|
55
56
|
builder.name { |b| name.to_xml b }
|
data/lib/iso_bib_item/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iso-bib-item
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.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: 2018-07-
|
11
|
+
date: 2018-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|