relaton-3gpp 1.19.0 → 1.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_3gpp/bibliographic_item.rb +1 -1
- data/lib/relaton_3gpp/data_fetcher.rb +138 -10
- data/lib/relaton_3gpp/parser.rb +2 -2
- data/lib/relaton_3gpp/version.rb +1 -1
- data/relaton_3gpp.gemspec +2 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45004cd52d3255e9882f17e3c4331025aaf389c21ad1c756ba3aeccd5953f5b0
|
4
|
+
data.tar.gz: d87bbfcdbdd04d17726554e7bcbd7438b8edc5f31dcc7030553522f292ea9ec2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e11c551066552effe3e897850210ba5b7e06f033b5ddc2798f1ec74b68534cd3b87772b6175f506af4909e376f55c078701035a2a4353399ab8f88f4ffc1d76
|
7
|
+
data.tar.gz: 2303de76da8eebe06ac967b54fe08b4e2cb78215f66cf8a789182f8c81d89286ca97034e1617dee50b0efb0e92a90c7aa75914903c0e79a336b830daa613e2d4
|
@@ -52,7 +52,7 @@ module Relaton3gpp
|
|
52
52
|
FileUtils.rm_f File.join(@output, "/*") # if renewal && dbs["2001-04-25_schedule"].any?
|
53
53
|
index.remove_all # if renewal
|
54
54
|
end
|
55
|
-
CSV.open(file, "r:bom|utf-8", headers: true
|
55
|
+
CSV.open(file, "r:bom|utf-8", headers: true).each do |row|
|
56
56
|
save_doc Parser.parse(row)
|
57
57
|
end
|
58
58
|
File.write CURRENT, @current.to_yaml, encoding: "UTF-8"
|
@@ -125,19 +125,147 @@ module Relaton3gpp
|
|
125
125
|
def save_doc(bib) # rubocop:disable Metrics/MethodLength
|
126
126
|
return unless bib
|
127
127
|
|
128
|
-
|
129
|
-
|
130
|
-
when "yaml" then bib.to_hash.to_yaml
|
131
|
-
else bib.send("to_#{@format}")
|
132
|
-
end
|
133
|
-
file = file_name(bib)
|
128
|
+
bib1 = bib
|
129
|
+
file = file_name(bib1)
|
134
130
|
if @files.include? file
|
135
|
-
|
131
|
+
bib1 = merge_duplication bib1, file
|
132
|
+
Util.warn "File #{file} already exists. Document: #{bib.docnumber}" if bib1.nil?
|
136
133
|
else
|
137
134
|
@files << file
|
135
|
+
index.add_or_update bib1.docnumber, file
|
136
|
+
end
|
137
|
+
File.write file, serialise(bib1), encoding: "UTF-8" unless bib1.nil?
|
138
|
+
end
|
139
|
+
|
140
|
+
#
|
141
|
+
# Merge duplication
|
142
|
+
#
|
143
|
+
# @param [Relaton3gpp::BibliographicItem] bib new bibliographic item
|
144
|
+
# @param [String] file file name of existing bibliographic item
|
145
|
+
#
|
146
|
+
# @return [Relaton3gpp::BibliographicItem, nil] merged bibliographic item or nil if no merge has been done
|
147
|
+
#
|
148
|
+
def merge_duplication(bib, file)
|
149
|
+
hash = YAML.load_file file
|
150
|
+
existed = BibliographicItem.from_hash hash
|
151
|
+
changed = update_link bib, existed
|
152
|
+
bib1, bib2, chng = transposed_relation bib, existed
|
153
|
+
changed ||= chng
|
154
|
+
chng = add_contributor(bib1, bib2)
|
155
|
+
changed ||= chng
|
156
|
+
bib1 if changed
|
157
|
+
end
|
158
|
+
|
159
|
+
#
|
160
|
+
# Update link in case one of bibliographic items has no link
|
161
|
+
#
|
162
|
+
# @param [Relaton3gpp::BibliographicItem] bib1
|
163
|
+
# @param [Relaton3gpp::BibliographicItem] bib2
|
164
|
+
#
|
165
|
+
# @return [Boolean] true if link has been updated
|
166
|
+
#
|
167
|
+
def update_link(bib1, bib2)
|
168
|
+
if bib1.link.any? && bib2.link.empty?
|
169
|
+
bib2.instance_variable_set(:@link, bib1.link)
|
170
|
+
true
|
171
|
+
elsif bib1.link.empty? && bib2.link.any?
|
172
|
+
bib1.instance_variable_set(:@link, bib2.link)
|
173
|
+
true
|
174
|
+
else false
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
#
|
179
|
+
# If one of bibliographic items has date gereater than anotherm=, make it relation
|
180
|
+
#
|
181
|
+
# @param [Relaton3gpp::BibliographicItem] bib new bibliographic item
|
182
|
+
# @param [Relaton3gpp::BibliographicItem] existed existing bibliographic item
|
183
|
+
#
|
184
|
+
# @return [Array<Relaton3gpp::BibliographicItem, Boolean>] main bibliographic item,
|
185
|
+
# related bibliographic item, true if relation has been added
|
186
|
+
#
|
187
|
+
def transposed_relation(bib, existed) # rubocop:disable Metrics/CyclomaticComplexity
|
188
|
+
return [bib, existed, false] if bib.date.none? && existed.date.none? ||
|
189
|
+
bib.date.any? && existed.date.none?
|
190
|
+
return [existed, bib, true] if bib.date.none? && existed.date.any?
|
191
|
+
|
192
|
+
check_transposed_date bib, existed
|
193
|
+
end
|
194
|
+
|
195
|
+
#
|
196
|
+
# Check if date of one bibliographic item is transposed to another
|
197
|
+
#
|
198
|
+
# @param [Relaton3gpp::BibliographicItem] bib new bibliographic item
|
199
|
+
# @param [Relaton3gpp::BibliographicItem] existed existing bibliographic item
|
200
|
+
#
|
201
|
+
# @return [Array<Relaton3gpp::BibliographicItem, Boolean>] main bibliographic item,
|
202
|
+
# related bibliographic item, true if relation has been added
|
203
|
+
#
|
204
|
+
def check_transposed_date(bib, existed)
|
205
|
+
if bib.date[0].on < existed.date[0].on
|
206
|
+
add_transposed_relation bib, existed
|
207
|
+
[bib, existed, true]
|
208
|
+
elsif bib.date[0].on > existed.date[0].on
|
209
|
+
add_transposed_relation existed, bib
|
210
|
+
[existed, bib, true]
|
211
|
+
else [bib, existed, false]
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
#
|
216
|
+
# Add transposed relation
|
217
|
+
#
|
218
|
+
# @param [Relaton3gpp::BibliographicItem] bib1 the main bibliographic item
|
219
|
+
# @param [Relaton3gpp::BibliographicItem] bib2 the transposed bibliographic item
|
220
|
+
#
|
221
|
+
# @return [Relaton3gpp::BibliographicItem]
|
222
|
+
#
|
223
|
+
def add_transposed_relation(bib1, bib2)
|
224
|
+
bib2.relation.each { |r| bib1.relation << r }
|
225
|
+
bib2.instance_variable_set :@relation, RelatonBib::DocRelationCollection.new([])
|
226
|
+
dec = RelatonBib::FormattedString.new content: "equivalent"
|
227
|
+
rel = RelatonBib::DocumentRelation.new(type: "adoptedAs", bibitem: bib2, description: dec)
|
228
|
+
bib1.relation << rel
|
229
|
+
end
|
230
|
+
|
231
|
+
def add_contributor(bib1, bib2) # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
|
232
|
+
changed = false
|
233
|
+
|
234
|
+
bib2.contributor.each do |bc|
|
235
|
+
next if bc.entity.is_a? RelatonBib::Organization
|
236
|
+
|
237
|
+
existed = bib1.contributor.find { |ic| ic.entity.name == bc.entity.name }
|
238
|
+
if existed
|
239
|
+
chng = add_affiliation existed, bc.entity.affiliation
|
240
|
+
changed ||= chng
|
241
|
+
else
|
242
|
+
bib1.contributor << bc
|
243
|
+
changed = true
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
changed
|
248
|
+
end
|
249
|
+
|
250
|
+
def add_affiliation(contrib, affiliation)
|
251
|
+
changed = false
|
252
|
+
|
253
|
+
affiliation.each do |a|
|
254
|
+
unless contrib.entity.affiliation.include? a
|
255
|
+
contrib.entity.affiliation << a
|
256
|
+
changed = true
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
changed
|
261
|
+
end
|
262
|
+
|
263
|
+
def serialise(bib)
|
264
|
+
case @format
|
265
|
+
when "xml" then bib.to_xml(bibdata: true)
|
266
|
+
when "yaml" then bib.to_hash.to_yaml
|
267
|
+
else bib.send("to_#{@format}")
|
138
268
|
end
|
139
|
-
index.add_or_update bib.docnumber, file
|
140
|
-
File.write file, c, encoding: "UTF-8"
|
141
269
|
end
|
142
270
|
|
143
271
|
#
|
data/lib/relaton_3gpp/parser.rb
CHANGED
@@ -109,7 +109,7 @@ module Relaton3gpp
|
|
109
109
|
|
110
110
|
def release
|
111
111
|
@release ||= case @row["WPM Code 2G"]
|
112
|
-
when /Release_(\d+)/ then "
|
112
|
+
when /Release_(\d+)/ then "REL-#{$1}"
|
113
113
|
when /PH(\d+)/ then "Ph#{$1}"
|
114
114
|
else @row["Release"]
|
115
115
|
end
|
@@ -254,7 +254,7 @@ module Relaton3gpp
|
|
254
254
|
aff << RelatonBib::Affiliation.new(organization: org)
|
255
255
|
end
|
256
256
|
surname = RelatonBib::LocalizedString.new @row["Last Name"], "en", "Latn"
|
257
|
-
forename = RelatonBib::
|
257
|
+
forename = RelatonBib::Forename.new content: @row["First Name"], language: ["en"], script: ["Latn"]
|
258
258
|
name = RelatonBib::FullName.new(surname: surname, forename: [forename])
|
259
259
|
person = RelatonBib::Person.new(name: name, affiliation: aff)
|
260
260
|
role = { type: "author" }
|
data/lib/relaton_3gpp/version.rb
CHANGED
data/relaton_3gpp.gemspec
CHANGED
@@ -36,7 +36,8 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
|
|
36
36
|
# For more information and examples about making a new gem, checkout our
|
37
37
|
# guide at: https://bundler.io/guides/creating_gem.html
|
38
38
|
|
39
|
+
spec.add_dependency "csv"
|
39
40
|
spec.add_dependency "net-ftp", "~> 0.1.0"
|
40
|
-
spec.add_dependency "relaton-bib", "~> 1.19.
|
41
|
+
spec.add_dependency "relaton-bib", "~> 1.19.1"
|
41
42
|
spec.add_dependency "relaton-index", "~> 0.2.0"
|
42
43
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-3gpp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.19.
|
4
|
+
version: 1.19.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: csv
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: net-ftp
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -30,14 +44,14 @@ dependencies:
|
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.19.
|
47
|
+
version: 1.19.1
|
34
48
|
type: :runtime
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.19.
|
54
|
+
version: 1.19.1
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: relaton-index
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|