relaton-iec 2.0.0.pre.alpha.2 → 2.0.0.pre.alpha.3
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 +4 -4
- data/lib/relaton/iec/bibliography.rb +54 -1
- data/lib/relaton/iec/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ed597ec310f08e21a319b80ba42b45dc9e431a2b14100c18d45353314c44bb80
|
|
4
|
+
data.tar.gz: c9f4043f6d6e9e98359afea8ff2f6b9499ca408712f65f4c90d514a290fdedfe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c04abe068d4badc329f6e2a7598bf13562b3e21b6163a1d02593b7c52ba91385cd97c1c45aee087f8b909dca148bdaa4bdf58cffaf4e0b35036ddf569e9efb95
|
|
7
|
+
data.tar.gz: 120b8a7267badaf015db74182579fe079fb43e08d9fc2987c72d7cfb2772581f3467e969c24ad51245d5de8f098a9562d27b45048bf0fd4f0c97164e39481c99
|
|
@@ -179,10 +179,63 @@ module Relaton
|
|
|
179
179
|
ret = hit.item
|
|
180
180
|
if publication_date_in_range?(ret, opts)
|
|
181
181
|
Util.info "Found: `#{ret.docidentifier.first.content}`", key: pubid.to_s
|
|
182
|
-
ret
|
|
182
|
+
freeze_item(ret, opts)
|
|
183
183
|
end
|
|
184
184
|
end
|
|
185
185
|
|
|
186
|
+
# Freeze a document in time by filtering out relations, dates, and status
|
|
187
|
+
# that fall outside the specified date range.
|
|
188
|
+
def freeze_item(item, opts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
189
|
+
return item unless opts[:publication_date_before] || opts[:publication_date_after]
|
|
190
|
+
|
|
191
|
+
item.relation = item.relation.select { |r| relation_in_range?(r, opts) }
|
|
192
|
+
|
|
193
|
+
had_obsoleted = item.date.any? { |d| d.type == "obsoleted" }
|
|
194
|
+
item.date = item.date.select { |d| date_entry_in_range?(d, opts) }
|
|
195
|
+
lost_obsoleted = had_obsoleted && item.date.none? { |d| d.type == "obsoleted" }
|
|
196
|
+
|
|
197
|
+
if lost_obsoleted && item.status&.stage&.content == "95"
|
|
198
|
+
item.status.stage.content = "60"
|
|
199
|
+
item.status.substage&.content = "60"
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
item
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Check if a relation's bibitem falls within the date range.
|
|
206
|
+
def relation_in_range?(rel, opts) # rubocop:disable Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity
|
|
207
|
+
rel.bibitem.date&.each do |d|
|
|
208
|
+
dt = (d.at || d.from)&.to_date
|
|
209
|
+
next unless dt
|
|
210
|
+
|
|
211
|
+
return false if opts[:publication_date_before] && dt >= opts[:publication_date_before]
|
|
212
|
+
return false if opts[:publication_date_after] && dt < opts[:publication_date_after]
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
rel.bibitem.docidentifier&.each do |did|
|
|
216
|
+
year = did.content[/:(\d{4})/, 1]&.to_i
|
|
217
|
+
next unless year&.positive?
|
|
218
|
+
|
|
219
|
+
return false if opts[:publication_date_before] && year >= opts[:publication_date_before].year
|
|
220
|
+
return false if opts[:publication_date_after] && year < opts[:publication_date_after].year
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
true
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# Check if a date entry falls within the date range (always keeps published).
|
|
227
|
+
def date_entry_in_range?(date_entry, opts)
|
|
228
|
+
return true if date_entry.type == "published"
|
|
229
|
+
|
|
230
|
+
dt = (date_entry.at || date_entry.from)&.to_date
|
|
231
|
+
return true unless dt
|
|
232
|
+
|
|
233
|
+
return false if opts[:publication_date_before] && dt >= opts[:publication_date_before]
|
|
234
|
+
return false if opts[:publication_date_after] && dt < opts[:publication_date_after]
|
|
235
|
+
|
|
236
|
+
true
|
|
237
|
+
end
|
|
238
|
+
|
|
186
239
|
# Analyze why no match was found and give helpful tips.
|
|
187
240
|
# @param pubid [Pubid::Iec::Identifier]
|
|
188
241
|
# @param result [Relaton::Iec::HitCollection]
|
data/lib/relaton/iec/version.rb
CHANGED