class Dhall::Import::URI
Public Class Methods
decode(headers, authority, *path, query)
click to toggle source
# File lib/dhall/binary.rb, line 236 def self.decode(headers, authority, *path, query) uri = ::URI.scheme_list[name.split(/::/).last.upcase].build( Parser.parse(authority, root: :authority).value.merge( path: "/#{path.join("/")}" ) ) uri.instance_variable_set(:@query, query) new(headers: headers, uri: uri) end
Public Instance Methods
as_json()
click to toggle source
# File lib/dhall/ast.rb, line 1460 def as_json [@headers&.as_json, authority, *path, uri.query] end
canonical()
click to toggle source
# File lib/dhall/ast.rb, line 1423 def canonical with( path: (path[1..-1] + [""]).reduce([[], path.first]) { |(pth, prev), c| c == ".." ? [pth, prev] : [pth + [prev], c] }.first.reject { |c| c == "." } ) end
chain_onto(relative_to)
click to toggle source
# File lib/dhall/ast.rb, line 1415 def chain_onto(relative_to) if headers.is_a?(Import) with(headers: headers.with(path: headers.real_path(relative_to))) else self end end
headers()
click to toggle source
Calls superclass method
# File lib/dhall/ast.rb, line 1404 def headers header_type = RecordType.new( record: { "mapKey" => Builtins[:Text], "mapValue" => Builtins[:Text] } ) super || EmptyList.new(element_type: header_type) end
location()
click to toggle source
# File lib/dhall/ast.rb, line 1450 def location Union.from(Location, "Remote", to_s.as_dhall) end
origin()
click to toggle source
# File lib/dhall/ast.rb, line 1442 def origin "#{uri.scheme}://#{authority}" end
path()
click to toggle source
# File lib/dhall/ast.rb, line 1454 def path path = uri.path.split(/\//, -1) path = path[1..-1] if path.length > 1 && path.first.empty? path end
port()
click to toggle source
# File lib/dhall/ast.rb, line 1431 def port uri.port && uri.port != uri.default_port ? uri.port : nil end
to_s()
click to toggle source
# File lib/dhall/ast.rb, line 1446 def to_s uri.to_s end
with(attrs)
click to toggle source
Calls superclass method
# File lib/dhall/ast.rb, line 1395 def with(attrs) if attrs.key?(:path) attrs[:uri] = uri + Util.path_components_to_uri(*attrs.delete(:path)) end super end