Class: Dhall::Resolvers::Standard
- Inherits:
-
Object
- Object
- Dhall::Resolvers::Standard
- Defined in:
- lib/dhall/resolve.rb
Instance Attribute Summary collapse
-
#deadline ⇒ Object
readonly
Returns the value of attribute deadline.
Instance Method Summary collapse
- #cache_fetch(key, &fallback) ⇒ Object
- #child(parent_source) ⇒ Object
- #finish! ⇒ Object
-
#initialize(path_reader: ReadPathSources, http_reader: StandardReadHttpSources, https_reader: http_reader, environment_reader: ReadEnvironmentSources, cache: StandardFileCache.new, max_depth: Float::INFINITY) ⇒ Standard
constructor
A new instance of Standard.
- #resolve_environment(env_source) ⇒ Object
- #resolve_http(http_source) ⇒ Object
- #resolve_https(https_source) ⇒ Object
- #resolve_path(path_source) ⇒ Object
- #with_deadline(deadline) ⇒ Object
Constructor Details
#initialize(path_reader: ReadPathSources, http_reader: StandardReadHttpSources, https_reader: http_reader, environment_reader: ReadEnvironmentSources, cache: StandardFileCache.new, max_depth: Float::INFINITY) ⇒ Standard
Returns a new instance of Standard.
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
# File 'lib/dhall/resolve.rb', line 264 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 |
Instance Attribute Details
#deadline ⇒ Object (readonly)
Returns the value of attribute deadline.
262 263 264 |
# File 'lib/dhall/resolve.rb', line 262 def deadline @deadline end |
Instance Method Details
#cache_fetch(key, &fallback) ⇒ Object
290 291 292 293 294 |
# File 'lib/dhall/resolve.rb', line 290 def cache_fetch(key, &fallback) @cache.fetch(key) do Promise.resolve(nil).then(&fallback) end end |
#child(parent_source) ⇒ Object
344 345 346 347 348 349 350 351 352 353 |
# File 'lib/dhall/resolve.rb', line 344 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! ⇒ Object
332 333 334 335 336 337 338 339 340 341 342 |
# File 'lib/dhall/resolve.rb', line 332 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) ⇒ Object
302 303 304 305 306 |
# File 'lib/dhall/resolve.rb', line 302 def resolve_environment(env_source) @env_resolutions.register( SourceWithDeadline.new(env_source, @deadline) ) end |
#resolve_http(http_source) ⇒ Object
308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/dhall/resolve.rb', line 308 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) ⇒ Object
320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/dhall/resolve.rb', line 320 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) ⇒ Object
296 297 298 299 300 |
# File 'lib/dhall/resolve.rb', line 296 def resolve_path(path_source) @path_resolutions.register( SourceWithDeadline.new(path_source, @deadline) ) end |
#with_deadline(deadline) ⇒ Object
282 283 284 285 286 287 288 |
# File 'lib/dhall/resolve.rb', line 282 def with_deadline(deadline) dup.tap do |c| c.instance_eval do @deadline = deadline end end end |