relaton-3gpp 1.19.0 → 1.19.1

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: 8ff1174543dfbd48b4d626209d606068d47ae500cd7b9bbf5cd76fa349286d04
4
- data.tar.gz: df03d0d8c121fdf64838e5d4d4c5ee763d7e44296a25d028203284dbd5fccd87
3
+ metadata.gz: 45004cd52d3255e9882f17e3c4331025aaf389c21ad1c756ba3aeccd5953f5b0
4
+ data.tar.gz: d87bbfcdbdd04d17726554e7bcbd7438b8edc5f31dcc7030553522f292ea9ec2
5
5
  SHA512:
6
- metadata.gz: f7c829da8ad2a8c9cadba2293d87e0f8cf90db08ce35f91b411d00f3c261d990c6b3d2a105ac81bc9112e726acf913e471b364c8bc5c44af762e36c1b89cf5ea
7
- data.tar.gz: 1e6d5b9679d1ea1c59aee4a43c807772bfadb0a28943d56930f0295cd75aa1bddfbfdc958406616b3622d54afa8d427a26b08d476d505130dd5585ede977cef4
6
+ metadata.gz: 9e11c551066552effe3e897850210ba5b7e06f033b5ddc2798f1ec74b68534cd3b87772b6175f506af4909e376f55c078701035a2a4353399ab8f88f4ffc1d76
7
+ data.tar.gz: 2303de76da8eebe06ac967b54fe08b4e2cb78215f66cf8a789182f8c81d89286ca97034e1617dee50b0efb0e92a90c7aa75914903c0e79a336b830daa613e2d4
@@ -80,7 +80,7 @@ module Relaton3gpp
80
80
  #
81
81
  # @return [Hash
82
82
  #
83
- def to_hash
83
+ def to_hash(embedded: false)
84
84
  hash = super
85
85
  hash["radiotechnology"] = @radiotechnology if @radiotechnology
86
86
  hash["common-ims-spec"] = @common_ims_spec if @common_ims_spec
@@ -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, col_sep: ";").each do |row|
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
- c = case @format
129
- when "xml" then bib.to_xml(bibdata: true)
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
- Util.warn "File #{file} already exists. Document: #{bib.docnumber}"
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
  #
@@ -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 "R#{$1}"
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::LocalizedString.new @row["First Name"], "en", "Latn"
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" }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Relaton3gpp
4
- VERSION = "1.19.0"
4
+ VERSION = "1.19.1"
5
5
  end
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.0"
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.0
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-03 00:00:00.000000000 Z
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.0
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.0
54
+ version: 1.19.1
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: relaton-index
43
57
  requirement: !ruby/object:Gem::Requirement