@@ -22,11 +22,11 @@ class << self
2222 # HTTP Request headers.
2323 # @return [IO] File stream
2424 # @yield [IO] File stream
25- def self . open_file ( filename_or_url , options = { } , &block )
25+ def self . open_file ( filename_or_url , ** options , &block )
2626 case
2727 when filename_or_url . to_s =~ /^file:/
2828 path = filename_or_url [ 5 ..-1 ]
29- Kernel . open ( path . to_s , options , &block )
29+ Kernel . open ( path . to_s , ** options , &block )
3030 when ( filename_or_url . to_s =~ %r{^#{ REMOTE_PATH } } && Dir . exist? ( LOCAL_PATH ) )
3131 localpath = RDF ::URI ( filename_or_url ) . dup
3232 localpath . query = nil
@@ -44,6 +44,7 @@ def self.open_file(filename_or_url, options = {}, &block)
4444 }
4545 #puts "use #{filename_or_url} locally"
4646 document_options [ :headers ] [ :content_type ] = case filename_or_url . to_s
47+ when /\. nt$/ then 'application/n-triples'
4748 when /\. ttl$/ then 'text/turtle'
4849 when /\. ldpatch$/ then 'text/ldpatch'
4950 else 'unknown'
@@ -53,14 +54,14 @@ def self.open_file(filename_or_url, options = {}, &block)
5354 # For overriding content type from test data
5455 document_options [ :headers ] [ :content_type ] = options [ :contentType ] if options [ :contentType ]
5556
56- remote_document = RDF ::Util ::File ::RemoteDocument . new ( response . read , document_options )
57+ remote_document = RDF ::Util ::File ::RemoteDocument . new ( response . read , ** document_options )
5758 if block_given?
5859 yield remote_document
5960 else
6061 remote_document
6162 end
6263 else
63- original_open_file ( filename_or_url , options ) do |rd |
64+ original_open_file ( filename_or_url , ** options ) do |rd |
6465 # Override content_type
6566 if options [ :contentType ]
6667 rd . headers [ :content_type ] = options [ :contentType ]
@@ -112,7 +113,7 @@ def self.open(file)
112113 g = RDF ::Repository . load ( file , format : :ttl )
113114 JSON ::LD ::API . fromRDF ( g ) do |expanded |
114115 JSON ::LD ::API . frame ( expanded , FRAME ) do |framed |
115- yield Manifest . new ( framed [ '@graph' ] . first )
116+ yield Manifest . new ( framed )
116117 end
117118 end
118119 end
@@ -142,23 +143,23 @@ def input
142143 when Hash then action [ 'patch' ]
143144 else action
144145 end
145- @input ||= RDF ::Util ::File . open_file ( URI . decode ( url ) ) { |f | f . read }
146+ @input ||= RDF ::Util ::File . open_file ( CGI . unescape ( url ) ) { |f | f . read }
146147 end
147148
148149 def data
149150 action . is_a? ( Hash ) && action [ "data" ]
150151 end
151152
152153 def target_graph
153- @graph ||= RDF ::Graph . load ( URI . decode ( data ) , base_uri : base )
154+ @graph ||= RDF ::Graph . load ( CGI . unescape ( data ) , base_uri : base )
154155 end
155156
156157 def expected
157- @expected ||= RDF ::Util ::File . open_file ( URI . decode ( result ) ) { |f | f . read }
158+ @expected ||= RDF ::Util ::File . open_file ( CGI . unescape ( result ) ) { |f | f . read }
158159 end
159160
160161 def expected_graph
161- @expected_graph ||= RDF ::Graph . load ( URI . decode ( result ) , base_uri : base )
162+ @expected_graph ||= RDF ::Graph . load ( CGI . unescape ( result ) , base_uri : base )
162163 end
163164
164165 def evaluate?
0 commit comments