Module FileUtils::Stage
In: lib/facets/core/fileutils/stage.rb

Staging provides a means of easily transfering files from one location to another based on a set of transfer rules.

Methods

Public Instance methods

Remove the temporary folder now.

Parse individual transfer rule.

Substitue package information for rule variables. (eg. $name).

There is one parameter that deserves additional attention. This is the setting called ‘rules’. The rules setting allows you to define how files are copied into the distribution package, so instead of a one to one copy of the included files, you can actually have a file placed in a different location within the distribution. This can be very handy if you wish to develop your project with one layout, but need to distribute it with another.

The rules parameter is a literal string that consists of one rule per line. A line consists three space separated entries.

  from_path file_glob to_path

If no ‘to_path’ is given then it is considered the same as the ‘from_path’. Each entry also supports two substitution variables: $name and $version, Here is a possible example:

  rules: |
    lib **/* lib/$name/$version

This will move any file under lib/ to the equivalent location under lib/$name/$version/. The default set of rules is a mirror image transfer, spelled out it would be:

  rules: |
    bin  *
    ext  **/*
    lib  **/*
    data **/*
    conf **/*

If your using the Library class against a normal project folder the alterntive is to create versioned paths, basically as follows:

  rules: |
    ext/$name   **/*  ext/$name/$version
    lib/$name   **/*  lib/$name/$version
    data/$name  **/*  ext/$name/$version
    conf/$name  **/*  ext/$name/$version

But this is just example. To version tier you package, simply use the tier option.

Please note that the rules parameter is a new feature and is still considered beta.

Stage and execute block in the staged location.

Generate staging ground. Since there are sometimes special transfer rules we need to create a separate temporary location for the package. Also, some package formats, like Debian‘s, need a complete install "image". So a staging ground is often a neccessity in any case.

Determine transfer rules.

Rules should proceed from the most general to the most specific.

[Validate]