iso-bib-item 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 423970a46ac3548707c24f614d31e459ede59b5cf402ed4d073dccf405f40920
4
- data.tar.gz: 91540a5d39dd4f2a522bf47d584de113bf66218c393ef6e9b04b054b9933bc20
3
+ metadata.gz: 6152b8b2dac4f1407c12f429da08f38a998fb370a0365daf0244b83c1cf11aa1
4
+ data.tar.gz: 2e2c14cd1a79aad12de2188bda4fe184182a1969ea5fb61acba618d2a51b8528
5
5
  SHA512:
6
- metadata.gz: f63914c86938dbf6279e1d04830fabbc6229bbcbd92bd1800927a70af0c2936856ef0a9aa3aae5ca84e323e9f0ffb462629561386b291fa56c520285e76b9078
7
- data.tar.gz: 0c7a2f6acf70632d5d75e1a9dde3a36b0c5a583f20eea2725e150ccfec4961db6cb3f6933fdd2d5dafa231c2e5dd1fd90c0b92c4506eb044ae4482f4b3ae06f0
6
+ metadata.gz: 8717fbba17d12177e540244ecc56623ff7160093e3316bb760dc493798a4d2129f03aeb0e1d6fc1e2bb7c246806be4a0773068e0a90d95338e03872515e66436
7
+ data.tar.gz: 3366b6defa16b2cdea5ca407cfeb18b8adbd83e7ec52e2958d9e711c4819540b152146bc2469d608299dce56d8690cc4a63d75773091d93211c68e8107cfd5a5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- iso-bib-item (0.2.4)
4
+ iso-bib-item (0.2.5)
5
5
  isoics (~> 0.1.6)
6
6
  nokogiri (~> 1.8.4)
7
7
  ruby_deep_clone (~> 0.8.0)
@@ -15,7 +15,7 @@ GEM
15
15
  docile (1.3.1)
16
16
  equivalent-xml (0.6.0)
17
17
  nokogiri (>= 1.4.3)
18
- isoics (0.1.6)
18
+ isoics (0.1.7)
19
19
  json (2.1.0)
20
20
  method_source (0.9.0)
21
21
  mini_portile2 (2.3.0)
data/LICENSE.txt CHANGED
@@ -1,21 +1,25 @@
1
- The MIT License (MIT)
1
+ BSD 2-Clause License
2
2
 
3
- Copyright (c) 2018 Andrei Kislichenko
3
+ Copyright (c) 2018, Ribose
4
+ All rights reserved.
4
5
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
11
8
 
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
14
11
 
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/iso-bib-item.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.summary = %(IsoBibItem: Ruby ISOXMLDOC impementation.)
14
14
  spec.description = %(IsoBibItem: Ruby ISOXMLDOC impementation.)
15
15
  spec.homepage = 'https://github.com/riboseinc/gdbib'
16
- spec.license = 'MIT'
16
+ spec.license = 'BSD-2-Clause'
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
19
  f.match(%r{^(test|spec|features)/})
@@ -84,7 +84,7 @@ module IsoBibItem
84
84
 
85
85
  # @params builder [Nokogiri::XML::Builder]
86
86
  def to_xml(builder)
87
- builder.affilation do
87
+ builder.affiliation do
88
88
  builder.name { name.to_xml builder } if name
89
89
  description.each { |d| builder.description { d.to_xml builder } }
90
90
  organization.to_xml builder
@@ -26,13 +26,20 @@ module IsoBibItem
26
26
  private
27
27
 
28
28
  def fetch_docid(doc)
29
- did = doc.at('/bibitem/docidentifier')
30
- return unless did
31
- did.text == "IEV" and return IsoBibItem::IsoDocumentId.new(project_number: "IEV", part_number: nil, prefix: nil)
32
- id = did.text.match(/(?<project>\d+)(?<hyphen>-)?(?(<hyphen>)(?<part>\d*))/)
33
- IsoBibItem::IsoDocumentId.new(project_number: id.nil? ? nil : id[:project],
34
- part_number: id.nil? ? nil : id[:part],
35
- prefix: nil)
29
+ ret = []
30
+ doc.xpath("/bibitem/docidentifier").each do |did|
31
+ #did = doc.at('/bibitem/docidentifier')
32
+ type = did.at("./@type")
33
+ if did.text == "IEV" then ret << IsoBibItem::IsoDocumentId.new(project_number: "IEV", part_number: nil, prefix: nil)
34
+ else
35
+ id = did.text.match(/^(?<project>.*\d+)(?<hyphen>-)?(?(<hyphen>)(?<part>\d*))$/)
36
+ ret << IsoBibItem::IsoDocumentId.new(project_number: id.nil? ? did.text : id[:project],
37
+ part_number: id.nil? ? nil : id[:part],
38
+ prefix: nil,
39
+ type: type&.text)
40
+ end
41
+ end
42
+ ret
36
43
  end
