relaton-bib 1.10.3 → 1.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/relaton_bib/bibxml_parser.rb +38 -11
- data/lib/relaton_bib/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: 826acb78507045bc31dd931b706331e248a682507b1454df64d957f97a856fce
|
4
|
+
data.tar.gz: 2a8bd874712691f4586d0a0d75f4c102731d592abf484ddd70a97cc7a2d72c24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff8a95d1afc8c44ce738e6c48cefa65d87fe2f5f2d431e5d5933d8ded66ba577797e55933b8f8082f6dc21841ec68dc3de16c8579d7b5a5af539229f183700c2
|
7
|
+
data.tar.gz: a2a7c1b255cffefcc84c93542062ff42a34b4b6e3c6b1077cb3f6a49c4c2002724ab6cb2f20d54a53fd6a06c423a7a0b43b762ebc0417be30bb85055116cc4a5
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module RelatonBib
|
2
2
|
module BibXMLParser
|
3
3
|
# SeriesInfo what should be saved as docidentifiers in the Relaton model.
|
4
|
-
SERIESINFONAMES = ["DOI"
|
4
|
+
SERIESINFONAMES = ["DOI"].freeze
|
5
5
|
|
6
6
|
FLAVOR = nil
|
7
7
|
|
@@ -75,27 +75,55 @@ module RelatonBib
|
|
75
75
|
#
|
76
76
|
def docids(reference, ver) # rubocop:disable Metrics/MethodLength,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/AbcSize
|
77
77
|
ret = []
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
ret << DocumentIdentifier.new(type:
|
78
|
+
si = reference.at("./seriesInfo[@name='Internet-Draft']",
|
79
|
+
"./front/seriesInfo[@name='Internet-Draft']")
|
80
|
+
if si
|
81
|
+
id = si[:value]
|
82
|
+
id.sub!(/(?<=-)\d{2}$/, ver) if ver
|
83
|
+
ret << DocumentIdentifier.new(type: "Internet-Draft", id: id, primary: true)
|
84
|
+
else
|
85
|
+
id = reference["anchor"] || reference["docName"] || reference["number"]
|
86
|
+
ret << create_docid(id, ver) if id
|
84
87
|
end
|
88
|
+
|
85
89
|
%w[anchor docName number].each do |atr|
|
86
90
|
if reference[atr]
|
87
|
-
|
91
|
+
type = pubid_type id
|
92
|
+
ret << DocumentIdentifier.new(id: reference[atr], type: type, scope: atr)
|
88
93
|
end
|
89
94
|
end
|
95
|
+
|
90
96
|
ret + reference.xpath("./seriesInfo", "./front/seriesInfo").map do |si|
|
91
97
|
next unless SERIESINFONAMES.include? si[:name]
|
92
98
|
|
93
99
|
id = si[:value]
|
94
|
-
id.sub!(/(?<=-)\d{2}$/, ver) if ver && si[:name] == "Internet-Draft"
|
100
|
+
# id.sub!(/(?<=-)\d{2}$/, ver) if ver && si[:name] == "Internet-Draft"
|
95
101
|
DocumentIdentifier.new(id: id, type: si[:name])
|
96
102
|
end.compact
|
97
103
|
end
|
98
104
|
|
105
|
+
def create_docid(id, ver) # rubocop:disable Metrics/MethodLength
|
106
|
+
pref, num = id_to_pref_num(id)
|
107
|
+
if %w[RFC BCP FYI STD].include?(pref)
|
108
|
+
num.sub!(/^-?0+/, "")
|
109
|
+
pid = "#{pref} #{num}"
|
110
|
+
type = pubid_type id
|
111
|
+
elsif %w[I-D draft].include?(pref)
|
112
|
+
pid = "draft-#{num}"
|
113
|
+
pid.sub!(/(?<=-)\d{2}$/, ver) if ver
|
114
|
+
type = "Internet-Draft"
|
115
|
+
else
|
116
|
+
pid = pref ? "#{pref} #{num}" : num
|
117
|
+
type = pubid_type id
|
118
|
+
end
|
119
|
+
DocumentIdentifier.new(type: type, id: pid, primary: true)
|
120
|
+
end
|
121
|
+
|
122
|
+
def id_to_pref_num(id)
|
123
|
+
tn = /^(?<pref>I-D|draft|3GPP|W3C|[A-Z]{2,})[._-]?(?<num>.+)/.match id
|
124
|
+
tn && tn.to_a[1..2]
|
125
|
+
end
|
126
|
+
|
99
127
|
#
|
100
128
|
# Extract document identifier type from identifier
|
101
129
|
#
|
@@ -104,8 +132,7 @@ module RelatonBib
|
|
104
132
|
# @return [String]
|
105
133
|
#
|
106
134
|
def pubid_type(id)
|
107
|
-
|
108
|
-
type_match && type_match[1]
|
135
|
+
id_to_pref_num(id)&.first
|
109
136
|
end
|
110
137
|
|
111
138
|
#
|
data/lib/relaton_bib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-bib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.10.
|
4
|
+
version: 1.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|