Skip to content

Instantly share code, notes, and snippets.

@tpluscode
Last active January 24, 2025 17:15
Show Gist options
  • Save tpluscode/69e3af86056188a2b18f6643c27d601c to your computer and use it in GitHub Desktop.
Save tpluscode/69e3af86056188a2b18f6643c27d601c to your computer and use it in GitHub Desktop.
n3 rule runs twice
eye test.n3 files.n3 rules.n3
prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
prefix string: <http://www.w3.org/2000/10/swap/string#>
prefix log: <http://www.w3.org/2000/10/swap/log#>
prefix file: <http://www.w3.org/2000/10/swap/file#>
{
( ?suffix ) file:temp ?path .
} <= {
?uri log:uri ( "urn:rand:" ( 1000 )!e:random )!string:concatenation .
(
#"/tmp/"
?uri!log:uuid
?suffix
) string:concatenation ?path .
} .
{
?path file:rm ?iDoNotCare .
} <= {
( "rm " ?path )!string:concatenation!e:exec .
} .
prefix e: <http://eulersharp.sourceforge.net/2003/03swap/log-rules#>
prefix log: <http://www.w3.org/2000/10/swap/log#>
prefix string: <http://www.w3.org/2000/10/swap/string#>
PREFIX tuner: <https://api-tuner.described.at/>
prefix file: <http://www.w3.org/2000/10/swap/file#>
{
( ?method ?endpointUri ?header ?body ) tuner:response ?res .
} <= {
( ?method " " ?endpointUri )!string:concatenation^e:trace .
() file:temp ?responseBodyFile .
( ?responseBodyFile ".curl.json" ) string:concatenation ?responseHeadersFile .
( ?responseBodyFile ".n3" ) string:concatenation ?responseFile .
(
"curl -s -X " ?method " " ?endpointUri
" -H 'Content-Type:text/turtle' "
" --data-raw '" ?body!log:n3String "'"
" -w %{json} "
" -o " ?responseBodyFile
" > " ?responseHeadersFile
)!string:concatenation!e:exec .
?responseHeadersFile!file:rm .
?responseBodyFile!file:rm .
#?temp log:semanticsOrError ?res .
} .
PREFIX string: <http://www.w3.org/2000/10/swap/string#>
PREFIX log: <http://www.w3.org/2000/10/swap/log#>
PREFIX tuner: <https://api-tuner.described.at/>
prefix earl: <http://www.w3.org/ns/earl#>
PREFIX qlever: <https://qlever.described.at/>
prefix string: <http://www.w3.org/2000/10/swap/string#>
# Check OK response and
{
(
"GET" "https://example.com"
{}
{
}
) tuner:response ?res .
?res string:contains "Example" .
#?res tuner:statusCode 204 .
#?res tuner:body ?body .
} => {
[] earl:passed true
} .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment