relaton-w3c 1.11.3 → 1.11.6
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 -24
- data/.rubocop.yml +1 -1
- data/data/reference.W3C.DSig-label.xml +1 -1
- data/data/reference.W3C.P3P-rdfschema.xml +1 -1
- data/data/reference.W3C.P3P.xml +1 -1
- data/data/reference.W3C.PICS-labels.xml +1 -1
- data/data/reference.W3C.PICS-rules.xml +1 -1
- data/data/reference.W3C.PICS-services.xml +1 -1
- data/data/reference.W3C.daml-oil-reference.xml +1 -1
- data/data/reference.W3C.soap11.xml +1 -1
- data/data/reference.W3C.soap12-part1.xml +1 -1
- data/data/reference.W3C.soap12-part2.xml +1 -1
- data/data/reference.W3C.xkms.xml +1 -1
- data/data/reference.W3C.xml-c14n.xml +1 -1
- data/data/reference.W3C.xmldsig-core.xml +1 -1
- data/data/reference.W3C.xmlenc-core.xml +1 -1
- data/data/reference.W3C.xpath.xml +1 -1
- data/lib/relaton_w3c/data_fetcher.rb +6 -54
- data/lib/relaton_w3c/data_index.rb +50 -45
- data/lib/relaton_w3c/data_parser.rb +61 -29
- data/lib/relaton_w3c/version.rb +1 -1
- data/lib/relaton_w3c/w3c_bibliography.rb +3 -3
- data/lib/relaton_w3c/workgroups.yaml +2 -0
- data/lib/relaton_w3c.rb +0 -3
- data/relaton_w3c.gemspec +3 -3
- metadata +7 -10
- data/lib/relaton_w3c/hit.rb +0 -15
- data/lib/relaton_w3c/hit_collection.rb +0 -172
- data/lib/relaton_w3c/scrapper.rb +0 -218
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faf78f2abf348e9aa6dd74f2f0fe94899d9d6fc34af3368849a818b6dd856e26
|
4
|
+
data.tar.gz: c4cabbd9559b9f122f34fbb204f7780606bfc87c9db999492fbdd2b6b02639b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc6e6c80914b8973091795b1f234ea57a49499bb0466ae04a14358c30e526c38a6f607031e9dd0d4963c2caccca26dd9418939c871b4f47016aa094156d783a3
|
7
|
+
data.tar.gz: 041625ce66ae2949112bc20856de89b05fd4772c1dd1f3413a3a5b04059ec7cb84f8b92517a3634294080031760fca8795b7ae113bbfae03986f775c5f52acb0
|
data/.github/workflows/rake.yml
CHANGED
@@ -10,27 +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', '2.5' ]
|
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
|
-
# https://github.com/ruby-debug/debase/issues/89#issuecomment-686827382
|
28
|
-
- if: matrix.os == 'macos-latest' && matrix.ruby == '2.5'
|
29
|
-
run: echo BUNDLE_BUILD__DEBASE="--with-cflags=\"-Wno-error=implicit-function-declaration\"" >> $GITHUB_ENV
|
30
|
-
|
31
|
-
- uses: ruby/setup-ruby@v1
|
32
|
-
with:
|
33
|
-
ruby-version: ${{ matrix.ruby }}
|
34
|
-
bundler-cache: true
|
35
|
-
|
36
|
-
- run: bundle exec rake
|
13
|
+
uses: relaton/support/.github/workflows/rake.yml@master
|
data/.rubocop.yml
CHANGED
data/data/reference.W3C.P3P.xml
CHANGED
data/data/reference.W3C.xkms.xml
CHANGED
@@ -68,60 +68,7 @@ module RelatonW3c
|
|
68
68
|
end
|
69
69
|
|
70
70
|
#
|
71
|
-
#
|
72
|
-
#
|
73
|
-
# def create_index
|
74
|
-
# index_file = "index-w3c.yaml"
|
75
|
-
# index_yaml = @index.sort do |a, b|
|
76
|
-
# compare_index_items a, b
|
77
|
-
# end.to_yaml
|
78
|
-
# File.write index_file, index_yaml, encoding: "UTF-8"
|
79
|
-
# end
|
80
|
-
|
81
|
-
#
|
82
|
-
# Compare index items
|
83
|
-
#
|
84
|
-
# @param [Hash] aid first item
|
85
|
-
# @param [Hash] bid second item
|
86
|
-
#
|
87
|
-
# @return [Integer] comparison result
|
88
|
-
#
|
89
|
-
# def compare_index_items(aid, bid) # rubocop:disable Metrics/AbcSize
|
90
|
-
# ret = aid[:code] <=> bid[:code]
|
91
|
-
# ret = stage_weight(bid[:stage]) <=> stage_weight(aid[:stage]) if ret.zero?
|
92
|
-
# ret = date_weight(bid[:date]) <=> date_weight(aid[:date]) if ret.zero?
|
93
|
-
# # ret = aid[:type] <=> bid[:type] if ret.zero?
|
94
|
-
# ret
|
95
|
-
# end
|
96
|
-
|
97
|
-
#
|
98
|
-
# Weight of stage
|
99
|
-
#
|
100
|
-
# @param [String, nil] stage stage
|
101
|
-
#
|
102
|
-
# @return [Integer] weight
|
103
|
-
#
|
104
|
-
# def stage_weight(stage)
|
105
|
-
# return DataParser::STAGES.size if stage.nil?
|
106
|
-
|
107
|
-
# DataParser::STAGES.keys.index(stage)
|
108
|
-
# end
|
109
|
-
|
110
|
-
#
|
111
|
-
# Weight of date
|
112
|
-
#
|
113
|
-
# @param [String] date date
|
114
|
-
#
|
115
|
-
# @return [String] weight
|
116
|
-
#
|
117
|
-
# def date_weight(date)
|
118
|
-
# return "99999999" if date.nil?
|
119
|
-
|
120
|
-
# date
|
121
|
-
# end
|
122
|
-
|
123
|
-
#
|
124
|
-
# Query RDF source for documents
|
71
|
+
# Query RDF source for versioned documents
|
125
72
|
#
|
126
73
|
# @return [RDF::Query::Solutions] query results
|
127
74
|
#
|
@@ -140,6 +87,11 @@ module RelatonW3c
|
|
140
87
|
data.query sse
|
141
88
|
end
|
142
89
|
|
90
|
+
#
|
91
|
+
# Query RDF source for unversioned documents
|
92
|
+
#
|
93
|
+
# @return [Array<RDF::Query::Solution>] query results
|
94
|
+
#
|
143
95
|
def query_unversioned_docs
|
144
96
|
sse = SPARQL.parse(%(
|
145
97
|
PREFIX doc: <http://www.w3.org/2000/10/swap/pim/doc#>
|
@@ -13,25 +13,6 @@ module RelatonW3c
|
|
13
13
|
@index = index
|
14
14
|
end
|
15
15
|
|
16
|
-
#
|
17
|
-
# Create index from a GitHub repository
|
18
|
-
#
|
19
|
-
# @return [RelatonW3c::DataIndex] data index
|
20
|
-
#
|
21
|
-
def self.create_from_repo # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
22
|
-
resp = Zip::InputStream.new URI("#{W3cBibliography::SOURCE}index-w3c.zip").open
|
23
|
-
zip = resp.get_next_entry
|
24
|
-
|
25
|
-
# Newer versions of Psych uses the `permitted_classes:` parameter
|
26
|
-
index = if YAML.method(:safe_load).parameters.collect(&:last).index(:permitted_classes)
|
27
|
-
YAML.safe_load(zip.get_input_stream.read, permitted_classes: [Symbol])
|
28
|
-
else
|
29
|
-
YAML.safe_load(zip.get_input_stream.read, [Symbol])
|
30
|
-
end
|
31
|
-
|
32
|
-
DataIndex.new index: index
|
33
|
-
end
|
34
|
-
|
35
16
|
#
|
36
17
|
# Add document to index
|
37
18
|
#
|
@@ -39,7 +20,9 @@ module RelatonW3c
|
|
39
20
|
# @param [String] file path to document file
|
40
21
|
#
|
41
22
|
def add(docnumber, file)
|
42
|
-
|
23
|
+
dnparts = self.class.docnumber_to_parts docnumber
|
24
|
+
dnparts[:file] = file
|
25
|
+
@index << dnparts
|
43
26
|
end
|
44
27
|
|
45
28
|
#
|
@@ -67,11 +50,14 @@ module RelatonW3c
|
|
67
50
|
# @return [String] document's filename
|
68
51
|
#
|
69
52
|
def search(ref) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
70
|
-
dparts = docnumber_to_parts(ref)
|
53
|
+
dparts = self.class.docnumber_to_parts(ref)
|
54
|
+
return if dparts[:code].nil?
|
55
|
+
|
71
56
|
@index.detect do |parts|
|
72
57
|
parts[:code].match?(/^#{Regexp.escape dparts[:code]}/i) &&
|
73
58
|
(dparts[:stage].nil? || dparts[:stage].casecmp?(parts[:stage])) &&
|
74
|
-
(dparts[:type].nil? || dparts[:type].casecmp?(parts[:type])
|
59
|
+
(dparts[:type].nil? || dparts[:type].casecmp?(parts[:type]) ||
|
60
|
+
(parts[:type].nil? && dparts[:type] == "TR")) &&
|
75
61
|
(dparts[:date].nil? || dparts[:date] == parts[:date]) &&
|
76
62
|
(dparts[:suff].nil? || dparts[:suff].casecmp?(parts[:suff]))
|
77
63
|
end&.fetch(:file)
|
@@ -86,7 +72,7 @@ module RelatonW3c
|
|
86
72
|
# @return [Integer] comparison result
|
87
73
|
#
|
88
74
|
def compare_index_items(aid, bid) # rubocop:disable Metrics/AbcSize
|
89
|
-
ret = aid[:code] <=> bid[:code]
|
75
|
+
ret = aid[:code].downcase <=> bid[:code].downcase
|
90
76
|
ret = stage_weight(bid[:stage]) <=> stage_weight(aid[:stage]) if ret.zero?
|
91
77
|
ret = date_weight(bid[:date]) <=> date_weight(aid[:date]) if ret.zero?
|
92
78
|
# ret = aid[:type] <=> bid[:type] if ret.zero?
|
@@ -119,28 +105,47 @@ module RelatonW3c
|
|
119
105
|
date
|
120
106
|
end
|
121
107
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
(
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
108
|
+
class << self
|
109
|
+
#
|
110
|
+
# Create index from a GitHub repository
|
111
|
+
#
|
112
|
+
# @return [RelatonW3c::DataIndex] data index
|
113
|
+
#
|
114
|
+
def create_from_repo # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
115
|
+
resp = Zip::InputStream.new URI("#{W3cBibliography::SOURCE}index-w3c.zip").open
|
116
|
+
zip = resp.get_next_entry
|
117
|
+
|
118
|
+
# Newer versions of Psych uses the `permitted_classes:` parameter
|
119
|
+
index = if YAML.method(:safe_load).parameters.collect(&:last).index(:permitted_classes)
|
120
|
+
YAML.safe_load(zip.get_input_stream.read, permitted_classes: [Symbol])
|
121
|
+
else
|
122
|
+
YAML.safe_load(zip.get_input_stream.read, [Symbol])
|
123
|
+
end
|
124
|
+
|
125
|
+
DataIndex.new index: index
|
126
|
+
end
|
127
|
+
|
128
|
+
#
|
129
|
+
# Parse document number to parts
|
130
|
+
#
|
131
|
+
# @param [String] docnumber document number
|
132
|
+
#
|
133
|
+
# @return [Hash{Symbol=>String}] document parts
|
134
|
+
#
|
135
|
+
def docnumber_to_parts(docnumber) # rubocop:disable Metrics/MethodLength
|
136
|
+
%r{
|
137
|
+
^(?:(?:(?<stage>WD|CRD|CR|PR|PER|REC|SPSD|OBSL|RET)|(?<type>D?NOTE|TR))-)?
|
138
|
+
(?<code>\w+(?:[+-][\w.]+)*?)
|
139
|
+
(?:-(?<date>\d{8}|\d{6}|\d{4}))?
|
140
|
+
(?:/(?<suff>\w+))?$
|
141
|
+
}xi =~ docnumber
|
142
|
+
entry = { code: code }
|
143
|
+
entry[:stage] = stage if stage
|
144
|
+
entry[:type] = type if type
|
145
|
+
entry[:date] = date if date
|
146
|
+
entry[:suff] = suff if suff
|
147
|
+
entry
|
148
|
+
end
|
144
149
|
end
|
145
150
|
end
|
146
151
|
end
|
@@ -86,9 +86,10 @@ module RelatonW3c
|
|
86
86
|
# @return [RelatonBib::TypedTitleStringCollection] title
|
87
87
|
#
|
88
88
|
def parse_title
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
content = if @sol.respond_to?(:title) then @sol.title.to_s
|
90
|
+
else document_versions.max_by { |dv| dv.date.to_s }.title.to_s
|
91
|
+
end
|
92
|
+
t = RelatonBib::TypedTitleString.new content: content
|
92
93
|
RelatonBib::TypedTitleStringCollection.new [t]
|
93
94
|
end
|
94
95
|
|
@@ -99,7 +100,6 @@ module RelatonW3c
|
|
99
100
|
#
|
100
101
|
def parse_link
|
101
102
|
link = @sol.respond_to?(:link) ? @sol.link : @sol.version_of
|
102
|
-
|
103
103
|
[RelatonBib::TypedUri.new(type: "src", content: link.to_s)]
|
104
104
|
end
|
105
105
|
|
@@ -109,9 +109,7 @@ module RelatonW3c
|
|
109
109
|
# @return [Arra<RelatonBib::DocumentIdentifier>] docidentifier
|
110
110
|
#
|
111
111
|
def parse_docid
|
112
|
-
|
113
|
-
|
114
|
-
id = pub_id(@sol.link)
|
112
|
+
id = @sol.respond_to?(:link) ? pub_id(@sol.link) : pub_id(@sol.version_of)
|
115
113
|
[RelatonBib::DocumentIdentifier.new(type: "W3C", id: id, primary: true)]
|
116
114
|
end
|
117
115
|
|
@@ -169,7 +167,7 @@ module RelatonW3c
|
|
169
167
|
#
|
170
168
|
def type
|
171
169
|
# thre are many types, we need to find the right one
|
172
|
-
@type ||= types_stages&.detect { |t| USED_TYPES.include?(t) }
|
170
|
+
@type ||= types_stages&.detect { |t| USED_TYPES.include?(t) } || "technicalReport"
|
173
171
|
end
|
174
172
|
|
175
173
|
#
|
@@ -221,10 +219,16 @@ module RelatonW3c
|
|
221
219
|
def parse_relation
|
222
220
|
if @sol.respond_to?(:link)
|
223
221
|
relations + editor_drafts
|
224
|
-
else
|
222
|
+
else
|
223
|
+
document_versions.map { |r| create_relation(r.link.to_s, "hasEdition") }
|
225
224
|
end
|
226
225
|
end
|
227
226
|
|
227
|
+
#
|
228
|
+
# Create relations
|
229
|
+
#
|
230
|
+
# @return [Array<RelatonBib::DocumentRelation>] relations
|
231
|
+
#
|
228
232
|
def relations # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
229
233
|
{
|
230
234
|
"doc:obsoletes" => { type: "obsoletes" },
|
@@ -234,14 +238,16 @@ module RelatonW3c
|
|
234
238
|
":previousEdition" => { type: "editionOf" },
|
235
239
|
}.reduce([]) do |acc, (predicate, tp)|
|
236
240
|
acc + relation_query(predicate).map do |r|
|
237
|
-
|
238
|
-
bib = W3cBibliographicItem.new formattedref: fr
|
239
|
-
tp[:description] = RelatonBib::FormattedString.new content: tp[:description] if tp[:description]
|
240
|
-
RelatonBib::DocumentRelation.new(**tp, bibitem: bib)
|
241
|
+
create_relation(r.rel.to_s, tp[:type], tp[:description])
|
241
242
|
end
|
242
243
|
end
|
243
244
|
end
|
244
245
|
|
246
|
+
#
|
247
|
+
# Parse editor drafts relation
|
248
|
+
#
|
249
|
+
# @return [Array<RelatonBib::DocumentRelation>] relation
|
250
|
+
#
|
245
251
|
def editor_drafts # rubocop:disable Metrics/MethodLength
|
246
252
|
sse = SPARQL.parse(%(
|
247
253
|
PREFIX : <http://www.w3.org/2001/02pd/rec54#>
|
@@ -250,15 +256,17 @@ module RelatonW3c
|
|
250
256
|
WHERE { <#{@sol.link}> :ED ?rel . }
|
251
257
|
))
|
252
258
|
@fetcher.data.query(sse).map do |s|
|
253
|
-
|
254
|
-
bib = W3cBibliographicItem.new formattedref: fr
|
255
|
-
desc = RelatonBib::FormattedString.new content: "Editor's draft"
|
256
|
-
RelatonBib::DocumentRelation.new(
|
257
|
-
type: "hasDraft", description: desc, bibitem: bib,
|
258
|
-
)
|
259
|
+
create_relation(s.rel.to_s, "hasDraft", "Editor's draft")
|
259
260
|
end
|
260
261
|
end
|
261
262
|
|
263
|
+
#
|
264
|
+
# Query for relations
|
265
|
+
#
|
266
|
+
# @param [String] predicate relation type
|
267
|
+
#
|
268
|
+
# @return [RDF::Query::Solutions] query result
|
269
|
+
#
|
262
270
|
def relation_query(predicate)
|
263
271
|
sse = SPARQL.parse(%(
|
264
272
|
PREFIX : <http://www.w3.org/2001/02pd/rec54#>
|
@@ -270,19 +278,43 @@ module RelatonW3c
|
|
270
278
|
@fetcher.data.query(sse).order_by(:rel)
|
271
279
|
end
|
272
280
|
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
@
|
280
|
-
|
281
|
-
|
282
|
-
|
281
|
+
#
|
282
|
+
# Query document versions relations
|
283
|
+
#
|
284
|
+
# @return [RDF::Query::Solutions] query results
|
285
|
+
#
|
286
|
+
def document_versions # rubocop:disable Metrics/MethodLength
|
287
|
+
@document_versions ||= begin
|
288
|
+
sse = SPARQL.parse(%(
|
289
|
+
PREFIX : <http://www.w3.org/2001/02pd/rec54#>
|
290
|
+
PREFIX dc: <http://purl.org/dc/elements/1.1/>
|
291
|
+
PREFIX doc: <http://www.w3.org/2000/10/swap/pim/doc#>
|
292
|
+
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
293
|
+
SELECT ?link ?title ?date
|
294
|
+
WHERE { ?link doc:versionOf <#{@sol.version_of}> ; dc:title ?title ; dc:date ?date }
|
295
|
+
))
|
296
|
+
@fetcher.data.query(sse)
|
283
297
|
end
|
284
298
|
end
|
285
299
|
|
300
|
+
#
|
301
|
+
# Create relation
|
302
|
+
#
|
303
|
+
# @param [String] url relation URL
|
304
|
+
# @param [String] type relation type
|
305
|
+
# @param [String, nil] desc relation description
|
306
|
+
#
|
307
|
+
# @return [RelatonBib::DocumentRelation] <description>
|
308
|
+
#
|
309
|
+
def create_relation(url, type, desc = nil)
|
310
|
+
id = pub_id(url)
|
311
|
+
fref = RelatonBib::FormattedRef.new content: id
|
312
|
+
docid = RelatonBib::DocumentIdentifier.new(type: "W3C", id: id, primary: true)
|
313
|
+
bib = W3cBibliographicItem.new formattedref: fref, docid: [docid]
|
314
|
+
dsc = RelatonBib::FormattedString.new content: desc if desc
|
315
|
+
RelatonBib::DocumentRelation.new(type: type, bibitem: bib, description: dsc)
|
316
|
+
end
|
317
|
+
|
286
318
|
#
|
287
319
|
# Parse formattedref
|
288
320
|
#
|
data/lib/relaton_w3c/version.rb
CHANGED
@@ -9,10 +9,10 @@ module RelatonW3c
|
|
9
9
|
|
10
10
|
class << self
|
11
11
|
# @param text [String]
|
12
|
-
# @return [RelatonW3c::
|
13
|
-
def search(text) # rubocop:disable Metrics/MethodLength
|
12
|
+
# @return [RelatonW3c::W3cBibliographicItem]
|
13
|
+
def search(text) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
14
14
|
ref = DataParser.parse_identifier text.sub(/^W3C\s/, "")
|
15
|
-
file = DataIndex.create_from_repo.search(
|
15
|
+
file = DataIndex.create_from_repo.search ref.gsub(" ", "-").squeeze("-")
|
16
16
|
return unless file
|
17
17
|
|
18
18
|
url = "#{SOURCE}#{file}"
|
@@ -103,6 +103,8 @@
|
|
103
103
|
name: Web Services Architecture Working Group
|
104
104
|
'https://www.w3.org/2011/webappsec':
|
105
105
|
name: Web Application Security Working Group
|
106
|
+
'https://www.w3.org/groups/wg/webappsec':
|
107
|
+
name: Web Application Security Working Group
|
106
108
|
'https://www.w3.org/Social/WG':
|
107
109
|
name: Social Web Working Group
|
108
110
|
'https://www.w3.org/XML/Core':
|
data/lib/relaton_w3c.rb
CHANGED
@@ -2,9 +2,6 @@ require "relaton_bib"
|
|
2
2
|
require "relaton_w3c/version"
|
3
3
|
require "relaton_w3c/w3c_bibliography"
|
4
4
|
require "relaton_w3c/w3c_bibliographic_item"
|
5
|
-
# require "relaton_w3c/hit_collection"
|
6
|
-
# require "relaton_w3c/hit"
|
7
|
-
# require "relaton_w3c/scrapper"
|
8
5
|
require "relaton_w3c/xml_parser"
|
9
6
|
require "relaton_w3c/bibxml_parser"
|
10
7
|
require "relaton_w3c/hash_converter"
|
data/relaton_w3c.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
"using the IsoBibliographicItem model"
|
15
15
|
spec.homepage = "https://github.com/relaton/relaton-wc3"
|
16
16
|
spec.license = "BSD-2-Clause"
|
17
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
17
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
|
18
18
|
|
19
19
|
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
20
20
|
|
@@ -39,8 +39,8 @@ Gem::Specification.new do |spec|
|
|
39
39
|
|
40
40
|
spec.add_dependency "linkeddata", "~> 3.1.0"
|
41
41
|
spec.add_dependency "mechanize", "~> 2.8.0"
|
42
|
-
spec.add_dependency "rdf", "~> 3.
|
43
|
-
spec.add_dependency "rdf-normalize", "~> 0.
|
42
|
+
spec.add_dependency "rdf", "~> 3.2.0"
|
43
|
+
spec.add_dependency "rdf-normalize", "~> 0.5.0"
|
44
44
|
spec.add_dependency "relaton-bib", "~> 1.11.0"
|
45
45
|
spec.add_dependency "rubyzip", "~> 2.3.0"
|
46
46
|
spec.add_dependency "shex", "~> 0.6.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: relaton-w3c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.11.
|
4
|
+
version: 1.11.6
|
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: equivalent-xml
|
@@ -114,28 +114,28 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 3.
|
117
|
+
version: 3.2.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 3.
|
124
|
+
version: 3.2.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rdf-normalize
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.
|
131
|
+
version: 0.5.0
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.
|
138
|
+
version: 0.5.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: relaton-bib
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -247,10 +247,7 @@ files:
|
|
247
247
|
- lib/relaton_w3c/data_index.rb
|
248
248
|
- lib/relaton_w3c/data_parser.rb
|
249
249
|
- lib/relaton_w3c/hash_converter.rb
|
250
|
-
- lib/relaton_w3c/hit.rb
|
251
|
-
- lib/relaton_w3c/hit_collection.rb
|
252
250
|
- lib/relaton_w3c/processor.rb
|
253
|
-
- lib/relaton_w3c/scrapper.rb
|
254
251
|
- lib/relaton_w3c/version.rb
|
255
252
|
- lib/relaton_w3c/w3c_bibliographic_item.rb
|
256
253
|
- lib/relaton_w3c/w3c_bibliography.rb
|
@@ -270,7 +267,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
270
267
|
requirements:
|
271
268
|
- - ">="
|
272
269
|
- !ruby/object:Gem::Version
|
273
|
-
version: 2.
|
270
|
+
version: 2.6.0
|
274
271
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
275
272
|
requirements:
|
276
273
|
- - ">="
|
data/lib/relaton_w3c/hit.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module RelatonW3c
|
4
|
-
# Hit.
|
5
|
-
class Hit < RelatonBib::Hit
|
6
|
-
#
|
7
|
-
# Parse page.
|
8
|
-
#
|
9
|
-
# @param lang [String, NilClass]
|
10
|
-
# @return [RelatonW3c::W3cBibliographicItem]
|
11
|
-
def fetch(_lang = nil)
|
12
|
-
@fetch ||= Scrapper.parse_page hit
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,172 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "fileutils"
|
4
|
-
require "yaml"
|
5
|
-
|
6
|
-
module RelatonW3c
|
7
|
-
# Page of hit collection.
|
8
|
-
class HitCollection < RelatonBib::HitCollection
|
9
|
-
TYPES = {
|
10
|
-
"CR" => "Candidate Recommendation",
|
11
|
-
"NOTE" => "Group Note",
|
12
|
-
"PER" => "Proposed Edited Recommendation",
|
13
|
-
"PR" => "Proposed Recommendation",
|
14
|
-
"REC" => "Recommendation",
|
15
|
-
"RET" => "Retired",
|
16
|
-
"WD" => "Working Draft",
|
17
|
-
}.freeze
|
18
|
-
DOMAIN = "https://www.w3.org"
|
19
|
-
DATADIR = File.expand_path(".relaton/w3c", Dir.home).freeze
|
20
|
-
DATAFILE = File.expand_path("bibliography.yml", DATADIR).freeze
|
21
|
-
|
22
|
-
# @param ref [String] reference to search
|
23
|
-
def initialize(ref)
|
24
|
-
%r{
|
25
|
-
^(?:W3C\s)?
|
26
|
-
(?<type>(?:CR|NOTE|PER|PR|REC|RET|WD|Candidate\sRecommendation|
|
27
|
-
Group\sNote|Proposed\sEdited\sRecommendation|Proposed\sRecommendation|
|
28
|
-
Recommendation|Retired|Working\sDraft))? # type
|
29
|
-
\s?
|
30
|
-
(?<title_date>.+) # title_date
|
31
|
-
}x =~ ref
|
32
|
-
super
|
33
|
-
@array = from_yaml title_date, type
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
#
|
39
|
-
# Fetch data form yaml
|
40
|
-
#
|
41
|
-
# @param title_date [String]
|
42
|
-
# @param type [String]
|
43
|
-
# @return [Array<Hash>]
|
44
|
-
def from_yaml(title_date, type) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity,Metrics/MethodLength,Metrics/PerceivedComplexity
|
45
|
-
/(?<title>.+)\s(?<date>\d{4}-\d{2}-\d{2})$/ =~ title_date
|
46
|
-
title ||= title_date
|
47
|
-
result = data.select do |hit|
|
48
|
-
(hit["title"].casecmp?(title) ||
|
49
|
-
hit["link"].split("/").last.match?(/-#{title}-/)) &&
|
50
|
-
type_date_filter(hit, type, date)
|
51
|
-
end
|
52
|
-
if result.empty?
|
53
|
-
result = data.select { |h| h["link"].split("/").last.match?(/#{title}/) }
|
54
|
-
end
|
55
|
-
result.map { |h| Hit.new(h, self) }
|
56
|
-
end
|
57
|
-
|
58
|
-
# @param hit [Hash]
|
59
|
-
# @param type [String]
|
60
|
-
# @param date [String]
|
61
|
-
# @return [TrueClass, FalseClass]
|
62
|
-
def type_date_filter(hit, type, date) # rubocop:disable Metrics/AbcSize
|
63
|
-
if (type && hit["type"] != short_type(type)) || (date && hit["date"] != date)
|
64
|
-
history = get_history hit, type, date
|
65
|
-
return false unless history.any?
|
66
|
-
|
67
|
-
hit["type"] = short_type type
|
68
|
-
hit["datepub"] = history.first.at("td").text
|
69
|
-
hit["link"] = history.first.at("a")[:href]
|
70
|
-
end
|
71
|
-
true
|
72
|
-
end
|
73
|
-
|
74
|
-
# @param hit [Hash]
|
75
|
-
# @param type [String]
|
76
|
-
# @param date [String]
|
77
|
-
# @return [Array<Nokogiri::XML::Element>, Nokogiri::HTML::NodeSet]
|
78
|
-
def get_history(hit, type, date)
|
79
|
-
resp = Net::HTTP.get URI.parse(HitCollection::DOMAIN + hit["history"])
|
80
|
-
history_doc = Nokogiri::HTML resp
|
81
|
-
history = history_doc.xpath(
|
82
|
-
"//table//a[contains(.,'#{long_type(type)}')]/../..",
|
83
|
-
)
|
84
|
-
return filter_history_by_date(history, history_doc, type, date) if date
|
85
|
-
|
86
|
-
history
|
87
|
-
end
|
88
|
-
|
89
|
-
# @param history [Nokogiri::XML::NodeSet]
|
90
|
-
# @param history_doc [Nokogiri::HTML::NodeSet]
|
91
|
-
# @param type [String]
|
92
|
-
# @param date [String]
|
93
|
-
# @return [Array<Nokogiri::XML::Element>, Nokogiri::HTML::NodeSet]
|
94
|
-
def filter_history_by_date(history, history_doc, type, date)
|
95
|
-
if type
|
96
|
-
history.select do |h|
|
97
|
-
h.at("td[@class='table_datecol']").text == date
|
98
|
-
end
|
99
|
-
else
|
100
|
-
history_doc.xpath(
|
101
|
-
"//table//td[@class='table_datecol'][.='#{date}']/..",
|
102
|
-
)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
#
|
107
|
-
# Convetr long type name to short
|
108
|
-
#
|
109
|
-
# @param type [String]
|
110
|
-
# @return [String]
|
111
|
-
def short_type(type)
|
112
|
-
tp = TYPES.select { |_, v| v == type }.keys
|
113
|
-
tp.first || type
|
114
|
-
end
|
115
|
-
|
116
|
-
#
|
117
|
-
# Convert shot type name to long
|
118
|
-
#
|
119
|
-
# @param [String]
|
120
|
-
# @return [String]
|
121
|
-
def long_type(type)
|
122
|
-
TYPES[type] || type
|
123
|
-
end
|
124
|
-
|
125
|
-
#
|
126
|
-
# Fetches YAML data
|
127
|
-
#
|
128
|
-
# @return [Hash]
|
129
|
-
def data
|
130
|
-
FileUtils.mkdir_p DATADIR
|
131
|
-
ctime = File.ctime DATAFILE if File.exist? DATAFILE
|
132
|
-
fetch_data if !ctime || ctime.to_date < Date.today
|
133
|
-
@data ||= YAML.safe_load File.read(DATAFILE, encoding: "UTF-8")
|
134
|
-
end
|
135
|
-
|
136
|
-
#
|
137
|
-
# fetch data form server and save it to file.
|
138
|
-
#
|
139
|
-
def fetch_data
|
140
|
-
resp = Net::HTTP.get_response URI.parse("#{DOMAIN}/TR/")
|
141
|
-
# return if there aren't any changes since last fetching
|
142
|
-
return unless resp.code == "200"
|
143
|
-
|
144
|
-
doc = Nokogiri::HTML resp.body
|
145
|
-
@data = doc.xpath("//ul[@id='container']/li").map do |h_el|
|
146
|
-
link = h_el.at("h2/a")
|
147
|
-
pubdetails = h_el.at("p[@class='pubdetails']")
|
148
|
-
fetch_hit h_el, link, pubdetails
|
149
|
-
end
|
150
|
-
File.write DATAFILE, @data.to_yaml, encoding: "UTF-8"
|
151
|
-
end
|
152
|
-
|
153
|
-
# @param h_el [Nokogiri::XML::Element]
|
154
|
-
# @param link [Nokogiri::XML::Element]
|
155
|
-
# @param pubdetails [Nokogiri::XML::Element]
|
156
|
-
def fetch_hit(h_el, link, pubdetails) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
|
157
|
-
datepub = pubdetails.at("text()").text.match(/\d{4}-\d{2}-\d{2}/).to_s
|
158
|
-
editor = h_el.xpath("ul[@class='editorlist']/li").map { |e| e.text.strip }
|
159
|
-
keyword = h_el.xpath("ul[@class='taglist']/li").map { |e| e.text.strip }
|
160
|
-
{
|
161
|
-
"title" => link.text.gsub("\u00a0", " "),
|
162
|
-
"link" => link[:href],
|
163
|
-
"type" => h_el.at("div").text.upcase,
|
164
|
-
"workgroup" => h_el.xpath("p[@class='deliverer']").map(&:text),
|
165
|
-
"datepub" => datepub,
|
166
|
-
"history" => pubdetails.at("a[text()='History']")[:href],
|
167
|
-
"editor" => editor,
|
168
|
-
"keyword" => keyword,
|
169
|
-
}
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
data/lib/relaton_w3c/scrapper.rb
DELETED
@@ -1,218 +0,0 @@
|
|
1
|
-
module RelatonW3c
|
2
|
-
class Scrapper
|
3
|
-
DOCTYPES = {
|
4
|
-
"CR" => "candidateRecommendation",
|
5
|
-
"NOTE" => "groupNote",
|
6
|
-
"PER" => "proposedEditedRecommendation",
|
7
|
-
"PR" => "proposedRecommendation",
|
8
|
-
"REC" => "recommendation",
|
9
|
-
"RET" => "retired",
|
10
|
-
"WD" => "workingDraft",
|
11
|
-
}.freeze
|
12
|
-
|
13
|
-
class << self
|
14
|
-
# @param hit [Hash]
|
15
|
-
# @return [RelatonW3c::W3cBibliographicItem]
|
16
|
-
def parse_page(hit) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
17
|
-
resp = Net::HTTP.get_response URI.parse(hit["link"])
|
18
|
-
doc = resp.code == "200" ? Nokogiri::HTML(resp.body) : nil
|
19
|
-
W3cBibliographicItem.new(
|
20
|
-
type: "standard",
|
21
|
-
docid: fetch_docid(hit),
|
22
|
-
fetched: Date.today.to_s,
|
23
|
-
language: ["en"],
|
24
|
-
script: ["Latn"],
|
25
|
-
title: fetch_title(hit, doc),
|
26
|
-
abstract: fetch_abstract(doc),
|
27
|
-
link: fetch_link(hit),
|
28
|
-
date: fetch_date(hit, doc),
|
29
|
-
doctype: fetch_doctype(hit, doc),
|
30
|
-
contributor: fetch_contributor(hit, doc),
|
31
|
-
relation: fetch_relation(doc),
|
32
|
-
keyword: hit["keyword"],
|
33
|
-
)
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
# @param hit [Hash]
|
39
|
-
# @return [Array<RelatonBib::DocumentIdentifier>]
|
40
|
-
def fetch_docid(hit)
|
41
|
-
id = hit["link"].split("/").last
|
42
|
-
[RelatonBib::DocumentIdentifier.new(id: id, type: "W3C", primary: true)]
|
43
|
-
end
|
44
|
-
|
45
|
-
# @param hit [Hash]
|
46
|
-
# @param doc [Nokogiri::HTML::Document]
|
47
|
-
# @return [Array<RelatonBib::TypedTitleString>]
|
48
|
-
def fetch_title(hit, doc) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
49
|
-
titles = []
|
50
|
-
if doc
|
51
|
-
title = doc.at("//*[contains(@id, 'title')]")&.text
|
52
|
-
if title && !title.empty?
|
53
|
-
titles << { content: title.gsub(/\n/, " "), type: "main" }
|
54
|
-
end
|
55
|
-
subtitle = doc.at(
|
56
|
-
"//h2[@id='subtitle']|//p[contains(@class, 'subline')]",
|
57
|
-
)&.text
|
58
|
-
titles << { content: subtitle, tipe: "subtitle" } if subtitle
|
59
|
-
end
|
60
|
-
if titles.empty? && hit["title"]
|
61
|
-
titles << { content: hit["title"], type: "main" }
|
62
|
-
end
|
63
|
-
titles.map do |t|
|
64
|
-
title = RelatonBib::FormattedString.new(
|
65
|
-
content: t[:content], language: "en", script: "Latn",
|
66
|
-
)
|
67
|
-
RelatonBib::TypedTitleString.new(type: t[:type], title: title)
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
# @param doc [Nokogiri::HTML::Document, NilClass]
|
72
|
-
# @return [Array<RelatonBib::FormattedString>]
|
73
|
-
def fetch_abstract(doc)
|
74
|
-
return [] unless doc
|
75
|
-
|
76
|
-
content = doc.at("//h2[.='Abstract']/following-sibling::p",
|
77
|
-
"//div[@class='abstract']/p").text
|
78
|
-
[RelatonBib::FormattedString.new(content: content, language: "en",
|
79
|
-
script: "Latn")]
|
80
|
-
end
|
81
|
-
|
82
|
-
# @param hit [Hash]
|
83
|
-
# @return [Array<RelatonBib::TypedUri>]
|
84
|
-
def fetch_link(hit)
|
85
|
-
[RelatonBib::TypedUri.new(type: "src", content: hit["link"])]
|
86
|
-
end
|
87
|
-
|
88
|
-
# @param hit [Hash]
|
89
|
-
# @param doc [Nokogiri::HTML::Document, NilClass]
|
90
|
-
# @return [Array<RelatonBib::BibliographicDate>]
|
91
|
-
def fetch_date(hit, doc) # rubocop:disable Metrics/CyclomaticComplexity
|
92
|
-
on = hit["datepub"] || doc&.at("//h2/time[@datetime]")&.attr(:datetime)
|
93
|
-
on ||= fetch_date1(doc) || fetch_date2(doc)
|
94
|
-
[RelatonBib::BibliographicDate.new(type: "published", on: on)] if on
|
95
|
-
end
|
96
|
-
|
97
|
-
# @param doc [Nokogiri::HTML::Document, NilClass]
|
98
|
-
# @return [String]
|
99
|
-
def fetch_date1(doc)
|
100
|
-
d = doc&.at("//h2[@property='dc:issued']")&.attr(:content)
|
101
|
-
d&.match(/\d{4}-\d{2}-\d{2}/)&.to_s
|
102
|
-
end
|
103
|
-
|
104
|
-
# @param doc [Nokogiri::HTML::Document, NilClass]
|
105
|
-
# @return [String]
|
106
|
-
def fetch_date2(doc)
|
107
|
-
d = doc&.at("//h2[contains(@id, 'w3c-recommendation')]")
|
108
|
-
return unless d
|
109
|
-
|
110
|
-
Date.parse(d.attr(:id.match(/\d{2}-\w+-\d{4}/).to_s)).to_s
|
111
|
-
end
|
112
|
-
|
113
|
-
# @param hit [Hash]
|
114
|
-
# @param doc [Nokogiri::HTML::Document, NilClass]
|
115
|
-
# @return [String]
|
116
|
-
def fetch_doctype(hit, doc)
|
117
|
-
if hit["type"]
|
118
|
-
DOCTYPES[hit["type"]]
|
119
|
-
elsif doc
|
120
|
-
type = HitCollection::TYPES.detect do |_k, v|
|
121
|
-
doc.at("//h2[contains(., '#{v}')]/time[@datetime]")
|
122
|
-
end
|
123
|
-
DOCTYPES[type&.first]
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
# @param hit [Hash]
|
128
|
-
# @param doc [Nokogiri::HTML::Document, NilClass]
|
129
|
-
# @return [Array<RelatonBib::ContributionInfo>]
|
130
|
-
def fetch_contributor(hit, doc) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
|
131
|
-
if doc
|
132
|
-
editors = find_contribs(doc, "Editors").reduce([]) do |mem, ed|
|
133
|
-
c = parse_contrib ed, "editor"
|
134
|
-
mem << c if c
|
135
|
-
mem
|
136
|
-
end
|
137
|
-
contribs = find_contribs(doc, "Authors").reduce(editors) do |mem, ath|
|
138
|
-
ed = mem.detect { |e| e[:id] && e[:id] == ath["data-editor-id"] }
|
139
|
-
if ed
|
140
|
-
ed[:role] << { type: "author" }
|
141
|
-
else
|
142
|
-
mem << parse_contrib(ath, "author")
|
143
|
-
end
|
144
|
-
mem
|
145
|
-
end
|
146
|
-
contribs.map { |c| contrib_info(**c) }
|
147
|
-
else
|
148
|
-
hit["editor"].map do |ed|
|
149
|
-
contrib_info name: ed, role: [{ type: "editor" }]
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
# @param doc [Nokogiri::NTML::Document]
|
155
|
-
# @param type [String]
|
156
|
-
# @return [Array<Nokogiri::XML::Element]
|
157
|
-
def find_contribs(doc, type)
|
158
|
-
doc.xpath("//dt[contains(.,'#{type}')]/following-sibling::dd"\
|
159
|
-
"[preceding-sibling::dt[1][contains(.,'#{type}')]]")
|
160
|
-
end
|
161
|
-
|
162
|
-
# @param element [Nokogiri::XML::Element]
|
163
|
-
# @param type [String]
|
164
|
-
# @return [Hash]
|
165
|
-
def parse_contrib(element, type) # rubocop:disable Metrics/MethodLength
|
166
|
-
p = element.at("a")
|
167
|
-
return unless p
|
168
|
-
|
169
|
-
contrib = {
|
170
|
-
name: p.text,
|
171
|
-
url: p[:href],
|
172
|
-
role: [{ type: type }],
|
173
|
-
id: element["data-editor-id"],
|
174
|
-
}
|
175
|
-
org = element.at("a[2]")
|
176
|
-
contrib[:org] = { name: org.text, url: org[:href] } if org
|
177
|
-
contrib
|
178
|
-
end
|
179
|
-
|
180
|
-
# @param name [String]
|
181
|
-
# @param url [String, NilClass]
|
182
|
-
# @param role [Array<Hash>]
|
183
|
-
# @parma org [Hash]
|
184
|
-
# @return [RelatonBib::ContributionInfo]
|
185
|
-
def contrib_info(**args)
|
186
|
-
completename = RelatonBib::LocalizedString.new(args[:name])
|
187
|
-
name = RelatonBib::FullName.new completename: completename
|
188
|
-
af = []
|
189
|
-
if args[:org]
|
190
|
-
org = RelatonBib::Organization.new(**args[:org])
|
191
|
-
af << RelatonBib::Affiliation.new(organization: org)
|
192
|
-
end
|
193
|
-
en = RelatonBib::Person.new name: name, url: args[:url], affiliation: af
|
194
|
-
RelatonBib::ContributionInfo.new entity: en, role: args[:role]
|
195
|
-
end
|
196
|
-
|
197
|
-
# @param doc [Nokogiri::HTML::Document]
|
198
|
-
# @return [Array<RelatonBib::DocumentRelation>]
|
199
|
-
def fetch_relation(doc)
|
200
|
-
return [] unless doc && (link = recommendation_link(doc))
|
201
|
-
|
202
|
-
hit = { "link" => link }
|
203
|
-
item = parse_page hit
|
204
|
-
[RelatonBib::DocumentRelation.new(type: "obsoletedBy", bibitem: item)]
|
205
|
-
end
|
206
|
-
|
207
|
-
# @param doc [Nokogiri::HTML::Document]
|
208
|
-
# @return [String, NilClass]
|
209
|
-
def recommendation_link(doc)
|
210
|
-
recom = doc.at("//dt[.='Latest Recommendation:']",
|
211
|
-
"//dt[.='Previous Recommendation:']")
|
212
|
-
return unless recom
|
213
|
-
|
214
|
-
recom.at("./following-sibling::dd/a")[:href]
|
215
|
-
end
|
216
|
-
end
|
217
|
-
end
|
218
|
-
end
|