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.
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# 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 |
Instance Attribute Details
#deadline ⇒ Object (readonly)
Returns the value of attribute deadline.
254 255 256 |
# File 'lib/dhall/resolve.rb', line 254 def deadline @deadline end |
Instance Method Details
#cache_fetch(key, &fallback) ⇒ Object
282 283 284 285 286 |
# 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) ⇒ Object
336 337 338 339 340 341 342 343 344 345 |
# 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! ⇒ Object
324 325 326 327 328 329 330 331 332 333 334 |
# 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) ⇒ Object
294 295 296 297 298 |
# 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) ⇒ Object
300 301 302 303 304 305 306 307 308 309 310 |
# 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) ⇒ Object
312 313 314 315 316 317 318 319 320 321 322 |
# 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) ⇒ Object
288 289 290 291 292 |
# File 'lib/dhall/resolve.rb', line 288 def resolve_path(path_source) @path_resolutions.register( SourceWithDeadline.new(path_source, @deadline) ) end |
#with_deadline(deadline) ⇒ Object
274 275 276 277 278 279 280 |
# File 'lib/dhall/resolve.rb', line 274 def with_deadline(deadline) dup.tap do |c| c.instance_eval do @deadline = deadline end end end |