diff --git a/CHANGELOG.md b/CHANGELOG.md index 09777f2..ae5e331 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,8 +90,8 @@ replacement, and each removed path, column or flag. and carries the same three. `person.prefix` is null where a person has no title, where it used to be an empty string, so `--format sql` writes `NULL` and a `string` struct field reading it becomes `*string`. -- `en_US.phone` draws its exchange, `exch`, from the central office codes NANPA can - assign: `200` to `999`, never `N11`, `555`, `950`, `958`, `959` or `976`. +- `en_US.phone-exchange` draws a central office code NANPA can assign: `200` to `999`, + never `N11`, `555`, `950`, `958`, `959` or `976`. `en_US.phone` draws its `exch` from it. - `ErrNoColumns` is 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 diff --git a/README.md b/README.md index f57ae5a..201ac22 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ which binds a [name](#names), nor be `-`, which a struct tag reserves; dot-prefi Each locale carries `address`, `color`, `company`, `date`, `email`, `first-name`, `ip`, `last-name`, `person`, `phone`, `price`, `sentence`, `sex`, `time`, `url`, `username`, `version` and `word`, formatted per locale; `sv_SE` adds -`personnummer` and `samordningsnummer`, `en_US` adds `ssn` and `itin`. `misc` +`personnummer` and `samordningsnummer`, `en_US` adds `ssn`, `itin` and `phone-exchange`. `misc` carries `car`, `coordinate`, `creditcard` (Luhn-valid), `currency` (ISO 4217), `datetime` (RFC 3339), `emoji`, `httpmethod`, `httpstatus`, `language` (ISO 639-1, with its 639-2/T code), `loglevel` (syslog severity), `mac`, `mimetype`, `objectid`, diff --git a/data/en_US/phone-exchange.json b/data/en_US/phone-exchange.json new file mode 100644 index 0000000..8966fca --- /dev/null +++ b/data/en_US/phone-exchange.json @@ -0,0 +1,17 @@ +[ + { "format": "{int(2,9)}0{digits(1)}", "weight": 80 }, + { "format": "{int(2,9)}1{int(2,9)}", "weight": 64 }, + { "format": "{int(2,9)}10", "weight": 8 }, + { "format": "{int(2,4)}{int(2,9)}{digits(1)}", "weight": 240 }, + { "format": "{int(6,8)}{int(2,9)}{digits(1)}", "weight": 240 }, + { "format": "5{int(2,4)}{digits(1)}", "weight": 30 }, + { "format": "5{int(6,9)}{digits(1)}", "weight": 40 }, + { "format": "55{int(0,4)}", "weight": 5 }, + { "format": "55{int(6,9)}", "weight": 4 }, + { "format": "9{int(2,4)}{digits(1)}", "weight": 30 }, + { "format": "9{int(8,9)}{digits(1)}", "weight": 20 }, + { "format": "95{int(1,7)}", "weight": 7 }, + { "format": "96{digits(1)}", "weight": 10 }, + { "format": "97{int(0,5)}", "weight": 6 }, + { "format": "97{int(7,9)}", "weight": 3 } +] diff --git a/data/en_US/phone.json b/data/en_US/phone.json index a5e9f9e..30d4483 100644 --- a/data/en_US/phone.json +++ b/data/en_US/phone.json @@ -3,45 +3,13 @@ "format": "({area}) {exch}-{line}", "weight": 2, "area": ["202", "212", "213", "305", "312", "404", "415", "469", "503", "512", "602", "617", "646", "702", "718", "720", "737", "773", "786", "808", "917"], - "exch": [ - { "format": "{int(2,9)}0{digits(1)}", "weight": 80 }, - { "format": "{int(2,9)}1{int(2,9)}", "weight": 64 }, - { "format": "{int(2,9)}10", "weight": 8 }, - { "format": "{int(2,4)}{int(2,9)}{digits(1)}", "weight": 240 }, - { "format": "{int(6,8)}{int(2,9)}{digits(1)}", "weight": 240 }, - { "format": "5{int(2,4)}{digits(1)}", "weight": 30 }, - { "format": "5{int(6,9)}{digits(1)}", "weight": 40 }, - { "format": "55{int(0,4)}", "weight": 5 }, - { "format": "55{int(6,9)}", "weight": 4 }, - { "format": "9{int(2,4)}{digits(1)}", "weight": 30 }, - { "format": "9{int(8,9)}{digits(1)}", "weight": 20 }, - { "format": "95{int(1,7)}", "weight": 7 }, - { "format": "96{digits(1)}", "weight": 10 }, - { "format": "97{int(0,5)}", "weight": 6 }, - { "format": "97{int(7,9)}", "weight": 3 } - ], + "exch": "{.phone-exchange}", "line": "{digits(4)}" }, { "format": "{area}-{exch}-{line}", "area": ["202", "212", "213", "305", "312", "404", "415", "469", "503", "512", "602", "617", "646", "702", "718", "720", "737", "773", "786", "808", "917"], - "exch": [ - { "format": "{int(2,9)}0{digits(1)}", "weight": 80 }, - { "format": "{int(2,9)}1{int(2,9)}", "weight": 64 }, - { "format": "{int(2,9)}10", "weight": 8 }, - { "format": "{int(2,4)}{int(2,9)}{digits(1)}", "weight": 240 }, - { "format": "{int(6,8)}{int(2,9)}{digits(1)}", "weight": 240 }, - { "format": "5{int(2,4)}{digits(1)}", "weight": 30 }, - { "format": "5{int(6,9)}{digits(1)}", "weight": 40 }, - { "format": "55{int(0,4)}", "weight": 5 }, - { "format": "55{int(6,9)}", "weight": 4 }, - { "format": "9{int(2,4)}{digits(1)}", "weight": 30 }, - { "format": "9{int(8,9)}{digits(1)}", "weight": 20 }, - { "format": "95{int(1,7)}", "weight": 7 }, - { "format": "96{digits(1)}", "weight": 10 }, - { "format": "97{int(0,5)}", "weight": 6 }, - { "format": "97{int(7,9)}", "weight": 3 } - ], + "exch": "{.phone-exchange}", "line": "{digits(4)}" } ] diff --git a/shippedindex.go b/shippedindex.go index 32ef0e2..f6a96ea 100644 --- a/shippedindex.go +++ b/shippedindex.go @@ -14,6 +14,7 @@ var shippedIndex = map[string]shippedEntry{ "en_US.last-name": {paths: []string{"", "count", "name"}}, "en_US.person": {paths: []string{"", "first", "last", "prefix", "sex"}}, "en_US.phone": {paths: []string{"", "area", "exch", "line"}}, + "en_US.phone-exchange": {paths: []string{""}}, "en_US.price": {paths: []string{"", "amt", "cents"}}, "en_US.sentence": {paths: []string{"", "adj", "noun", "prep", "verb"}}, "en_US.sex": {paths: []string{"", "code", "first-name", "first-name.count", "first-name.name", "first-name.sex", "name", "title", "title.name", "title.sex", "title.share"}}, diff --git a/todo.md b/todo.md index 23dd2d0..eb5c2f9 100644 --- a/todo.md +++ b/todo.md @@ -6,7 +6,7 @@ `Bar = 9` -`Next ID = 86` +`Next ID = 87` | Goal | W | |---|---| @@ -108,6 +108,7 @@ | 30 | 0.3.0 | | **Draw `email.local` from `username`, so the two share one handle list.** | 2 | 2 | 3 | 5 | 5.7 | 11.5 | | 40 | 0.3.0 | | **Parse `defaultTable`'s path with the library's grammar.** | 2 | 2 | 3 | 5 | 5.7 | 11.5 | | 75 | 0.3.0 | | **Run every README `sh`, `go` and `text` example as a test, and compare each "Renders" line to a seeded render.** | 2 | 6 | 4 | 7 | 11.2 | 11.5 | +| 86 | 0.3.0 | | **Read `en_US.phone`'s area codes from one category, as its exchange reads `en_US.phone-exchange`.** | 1 | 2 | 2 | 5 | 3.2 | 11.5 | | 33 | 0.3.0 | | **Group `data/misc` into folders where a group name makes a path easier to guess.** | 4 | 5 | 4 | 5 | 5 | 10.8 | | 47 | 0.3.0 | defect | **Refuse a category naming a hidden rows file, `"rows": ".x.tsv"`, as a rows file that is not there.** | 1 | 1 | 2 | 5 | 6 | 10.2 | | 72 | 0.3.0 | principle | **Fail the merge gate when test coverage falls below the last recorded figure.** | 2 | 3 | 2 | 5 | 3 | 10.2 | @@ -389,6 +390,10 @@ The CLI counts brackets of its own, so a change to the selector grammar desyncs `readme_test.go` loads and renders each `json` block, but runs no `sh` example (CLI, Records, Table, Linked tables), no `go` example (Library) and no `text` block of error text, and compares no "Renders e.g." output, so goal 11.2 is not met. +### 86. Read `en_US.phone`'s area codes from one category, as its exchange reads `en_US.phone-exchange`. + +Both phone formats carry the same 21-code `area` list, so an edit to one copy can miss the other. + ### 47. Refuse a category naming a hidden rows file, `"rows": ".x.tsv"`, as a rows file that is not there. `loadDir` indexes hidden TSVs and skips them in two places, so one loads where its comment says a hidden file is never data.