relaton-bib 1.13.6 → 1.13.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +0 -1
- data/lib/relaton_bib/bibliographic_item.rb +8 -4
- data/lib/relaton_bib/bibxml_parser.rb +18 -18
- data/lib/relaton_bib/typed_title_string.rb +22 -17
- 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: 566350d7e96478f76484698d7b249e2fc7e22a454a3b2e9572d23b4ddac14723
|
4
|
+
data.tar.gz: 53be5f2b3ee6967f22e654aae40133cbdba560ad176bbfc4c8c0f5cee541385c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fbbf49b3d1cb2cd5a4e1b423f547cf03d4a9d2c8d9178b15e4089d384e8c42f15de338f9a8991c1cd9fd83e9a2ac1c1783b11b7d1f7fbd30d8b53e7652db077
|
7
|
+
data.tar.gz: 011acbf178b30a5b62f9180f229e49ee4c804e75cba490df2802bad897261a6fed9e1d3a40c6cbd78554375de7884c1447afbdc02e48570976f439244edbaedd
|
data/.github/workflows/rake.yml
CHANGED
@@ -956,7 +956,7 @@ module RelatonBib
|
|
956
956
|
builder.author do |xml|
|
957
957
|
xml.parent[:role] = "editor" if c.role.detect { |r| r.type == "editor" }
|
958
958
|
if c.entity.is_a?(Person) then render_person xml, c.entity
|
959
|
-
else render_organization xml, c.entity
|
959
|
+
else render_organization xml, c.entity, c.role
|
960
960
|
end
|
961
961
|
render_address xml, c
|
962
962
|
end
|
@@ -1039,14 +1039,18 @@ module RelatonBib
|
|
1039
1039
|
# @param [Nokogiri::XML::Builder] builder xml builder
|
1040
1040
|
# @param [RelatonBib::Organization] org organization
|
1041
1041
|
#
|
1042
|
-
def render_organization(builder, org) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
|
1042
|
+
def render_organization(builder, org, role = []) # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/AbcSize
|
1043
1043
|
ab = org&.abbreviation&.content
|
1044
1044
|
on = org&.name&.first&.content
|
1045
1045
|
orgname = if BibXMLParser::ORGNAMES.key?(ab) then ab
|
1046
1046
|
else BibXMLParser::ORGNAMES.key(on) || on || ab
|
1047
1047
|
end
|
1048
|
-
|
1049
|
-
|
1048
|
+
if role.detect { |r| r.description.detect { |d| d.content == "BibXML author" } }
|
1049
|
+
builder.parent[:fullname] = orgname
|
1050
|
+
else
|
1051
|
+
o = builder.organization orgname
|
1052
|
+
o[:abbrev] = ab if ab
|
1053
|
+
end
|
1050
1054
|
end
|
1051
1055
|
end
|
1052
1056
|
end
|
@@ -12,6 +12,11 @@ module RelatonBib
|
|
12
12
|
"3GPP" => "3rd Generation Partnership Project",
|
13
13
|
}.freeze
|
14
14
|
|
15
|
+
FULLNAMEORG = [
|
16
|
+
"IAB", "Internet Architecture Board", "IAB and IESG", "IESG",
|
17
|
+
"IAB Advisory Committee", "Internet Engineering Steering Group"
|
18
|
+
].freeze
|
19
|
+
|
15
20
|
#
|
16
21
|
# Parse BibXML content
|
17
22
|
#
|
@@ -215,19 +220,24 @@ module RelatonBib
|
|
215
220
|
# @return [Array<Hash>]
|
216
221
|
def contributors(reference)
|
217
222
|
reference.xpath("./front/author").map do |contrib|
|
218
|
-
|
219
|
-
else organization(contrib)
|
220
|
-
end
|
223
|
+
full_name_org(contrib) || person(contrib, reference) || organization(contrib)
|
221
224
|
end.compact
|
222
|
-
|
225
|
+
end
|
226
|
+
|
227
|
+
def full_name_org(contrib)
|
228
|
+
return unless FULLNAMEORG.include? contrib[:fullname]
|
229
|
+
|
230
|
+
role = contributor_role(contrib)
|
231
|
+
role[:description] = ["BibXML author"]
|
232
|
+
{ entity: new_org(contrib[:fullname]), role: [role] }
|
223
233
|
end
|
224
234
|
|
225
235
|
# @param author [Nokogiri::XML::Element]
|
226
236
|
# @param reference [Nokogiri::XML::Element]
|
227
237
|
# @return [Array<Hash{Symbol=>RelatonBib::Person,Symbol=>Array<String>}>]
|
228
238
|
def person(author, reference)
|
229
|
-
|
230
|
-
|
239
|
+
return unless author[:fullname] || author[:surname]
|
240
|
+
|
231
241
|
entity = Person.new(
|
232
242
|
name: full_name(author, reference),
|
233
243
|
affiliation: affiliation(author),
|
@@ -241,15 +251,6 @@ module RelatonBib
|
|
241
251
|
# @return [Array<Hash{Symbol=>RelatonBib::Organization,
|
242
252
|
# Symbol=>Array<String>}>]
|
243
253
|
def organization(contrib)
|
244
|
-
# publisher = { entity: new_org, role: [type: "publisher"] }
|
245
|
-
# orgs = reference.xpath("./seriesinfo").reduce([]) do |mem, si|
|
246
|
-
# next mem unless si[:stream]
|
247
|
-
|
248
|
-
# mem << { entity: new_org(si[:stream], nil), role: [type: "author"] }
|
249
|
-
# end
|
250
|
-
# orgs + reference.xpath(
|
251
|
-
# "front/author[not(@surname)][not(@fullname)]/organization",
|
252
|
-
# ).map do |org|
|
253
254
|
org = contrib.at("./organization")
|
254
255
|
orgname = org.text.strip
|
255
256
|
return if orgname.empty?
|
@@ -299,10 +300,9 @@ module RelatonBib
|
|
299
300
|
end
|
300
301
|
|
301
302
|
# @param name [String]
|
302
|
-
# @param abbr [String]
|
303
|
+
# @param abbr [String, nil]
|
303
304
|
# @return [RelatonBib::Organization]
|
304
|
-
def new_org(name, abbr)
|
305
|
-
# (name = "Internet Engineering Task Force", abbr = "IETF")
|
305
|
+
def new_org(name, abbr = nil)
|
306
306
|
Organization.new name: name, abbreviation: abbr
|
307
307
|
end
|
308
308
|
|
@@ -101,6 +101,7 @@ module RelatonBib
|
|
101
101
|
# @param content [String]
|
102
102
|
# @param language [String]
|
103
103
|
# @param script [String]
|
104
|
+
# @param format [String]
|
104
105
|
def initialize(**args) # rubocop:disable Metrics/MethodLength
|
105
106
|
unless args[:title] || args[:content]
|
106
107
|
raise ArgumentError, %{Keyword "title" or "content" should be passed.}
|
@@ -108,24 +109,35 @@ module RelatonBib
|
|
108
109
|
|
109
110
|
@type = args[:type]
|
110
111
|
|
111
|
-
|
112
|
-
|
112
|
+
case args[:title]
|
113
|
+
when FormattedString then @title = args[:title]
|
114
|
+
when Hash then @title = FormattedString.new(**args[:title])
|
113
115
|
else
|
114
116
|
fsargs = args.select { |k, _v| ARGS.include? k }
|
115
117
|
@title = FormattedString.new(**fsargs)
|
116
118
|
end
|
117
119
|
end
|
118
120
|
|
119
|
-
#
|
120
|
-
#
|
121
|
-
|
121
|
+
#
|
122
|
+
# Create TypedTitleStringCollection from string
|
123
|
+
#
|
124
|
+
# @param title [String] title string
|
125
|
+
# @param lang [String, nil] language code Iso639
|
126
|
+
# @param script [String, nil] script code Iso15924
|
127
|
+
# @param format [String] format text/html, text/plain
|
128
|
+
#
|
129
|
+
# @return [TypedTitleStringCollection] collection of TypedTitleString
|
130
|
+
#
|
131
|
+
def self.from_string(title, lang = nil, script = nil, format = "text/plain")
|
122
132
|
types = %w[title-intro title-main title-part]
|
123
133
|
ttls = split_title(title)
|
124
134
|
tts = ttls.map.with_index do |p, i|
|
125
|
-
|
135
|
+
next unless p
|
136
|
+
|
137
|
+
new type: types[i], content: p, language: lang, script: script, format: format
|
126
138
|
end.compact
|
127
139
|
tts << new(type: "main", content: ttls.compact.join(" - "),
|
128
|
-
language: lang, script: script)
|
140
|
+
language: lang, script: script, format: format)
|
129
141
|
TypedTitleStringCollection.new tts
|
130
142
|
end
|
131
143
|
|
@@ -140,10 +152,10 @@ module RelatonBib
|
|
140
152
|
end
|
141
153
|
|
142
154
|
# @param ttls [Array<String>]
|
143
|
-
# @return [Array<
|
155
|
+
# @return [Array<String, nil>]
|
144
156
|
def self.intro_or_part(ttls)
|
145
157
|
if /^(Part|Partie) \d+:/.match? ttls[1]
|
146
|
-
[nil, ttls[0], ttls[1
|
158
|
+
[nil, ttls[0], ttls[1..].join(" -- ")]
|
147
159
|
else
|
148
160
|
parts = ttls.slice(2..-1)
|
149
161
|
part = parts.join " -- " if parts.any?
|
@@ -162,13 +174,6 @@ module RelatonBib
|
|
162
174
|
th = title.to_hash
|
163
175
|
return th unless type
|
164
176
|
|
165
|
-
# hash = { "type" => type }
|
166
|
-
# if th.is_a? String
|
167
|
-
# hash["content"] = th
|
168
|
-
# else
|
169
|
-
# hash.merge! th
|
170
|
-
# end
|
171
|
-
# hash
|
172
177
|
th.merge "type" => type
|
173
178
|
end
|
174
179
|
|
@@ -176,7 +181,7 @@ module RelatonBib
|
|
176
181
|
# @param count [Integer] number of titles
|
177
182
|
# @return [String]
|
178
183
|
def to_asciibib(prefix = "", count = 1) # rubocop:disable Metrics/AbcSize
|
179
|
-
pref = prefix.empty? ? prefix : prefix
|
184
|
+
pref = prefix.empty? ? prefix : "#{prefix}."
|
180
185
|
out = count > 1 ? "#{pref}title::\n" : ""
|
181
186
|
out += "#{pref}title.type:: #{type}\n" if type
|
182
187
|
out += title.to_asciibib "#{pref}title", 1, !(type.nil? || type.empty?)
|
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.13.
|
4
|
+
version: 1.13.8
|
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-09-
|
11
|
+
date: 2022-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|