iso-bib-item 0.2.5 → 0.3.0

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: 6152b8b2dac4f1407c12f429da08f38a998fb370a0365daf0244b83c1cf11aa1
4
- data.tar.gz: 2e2c14cd1a79aad12de2188bda4fe184182a1969ea5fb61acba618d2a51b8528
3
+ metadata.gz: 9151a606d6472ed717dd72355de133f60267115db58ad044487e90c6dd8121f0
4
+ data.tar.gz: 582951ceb750e9a04249adce617003dfa0ae0846d6b2d26c2325e06fea3daf85
5
5
  SHA512:
6
- metadata.gz: 8717fbba17d12177e540244ecc56623ff7160093e3316bb760dc493798a4d2129f03aeb0e1d6fc1e2bb7c246806be4a0773068e0a90d95338e03872515e66436
7
- data.tar.gz: 3366b6defa16b2cdea5ca407cfeb18b8adbd83e7ec52e2958d9e711c4819540b152146bc2469d608299dce56d8690cc4a63d75773091d93211c68e8107cfd5a5
6
+ metadata.gz: 326360eeb3139af52a7fd7fe7f839ce72c9c20b33bc3ac73a4427e6167e047a48e13536bd4894ea1da638bbd7657d0cbb570af43c05349a896163b291cddc5bb
7
+ data.tar.gz: 587f9215a2668f7170e269305e90b9601c5963560fb5eb7871961f3e5016843954eba2041b3f525ecfde9d776b0ff79a13e4306ad44b94d3a38070bdf756b08e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- iso-bib-item (0.2.5)
4
+ iso-bib-item (0.3.0)
5
5
  isoics (~> 0.1.6)
6
6
  nokogiri (~> 1.8.4)
7
7
  ruby_deep_clone (~> 0.8.0)
@@ -28,19 +28,19 @@ GEM
28
28
  byebug (~> 10.0)
29
29
  pry (~> 0.10)
30
30
  rake (10.5.0)
31
- rspec (3.7.0)
32
- rspec-core (~> 3.7.0)
33
- rspec-expectations (~> 3.7.0)
34
- rspec-mocks (~> 3.7.0)
35
- rspec-core (3.7.1)
36
- rspec-support (~> 3.7.0)
37
- rspec-expectations (3.7.0)
31
+ rspec (3.8.0)
32
+ rspec-core (~> 3.8.0)
33
+ rspec-expectations (~> 3.8.0)
34
+ rspec-mocks (~> 3.8.0)
35
+ rspec-core (3.8.0)
36
+ rspec-support (~> 3.8.0)
37
+ rspec-expectations (3.8.1)
38
38
  diff-lcs (>= 1.2.0, < 2.0)
39
- rspec-support (~> 3.7.0)
40
- rspec-mocks (3.7.0)
39
+ rspec-support (~> 3.8.0)
40
+ rspec-mocks (3.8.0)
41
41
  diff-lcs (>= 1.2.0, < 2.0)
42
- rspec-support (~> 3.7.0)
43
- rspec-support (3.7.1)
42
+ rspec-support (~> 3.8.0)
43
+ rspec-support (3.8.0)
44
44
  ruby_deep_clone (0.8.0)
45
45
  simplecov (0.16.1)
46
46
  docile (~> 1.1)
@@ -36,6 +36,7 @@ module IsoBibItem
36
36
  ret << IsoBibItem::IsoDocumentId.new(project_number: id.nil? ? did.text : id[:project],
37
37
  part_number: id.nil? ? nil : id[:part],
38
38
  prefix: nil,
39
+ id: did.text,
39
40
  type: type&.text)
40
41
  end
41
42
  end
@@ -29,6 +29,9 @@ module IsoBibItem
29
29
  # @return [Integer]
30
30
  attr_reader :part_number
31
31
 
32
+ # @return [String]
33
+ attr_reader :id
34
+
32
35
  # @return [Prefix]
33
36
  attr_reader :prefix
34
37
 
@@ -37,21 +40,41 @@ module IsoBibItem
37
40
 
38
41
  # @param project_number [Integer]
39
42
  # @param part_number [Integer]
40
- def initialize(project_number:, part_number:, prefix:, type: nil)
43
+ def initialize(project_number:, part_number:, prefix:, id:, type: nil)
41
44
  @project_number = project_number
42
45
  @part_number = part_number
43
46
  @prefix = prefix
