Parses a mix composer.new recipe reference: COOKBOOK:GROUP/RECIPE,
with an optional @SOURCE naming where the cookbook comes from.
iex> ComposerNew.Ref.parse("cb_lab:lv/base@github:elixir-composer/cb_lab@v0.3.0")
{:ok,
%{
cookbook: "cb_lab",
path: "lv/base",
source: [github: "elixir-composer/cb_lab", ref: "v0.3.0"],
spec: "github:elixir-composer/cb_lab@v0.3.0"
}}This is a copy of the name and @source rules of Composer.Ref (the
archive can't depend on composer), and a fixture shared by both
projects' tests keeps the two in step:
- the reference is split on its first
@; only the name before it is normalized from-to_ - names are lowercase
[a-z0-9_]segments - a source is a version (
3.5.0is== 3.5.0, a partial3.5is~> 3.0, Igniter's rule, and a requirement such as~> 3.5is kept),github:OWNER/REPO[@GITREF],git:URLorpath:PATH
On top of those, a reference here must name a cookbook (no shortnames),
can't be hex:, and core:, which ships with composer, takes no
source.
Parsing never creates atoms.
Summary
Functions
Expands path against env.cwd, with a leading ~ as env.home.
Like install_spec/3, for a whole package[@spec] string as
--install and --extra-dep take it.
The mix igniter.install argument for package from spec (the text
after @, or nil), with a path: source made absolute against
env.cwd and env.home, since the install runs inside the new app.
Parses a reference. spec is the text after the @ as written, or
nil; source is its parsed form ([] for none, meaning the latest
Hex release).
Parses a bare source, with no package name, as --composer takes it:
path:../composer, github:owner/repo, ~> 0.3, ...
Types
Functions
Expands path against env.cwd, with a leading ~ as env.home.
Like install_spec/3, for a whole package[@spec] string as
--install and --extra-dep take it.
The mix igniter.install argument for package from spec (the text
after @, or nil), with a path: source made absolute against
env.cwd and env.home, since the install runs inside the new app.
Parses a reference. spec is the text after the @ as written, or
nil; source is its parsed form ([] for none, meaning the latest
Hex release).
Parses a bare source, with no package name, as --composer takes it:
path:../composer, github:owner/repo, ~> 0.3, ...