iso-bib-item 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +12 -12
- data/lib/iso_bib_item/from_xml.rb +1 -0
- data/lib/iso_bib_item/iso_bibliographic_item.rb +32 -11
- 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: 9151a606d6472ed717dd72355de133f60267115db58ad044487e90c6dd8121f0
|
4
|
+
data.tar.gz: 582951ceb750e9a04249adce617003dfa0ae0846d6b2d26c2325e06fea3daf85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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.
|
32
|
-
rspec-core (~> 3.
|
33
|
-
rspec-expectations (~> 3.
|
34
|
-
rspec-mocks (~> 3.
|
35
|
-
rspec-core (3.
|
36
|
-
rspec-support (~> 3.
|
37
|
-
rspec-expectations (3.
|
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.
|
40
|
-
rspec-mocks (3.
|
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.
|
43
|
-
rspec-support (3.
|
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)
|
@@ -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|
|
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.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-
|
11
|
+
date: 2018-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|