iso-bib-item 0.2.0 → 0.2.1

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: 1fa989f9c13fbb68e055a71c3e69b85c1aaaa2659ab20065bd3b07ac24154e47
4
- data.tar.gz: 953d20175ece7b483a185dbd48028f03f99dafd39fa0d7467e7feebe202c5aa6
3
+ metadata.gz: '005497c6ee099cac8fce79fcbf9af9c67860ba38ac5873f1b580cc71cb3c4ef5'
4
+ data.tar.gz: 1041b3b192fb759e031ea28bccca0f035733c4b4074f6098d21d2834ce652b24
5
5
  SHA512:
6
- metadata.gz: ca6ac6fc0f254f5932c4c2a1704e628e7aeab626804def141c900d9d778b195683c261074ac2ecd3652fef5ea394f82f2476f8c2d866b6ddb6aa54cc807def9d
7
- data.tar.gz: e984e55d216273d9b5db76e71135e33b02ea04e9cef07a5ac9651f0a326dc1646b0e6bcec4313f7bc59bd90deac41de5ea8053bda957266f4f93d8db6c65e47f
6
+ metadata.gz: 66a54aa8817aab27644a0f153ead6c69cfd84a422804aaa6ed5355ef5e41b0ff46b1664f43dd62302a5ce236174d966cab6a7f43030bbb5df5a373c64fe1e885
7
+ data.tar.gz: 9223a95713fc750f966de70aa33689f1e9721311c863bd4a9e4590cc5e16acedf48621d702fd851145ebff13d8556edea69b8e6572cc3867c5c73650c8031217
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- iso-bib-item (0.1.11)
4
+ iso-bib-item (0.2.1)
5
5
  isoics (~> 0.1.6)
6
6
  nokogiri (~> 1.8.4)
7
7
  ruby_deep_clone (~> 0.8.0)
@@ -42,8 +42,8 @@ module IsoBibItem
42
42
  when 1
43
43
  intro, main, part = nil, titl[0], nil
44
44
  when 2
45
- if /^(Part|Partie) \d+:/.match? titles[1]
46
- intro, main, part = nil, titl[0], titles[1]
45
+ if /^(Part|Partie) \d+:/.match? titl[1]
46
+ intro, main, part = nil, titl[0], titl[1]
47
47
  else
48
48
  intro, main, part = titl[0], titl[1], nil
49
49
  end
@@ -92,16 +92,17 @@ module IsoBibItem
92
92
  # @TODO Organization doesn't recreated
93
93
  def fetch_workgroup(doc)
94
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)
95
+ tc = eg&.at('technical_committee')
96
+ sc = eg&.at('subcommittee')
97
+ scom = iso_subgroup(sc)
98
+ wg = eg&.at('workgroup')
99
+ wgrp = iso_subgroup(wg)
100
100
  IsoProjectGroup.new(technical_committee: iso_subgroup(tc),
101
101
  subcommittee: scom, workgroup: wgrp)
102
102
  end
103
103
 
104
104
  def iso_subgroup(com)
105
+ return nil if com.nil?
105
106
  IsoSubgroup.new(name: com.text, type: com[:type],
106
107
  number: com[:number].to_i)
107
108
  end
@@ -114,11 +115,11 @@ module IsoBibItem
114
115
  end
115
116
 
116
117
  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
118
+ cp = doc.at('/bibitem/copyright') || return
119
+ org = cp&.at('owner/organization')
120
+ name = org&.at('name').text
121
+ abbr = org&.at('abbreviation')&.text
122
+ url = org&.at('uri')&.text
122
123
  entity = Organization.new(name: name, abbreviation: abbr, url: url)
123
124
  from = cp.at('from').text
124
125
  to = cp.at('to')&.text
@@ -270,7 +270,7 @@ module IsoBibItem
270
270
  status.to_xml builder
271
271
  copyright&.to_xml builder
272
272
  relations.each { |r| r.to_xml builder }
273
- workgroup.to_xml builder
273
+ workgroup&.to_xml builder
274
274
  if opts[:note]
275
275
  builder.note("ISO DATE: #{opts[:note]}", format: 'text/plain')
276
276
  end
@@ -37,8 +37,9 @@ module IsoBibItem
37
37
 
38
38
  # @param builder [Nokogiri::XML::Builder]
39
39
  def to_xml(builder)
40
+ return unless technical_committee || subcommittee || workgroup || secretariat
40
41
  builder.editorialgroup do
41
- builder.technical_committee { technical_committee.to_xml builder }
42
+ builder.technical_committee { technical_committee.to_xml builder } if technical_committee
42
43
  builder.subcommittee { subcommittee.to_xml builder } if subcommittee
43
44
  builder.workgroup { workgroup.to_xml builder } if workgroup
44
45
  builder.secretariat secretariat if secretariat
@@ -30,6 +30,7 @@ module IsoBibItem
30
30
 
31
31
  # @param builder [Nokogiri::XML::Builder]
32
32
  def to_xml(builder)
33
+ return unless content
33
34
  builder.parent['language'] = language.join(',') if language.any?
34
35
  builder.parent['script'] = script.join(',') if script.any?
35
36
  builder.text content
@@ -54,9 +54,7 @@ module IsoBibItem
54
54
  def to_xml(builder)
55
55
  builder.organization do
56
56
  builder.name { |b| name.to_xml b }
57
- # unless abbreviati.content.nil? || abbreviation.content.empty?
58
- builder.abbreviation { |a| abbreviation.to_xml a }
59
- # end
57
+ builder.abbreviation { |a| abbreviation.to_xml a } if abbreviation&.to_s
60
58
  builder.uri uri.to_s if uri
61
59
  identifiers.each { |identifier| identifier.to_xml builder }
62
60
  super
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module IsoBibItem
4
- VERSION = '0.2.0'.freeze
4
+ VERSION = '0.2.1'.freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iso-bib-item
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.