Basic

Reading a folder as a contract

The folder is the library, and the library is what the build promises about. The promise is a list, and the list is what a test checks.

What you will see

One line with a reason. Reported is not ignored, which is the claim.

About 1 min of reading

Try It

Count found and built

1

Write the roots

printf 'content/\nassets/\n' > /tmp/r.txt; wc -l < /tmp/r.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
2. Two roots is the list a reader checks.
2

Write found and built

printf 'found 12 built 11\n' | awk '{print $2-$3}'

Before you run it, say out loud what it will print. Then open the answer.

What it prints
1. One difference is the whole answer, and the answer is a name.
3

Report a skipped file

printf 'skip notes.pdf reason=not-taken\n' > /tmp/s.txt; cat /tmp/s.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
One line with a reason. Reported is not ignored, which is the claim.

Data Flow

A folder to a list and a count
1 The roots are written as a list
↓
2 The walk names the extension it takes
↓
3 The rest are reported as skipped
↓
4 Found and built are written as two numbers
Why this works
Why the walk is done twice

Once for content and once for assets. Two walks is two contracts, and two contracts is what makes an asset findable.

The failure at this step

A file that is found and not built. The difference is the whole answer, and the answer is a name.

Examples

The walk names what it takes

One extension is taken and the rest are reported. Reported is not ignored, and reported is a claim.

The count is the contract

Files found and files built. Two numbers, and two numbers is what a difference names.

A folder that is not read is a bug

The walk is written as a list of roots. A list of roots is a list that a reader can check.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Content as data with a shape
Previous Lesson
Content as data with a shape
Next Lesson
A template as a shape with holes
A template as a shape with holes →