10 KiB
10 KiB
Changelog
Format: Keep a Changelog. A release's
Breaking section comes first and names each rejected spelling with its
replacement, and each removed path, column or flag.
[Unreleased]
Added
- Step up:
..after a row steps up to the row its link column names, so{/city[Oslo]..country.name}rendersNorway, and.after it steps down again, drawing afresh.Newrefuses a..naming anything but the parent table, and a selector after a... - A path, given to
Fakeor referenced in a template, may not read into a level carrying arepeat, andListadvertises no such path: wherexcarries"repeat": 3,Fake("x.a")fails naming the levelx, andFake("x")renders it whole. - Every
{…}draws afresh, and a name is the one way to keep a pick:{p.a} {p.b},{w} {uppercase(w)}and{/person.first} {/person.last}are two draws each, which{p as q}{q.a} {q.b}and{/person as n}{n.first} {n.last}make one.{/misc.territory as t}binds one row ofmisc.territorytotand prints nothing;{t},{t.capital}and{lowercase(t.name)}read that one row.{x as n}binds a reference, a sibling field or a path into one; a name lives in the category binding it, and picks again on every iteration of arepeat, or every draw of a choice item, binding it. A struct's tags share its names,{/sv_SE.person as p}{p.first}beside{p.sex}. A name is a{calc()}operand:{/misc.coordinate.lat as lat}{calc(lat * 60)}. WhatNewrefuses is listed under Names. - First release: the CLI, the library and the shipped data set.
- The CLI renders exactly the template on its stdin,
echo '{/sv_SE.person} hihi' | fejkdata, and adds nothing under--format text:echo's newline ends the render, and--separatordefaults to empty. Whitespace around a JSON object, array or string template is dropped, and a bare number or boolean is a format string, printed as written. A lone reference,{/users}, is the recordusersunder--format. An argument other than a flag, or nothing piped in, exits 2; an empty or blank stdin is a format string, and renders as sent. - A template or data file loads whatever is well-formed and means one thing, even where
part of it does nothing: a default written out; a one-item choice; an object holding only
a format; a constant sample such as
{int(5,5)}; aweight,separatorordatatypewhere it does nothing; a name nothing reads; a repeated item, which counts as written; a weight of0, which is never drawn; arepeator count of0, which renders nothing;+5,05and-0; and a reference into the category it sits in. A rows file no category names is ignored.New(WithDataFS())loads no data, and renders templates that read none. The CLI's-ntakes0;--listignores--repeat,--separator,--formatand--table, and--tableis ignored without--format sql. - Table categories: a category JSON naming a
rowsTSV beside it, with the optionskey,name,weightandparent; a path selects a row by key or name,misc.territory[SE], and descends to a linked table by name, one path drawing each row inside the row above it.rowsis an option, so no template may carry a field of that name. Anamewithout akeyresolves inside the table'sparent. Refused atNew: anamewithout akeyor aparent, a name repeating inside one parent row, a name spelling another row's key, and a table named like a column of any table above it. misc.territory,misc.currency,misc.language,misc.httpstatusandmisc.mimetypeare tables.misc.territoryis every ISO 3166-1 territory that has a capital, a currency and a TLD, with the columnscalling-code,capital,country,currency,flag,languages,numericandtldadded,countryholding the alpha-2 code of the sovereign state it belongs to and its own where it is one;misc.currencythe current ISO 4217 currencies with a minor unit, withdecimalsandnumericadded, and its symbols from CLDR;misc.languageevery ISO 639-2 entry carrying a 639-1 code, with acode3column holding its 639-2/T code;misc.httpstatuseach code the IANA registry lists with a plain reason phrase; andmisc.mimetypeeach type mime-db records as IANA-registered and gives a filename extension.DATA-LICENSES.mdlists each source.misc.timezone,misc.carandmisc.useragentare tables too.misc.timezoneis every zone tzdbzone.tabgives a shipped territory, withoffsetholding the zone's standard UTC offset andterritorylinking tomisc.territory, somisc.territory[SE].timezonedrawsEurope/Stockholm; zones of a territorymisc.territorydoes not ship, Antarctica's among them, and the constantUTCare gone; spell that one as the text"UTC". Aweightcolumn carries the population GeoNames records in each zone, so a draw favours the zones people live in.misc.useragentis the top-user-agents desktop and mobile lists withbrowser,deviceandoscolumns.misc.carkeeps its makes and models in amakeand amodelcolumn.misc.httpmethod,misc.protocolandmisc.portare IANA's registries as tables.misc.httpmethodis the eight methods RFC 9110 defines and PATCH, carryingsafeandidempotentastrueorfalse;misc.protocolthe keyword, itsnumberand itsname, selectable by either;misc.portrenders a TCP port number, with the IANAservicename beside it, keeping the first service the registry describes for a port so a number selects one row.misc.tldis the IANA root zone as a table: every delegated TLD keyed with its leading dot,.seand.xn--p1ai, the register'stypebeside it, and aunicodecolumn holding the form the register displays, somisc.tld[.рф]selects the row.xn--p1airenders. A delegation the register marks "Not assigned" does not ship.misc.loglevelis the eight syslog severities: thekeyworda configuration writes,errandinfo, keyed by the numericalcodea PRI encodes and selectable by either, with theseverityRFC 5424 spells beside it.geo.SEandgeo.US: five linked tables per country,region,municipality,locality,postal-codeandstreet, weighted by population and address counts and built from SCB, GeoNames, Trafikverket NVDB and the US Census Bureau, and anaddressrecord binding one locality and drawing its street and postal code inside it.sv_SE.addressanden_US.addressbind those records once, soen_US.address.streetno longer carriesnameandsuffix, and a locale'saddressreads its country'sgeomodule. Every Swedish postort the import can place and give a street ships with all its streets. Of the US incorporated places that hold most of some postal code's land, every state capital but Honolulu, every place of 100,000 or more, and a tenth of the rest drawn by population down to villages of a hundred people ship, so a smaller city may be missing; each carries a quarter of its streets, at least ten.{date(from,to,'layout')}and{time('layout')}: a second between two days, or within one, in a single-quoted Go layout, drawn in UTC;frommay equalto.sv_SE.date,en_US.date,sv_SE.timeanden_US.timerender through them, sodate.year,date.month,date.day,time.hour,time.minute,time.minute.t,time.secandtime.ampmare no longer paths — a part of a date is now its own{date(…,'2006')}.misc.datetimeis an RFC 3339 instant.sex,first-nameandlast-nametables insv_SEanden_US, weighted by bearers from SCB, the SSA and the Census Bureau;first-namelinks tosex, and a name both sexes carry is a row under each.personbinds one first name and reads its sex through it, and its columns arefirst,last,prefixandsex;person.femalefirstandperson.malefirstare no longer paths — drawsex[f].first-nameandsex[m].first-nameinstead.en_US.titlelinks tosexas well, soen_US.person.prefixdrawsMrorMswithout contradicting the record'ssex;sv_SE.titleis an unsexed table of the same shape.sv_SE.personnummerandsv_SE.samordningsnummer, Skatteverket's test series from asv_SE.birth-numbertable undersex, in place ofsv_SE.ssn, whosessn.mmdd,ssn.mmdd.mandssn.mmdd.dgo with it.en_US.ssnnow draws the ranges the SSA assigns and carries the columnsarea,groupandserial, soecho '{/en_US.ssn}' | fejkdata --format csvwrites a header where it used to fail;en_US.itinis new and carries the same three.person.prefixis null where a person has no title, where it used to be an empty string, so--format sqlwritesNULLand astringstruct field reading it becomes*string.en_US.phone-exchangedraws the three digits after a US area code evenly from the codes NANPA may assign:200to999, except211,311…911,555,950,958,959and976.en_US.phonedraws itsexchangefrom it.ErrNoColumnsis exported, so a caller can tell the one record fence a path can answer from the rest.- An error names a spelling that runs: a layout is named single-quoted and free of
its own quotes, a row of a table with no key is named as the path that selects it,
sv_SE.sex[f].first-name[Kim], and a category with no columns names the record that gives it one. - The shipped data comes in Go packages, one per module, each exporting
FS:github.com/larvit/fejkdata/data/en_US(packageenus),…/sv_SE(svse),…/misc,…/geo/SE(geose) and…/geo/US(geous).data.Modules(), fromgithub.com/larvit/fejkdata/data, lists every one, and the CLI carries them all. Each package'sModules()returns itsFSand every module it reads:svse.Modules()holds the Swedish places too.Newloads the modulesWithDataFS(modules...)names and the foldersWithDataPathnames, and fails, namingWithDataFS, where no such option is given. A manifest'snamespacemounts its source under a dot path. - A data source whose root holds a
.fejkdata.jsonmanifest with anindexloads each category on the first call reaching it, as each shipped module does. Data failing to load, inNewor on that first call, gives an error matchingErrLoad, and the CLI exits 1. A source without an index loads inNew, with the indexed categories it reads. Every other shipped category loads on the first call reaching it, so one your replacement breaks fails there.