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: "cloudflare-ipfs.com") ⇒ ReadPathAndIPFSSources

Returns a new instance of ReadPathAndIPFSSources.



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/dhall/resolve.rb', line 73

def initialize(
	path_reader: ReadPathSources,
	http_reader: ReadHttpSources,
	https_reader: http_reader,
	public_gateway: "cloudflare-ipfs.com"
)
	@path_reader = path_reader
	@http_reader = http_reader
	@https_reader = https_reader
	@public_gateway = public_gateway
end

Instance Method Details

#arityObject



85
86
87
# File 'lib/dhall/resolve.rb', line 85

def arity
	1
end

#call(sources) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/dhall/resolve.rb', line 89

def call(sources)
	@path_reader.call(sources).map.with_index do |promise, idx|
		source = sources[idx]
		if source.is_a?(Import::AbsolutePath) &&
		   ["ipfs", "ipns"].include?(source.path.first)
			gateway_fallback(source, promise)
		else
			promise
		end
	end
end

#to_procObject



101
102
103
# File 'lib/dhall/resolve.rb', line 101

def to_proc
	method(:call).to_proc
end