linkheaders-processor 0.1.13 → 0.1.14

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: e88dd164547a9a21ce0f1a3ffa85f2af4190ea6a588da445387cdfa2dca7e25d
4
- data.tar.gz: f800677c8d4cb18e274defb5dbda5d2f58431cab40899ae15cfb2f866fcf8644
3
+ metadata.gz: 4df2bc9ea84550e0de7be8110f49121ea84962ac797b01860858a445213787d5
4
+ data.tar.gz: ea148084a6ee71bb8e5509ae94c1dde4714dc66e609527b8c186362cc71c7c76
5
5
  SHA512:
6
- metadata.gz: ad4b8814c9ace9def1edd94e53e890c8d534a40d7cad4d55f7dbd0426e1310d29277a1849fd63ebada06fa3c9812a9d189c86ef2635ffe846fe52ff5f4864e2e
7
- data.tar.gz: 99573e84fa6eb0412a5223cb188f333c37a8dbb3c877fcf5ea403a71bfc18d57d477920c6000b280fbb8cc920548ddd11ea95dcdb0df4f0a896e30a68fe84d9b
6
+ metadata.gz: 9b66ae4ca8d0b48f71d4d33f2bccc1575abc5efe65ebe7bc756cab9fb47836d06fe9dc011ae0e55b0a3be6db331e3018e62d006bb8140b181538b65dc66cbab1
7
+ data.tar.gz: 8c2ae044bd1a111f915ea419932b431227b344386ad1824d4e1fc6f86269c2c513d72918d693addf0fa6e0ae0a3fcc2cabb9fa9c27542b3f5bed4d1d5edbf3d9
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- linkheaders-processor (0.1.13)
4
+ linkheaders-processor (0.1.14)
5
5
  json (~> 2.0)
6
6
  json-ld (~> 3.2)
7
7
  json-ld-preloaded (~> 3.2)
8
+ link_header (~> 0.0.8)
8
9
  metainspector (~> 5.11.2)
9
10
  rest-client (~> 2.1)
10
11
  securerandom (~> 0.1.0)
@@ -1,4 +1,5 @@
1
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' => '*/*'}
2
3
 
3
4
  TEXT_FORMATS = {
4
5
  'text' => ['text/plain',],
@@ -1,3 +1,4 @@
1
+
1
2
  module LinkHeaders
2
3
  class LinkFactory
3
4
 
@@ -191,5 +192,24 @@ module LinkHeaders
191
192
  self.send("#{k}=", v)
192
193
  end
193
194
  end
195
+
196
+ #
197
+ # Create an HTML version of the link
198
+ # @return [String] HTML version of the Link object
199
+ #
200
+ def to_html
201
+ methods = self.linkmethods
202
+ href = self.href
203
+ rel = self.relation
204
+ anchor = self.anchor
205
+ properties = []
206
+ methods.each do |method|
207
+ value = self.send(method)
208
+ properties << [method, value]
209
+ end
210
+ properties << ["rel", rel]
211
+ properties << ["anchor", anchor]
212
+ LinkHeader::Link.new(href, properties).to_html
213
+ end
194
214
  end
195
215
  end
@@ -3,6 +3,6 @@
3
3
 
4
4
  module LinkHeaders
5
5
  class Processor
6
- VERSION = "0.1.13"
6
+ VERSION = "0.1.14"
7
7
  end
8
8
  end
@@ -4,7 +4,7 @@ require_relative 'processor/version'
4
4
  require_relative 'constants'
5
5
  require_relative 'link'
6
6
  require_relative 'web_utils'
7
-
7
+ require 'link_header'
8
8
  require 'json'
9
9
  require 'rest-client'
10
10
  require 'securerandom'
@@ -189,7 +189,7 @@ module LinkHeaders
189
189
  end
190
190
 
191
191
  def processJSONLinkset(href:)
192
- _headers, linkset = fetch(href, { 'Accept' => 'application/linkset+json' })
192
+ _headers, linkset = lhfetch(href, { 'Accept' => 'application/linkset+json' })
193
193
  # warn "Linkset body #{linkset.inspect}"
194
194
  newlinks = Array.new
195
195
  return nil unless linkset
@@ -242,7 +242,7 @@ module LinkHeaders
242
242
 
243
243
  def processTextLinkset(href:)
244
244
  newlinks = Array.new
245
- headers, linkset = fetch(href, { 'Accept' => 'application/linkset' })
245
+ headers, linkset = lhfetch(href, { 'Accept' => 'application/linkset' })
246
246
  # warn "linkset body #{linkset.inspect}"
247
247
  return {} unless linkset
248
248
 
@@ -1,4 +1,4 @@
1
- def fetch(url, headers = ACCEPT_ALL_HEADER) # we will try to retrieve turtle whenever possible
1
+ def lhfetch(url, headers = ACCEPT_STAR_HEADER)
2
2
  # warn "In fetch routine now. "
3
3
 
4
4
  # warn "executing call over the Web to #{url.to_s}"
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- RSpec.describe LinkHeader::Parser do
3
+ RSpec.describe LinkHeaders::Processor do
4
4
  it 'has a version number' do
5
- expect(LinkHeader::Parser::VERSION).not_to be nil
5
+ expect(LinkHeaders::Processor::VERSION).not_to be nil
6
6
  end
7
7
  end
data/spec/spec_helper.rb CHANGED
@@ -7,7 +7,7 @@ RSpec.configure do |config|
7
7
  config.example_status_persistence_file_path = ".rspec_status"
8
8
 
9
9
  # Disable RSpec exposing methods globally on `Module` and `main`
10
- config.disable_monkey_patching!
10
+ # config.disable_monkey_patching!
11
11
 
12
12
  config.expect_with :rspec do |c|
13
13
  c.syntax = :expect
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.13
4
+ version: 0.1.14
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-02 00:00:00.000000000 Z
11
+ date: 2022-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 5.11.2
111
+ - !ruby/object:Gem::Dependency
112
+ name: link_header
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.0.8
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.0.8
111
125
  description: A parser/processor for Link Headers and Linksets in both JSON and Text
112
126
  formats.
113
127
  email: