Class: Dhall::Resolvers::ReadPathAndIPFSSources

Inherits:
Object
  • Object
show all
Defined in:
lib/dhall/resolve.rb

Instance Method Summary collapse

Constructor Details

#initialize(path_reader: ReadPathSources, http_reader: ReadHttpSources, https_reader: http_reader, public_gateway: URI("https://cloudflare-ipfs.com")) ⇒ ReadPathAndIPFSSources

Returns a new instance of ReadPathAndIPFSSources.



98
99
100
101
102
103
104
105
106
107
108
# File 'lib/dhall/resolve.rb', line 98

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

Instance Method Details

#arityObject



110
111
112
# File 'lib/dhall/resolve.rb', line 110

def arity
	1
end

#call(sources) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
# File 'lib/dhall/resolve.rb', line 114

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_procObject



126
127
128
# File 'lib/dhall/resolve.rb', line 126

def to_proc
	method(:call).to_proc
end