Class: Dhall::Import::URI
- Inherits:
-
Object
- Object
- Dhall::Import::URI
- Defined in:
- lib/dhall/ast.rb,
lib/dhall/binary.rb
Class Method Summary collapse
Instance Method Summary collapse
- #as_json ⇒ Object
- #authority ⇒ Object
- #canonical ⇒ Object
- #chain_onto(relative_to) ⇒ Object
- #headers ⇒ Object
- #location ⇒ Object
- #origin ⇒ Object
- #path ⇒ Object
- #port ⇒ Object
- #to_s ⇒ Object
- #with(attrs) ⇒ Object
Class Method Details
.decode(headers, authority, *path, query) ⇒ Object
230 231 232 233 234 235 236 237 238 |
# File 'lib/dhall/binary.rb', line 230 def self.decode(headers, , *path, query) uri = ::URI.scheme_list[name.split(/::/).last.upcase].build( Parser.parse(, root: :authority).value.merge( path: Util.path_components_to_uri(*path).path ) ) uri.instance_variable_set(:@query, query) new(headers: headers, uri: uri) end |
Instance Method Details
#as_json ⇒ Object
1410 1411 1412 |
# File 'lib/dhall/ast.rb', line 1410 def as_json [@headers&.as_json, , *path, uri.query] end |
#authority ⇒ Object
1385 1386 1387 1388 1389 1390 |
# File 'lib/dhall/ast.rb', line 1385 def [ uri.userinfo, [uri.host, port].compact.join(":") ].compact.join("@") end |
#canonical ⇒ Object
1373 1374 1375 1376 1377 1378 1379 |
# File 'lib/dhall/ast.rb', line 1373 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) ⇒ Object
1365 1366 1367 1368 1369 1370 1371 |
# File 'lib/dhall/ast.rb', line 1365 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 ⇒ Object
1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 |
# File 'lib/dhall/ast.rb', line 1354 def headers header_type = RecordType.new( record: { "mapKey" => Builtins[:Text], "mapValue" => Builtins[:Text] } ) super || EmptyList.new(element_type: header_type) end |
#location ⇒ Object
1400 1401 1402 |
# File 'lib/dhall/ast.rb', line 1400 def location Union.from(Location, "Remote", to_s.as_dhall) end |
#origin ⇒ Object
1392 1393 1394 |
# File 'lib/dhall/ast.rb', line 1392 def origin "#{uri.scheme}://#{}" end |
#path ⇒ Object
1404 1405 1406 1407 1408 |
# File 'lib/dhall/ast.rb', line 1404 def path path = uri.path.split(/\//, -1).map(&::URI.method(:unescape)) path = path[1..-1] if path.length > 1 && path.first.empty? path end |
#port ⇒ Object
1381 1382 1383 |
# File 'lib/dhall/ast.rb', line 1381 def port uri.port && uri.port != uri.default_port ? uri.port : nil end |
#to_s ⇒ Object
1396 1397 1398 |
# File 'lib/dhall/ast.rb', line 1396 def to_s uri.to_s end |
#with(attrs) ⇒ Object
1345 1346 1347 1348 1349 1350 1351 1352 |
# File 'lib/dhall/ast.rb', line 1345 def with(attrs) if attrs.key?(:path) attrs[:uri] = uri + Util.path_components_to_uri(*attrs.delete(:path)) end super end |