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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 35146363462622bb4a40fd392cd10ee47b411bbfee238108da476e365944f263
4
- data.tar.gz: a1ed4d24e83c8ace967b7c38d4a745b160497744f43e956a5644610641d0eda5
3
+ metadata.gz: 1fa989f9c13fbb68e055a71c3e69b85c1aaaa2659ab20065bd3b07ac24154e47
4
+ data.tar.gz: 953d20175ece7b483a185dbd48028f03f99dafd39fa0d7467e7feebe202c5aa6
5
5
  SHA512:
6
- metadata.gz: b62d9e9c5aeab6ab50f62a2fd3f81b0e4d981034dd258cd05c15279be94afe4f410a99e1fbfd8fc028a7f596a4cf00e564d581b89c6ed0651244554e51d280e3
7
- data.tar.gz: 69921f12e852458b2047f01825412e35228a4fcd9df581b30b6ec82d1bb4755f152bca5aedde1a3cbdfaa360eeed031bb0f6f52b18c95a4e0b507d077d5ef811
6
+ metadata.gz: ca6ac6fc0f254f5932c4c2a1704e628e7aeab626804def141c900d9d778b195683c261074ac2ecd3652fef5ea394f82f2476f8c2d866b6ddb6aa54cc807def9d
7
+ data.tar.gz: e984e55d216273d9b5db76e71135e33b02ea04e9cef07a5ac9651f0a326dc1646b0e6bcec4313f7bc59bd90deac41de5ea8053bda957266f4f93d8db6c65e47f
data/.travis.yml CHANGED
@@ -1,5 +1,14 @@
1
1
  sudo: false
2
2
  language: ruby
3
+
3
4
  rvm:
4
- - 2.4.0
5
+ - 2.5
6
+ - 2.4
7
+ - 2.3
8
+ - ruby-head
9
+
5
10
  before_install: gem install bundler -v 1.16.1
11
+
12
+ matrix:
13
+ allow_failures:
14
+ - rvm: ruby-head
data/README.adoc CHANGED
@@ -416,3 +416,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
416
416
  == License
417
417
 
418
418
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
419
+
@@ -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 = Time.strptime(on, '%Y-%d') if on
27
- @from = Time.strptime(from, '%Y-%d') if from
28
- @to = Time.strptime(to, '%Y-%d') if 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 = ContributionInfo.new entity: Organization.new(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
- e = c[:entity].is_a?(Hash) ? Organization.new(c[:entity]) : c[:entity]
173
- ContributionInfo.new(entity: e, role: c[:roles])
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:, bib_locality: [], bibitem: nil)
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(doc)
5
- xml = Nokogiri::XML(doc)
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: langs(doc).map { |l| l[:lang] },
11
- script: langs(doc).map { |l| script(l[:lang]) }.uniq,
12
- titles: titles,
13
- type: fetch_type(hit_data['title']),
14
- docstatus: fetch_status(doc, hit_data['status']),
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(hit_data['title']),
17
+ contributors: fetch_contributors(doc),
18
18
  workgroup: fetch_workgroup(doc),
19
- abstract: abstract,
20
- copyright: fetch_copyright(hit_data['title'], doc),
21
- link: fetch_link(doc, url),
19
+ abstract: fetch_abstract(doc),
20
+ copyright: fetch_copyright(doc),
21
+ link: fetch_link(doc),
22
22
  relations: fetch_relations(doc)
23
- =end
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:, group:, subgroup:)
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
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
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 = IsoDocumentId.new args[:docid]
127
- @edition = args[:edition]
128
- @title = args[:titles].map { |t| IsoLocalizedTitle.new(t) }
129
- @type = args[:type]
130
- @status = IsoDocumentStatus.new(args[:docstatus])
131
- @workgroup = IsoProjectGroup.new(args[:workgroup]) if args[:workgroup]
132
- @ics = args[:ics].map { |i| Ics.new(i) }
133
- @copyright = CopyrightAssociation.new args[:copyright] if args[:copyright]
134
- @link = args[:link].map { |s| TypedUri.new(s) }
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
- # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
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
- 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
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
- 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
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 [IsoDocumentStageCodes]
32
- attr_accessor :stage
31
+ # @return [String, NilClass]
32
+ attr_reader :stage
33
+
34
+ # @return [String, NilClass]
35
+ attr_reader :substage
33
36
 
34
- # @return [IsoDocumentSubstageCodes]
35
- attr_accessor :substage
37
+ # @return [Integer, NilClass]
38
+ attr_reader :iteration
36
39
 
37
- # @param status [String]
38
- # @param stage [IsoDocumentStageCodes]
39
- # @param substage [IsoDocumentSubstageCodes]
40
- def initialize(status:, stage:, substage:)
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 = stage
43
- @substage = 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 < Organization
7
+ class IsoProjectGroup
8
8
  # @return [IsoBibItem::IsoSubgroup]
9
9
  attr_reader :technical_committee
10
10
 
11
- # @return [IsoBibItem::soSubgroup]
11
+ # @return [IsoBibItem::IsoSubgroup]
12
12
  attr_reader :subcommittee
13
13
 
14
- # @return [IsoBibItem::soSubgroup]
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
- def initialize(name:, abbreviation: nil, url:, technical_committee:)
25
- super name: name, abbreviation: abbreviation, url: url
26
- @technical_committe = IsoSubgroup.new(technical_committee)
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:, number:)
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
- # @return [String]
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 }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module IsoBibItem
4
- VERSION = '0.1.11'.freeze
4
+ VERSION = '0.2.0'.freeze
5
5
  end
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.1.11
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-10 00:00:00.000000000 Z
11
+ date: 2018-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler