Module: Toys::SourceInfo::Origin
- Defined in:
- lib/toys/source_info/origin.rb
Overview
An origin describes where a source's content came from: the local file system, a git repository, a Ruby gem, or a block of code.
An origin is determined when a source spec is resolved, and it does not change as a loader descends into child sources. Every Toys::SourceInfo created by descending from another, whether by walking a directory or by entering a block or a subclass, shares its parent's origin object. A child created by resolving a new source spec gets its own origin instead.
An origin is thus fixed information about a resolution: which git remote and commit, or which gem and version, the content came from. Where a particular source sits within that content is tracked by the Toys::SourceInfo rather than by the origin, and is what makes #source_path differ from one source to the next while the origin stays the same.
This is distinct from #source_type, which says what a source is — a file, a directory, a block, or a subclass — rather than where it came from. The two vary independently: a git origin can yield either a file or a directory, and a block within a file loaded from git keeps that git origin.