Package.io |
|
---|---|
A Boid environment is a collection of packages. Eventually installable packages will include single Io source files, directories, and version control system checkouts. |
|
The |
Boid Package := Object clone do(
|
The |
canHandle := method(spec, false)
|
The |
install := method(
BoidError raise("packages of this type cannot yet be installed"))
|
Surprisingly, the |
uninstall := method(
BoidError raise("packages of this type cannot yet be uninstalled"))) |
Boid can install single-file packages, as long as they end with the .io file extension. |
Boid FilePackage := Boid Package clone do(
canHandle := method(spec,
spec matchesRegex("^.*\.io$"))
validates := method(spec,
File with(spec) exists)
isInstalled := method(spec,
localFile := File with(spec)
File with(Boid ioDir path .. "/" .. localFile name) exists)
|
Installation of a single-file package is pretty straightforward. |
install := method(spec, |
The |
if(canHandle(spec) not,
BoidError raise("`#{spec}' isn't recognized by #{type}" interpolate))
if(validates(spec) not,
BoidError raise("`#{spec}' does not exist" interpolate))
if(isInstalled(spec),
BoidError raise("`#{spec}' is already installed" interpolate)) |
If everything goes well the Io source file is copied to the io/ directory in the active environment and the original source file is left where it is. |
localFile := File with(spec)
pkgFile := File with(Boid ioDir path .. "/" .. localFile name)
localFile copyToPath(pkgFile path)
if(pkgFile exists not,
BoidError raise("addition of `#{localFile name}' to active environment failed" interpolate))
true)
|
When a single source file package is removed, it is just a matter of deleting the file from the io/ directory in the active environment. |
uninstall := method(spec,
if(canHandle(spec) not,
BoidError raise("`#{spec}' isn't recognized by #{type}" interpolate))
if(isInstalled(spec) not,
BoidError raise("`#{spec}' is not installed" interpolate))
localFile := File with(spec)
pkgFile := File with(Boid ioDir path .. "/" .. localFile name)
pkgFile remove
if(pkgFile exists,
BoidError raise("removal of `#{localFile name}' from active environment failed" interpolate))
true)) |
Available package handlers are kept in a list, ordered by priority from
highest to lowest. Only the |
Boid Package handlers := list(Boid FilePackage) |