37
44
 
38
45
  def fetch_titles(doc)
@@ -123,7 +130,7 @@ module IsoBibItem
123
130
  abbr = org&.at('abbreviation')&.text
124
131
  url = org&.at('uri')&.text
125
132
  entity = Organization.new(name: name, abbreviation: abbr, url: url)
126
- from = cp.at('from').text
133
+ from = cp.at('from')&.text
127
134
  to = cp.at('to')&.text
128
135
  owner = ContributionInfo.new entity: entity
129
136
  CopyrightAssociation.new(owner: owner, from: from, to: to)
@@ -32,12 +32,16 @@ module IsoBibItem
32
32
  # @return [Prefix]
33
33
  attr_reader :prefix
34
34
 
35
+ # @return [Prefix]
36
+ attr_reader :type
37
+
35
38
  # @param project_number [Integer]
36
39
  # @param part_number [Integer]
37
- def initialize(project_number:, part_number:, prefix:)
40
+ def initialize(project_number:, part_number:, prefix:, type: nil)
38
41
  @project_number = project_number
39
42
  @part_number = part_number
40
43
  @prefix = prefix
44
+ @type = type
41
45
  end
42
46
 
43
47
  def remove_part
@@ -45,7 +49,9 @@ module IsoBibItem
45
49
  end
46
50
 
47
51
  def to_xml(builder)
48
- builder.docidentifier(project_number + '-' + part_number)
52
+ attrs = {}
53
+ attrs[:type] = @type if @type
54
+ builder.docidentifier project_number + '-' + part_number, **attrs
49
55
  end
50
56
  end
51
57
 
@@ -133,9 +139,10 @@ module IsoBibItem
133
139
  ].include? k
134
140
  end
135
141
  super(super_args)
136
- @docidentifier = if args[:docid].is_a?(Hash)
137
- IsoDocumentId.new(args[:docid])
138
- else args[:docid] end
142
+ args[:docid] = [args[:docid]] unless args[:docid].is_a?(Array)
143
+ @docidentifier = args[:docid].map do |t|
144
+ t.is_a?(Hash) ? IsoDocumentId.new(t) : t
145
+ end
139
146
  @edition = args[:edition]
140
147
  @title = args[:titles].map do |t|
141
148
  t.is_a?(Hash) ? IsoLocalizedTitle.new(t) : t
@@ -172,7 +179,7 @@ module IsoBibItem
172
179
 
173
180
  @title.each(&:remove_part)
174
181
  @abstract = []
175
- @docidentifier.remove_part
182
+ @docidentifier.each(&:remove_part)
176
183
  @all_parts = true
177
184
  end
178
185
 
@@ -201,14 +208,14 @@ module IsoBibItem
201
208
 
202
209
  # @todo need to add ISO/IEC/IEEE
203
210
  # @return [String]
204
- def shortref(**opts)
211
+ def shortref(identifier, **opts)
205
212
  pubdate = dates.select { |d| d.type == "published" }
206
213
  year = if opts[:no_year] || pubdate.empty? then ""
207
214
  else ':' + pubdate&.first&.on&.year&.to_s
208
215
  end
209
216
  year += ": All Parts" if opts[:all_parts] || @all_parts
210
217
 
211
- "#{id(false, ' ')}#{year}"
218
+ "#{makeid(identifier, false, ' ')}#{year}"
212
219
  end
213
220
 
214
221
  # @param type [Symbol] type of url, can be :src/:obp/:rss
@@ -237,20 +244,22 @@ module IsoBibItem
237
244
  end
238
245
  end
239
246
 
