Skip to content

Commit bd73277

Browse files
Merge pull request #122 from opencultureconsulting/121-transform-grel-expression-containing-fails
fix bug that occurs when GREL contains brackets
2 parents 779a6e6 + 0a5b777 commit bd73277

File tree

5 files changed

+54
-6
lines changed

5 files changed

+54
-6
lines changed

help/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# orcli 0.2.1
1+
# orcli 0.2.2
22

33
## command help screens
44

orcli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# This script was generated by bashly 1.1.2 (https://bashly.dannyb.co)
2+
# This script was generated by bashly 1.1.3 (https://bashly.dannyb.co)
33
# Modifying it manually is not recommended
44

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

47514751
# :command.initialize
47524752
initialize() {
4753-
version="0.2.1"
4753+
version="0.2.2"
47544754
long_usage=''
47554755
set -e
47564756

src/bashly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: orcli
22
help: OpenRefine command-line interface written in Bash
3-
version: 0.2.1
3+
version: 0.2.2
44
footer: https://github.com/opencultureconsulting/orcli
55

66
dependencies:

src/transform_command.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ for i in "${!files[@]}"; do
8888
array[expression]="${array[expression]//$'\n'/}"
8989
# prepare curl options
9090
mapfile -t curloptions < <(for K in "${!array[@]}"; do
91-
echo "--data"
91+
echo "--data-urlencode"
9292
echo "$K=${array[$K]}"
9393
done)
9494
# get csrf token and post data to it's individual endpoint

tests/transform-bracket.sh

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
t="transform-bracket"
4+
5+
# create tmp directory
6+
tmpdir="$(mktemp -d)"
7+
trap '{ rm -rf "${tmpdir}"; }' 0 2 3 15
8+
9+
# assertion
10+
cat << "DATA" > "${tmpdir}/${t}.assert"
11+
email name test state gender purchase
12+
danny.baron@example1.com Danny Baron (Danny Baron) CA M TV
13+
melanie.white@example2.edu Melanie White (Melanie White) NC F iPhone
14+
danny.baron@example1.com D. Baron (D. Baron) CA M Winter jacket
15+
ben.tyler@example3.org Ben Tyler (Ben Tyler) NV M Flashlight
16+
arthur.duff@example4.com Arthur Duff (Arthur Duff) OR M Dining table
17+
danny.baron@example1.com Daniel Baron (Daniel Baron) CA M Bike
18+
jean.griffith@example5.org Jean Griffith (Jean Griffith) WA F Power drill
19+
melanie.white@example2.edu Melanie White (Melanie White) NC F iPad
20+
ben.morisson@example6.org Ben Morisson (Ben Morisson) FL M Amplifier
21+
arthur.duff@example4.com Arthur Duff (Arthur Duff) OR M Night table
22+
DATA
23+
24+
# transform
25+
cat << "DATA" > "${tmpdir}/${t}.history"
26+
[
27+
{
28+
"op": "core/column-addition",
29+
"engineConfig": {
30+
"facets": [],
31+
"mode": "row-based"
32+
},
33+
"baseColumnName": "name",
34+
"expression": "grel:forNonBlank(value, x, '(' + x + ')', null)",
35+
"newColumnName": "test",
36+
"columnInsertIndex": 2
37+
}
38+
]
39+
DATA
40+
41+
# action
42+
cd "${tmpdir}" || exit 1
43+
orcli import csv "https://git.io/fj5hF" --projectName "duplicates"
44+
orcli transform "duplicates" "${t}.history"
45+
orcli export tsv "duplicates" --output "${t}.output"
46+
47+
# test
48+
diff -u "${t}.assert" "${t}.output"

0 commit comments

Comments
 (0)