Distribution::Path — 파일시스템 기반 Distribution

Distribution::Path — 파일시스템 기반 Distribution

배포판(distribution)을 다루다 보면 메타데이터와 실제 파일이 파일시스템 어딘가에 그대로 놓여 있는 경우가 많아요. 그런 배포판을 표현하는 Distribution 구현이 바로 Distribution::Path예요.

출처: Raku Documentation — Distribution::Path

본문

class Distribution::Path does Distribution::Locally { }

파일시스템에 기반한 Distribution 구현이에요. 배포판의 루트에 META6.json 파일이 있어야 해요.

method new

method new(IO::Path $prefix, IO::Path :$meta-file = IO::Path)

주어진 $prefix에서 찾은 META6.json 파일로 새 Distribution::Path 인스턴스를 만들어요. $prefix는 메타데이터 안의 모든 경로가 이 값을 기준으로 접두사처럼 붙는 루트가 돼요. META6.json이 아닌 다른 파일명을 써야 한다면 :$meta-file을 선택적으로 넘기면 돼요.

method meta

method meta(Distribution::Path:D:)

메타데이터의 표현을 담은 Hash를 반환해요.

method content

method content($name-path --> IO::Handle:D)

$name-path가 나타내는 파일에 대한 IO::Handle을 돌려줘요. $name-path는 메타데이터에서 찾을 수 있는 상대 경로예요. 예를 들어 lib/Foo.rakumod이나 resources/foo.txt 같은 경로죠. 자세한 내용은 Distribution::Locally#method_content를 참고하세요.

출처: Raku Documentation — Distribution::Path