Skip to content

Commit 0bcb3e9

Browse files
committed
Use the manifest location as the base for finding entries.
1 parent 5d3887d commit 0bcb3e9

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

spec/suite_frame_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
end
1414
end
1515
end
16-
end unless ENV['CI'] || true
16+
end unless ENV['CI']

spec/suite_helper.rb

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,37 +72,50 @@ module SuiteTest
7272
FRAME_SUITE = RDF::URI("https://w3c.github.io/json-ld-framing/tests/")
7373

7474
class Manifest < JSON::LD::Resource
75+
attr_accessor :manifest_url
76+
7577
def self.open(file)
7678
RDF::Util::File.open_file(file) do |remote|
7779
json = JSON.parse(remote.read)
7880
if block_given?
79-
yield self.from_jsonld(json)
81+
yield self.from_jsonld(json, manifest_url: RDF::URI(file))
8082
else
81-
self.from_jsonld(json)
83+
self.from_jsonld(json, manifest_url: RDF::URI(file))
8284
end
8385
end
8486
end
8587

88+
def initialize(json, manifest_url:)
89+
@manifest_url = manifest_url
90+
super
91+
end
92+
8693
# @param [Hash] json framed JSON-LD
8794
# @return [Array<Manifest>]
88-
def self.from_jsonld(json)
89-
Manifest.new(json)
95+
def self.from_jsonld(json, manifest_url: )
96+
Manifest.new(json, manifest_url: manifest_url)
9097
end
9198

9299
def entries
93100
# Map entries to resources
94101
attributes['sequence'].map do |e|
95-
e.is_a?(String) ? Manifest.open("#{SUITE}#{e}") : Entry.new(e)
102+
e.is_a?(String) ? Manifest.open(manifest_url.join(e).to_s) : Entry.new(e, manifest_url: manifest_url)
96103
end
97104
end
98105
end
99106

100107
class Entry < JSON::LD::Resource
101108
attr_accessor :logger
109+
attr_accessor :manifest_url
110+
111+
def initialize(json, manifest_url:)
112+
@manifest_url = manifest_url
113+
super
114+
end
102115

103116
# Base is expanded input file
104117
def base
105-
options.fetch('base', "#{SUITE}#{property('input')}")
118+
options.fetch('base', manifest_url.join(property('input')).to_s)
106119
end
107120

108121
def options
@@ -138,7 +151,7 @@ def options
138151
file = options[:redirectTo]
139152
end
140153

141-
property(m) && "#{SUITE}#{file}"
154+
property(m) && manifest_url.join(file).to_s
142155
end
143156

144157
define_method("#{m}_json".to_sym) do

0 commit comments

Comments
 (0)