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: URI("https://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: URI("https://cloudflare-ipfs.com")) ⇒ ReadPathAndIPFSSources
Returns a new instance of ReadPathAndIPFSSources.
97 98 99 100 101 102 103 104 105 106 107 |
# 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 |
Instance Method Details
#arity ⇒ Object
109 110 111 |
# File 'lib/dhall/resolve.rb', line 109 def arity 1 end |
#call(sources) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# 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 ⇒ Object
125 126 127 |
# File 'lib/dhall/resolve.rb', line 125 def to_proc method(:call).to_proc end |