linkheaders-processor 0.1.14 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4df2bc9ea84550e0de7be8110f49121ea84962ac797b01860858a445213787d5
4
- data.tar.gz: ea148084a6ee71bb8e5509ae94c1dde4714dc66e609527b8c186362cc71c7c76
3
+ metadata.gz: ef79d8492d08ea54cc8c23067d4f3c443dee0941f5d901007928d62df93d8073
4
+ data.tar.gz: ec81315a8baedf8ea2b0ffdc1c882d44647ca45b0a2a5a1f71734c47ce3d9f64
5
5
  SHA512:
6
- metadata.gz: 9b66ae4ca8d0b48f71d4d33f2bccc1575abc5efe65ebe7bc756cab9fb47836d06fe9dc011ae0e55b0a3be6db331e3018e62d006bb8140b181538b65dc66cbab1
7
- data.tar.gz: 8c2ae044bd1a111f915ea419932b431227b344386ad1824d4e1fc6f86269c2c513d72918d693addf0fa6e0ae0a3fcc2cabb9fa9c27542b3f5bed4d1d5edbf3d9
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.14)
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.32.0)
121
+ rubocop (1.33.0)
122
122
  json (~> 2.3)
123
123
  parallel (~> 1.10)
124
124
  parser (>= 3.1.0.0)
@@ -3,6 +3,6 @@
3
3
 
4
4
  module LinkHeaders
5
5
  class Processor
6
- VERSION = "0.1.14"
6
+ VERSION = "0.1.16"
7
7
  end
8
8
  end
@@ -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
- HTML_FORMATS['html'].each do |format|
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,4 +1,4 @@
1
- def lhfetch(url, headers = ACCEPT_STAR_HEADER)
1
+ def lhfetch(url, headers = {accept: "*/*"})
2
2
  # warn "In fetch routine now. "
3
3
 
4
4
  # warn "executing call over the Web to #{url.to_s}"
@@ -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.14
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-04 00:00:00.000000000 Z
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
-