linkheaders-processor 0.1.14 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/lib/linkheaders/processor/version.rb +1 -1
- data/lib/linkheaders/processor.rb +1 -2
- data/lib/linkheaders/web_utils.rb +1 -1
- data/spec/linkheader/parser_spec.rb +30 -0
- metadata +2 -3
- data/lib/linkheaders/constants.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef79d8492d08ea54cc8c23067d4f3c443dee0941f5d901007928d62df93d8073
|
4
|
+
data.tar.gz: ec81315a8baedf8ea2b0ffdc1c882d44647ca45b0a2a5a1f71734c47ce3d9f64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b510601d2b51739b893b07c546d1ed723dd2bef296c3af59b7fdc3dbfdcfdc08f8e20741c6f2f9ca0957675c02c9ddfb6d5a21201976f256b1b2a45ee7dde2b
|
7
|
+
data.tar.gz: d20ed0c9b8b04607b104aad8ce5a07c26cc12ae16b925c9ccd3e9feca78f691592976a352ac301a907d517eb55b8972960b7cec4fc3913316c9453f1d2549098
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
linkheaders-processor (0.1.
|
4
|
+
linkheaders-processor (0.1.16)
|
5
5
|
json (~> 2.0)
|
6
6
|
json-ld (~> 3.2)
|
7
7
|
json-ld-preloaded (~> 3.2)
|
@@ -118,7 +118,7 @@ GEM
|
|
118
118
|
diff-lcs (>= 1.2.0, < 2.0)
|
119
119
|
rspec-support (~> 3.11.0)
|
120
120
|
rspec-support (3.11.0)
|
121
|
-
rubocop (1.
|
121
|
+
rubocop (1.33.0)
|
122
122
|
json (~> 2.3)
|
123
123
|
parallel (~> 1.10)
|
124
124
|
parser (>= 3.1.0.0)
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'processor/version'
|
4
|
-
require_relative 'constants'
|
5
4
|
require_relative 'link'
|
6
5
|
require_relative 'web_utils'
|
7
6
|
require 'link_header'
|
@@ -63,7 +62,7 @@ module LinkHeaders
|
|
63
62
|
newlinks = parse_http_link_headers(head) # pass guid to check against anchors in linksets
|
64
63
|
warn "HTTPlinks #{newlinks.inspect}"
|
65
64
|
|
66
|
-
|
65
|
+
['text/html','text/xhtml+xml', 'application/xhtml+xml'].each do |format|
|
67
66
|
if head[:content_type] and head[:content_type].match(format)
|
68
67
|
warn "found #{format} content - parsing"
|
69
68
|
htmllinks = parse_html_link_headers(body) # pass html body to find HTML link headers
|
@@ -1,7 +1,37 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require_relative '../../lib/linkheaders/processor'
|
3
|
+
require 'rest-client'
|
4
|
+
|
5
|
+
|
6
|
+
url1 = "https://w3id.org/a2a-fair-metrics/22-http-html-citeas-describedby-mixed/"
|
7
|
+
p = LinkHeaders::Processor.new(default_anchor: url1)
|
8
|
+
r = RestClient.get(url1)
|
9
|
+
p.extract_and_parse(response: r)
|
10
|
+
factory = p.factory # LinkHeaders::LinkFactory
|
11
|
+
|
2
12
|
|
3
13
|
RSpec.describe LinkHeaders::Processor do
|
14
|
+
|
4
15
|
it 'has a version number' do
|
5
16
|
expect(LinkHeaders::Processor::VERSION).not_to be nil
|
6
17
|
end
|
18
|
+
|
19
|
+
it "should find PURL citeas which has described-by and cite-as in mixed HTTP and HTML headers" do
|
20
|
+
expect(factory.all_links.length).to eq 5
|
21
|
+
end
|
22
|
+
it "should find find href on all links" do
|
23
|
+
expect(factory.all_links.select{|l| l.href}.length).to eq 5
|
24
|
+
end
|
25
|
+
it "should find find href on all links" do
|
26
|
+
expect(factory.all_links.select{|l| l.anchor}.length).to eq 5
|
27
|
+
end
|
28
|
+
it "should find 5 links in mixed HTTP and HTML headers" do
|
29
|
+
expect(factory.all_links.select{|l| l.relation}.length).to eq 5
|
30
|
+
end
|
31
|
+
it "should find one citeas in mixed HTTP and HTML headers" do
|
32
|
+
expect(factory.all_links.select{|l| l.relation == 'cite-as'}.length).to eq 1
|
33
|
+
end
|
34
|
+
it "should find described-by in mixed HTTP and HTML headers" do
|
35
|
+
expect(factory.all_links.select{|l| l.relation == 'describedby'}.length).to eq 1
|
36
|
+
end
|
7
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: linkheaders-processor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Wilkinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -137,7 +137,6 @@ files:
|
|
137
137
|
- README.md
|
138
138
|
- Rakefile
|
139
139
|
- launch.json
|
140
|
-
- lib/linkheaders/constants.rb
|
141
140
|
- lib/linkheaders/link.rb
|
142
141
|
- lib/linkheaders/processor.rb
|
143
142
|
- lib/linkheaders/processor/version.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
ACCEPT_ALL_HEADER = {'Accept' => 'text/turtle, application/ld+json, application/rdf+xml, text/xhtml+xml, application/n3, application/rdf+n3, application/turtle, application/x-turtle, text/n3, text/turtle, text/rdf+n3, text/rdf+turtle, application/n-triples' }
|
2
|
-
ACCEPT_STAR_HEADER = {'Accept' => '*/*'}
|
3
|
-
|
4
|
-
TEXT_FORMATS = {
|
5
|
-
'text' => ['text/plain',],
|
6
|
-
}
|
7
|
-
|
8
|
-
RDF_FORMATS = {
|
9
|
-
'jsonld' => ['application/ld+json', 'application/vnd.schemaorg.ld+json'], # NEW FOR DATACITE
|
10
|
-
'turtle' => ['text/turtle','application/n3','application/rdf+n3',
|
11
|
-
'application/turtle', 'application/x-turtle','text/n3','text/turtle',
|
12
|
-
'text/rdf+n3', 'text/rdf+turtle'],
|
13
|
-
#'rdfa' => ['text/xhtml+xml', 'application/xhtml+xml'],
|
14
|
-
'rdfxml' => ['application/rdf+xml'],
|
15
|
-
'triples' => ['application/n-triples','application/n-quads', 'application/trig']
|
16
|
-
}
|
17
|
-
|
18
|
-
XML_FORMATS = {
|
19
|
-
'xml' => ['text/xhtml','text/xml',]
|
20
|
-
}
|
21
|
-
|
22
|
-
HTML_FORMATS = {
|
23
|
-
'html' => ['text/html','text/xhtml+xml', 'application/xhtml+xml']
|
24
|
-
}
|
25
|
-
|
26
|
-
JSON_FORMATS = {
|
27
|
-
'json' => ['application/json',]
|
28
|
-
}
|
29
|
-
|