relaton-bib 1.11.4 → 1.11.7
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 +1 -20
- data/.rubocop.yml +1 -1
- data/lib/relaton_bib/bibliographic_item.rb +3 -1
- data/lib/relaton_bib/bibxml_parser.rb +2 -2
- data/lib/relaton_bib/localized_string.rb +56 -3
- data/lib/relaton_bib/version.rb +1 -1
- data/lib/relaton_bib/xml_parser.rb +1 -1
- data/lib/relaton_bib.rb +1 -0
- data/relaton-bib.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dffbd3f78b2468d48d601dd2cb1fa883c94d16d0b6c16a213219f85bbeef4c3
|
4
|
+
data.tar.gz: b04d3b2db08c74e0ba9599c36a35ebd00dc62501ce0847bbce046cbcc9892fa8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adf68e1aa4a1c7f8fc719cf51bfc1b74d0e8ae49374647d70140021d5250908c52b0728219cb5eda9aed442eaf3f12674648ac1e61af744ffce345d0e81c7b91
|
7
|
+
data.tar.gz: 29690620969a335e11ab867163f33b530072cea8ceaab4d2980c60eadf14c9eaddb2976c02826cdf13ad677dd2ef781539419a014929481bce0e90274cc6dad7
|
data/.github/workflows/rake.yml
CHANGED
@@ -10,23 +10,4 @@ on:
|
|
10
10
|
|
11
11
|
jobs:
|
12
12
|
rake:
|
13
|
-
|
14
|
-
runs-on: ${{ matrix.os }}
|
15
|
-
continue-on-error: ${{ matrix.experimental }}
|
16
|
-
strategy:
|
17
|
-
fail-fast: false
|
18
|
-
matrix:
|
19
|
-
ruby: [ '3.0', '2.7', '2.6' ]
|
20
|
-
os: [ ubuntu-latest, windows-latest, macos-latest ]
|
21
|
-
experimental: [ false ]
|
22
|
-
steps:
|
23
|
-
- uses: actions/checkout@v2
|
24
|
-
with:
|
25
|
-
submodules: true
|
26
|
-
|
27
|
-
- uses: ruby/setup-ruby@v1
|
28
|
-
with:
|
29
|
-
ruby-version: ${{ matrix.ruby }}
|
30
|
-
bundler-cache: true
|
31
|
-
|
32
|
-
- run: bundle exec rake
|
13
|
+
uses: relaton/support/.github/workflows/rake.yml@master
|
data/.rubocop.yml
CHANGED
@@ -37,7 +37,9 @@ module RelatonBib
|
|
37
37
|
TYPES = %W[article book booklet conference manual proceedings presentation
|
38
38
|
thesis techreport standard unpublished map electronic\sresource
|
39
39
|
audiovisual film video broadcast graphic_work music patent
|
40
|
-
inbook incollection inproceedings journal
|
40
|
+
inbook incollection inproceedings journal software website
|
41
|
+
webresource dataset archival social_media alert message
|
42
|
+
conversation misc].freeze
|
41
43
|
|
42
44
|
# @return [TrueClass, FalseClass, NilClass]
|
43
45
|
attr_accessor :all_parts
|
@@ -7,7 +7,7 @@ module RelatonBib
|
|
7
7
|
FLAVOR = nil
|
8
8
|
|
9
9
|
ORGNAMES = {
|
10
|
-
"IEEE" => "
|
10
|
+
"IEEE" => "Institute of Electrical and Electronics Engineers",
|
11
11
|
"W3C" => "World Wide Web Consortium",
|
12
12
|
"3GPP" => "3rd Generation Partnership Project",
|
13
13
|
}.freeze
|
@@ -194,7 +194,7 @@ module RelatonBib
|
|
194
194
|
# @return [Array<RelatonBib::FormattedString>]
|
195
195
|
def abstracts(ref)
|
196
196
|
ref.xpath("./front/abstract").map do |a|
|
197
|
-
c = a.
|
197
|
+
c = a.inner_html.gsub(/\s*(<\/?)t(>)\s*/, '\1p\2')
|
198
198
|
.gsub(/[\t\n]/, " ").squeeze " "
|
199
199
|
FormattedString.new(content: c, language: language(ref), script: "Latn",
|
200
200
|
format: "text/html")
|
@@ -56,12 +56,65 @@ module RelatonBib
|
|
56
56
|
else
|
57
57
|
builder.parent["language"] = language.join(",") if language&.any?
|
58
58
|
builder.parent["script"] = script.join(",") if script&.any?
|
59
|
-
builder.parent
|
59
|
+
builder.parent.inner_html = encode content
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
|
64
|
-
|
63
|
+
#
|
64
|
+
# Encode content.
|
65
|
+
#
|
66
|
+
# @param [String] cnt content
|
67
|
+
#
|
68
|
+
# @return [String] encoded content
|
69
|
+
#
|
70
|
+
def encode(cnt) # rubocop:disable Metrics/MethodLength
|
71
|
+
regex = /(?<prf>.*?)(?<xml><(?<tag>\w+)>.*<\/\k<tag>>)(?<sfx>.*)/m
|
72
|
+
if cnt.match(regex)
|
73
|
+
prf = Regexp.last_match(:prf).lstrip
|
74
|
+
xml = Regexp.last_match[:xml]
|
75
|
+
sfx = Regexp.last_match(:sfx).rstrip
|
76
|
+
parts = xml.scan(/\s*<(?<tago>\w+)>(?<cnt1>.*?)(?=<\/?\w+>)|(?<cnt2>.*?)<\/(?<tagc>\w+)>/)
|
77
|
+
out = scan_xml parts
|
78
|
+
"#{escp(prf)}#{out}#{escp(sfx)}"
|
79
|
+
else
|
80
|
+
escp cnt
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Scan XML and escape HTML entities.
|
86
|
+
#
|
87
|
+
# @param [Array<Array<String,nik>>] parts XML parts
|
88
|
+
#
|
89
|
+
# @return [String] output string
|
90
|
+
#
|
91
|
+
def scan_xml(parts) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/PerceivedComplexity,Metrics/MethodLength
|
92
|
+
return "" unless parts.any? && parts.first[0]
|
93
|
+
|
94
|
+
tago, cnt1, = parts.shift
|
95
|
+
if tago && tago == parts.first[3]
|
96
|
+
_, _, cnt2, tagc = parts.shift
|
97
|
+
"<#{tago}>#{escp(cnt1)}#{escp(cnt2)}</#{tagc}>"
|
98
|
+
elsif tago
|
99
|
+
inr = scan_xml parts
|
100
|
+
_, _, cnt2, tagc = parts.shift
|
101
|
+
if tago == tagc
|
102
|
+
"<#{tago}>#{escp(cnt1)}#{inr}#{escp(cnt2)}</#{tagc}>"
|
103
|
+
else
|
104
|
+
"#{escp("<#{tago}>#{cnt1}")}#{inr}#{escp("#{cnt2}</#{tagc}>")}"
|
105
|
+
end
|
106
|
+
end + scan_xml(parts)
|
107
|
+
end
|
108
|
+
|
109
|
+
#
|
110
|
+
# Escope HTML entities.
|
111
|
+
#
|
112
|
+
# @param [String] str input string
|
113
|
+
#
|
114
|
+
# @return [String] output string
|
115
|
+
#
|
116
|
+
def escp(str)
|
117
|
+
HTMLEntities.new.encode str
|
65
118
|
end
|
66
119
|
|
67
120
|
# @return [Hash]
|
data/lib/relaton_bib/version.rb
CHANGED
@@ -354,7 +354,7 @@ module RelatonBib
|
|
354
354
|
# @return [Array<RelatonBib::FormattedString>]
|
355
355
|
def fetch_abstract(item)
|
356
356
|
item.xpath("./abstract").map do |a|
|
357
|
-
c = a.
|
357
|
+
c = a.inner_html(encoding: "utf-8").strip
|
358
358
|
FormattedString.new(content: c, language: a[:language],
|
359
359
|
script: a[:script], format: a[:format])
|
360
360
|
end
|
data/lib/relaton_bib.rb
CHANGED
data/relaton-bib.gemspec
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.11.
|
4
|
+
version: 1.11.7
|
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-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: htmlentities
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: iso639
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|