Class: Dhall::Import
Defined Under Namespace
Classes: AbsolutePath, AsLocation, EnvironmentVariable, Expression, Http, Https, IntegrityCheck, MissingImport, NoIntegrityCheck, Path, RelativePath, RelativeToHomePath, RelativeToParentPath, Text, URI
Constant Summary
collapse
- Location =
LazyObject.new do
UnionType.new(
alternatives: {
"Local" => Builtins[:Text],
"Remote" => Builtins[:Text],
"Environment" => Builtins[:Text],
"Missing" => nil
}
)
end
- IMPORT_TYPES =
[
Expression,
Text,
AsLocation
].freeze
- PATH_TYPES =
[
Http, Https,
AbsolutePath, RelativePath, RelativeToParentPath, RelativeToHomePath,
EnvironmentVariable, MissingImport
].freeze
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Expression
#&, #*, #+, #as_dhall, #call, #concat, #deep_merge, #deep_merge_type, #dhall_eq, #digest, #fetch, #fusion, #merge, #normalize, #resolve, #shift, #slice, #substitute, #to_binary, #to_cbor, #to_proc, #to_s, #|
Constructor Details
#initialize(integrity_check, import_type, path) ⇒ Import
Returns a new instance of Import.
1673
1674
1675
1676
1677
1678
1679
|
# File 'lib/dhall/ast.rb', line 1673
def initialize(integrity_check, import_type, path)
super(
integrity_check: integrity_check || NoIntegrityCheck.new,
import_type: import_type,
path: path
)
end
|
Class Method Details
.decode(integrity_check, import_type, path_type, *parts) ⇒ Object
259
260
261
262
263
264
265
266
267
268
|
# File 'lib/dhall/binary.rb', line 259
def self.decode(integrity_check, import_type, path_type, *parts)
parts[0] = Dhall.decode(parts[0]) if path_type < 2 && !parts[0].nil?
path_type = PATH_TYPES.fetch(path_type)
new(
IntegrityCheck.decode(integrity_check),
IMPORT_TYPES[import_type],
path_type.decode(*parts)
)
end
|
Instance Method Details
#as_json ⇒ Object
1706
1707
1708
1709
1710
1711
1712
1713
1714
|
# File 'lib/dhall/ast.rb', line 1706
def as_json
[
24,
integrity_check&.as_json,
IMPORT_TYPES.index(import_type),
PATH_TYPES.index(path.class),
*path.as_json
]
end
|
#cache_key(relative_to) ⇒ Object
1697
1698
1699
1700
1701
1702
1703
1704
|
# File 'lib/dhall/ast.rb', line 1697
def cache_key(relative_to)
key = integrity_check.to_s
if key.empty?
real_path(relative_to)
else
key
end
end
|
#parse_and_check(raw, deadline: Util::NoDeadline.new) ⇒ Object
1693
1694
1695
|
# File 'lib/dhall/ast.rb', line 1693
def parse_and_check(raw, deadline: Util::NoDeadline.new)
integrity_check.check(import_type.call(raw, deadline: deadline))
end
|
#real_path(relative_to) ⇒ Object
1689
1690
1691
|
# File 'lib/dhall/ast.rb', line 1689
def real_path(relative_to)
path.chain_onto(relative_to).canonical
end
|
#with(options) ⇒ Object
1681
1682
1683
1684
1685
1686
1687
|
# File 'lib/dhall/ast.rb', line 1681
def with(options)
self.class.new(
options.fetch(:integrity_check, integrity_check),
options.fetch(:import_type, import_type),
options.fetch(:path, path)
)
end
|