Class: Dhall::Resolvers::ReadPathAndIPFSSources
- Inherits:
-
Object
- Object
- Dhall::Resolvers::ReadPathAndIPFSSources
- Defined in:
- lib/dhall/resolve.rb
Instance Method Summary collapse
- #arity ⇒ Object
- #call(sources) ⇒ Object
-
#initialize(path_reader: ReadPathSources, http_reader: ReadHttpSources, https_reader: http_reader, public_gateway: "cloudflare-ipfs.com") ⇒ ReadPathAndIPFSSources
constructor
A new instance of ReadPathAndIPFSSources.
- #to_proc ⇒ Object
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.
105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/dhall/resolve.rb', line 105 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
#arity ⇒ Object
117 118 119 |
# File 'lib/dhall/resolve.rb', line 117 def arity 1 end |
#call(sources) ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/dhall/resolve.rb', line 121 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 ⇒ Object
133 134 135 |
# File 'lib/dhall/resolve.rb', line 133 def to_proc method(:call).to_proc end |