hydra-core 10.0.0 → 10.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f45efd1b20cb587da16107c9eeb2436585a995f9
4
- data.tar.gz: f1b62768dd6b99194fd25f93fec69133ef385105
3
+ metadata.gz: 9a1cd5a8276ad78953ef0a08e5986ac669ce209d
4
+ data.tar.gz: f7584c638f094da3f0ff9a12d0c1985d71944b9d
5
5
  SHA512:
6
- metadata.gz: 8f60542cd2c982d5f8ba893c32a9109db4ba9b260814e71f172737d64d876ee1b459d2de3c072e9c76a0e044243717f200b8d6e9452d8489d9396f3a752c7df3
7
- data.tar.gz: 48a8abfa67c87d042828a936d7948beea5b3d5f263516fc2da008a71a6e39ee874b35aadbcc558be35e8bfb2e91b7da4937b974a3b4caf9cf8a796bb54701763
6
+ metadata.gz: da165812253d2b6adf23da94c47e731b3743a99308144536973e67f3104b901d100f50c637d4494b2a68efdd166ba0f1d6fbcbb9082edceb26aa3bd4d58aa5a4
7
+ data.tar.gz: 4b600ca2367362e556d66bbe2a6eb468c60e88a2a11cfb062a1f9ebddce26789448dda465f96baba25a9b9e1fc36b6e09b5b977114ad2144f1e382faa27ef36a
@@ -2,14 +2,18 @@ module Hydra::ContentNegotiation
2
2
  # CleanGraphRepository has a #find interface which returns a graph for use
3
3
  # with content negotiation.
4
4
  class CleanGraphRepository
5
- attr_reader :connection
6
- def initialize(connection)
5
+ attr_reader :connection, :replacer
6
+ # @param [#get] connection the connection to fedora
7
+ # @param [#call] replacer a function that is called with id and graph and returns a string representation of the new uri.
8
+ def initialize(connection, replacer = Hydra.config.id_to_resource_uri)
7
9
  @connection = connection
10
+ @replacer = replacer
8
11
  end
9
12
 
10
13
  def find(id)
11
14
  ReplacingGraphFinder.new(
12
- GraphFinder.new(connection, id)
15
+ GraphFinder.new(connection, id),
16
+ replacer
13
17
  ).graph
14
18
  end
15
19
  end
@@ -1,9 +1,13 @@
1
1
  module Hydra::ContentNegotiation
2
2
  # Replaces Fedora URIs in a graph with a Hydra-configured alternative.
3
3
  class FedoraUriReplacer
4
- def initialize(fedora_base_uri, graph)
4
+ # @param [String] fedora_base_uri the internal Fedora base uri
5
+ # @param [RDF::Graph] graph the original graph that needs URIs replaced
6
+ # @param [#call] replacer a function that is called with id and graph and returns a string representation of the new uri.
7
+ def initialize(fedora_base_uri, graph, replacer)
5
8
  @fedora_base_uri = fedora_base_uri
6
9
  @graph = graph
10
+ @replacer = replacer
7
11
  end
8
12
 
9
13
  def run
@@ -12,11 +16,11 @@ module Hydra::ContentNegotiation
12
16
 
13
17
  private
14
18
 
15
- attr_reader :fedora_base_uri, :graph
19
+ attr_reader :fedora_base_uri, :graph, :replacer
16
20
 
17
21
  def replace_uri(uri)
18
22
  id = ActiveFedora::Base.uri_to_id(uri)
19
- RDF::URI(Hydra.config.id_to_resource_uri.call(id, graph))
23
+ RDF::URI(replacer.call(id, graph))
20
24
  end
21
25
 
22
26
  def replaced_objects
@@ -2,6 +2,13 @@ module Hydra::ContentNegotiation
2
2
  # Decorator for Finder which replaces Fedora subjects in the graph with a
3
3
  # configured URI
4
4
  class ReplacingGraphFinder < SimpleDelegator
5
+
6
+ attr_reader :replacer
7
+ def initialize(graph_finder, replacer)
8
+ super(graph_finder)
9
+ @replacer = replacer
10
+ end
11
+
5
12
  def graph
6
13
  graph_replacer.run
7
14
  end
@@ -9,11 +16,13 @@ module Hydra::ContentNegotiation
9
16
  private
10
17
 
11
18
  def graph_replacer
12
- ::Hydra::ContentNegotiation::FedoraUriReplacer.new(base_uri, __getobj__.graph)
19
+ ::Hydra::ContentNegotiation::FedoraUriReplacer.new(base_uri,
20
+ __getobj__.graph,
21
+ replacer)
13
22
  end
14
23
 
15
24
  def base_uri
16
- @base_uri ||= uri.gsub(/#{id}$/,'')
25
+ @base_uri ||= ActiveFedora.fedora.host + ActiveFedora.fedora.base_path
17
26
  end
18
27
  end
19
28
  end
@@ -1,3 +1,3 @@
1
1
  module HydraHead
2
- VERSION = "10.0.0"
2
+ VERSION = "10.0.1"
3
3
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Hydra::ContentNegotiation::ReplacingGraphFinder do
4
+ let(:graph) { double }
5
+ let(:finder) { double(graph: graph,
6
+ uri: 'http://127.0.0.1:8986/rest/test/28/01/ph/00/2801ph009',
7
+ id: '2801ph009') }
8
+ let(:replacer) { double }
9
+ subject { described_class.new finder, replacer }
10
+
11
+ describe "graph" do
12
+ it "has the correct base url" do
13
+ expect(Hydra::ContentNegotiation::FedoraUriReplacer).to receive(:new)
14
+ .with(ending_with("/rest/test"), graph, replacer)
15
+ .and_return(double(run: nil))
16
+
17
+ subject.graph
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hydra-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.0
4
+ version: 10.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zumwalt, Bess Sadler, Julie Meloni, Naomi Dushay, Jessie Keck, John Scofield,
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-08 00:00:00.000000000 Z
12
+ date: 2016-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -31,14 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 10.0.0
34
+ version: 10.0.1
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: 10.0.0
41
+ version: 10.0.1
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: sqlite3
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -140,6 +140,7 @@ files:
140
140
  - spec/controllers/ip_based_ability_spec.rb
141
141
  - spec/factories.rb
142
142
  - spec/helpers/blacklight_helper_spec.rb
143
+ - spec/models/content_negotiation/replacing_graph_finder_spec.rb
143
144
  - spec/models/solr_document_spec.rb
144
145
  - spec/models/user_spec.rb
145
146
  - spec/rcov.opts
@@ -185,6 +186,7 @@ test_files:
185
186
  - spec/controllers/ip_based_ability_spec.rb
186
187
  - spec/factories.rb
187
188
  - spec/helpers/blacklight_helper_spec.rb
189
+ - spec/models/content_negotiation/replacing_graph_finder_spec.rb
188
190
  - spec/models/solr_document_spec.rb
189
191
  - spec/models/user_spec.rb
190
192
  - spec/rcov.opts