Skip to content

Commit

Permalink
doc: generate example.ris; a file with records of every types with ev…
Browse files Browse the repository at this point in the history
…ery fields
  • Loading branch information
customcommander committed Apr 8, 2021
1 parent 918b07f commit d40f795
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
example.ris
node_modules
yarn-error.log
out.txt
out.txt
yarn-error.log
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ tag-map.csv: doc/tag.jq tag-map.json
markdown-type:
@jq -M -S -r -f doc/type.jq type-map.json | awk -F"," -f doc/type.awk

example.ris: doc/example.jq tag-map.json
@jq -M -S -r -f $^ | tee $@

/tmp/ris.test: grammar.js index.js ris-parser.feature steps.js
yarn cucumber-js --require steps.js ris-parser.feature
touch $@
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,11 @@ The following command will:
```
make sample
```

## example.ris

The [example.ris](./example.ris) file contains one record (reference) of every type with every field:

```
make example.ris
```
25 changes: 25 additions & 0 deletions doc/example.jq
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def type: split(".")[0]; # e.g. "VIDEO.A2" -> "VIDEO"
def field: split(".")[1]; # e.g. "VIDEO.A2" -> "A2"

def type_record: "TY - \(.key | type)";
def field_record:
(.key | field) as $f
| if $f == "A2" or $f == "A3" or $f == "A4" or $f == "AU" then
"\($f) - \(.key)_Doe, John"
elif $f == "PY" then
"\($f) - 1666"
elif $f == "DA" then
"\($f) - 1969/07/20"
elif $f == "RP" then
"\($f) - IN FILE"
else
"\($f) - \(.key)_\(.value)"
end;

to_entries
| group_by(.key | type)
| map( .[0] as $first_entry
| map(field_record)
| "\($first_entry | type_record)\n\(. | join("\n"))\nER - "
)
| join("\n\n")

0 comments on commit d40f795

Please sign in to comment.