Skip to content

Commit

Permalink
Merge pull request #122 from opencultureconsulting/121-transform-grel…
Browse files Browse the repository at this point in the history
…-expression-containing-fails

fix bug that occurs when GREL contains brackets
  • Loading branch information
felixlohmeier authored Dec 6, 2023
2 parents 779a6e6 + 0a5b777 commit bd73277
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 6 deletions.
2 changes: 1 addition & 1 deletion help/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# orcli 0.2.1
# orcli 0.2.2

## command help screens

Expand Down
6 changes: 3 additions & 3 deletions orcli
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# This script was generated by bashly 1.1.2 (https://bashly.dannyb.co)
# This script was generated by bashly 1.1.3 (https://bashly.dannyb.co)
# Modifying it manually is not recommended

# :wrapper.bash3_bouncer
Expand Down Expand Up @@ -2264,7 +2264,7 @@ orcli_transform_command() {
array[expression]="${array[expression]//$'\n'/}"
# prepare curl options
mapfile -t curloptions < <(for K in "${!array[@]}"; do
echo "--data"
echo "--data-urlencode"
echo "$K=${array[$K]}"
done)
# get csrf token and post data to it's individual endpoint
Expand Down Expand Up @@ -4750,7 +4750,7 @@ orcli_run_parse_requirements() {

# :command.initialize
initialize() {
version="0.2.1"
version="0.2.2"
long_usage=''
set -e

Expand Down
2 changes: 1 addition & 1 deletion src/bashly.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: orcli
help: OpenRefine command-line interface written in Bash
version: 0.2.1
version: 0.2.2
footer: https://github.com/opencultureconsulting/orcli

dependencies:
Expand Down
2 changes: 1 addition & 1 deletion src/transform_command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ for i in "${!files[@]}"; do
array[expression]="${array[expression]//$'\n'/}"
# prepare curl options
mapfile -t curloptions < <(for K in "${!array[@]}"; do
echo "--data"
echo "--data-urlencode"
echo "$K=${array[$K]}"
done)
# get csrf token and post data to it's individual endpoint
Expand Down
48 changes: 48 additions & 0 deletions tests/transform-bracket.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

t="transform-bracket"

# create tmp directory
tmpdir="$(mktemp -d)"
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15

# assertion
cat << "DATA" > "${tmpdir}/${t}.assert"
email name test state gender purchase
[email protected] Danny Baron (Danny Baron) CA M TV
[email protected] Melanie White (Melanie White) NC F iPhone
[email protected] D. Baron (D. Baron) CA M Winter jacket
[email protected] Ben Tyler (Ben Tyler) NV M Flashlight
[email protected] Arthur Duff (Arthur Duff) OR M Dining table
[email protected] Daniel Baron (Daniel Baron) CA M Bike
[email protected] Jean Griffith (Jean Griffith) WA F Power drill
[email protected] Melanie White (Melanie White) NC F iPad
[email protected] Ben Morisson (Ben Morisson) FL M Amplifier
[email protected] Arthur Duff (Arthur Duff) OR M Night table
DATA

# transform
cat << "DATA" > "${tmpdir}/${t}.history"
[
{
"op": "core/column-addition",
"engineConfig": {
"facets": [],
"mode": "row-based"
},
"baseColumnName": "name",
"expression": "grel:forNonBlank(value, x, '(' + x + ')', null)",
"newColumnName": "test",
"columnInsertIndex": 2
}
]
DATA

# action
cd "${tmpdir}" || exit 1
orcli import csv "https://git.io/fj5hF" --projectName "duplicates"
orcli transform "duplicates" "${t}.history"
orcli export tsv "duplicates" --output "${t}.output"

# test
diff -u "${t}.assert" "${t}.output"

0 comments on commit bd73277

Please sign in to comment.