240
- def id(attribute, delim = '')
247
+ def makeid(id, attribute, delim = '')
241
248
  return nil if attribute && !@id_attribute
242
- contribs = publishers.map { |p| p&.entity&.abbreviation }.join '/'
243
- idstr = "#{contribs}#{delim}#{@docidentifier.project_number}"
244
- idstr = "IEV" if @docidentifier.project_number == "IEV"
245
- if @docidentifier.part_number&.size&.positive?
246
- idstr << "-#{@docidentifier.part_number}"
249
+ id = @docidentifier.reject { |i| i.type == "DOI" }[0] unless id
250
+ #contribs = publishers.map { |p| p&.entity&.abbreviation }.join '/'
251
+ #idstr = "#{contribs}#{delim}#{id.project_number}"
252
+ idstr = id.project_number.to_s
253
+ idstr = "IEV" if id.project_number == "IEV"
254
+ if id.part_number&.size&.positive?
255
+ idstr += "-#{id.part_number}"
247
256
  end
248
257
  idstr.strip
249
258
  end
250
259
 
251
260
  def xml_attrs(type)
252
261
  attrs = { type: type }
253
- attr_id = id(true)
262
+ attr_id = makeid(nil, true)&.gsub(/ /, "")
254
263
  attrs[:id] = attr_id if attr_id
255
264
  attrs
256
265
  end
@@ -260,7 +269,11 @@ module IsoBibItem
260
269
  title.each { |t| t.to_xml builder }
261
270
  link.each { |s| s.to_xml builder }
262
271
  # docidentifier.to_xml builder
263
- builder.docidentifier shortref(opts.merge(no_year: true))
272
+ @docidentifier.each do |i|
273
+ attrs = {}
274
+ attrs[:type] = i.type if i.type
275
+ builder.docidentifier shortref(i, opts.merge(no_year: true)), **attrs
276
+ end
264
277
  dates.each { |d| d.to_xml builder, opts }
265
278
  contributors.each do |c|
266
279
  builder.contributor do
@@ -280,7 +293,7 @@ module IsoBibItem
280
293
  builder.note("ISO DATE: #{opts[:note]}", format: 'text/plain')
281
294
  end
282
295
  ics.each { |i| i.to_xml builder }
283
- builder.allParts 'true' if @all_parts
296
+ builder.allparts 'true' if @all_parts
284
297
  yield(builder) if block_given?
285
298
  end
286
299
  end
@@ -81,17 +81,17 @@ module IsoBibItem
81
81
  attr_accessor :name
82
82
 
83
83
  # @return [Array<IsoBibItem::Affilation>]
84
- attr_accessor :affilation
84
+ attr_accessor :affiliation
85
85
 
86
86
  # @return [Array<IsoBibItem::PersonIdentifier>]
87
87
  attr_accessor :identifiers
88
88
 
89
89
  # @param name [IsoBibItem::FullName]
90
- # @param affilation [Array<IsoBibItem::Affilation>]
91
- def initialize(name:, affilation: [], contacts:)
90
+ # @param affiliation [Array<IsoBibItem::Affiliation>]
91
+ def initialize(name:, affiliation: [], contacts:)
92
92
  super(contacts: contacts)
93
93
  @name = name
94
- @affilation = affilation
94
+ @affiliation = affiliation
95
95
  @identifiers = []
96
96
  end
97
97
 
@@ -99,7 +99,7 @@ module IsoBibItem
99
99
  def to_xml(builder)
100
100
  builder.person do
101
101
  name.to_xml builder
102
- affilation.each { |a| a.to_xml builder }
102
+ affiliation.each { |a| a.to_xml builder }
103
103
  contacts.each { |contact| contact.to_xml builder }
104
104
  end
105
105
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module IsoBibItem
4
- VERSION = '0.2.4'.freeze
4
+ VERSION = '0.2.5'.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.2.4
4
+ version: 0.2.5
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-31 00:00:00.000000000 Z
11
+ date: 2018-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -175,7 +175,7 @@ files:
175
175
  - lib/iso_bib_item/version.rb
176
176
  homepage: https://github.com/riboseinc/gdbib
177
177
  licenses:
178
- - MIT
178
+ - BSD-2-Clause
179
179
  metadata: {}
180
180
  post_install_message:
181
181
  rdoc_options: []