options.scm
| 1 | ;;;; Copyright (C) 2019, 2020 Julien Lepiller <julien@lepiller.eu> |
| 2 | ;;;; |
| 3 | ;;;; This library is free software; you can redistribute it and/or |
| 4 | ;;;; modify it under the terms of the GNU Lesser General Public |
| 5 | ;;;; License as published by the Free Software Foundation; either |
| 6 | ;;;; version 3 of the License, or (at your option) any later version. |
| 7 | ;;;; |
| 8 | ;;;; This library is distributed in the hope that it will be useful, |
| 9 | ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 | ;;;; Lesser General Public License for more details. |
| 12 | ;;;; |
| 13 | ;;;; You should have received a copy of the GNU Lesser General Public |
| 14 | ;;;; License along with this library; if not, write to the Free Software |
| 15 | ;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 16 | ;;;; |
| 17 | |
| 18 | (define-module (jsonld options) |
| 19 | #:use-module (json) |
| 20 | #:use-module (jsonld download) |
| 21 | #:use-module (jsonld iri) |
| 22 | #:use-module (jsonld memoization) |
| 23 | #:use-module (web client) |
| 24 | #:use-module (web response) |
| 25 | #:use-module (web uri) |
| 26 | #:use-module (rnrs bytevectors) |
| 27 | #:use-module (ice-9 match) |
| 28 | #:use-module (srfi srfi-1) |
| 29 | #:use-module (srfi srfi-9) |
| 30 | #:export (jsonld-options? |
| 31 | jsonld-options-base |
| 32 | jsonld-options-compact-arrays? |
| 33 | jsonld-options-compact-to-relative? |
| 34 | jsonld-options-document-loader |
| 35 | jsonld-options-expand-context |
| 36 | jsonld-options-extract-all-scripts? |
| 37 | jsonld-options-frame-expansion? |
| 38 | jsonld-options-ordered? |
| 39 | jsonld-options-processing-mode |
| 40 | jsonld-options-produce-generalized-rdf? |
| 41 | jsonld-options-rdf-direction |
| 42 | jsonld-options-use-native-types? |
| 43 | jsonld-options-use-rdf-type? |
| 44 | new-jsonld-options |
| 45 | update-jsonld-options)) |
| 46 | |
| 47 | (define-record-type jsonld-options |
| 48 | (make-jsonld-options |
| 49 | base compact-arrays? compact-to-relative? document-loader expand-context |
| 50 | extract-all-scripts? frame-expansion? ordered? processing-mode |
| 51 | produce-generalized-rdf? rdf-direction use-native-types? use-rdf-type?) |
| 52 | jsonld-options? |
| 53 | (base jsonld-options-base) |
| 54 | (compact-arrays? jsonld-options-compact-arrays?) |
| 55 | (compact-to-relative? jsonld-options-compact-to-relative?) |
| 56 | (document-loader jsonld-options-document-loader) |
| 57 | (expand-context jsonld-options-expand-context) |
| 58 | (extract-all-scripts? jsonld-options-extract-all-scripts?) |
| 59 | (frame-expansion? jsonld-options-frame-expansion?) |
| 60 | (ordered? jsonld-options-ordered?) |
| 61 | (processing-mode jsonld-options-processing-mode) |
| 62 | (produce-generalized-rdf? jsonld-options-produce-generalized-rdf?) |
| 63 | (rdf-direction jsonld-options-rdf-direction) |
| 64 | (use-native-types? jsonld-options-use-native-types?) |
| 65 | (use-rdf-type? jsonld-options-use-rdf-type?)) |
| 66 | |
| 67 | (define* (new-jsonld-options #:key |
| 68 | (base #f) |
| 69 | (compact-arrays? #t) |
| 70 | (compact-to-relative? #t) |
| 71 | (document-loader (memoize download-json)) |
| 72 | (expand-context #f) |
| 73 | (extract-all-scripts? #f) |
| 74 | (frame-expansion? #f) |
| 75 | (ordered? #f) |
| 76 | (processing-mode "jsonld-1.1") |
| 77 | (produce-generalized-rdf? #t) |
| 78 | (rdf-direction #f) |
| 79 | (use-native-types? #f) |
| 80 | (use-rdf-type? #f)) |
| 81 | (make-jsonld-options |
| 82 | base compact-arrays? compact-to-relative? document-loader expand-context |
| 83 | extract-all-scripts? frame-expansion? ordered? processing-mode |
| 84 | produce-generalized-rdf? rdf-direction use-native-types? use-rdf-type?)) |
| 85 | |
| 86 | (define* (update-jsonld-options options #:key |
| 87 | (base (jsonld-options-base options)) |
| 88 | (compact-arrays? (jsonld-options-compact-arrays? options)) |
| 89 | (compact-to-relative? (jsonld-options-compact-to-relative? options)) |
| 90 | (document-loader (jsonld-options-document-loader options)) |
| 91 | (expand-context (jsonld-options-expand-context options)) |
| 92 | (extract-all-scripts? (jsonld-options-extract-all-scripts? options)) |
| 93 | (frame-expansion? (jsonld-options-frame-expansion? options)) |
| 94 | (ordered? (jsonld-options-ordered? options)) |
| 95 | (processing-mode (jsonld-options-processing-mode options)) |
| 96 | (produce-generalized-rdf? (jsonld-options-produce-generalized-rdf? options)) |
| 97 | (rdf-direction (jsonld-options-rdf-direction options)) |
| 98 | (use-native-types? (jsonld-options-use-native-types? options)) |
| 99 | (use-rdf-type? (jsonld-options-use-rdf-type? options))) |
| 100 | (make-jsonld-options |
| 101 | base compact-arrays? compact-to-relative? document-loader expand-context |
| 102 | extract-all-scripts? frame-expansion? ordered? processing-mode |
| 103 | produce-generalized-rdf? rdf-direction use-native-types? use-rdf-type?)) |
| 104 |