class Dhall::Resolvers::Standard
Attributes
deadline[R]
Public Class Methods
new( path_reader: ReadPathSources, http_reader: StandardReadHttpSources, https_reader: http_reader, environment_reader: ReadEnvironmentSources, cache: StandardFileCache.new, max_depth: Float::INFINITY )
click to toggle source
# File lib/dhall/resolve.rb, line 256 def initialize( path_reader: ReadPathSources, http_reader: StandardReadHttpSources, https_reader: http_reader, environment_reader: ReadEnvironmentSources, cache: StandardFileCache.new, max_depth: Float::INFINITY ) @path_resolutions = ResolutionSet.new(path_reader, max_depth: max_depth) @http_resolutions = ResolutionSet.new(http_reader, max_depth: max_depth) @https_resolutions = ResolutionSet.new(https_reader, max_depth: max_depth) @env_resolutions = ResolutionSet.new( environment_reader, max_depth: max_depth ) @deadline = Util::NoDeadline.new @cache = cache end
Public Instance Methods
cache_fetch(key, &fallback)
click to toggle source
# File lib/dhall/resolve.rb, line 282 def cache_fetch(key, &fallback) @cache.fetch(key) do Promise.resolve(nil).then(&fallback) end end
child(parent_source)
click to toggle source
# File lib/dhall/resolve.rb, line 336 def child(parent_source) dup.tap do |c| c.instance_eval do @path_resolutions = @path_resolutions.child(parent_source) @env_resolutions = @env_resolutions.child(parent_source) @http_resolutions = @http_resolutions.child(parent_source) @https_resolutions = @https_resolutions.child(parent_source) end end end
finish!()
click to toggle source
# File lib/dhall/resolve.rb, line 324 def finish! [ @path_resolutions, @env_resolutions, @http_resolutions, @https_resolutions ].each do |rset| Util.match_result_promises(*rset.resolutions, &rset.reader) end freeze end
resolve_environment(env_source)
click to toggle source
# File lib/dhall/resolve.rb, line 294 def resolve_environment(env_source) @env_resolutions.register( SourceWithDeadline.new(env_source, @deadline) ) end
resolve_http(http_source)
click to toggle source
# File lib/dhall/resolve.rb, line 300 def resolve_http(http_source) http_source.headers.resolve( resolver: self, relative_to: Dhall::Import::RelativePath.new ).then do |headers| source = http_source.with(headers: headers.normalize) @http_resolutions.register( SourceWithDeadline.new(source, @deadline) ) end end
resolve_https(https_source)
click to toggle source
# File lib/dhall/resolve.rb, line 312 def resolve_https(https_source) https_source.headers.resolve( resolver: self, relative_to: Dhall::Import::RelativePath.new ).then do |headers| source = https_source.with(headers: headers.normalize) @https_resolutions.register( SourceWithDeadline.new(source, @deadline) ) end end
resolve_path(path_source)
click to toggle source
# File lib/dhall/resolve.rb, line 288 def resolve_path(path_source) @path_resolutions.register( SourceWithDeadline.new(path_source, @deadline) ) end
with_deadline(deadline)
click to toggle source
# File lib/dhall/resolve.rb, line 274 def with_deadline(deadline) dup.tap do |c| c.instance_eval do @deadline = deadline end end end