class Dhall::Resolvers::ReadPathAndIPFSSources
Public Class Methods
new( path_reader: ReadPathSources, http_reader: ReadHttpSources, https_reader: http_reader, public_gateway: URI("https://cloudflare-ipfs.com") )
click to toggle source
# File lib/dhall/resolve.rb, line 97 def initialize( path_reader: ReadPathSources, http_reader: ReadHttpSources, https_reader: http_reader, public_gateway: URI("https://cloudflare-ipfs.com") ) @path_reader = path_reader @http_reader = http_reader @https_reader = https_reader @public_gateway = public_gateway end
Public Instance Methods
arity()
click to toggle source
# File lib/dhall/resolve.rb, line 109 def arity 1 end
call(sources)
click to toggle source
# File lib/dhall/resolve.rb, line 113 def call(sources) @path_reader.call(sources).map.with_index do |promise, idx| source = sources[idx] if source.canonical.is_a?(Import::AbsolutePath) && ["ipfs", "ipns"].include?(source.path.first) gateway_fallback(source, promise) else promise end end end
to_proc()
click to toggle source
# File lib/dhall/resolve.rb, line 125 def to_proc method(:call).to_proc end
Protected Instance Methods
gateway_fallback(source, promise)
click to toggle source
# File lib/dhall/resolve.rb, line 131 def gateway_fallback(source, promise) promise.catch { @http_reader.call([ source.to_uri(Import::Http, URI("http://localhost:8000")) ], "localhost").first }.catch do @https_reader.call([ source.to_uri(Import::Https, @public_gateway) ], "localhost").first end end