44
47
  @type = type
48
+ @id = id
45
49
  end
46
50
 
51
+ # in docid manipulations, assume ISO as the default: id-part:year
47
52
  def remove_part
48
53
  @part_number = nil
54
+ case @type
55
+ when "Chinese Standard" then @id = @id.sub(/\.\d+/, "")
56
+ else
57
+ @id = @id.sub(/-\d+/, "")
58
+ end
59
+ end
60
+
61
+ def remove_date
62
+ case @type
63
+ when "Chinese Standard" then @id = @id.sub(/-[12]\d\d\d/, "")
64
+ else
65
+ @id = @id.sub(/:[12]\d\d\d/, "")
66
+ end
67
+ end
68
+
69
+ def all_parts
70
+ @id = @id + " (all parts)"
49
71
  end
50
72
 
51
73
  def to_xml(builder)
52
74
  attrs = {}
53
75
  attrs[:type] = @type if @type
54
- builder.docidentifier project_number + '-' + part_number, **attrs
76
+ # builder.docidentifier project_number + '-' + part_number, **attrs
77
+ builder.docidentifier id, **attrs
55
78
  end
56
79
  end
57
80
 
@@ -172,14 +195,13 @@ module IsoBibItem
172
195
 
173
196
  # remove title part components and abstract
174
197
  def to_all_parts
175
- #me = Duplicate.duplicate(self)
176
198
  me = DeepClone.clone(self)
177
199
  me.disable_id_attribute
178
200
  @relations << DocumentRelation.new(type: "partOf", identifier: nil, url: nil, bibitem: me)
179
-
180
201
  @title.each(&:remove_part)
181
202
  @abstract = []
182
203
  @docidentifier.each(&:remove_part)
204
+ @docidentifier.each(&:all_parts)
183
205
  @all_parts = true
184
206
  end
185
207
 
@@ -188,12 +210,12 @@ module IsoBibItem
188
210
  # date of publication, abstracts. Make dated reference Instance relation
189
211
  # of the redacated document
190
212
  def to_most_recent_reference
191
- #me = Duplicate.duplicate(self)
192
213
  me = DeepClone.clone(self)
193
214
  me.disable_id_attribute
194
215
  @relations << DocumentRelation.new(type: "instance", identifier: nil, url: nil, bibitem: me)
195
216
  @abstract = []
196
217
  @dates = []
218
+ @docidentifier.each(&:remove_date)
197
219
  end
198
220
 
199
221
  # @param lang [String] language code Iso639
@@ -206,7 +228,6 @@ module IsoBibItem
206
228
  end
207
229
  end
208
230
 
209
- # @todo need to add ISO/IEC/IEEE
210
231
  # @return [String]
211
232
  def shortref(identifier, **opts)
212
233
  pubdate = dates.select { |d| d.type == "published" }
@@ -249,11 +270,10 @@ module IsoBibItem
249
270
  id = @docidentifier.reject { |i| i.type == "DOI" }[0] unless id
250
271
  #contribs = publishers.map { |p| p&.entity&.abbreviation }.join '/'
251
272
  #idstr = "#{contribs}#{delim}#{id.project_number}"
252
- idstr = id.project_number.to_s
273
+ #idstr = id.project_number.to_s
274
+ idstr = id.id.gsub(/:/, "-")
253
275
  idstr = "IEV" if id.project_number == "IEV"
254
- if id.part_number&.size&.positive?
255
- idstr += "-#{id.part_number}"
256
- end
276
+ #if id.part_number&.size&.positive? then idstr += "-#{id.part_number}"
257
277
  idstr.strip
258
278
  end
259
279
 
@@ -272,7 +292,8 @@ module IsoBibItem
272
292
  @docidentifier.each do |i|
273
293
  attrs = {}
274
294
  attrs[:type] = i.type if i.type
275
- builder.docidentifier shortref(i, opts.merge(no_year: true)), **attrs
295
+ # builder.docidentifier shortref(i, opts.merge(no_year: true)), **attrs
296
+ builder.docidentifier i.id, **attrs
276
297
  end
277
298
  dates.each { |d| d.to_xml builder, opts }
278
299
  contributors.each do |c|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module IsoBibItem
4
- VERSION = '0.2.5'.freeze
4
+ VERSION = '0.3.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.2.5
4
+ version: 0.3.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-08-25 00:00:00.000000000 Z
11
+ date: 2018-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler