relaton-bib 1.17.1 → 1.17.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/grammars/versions.json +1 -1
- data/lib/relaton_bib/bibtex_parser.rb +34 -36
- 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: 46d18122233ea0790d42f293b18648a094be8739cac59714cdf2419a5510062b
|
4
|
+
data.tar.gz: 918ef1f018e38e6cdfc0f0cafdf886311794910af463a08f15e5d21088e21062
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61a55508abb720be6180365bbd839987eeadcdc38ccc6160d9c03453303f38ba4b4b16731d03236db4e5b767871bdb00b29aa5eab91ca70bf6b9e69eeab0b22f
|
7
|
+
data.tar.gz: 5e4400c78c97db49cbd30d4bf4f105dfa365ecc570a876a594c10389913190c2d5536412f76cc41458c18ea78ea3f0f5e90681a698f99213076a2995ced94a51
|
data/grammars/versions.json
CHANGED
@@ -78,54 +78,50 @@ module RelatonBib
|
|
78
78
|
|
79
79
|
# @param bibtex [BibTeX::Entry]
|
80
80
|
# @return [Array<Hash>]
|
81
|
-
def fetch_contributor(bibtex) # rubocop:disable Metrics/AbcSize
|
82
|
-
|
83
|
-
fetch_person(bibtex
|
84
|
-
|
85
|
-
end
|
81
|
+
def fetch_contributor(bibtex) # rubocop:disable Metrics/AbcSize
|
82
|
+
contribs = []
|
83
|
+
fetch_person(bibtex, "author") { |author| contribs << author }
|
84
|
+
fetch_person(bibtex, "editor") { |editor| contribs << editor }
|
86
85
|
|
87
|
-
|
88
|
-
|
89
|
-
|
86
|
+
fetch_org(bibtex["publisher"], "publisher") { |pub| contribs << pub }
|
87
|
+
fetch_org(bibtex["institution"], "distributor", "sponsor") { |distr| contribs << distr }
|
88
|
+
fetch_org(bibtex["organization"], "distributor", "sponsor") { |org| contribs << org }
|
89
|
+
fetch_org(bibtex["school"], "distributor", "sponsor") { |school| contribs << school }
|
90
90
|
|
91
|
-
|
92
|
-
contributor << { entity: { name: bibtex.publisher.to_s }, role: [{ type: "publisher" }] }
|
93
|
-
end
|
91
|
+
fetch_howpublished(bibtex) { |pub| contribs << pub }
|
94
92
|
|
95
|
-
|
96
|
-
|
97
|
-
entity: { name: bibtex.institution.to_s },
|
98
|
-
role: [{ type: "distributor", description: ["sponsor"] }],
|
99
|
-
}
|
100
|
-
end
|
93
|
+
contribs
|
94
|
+
end
|
101
95
|
|
102
|
-
|
103
|
-
|
104
|
-
entity: { name: bibtex.organization.to_s },
|
105
|
-
role: [{ type: "distributor", description: ["sponsor"] }],
|
106
|
-
}
|
107
|
-
end
|
96
|
+
def fetch_howpublished(bibtex, &_)
|
97
|
+
return unless bibtex["howpublished"]
|
108
98
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
99
|
+
/\\publisher\{(?<name>.+)\},\\url\{(?<url>.+)\}/ =~ bibtex.howpublished.to_s
|
100
|
+
return unless name && url
|
101
|
+
|
102
|
+
name.gsub!(/\{\\?([^\\]+)\}/, '\1')
|
103
|
+
org = Organization.new(name: name, url: url)
|
104
|
+
yield entity: org, role: [{ type: "publisher" }]
|
105
|
+
end
|
106
|
+
|
107
|
+
def fetch_org(org, type, desc = nil, &_)
|
108
|
+
return unless org
|
109
|
+
|
110
|
+
role = { type: type }
|
111
|
+
role[:description] = [desc] if desc
|
112
|
+
yield entity: Organization.new(name: org.to_s), role: [role]
|
116
113
|
end
|
117
114
|
|
118
115
|
# @param bibtex [BibTeX::Entry]
|
119
116
|
# @return [Array<RelatonBib::Person>]
|
120
|
-
def fetch_person(
|
121
|
-
|
122
|
-
|
123
|
-
person.map do |name|
|
117
|
+
def fetch_person(bibtex, role, &_) # rubocop:disable Metrics/AbcSize
|
118
|
+
bibtex[role]&.each do |name|
|
124
119
|
parts = name.split ", "
|
125
120
|
surname = LocalizedString.new parts.first
|
126
121
|
fname = parts.size > 1 ? parts[1].split : []
|
127
122
|
forename = fname.map { |fn| Forename.new content: fn }
|
128
|
-
|
123
|
+
name = FullName.new(surname: surname, forename: forename)
|
124
|
+
yield entity: Person.new(name: name), role: [{ type: role }]
|
129
125
|
end
|
130
126
|
end
|
131
127
|
|
@@ -147,7 +143,7 @@ module RelatonBib
|
|
147
143
|
|
148
144
|
# @param bibtex [BibTeX::Entry]
|
149
145
|
# @return [RelatonBib::BiblioNoteCollection]
|
150
|
-
def fetch_note(bibtex)
|
146
|
+
def fetch_note(bibtex) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength
|
151
147
|
bibtex.select do |k, _v|
|
152
148
|
%i[annote howpublished comment note content].include? k
|
153
149
|
end.reduce(BiblioNoteCollection.new([])) do |mem, note|
|
@@ -156,6 +152,8 @@ module RelatonBib
|
|
156
152
|
when :content then "tableOfContents"
|
157
153
|
else note[0].to_s
|
158
154
|
end
|
155
|
+
next mem if type == "howpublished" && note[1].to_s.match?(/^\\publisher\{.+\},\\url\{.+\}$/)
|
156
|
+
|
159
157
|
mem << BiblioNote.new(type: type, content: note[1].to_s)
|
160
158
|
end
|
161
159
|
end
|
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.17.
|
4
|
+
version: 1.17.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|