]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
update ob-restclient
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Sat, 25 Nov 2023 10:43:15 +0000 (11:43 +0100)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Sun, 26 Nov 2023 15:46:00 +0000 (16:46 +0100)
Signed-off-by: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
elpa/ob-restclient-20200316.759/ob-restclient-autoloads.el [deleted file]
elpa/ob-restclient-20200316.759/ob-restclient-pkg.el [deleted file]
elpa/ob-restclient-20200316.759/ob-restclient.el [deleted file]
elpa/ob-restclient-20230301.1951/ob-restclient-autoloads.el [new file with mode: 0644]
elpa/ob-restclient-20230301.1951/ob-restclient-pkg.el [new file with mode: 0644]
elpa/ob-restclient-20230301.1951/ob-restclient.el [new file with mode: 0644]

diff --git a/elpa/ob-restclient-20200316.759/ob-restclient-autoloads.el b/elpa/ob-restclient-20200316.759/ob-restclient-autoloads.el
deleted file mode 100644 (file)
index 747e57d..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-;;; ob-restclient-autoloads.el --- automatically extracted autoloads
-;;
-;;; Code:
-
-(add-to-list 'load-path (directory-file-name
-                         (or (file-name-directory #$) (car load-path))))
-
-\f
-;;;### (autoloads nil "ob-restclient" "ob-restclient.el" (0 0 0 0))
-;;; Generated autoloads from ob-restclient.el
-
-(autoload 'org-babel-execute:restclient "ob-restclient" "\
-Execute a block of Restclient code with org-babel.
-This function is called by `org-babel-execute-src-block'
-
-\(fn BODY PARAMS)" nil nil)
-
-(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "ob-restclient" '("org-babel-")))
-
-;;;***
-\f
-;; Local Variables:
-;; version-control: never
-;; no-byte-compile: t
-;; no-update-autoloads: t
-;; coding: utf-8
-;; End:
-;;; ob-restclient-autoloads.el ends here
diff --git a/elpa/ob-restclient-20200316.759/ob-restclient-pkg.el b/elpa/ob-restclient-20200316.759/ob-restclient-pkg.el
deleted file mode 100644 (file)
index 2270e2f..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-;;; Generated package description from /Users/andreas/.emacs.d/elpa/ob-restclient-20200316.759/ob-restclient.el  -*- no-byte-compile: t -*-
-(define-package "ob-restclient" "20200316.759" "org-babel functions for restclient-mode" '((restclient "0")) :commit "0ebfc7c5ebf96d2fe1a476439831363a5a43b9b6" :authors '(("Alf Lervåg")) :maintainer '("Alf Lervåg") :keywords '("literate programming" "reproducible research") :url "https://github.com/alf/ob-restclient.el")
diff --git a/elpa/ob-restclient-20200316.759/ob-restclient.el b/elpa/ob-restclient-20200316.759/ob-restclient.el
deleted file mode 100644 (file)
index 9e3af3c..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-;;; ob-restclient.el --- org-babel functions for restclient-mode
-
-;; Copyright (C) Alf Lervåg
-
-;; Author: Alf Lervåg
-;; Keywords: literate programming, reproducible research
-;; Package-Version: 20200316.759
-;; Package-Commit: 0ebfc7c5ebf96d2fe1a476439831363a5a43b9b6
-;; Homepage: https://github.com/alf/ob-restclient.el
-;; Version: 0.02
-;; Package-Requires: ((restclient "0"))
-
-;;; License:
-
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-;;
-;; This program is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-;;
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to the
-;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
-
-;;; Commentary:
-;; This is a very simple first iteration at integrating restclient.el
-;; and org-mode.
-
-;;; Requirements:
-;; restclient.el
-
-;;; Code:
-(require 'ob)
-(require 'ob-ref)
-(require 'ob-comint)
-(require 'ob-eval)
-(require 'restclient)
-
-(defvar org-babel-default-header-args:restclient
-  `((:results . "raw"))
-  "Default arguments for evaluating a restclient block.")
-
-;;;###autoload
-(defun org-babel-execute:restclient (body params)
-  "Execute a block of Restclient code with org-babel.
-This function is called by `org-babel-execute-src-block'"
-  (message "executing Restclient source code block")
-  (with-temp-buffer
-    (let ((results-buffer (current-buffer))
-          (restclient-same-buffer-response t)
-          (restclient-same-buffer-response-name (buffer-name))
-          (display-buffer-alist
-           (cons
-            '("\\*temp\\*" display-buffer-no-window (allow-no-window . t))
-            display-buffer-alist)))
-
-      (insert (buffer-name))
-      (with-temp-buffer
-        (dolist (p params)
-          (let ((key (car p))
-                (value (cdr p)))
-            (when (eql key :var)
-              (insert (format ":%s = <<\n%s\n#\n" (car value) (cdr value))))))
-        (insert body)
-       (goto-char (point-min))
-       (delete-trailing-whitespace)
-       (goto-char (point-min))
-      (restclient-http-parse-current-and-do
-       'restclient-http-do (org-babel-restclient-raw-payload-p params) t))
-
-      (while restclient-within-call
-        (sleep-for 0.05))
-
-      (goto-char (point-min))
-      (when (search-forward (buffer-name) nil t)
-        (error "Restclient encountered an error"))
-
-      (if (org-babel-restclient-return-pure-payload-result-p params)
-          (org-babel-restclient-pure-payload-result)
-        (org-babel-restclient-wrap-result)))))
-
-(defun org-babel-restclient-wrap-result ()
-  "Wrap the contents of the buffer in an `org-mode' src block."
-  (let ((mode-name (substring (symbol-name major-mode) 0 -5)))
-    (insert (format "#+BEGIN_SRC %s\n" mode-name))
-    (goto-char (point-max))
-    (insert "#+END_SRC\n")
-    (buffer-string)))
-
-(defun org-babel-restclient-pure-payload-result ()
-  "Just return the payload."
-  (let ((comments-start
-         (save-excursion
-           (goto-char (point-max))
-           (while (comment-only-p (line-beginning-position) (line-end-position))
-             (forward-line -1))
-           ;; Include the last line as well
-           (forward-line)
-           (point))))
-    (buffer-substring (point-min) comments-start)))
-
-
-(defun org-babel-restclient-return-pure-payload-result-p (params)
-  "Return `t' if the `:results' key in PARAMS contains `value' or `table'."
-  (let ((result-type (cdr (assoc :results params))))
-    (when result-type
-      (string-match "value\\|table" result-type))))
-
-(defun org-babel-restclient-raw-payload-p (params)
-  "Return t if the `:results' key in PARAMS contain `file'."
-  (let ((result-type (cdr (assoc :results params))))
-    (when result-type
-      (string-match "file" result-type))))
-
-(provide 'ob-restclient)
-;;; ob-restclient.el ends here
diff --git a/elpa/ob-restclient-20230301.1951/ob-restclient-autoloads.el b/elpa/ob-restclient-20230301.1951/ob-restclient-autoloads.el
new file mode 100644 (file)
index 0000000..4c1aadc
--- /dev/null
@@ -0,0 +1,37 @@
+;;; ob-restclient-autoloads.el --- automatically extracted autoloads  -*- lexical-binding: t -*-
+;;
+;;; Code:
+
+(add-to-list 'load-path (directory-file-name
+                         (or (file-name-directory #$) (car load-path))))
+
+\f
+;;;### (autoloads nil "ob-restclient" "ob-restclient.el" (0 0 0 0))
+;;; Generated autoloads from ob-restclient.el
+
+(autoload 'org-babel-execute:restclient "ob-restclient" "\
+Execute a block of Restclient code with org-babel.
+This function is called by `org-babel-execute-src-block'
+
+\(fn BODY PARAMS)" nil nil)
+
+(autoload 'org-babel-variable-assignments:restclient "ob-restclient" "\
+Return a list of restclient statements assigning the block's variables specified in PARAMS.
+
+\(fn PARAMS)" nil nil)
+
+(register-definition-prefixes "ob-restclient" '("org-babel-"))
+
+;;;***
+\f
+;;;### (autoloads nil nil ("ob-restclient-pkg.el") (0 0 0 0))
+
+;;;***
+\f
+;; Local Variables:
+;; version-control: never
+;; no-byte-compile: t
+;; no-update-autoloads: t
+;; coding: utf-8
+;; End:
+;;; ob-restclient-autoloads.el ends here
diff --git a/elpa/ob-restclient-20230301.1951/ob-restclient-pkg.el b/elpa/ob-restclient-20230301.1951/ob-restclient-pkg.el
new file mode 100644 (file)
index 0000000..3cd4597
--- /dev/null
@@ -0,0 +1,14 @@
+(define-package "ob-restclient" "20230301.1951" "org-babel functions for restclient-mode"
+  '((restclient "0"))
+  :commit "ded3b7eb7b0592328a7a08ecce6f25278cba4a1d" :authors
+  '(("Alf Lervåg"))
+  :maintainers
+  '(("Alf Lervåg"))
+  :maintainer
+  '("Alf Lervåg")
+  :keywords
+  '("literate programming" "reproducible research")
+  :url "https://github.com/alf/ob-restclient.el")
+;; Local Variables:
+;; no-byte-compile: t
+;; End:
diff --git a/elpa/ob-restclient-20230301.1951/ob-restclient.el b/elpa/ob-restclient-20230301.1951/ob-restclient.el
new file mode 100644 (file)
index 0000000..ff5cf6b
--- /dev/null
@@ -0,0 +1,145 @@
+;;; ob-restclient.el --- org-babel functions for restclient-mode
+
+;; Copyright (C) Alf Lervåg
+
+;; Author: Alf Lervåg
+;; Keywords: literate programming, reproducible research
+;; Homepage: https://github.com/alf/ob-restclient.el
+;; Version: 0.02
+;; Package-Requires: ((restclient "0"))
+
+;;; License:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+;; This is a very simple first iteration at integrating restclient.el
+;; and org-mode.
+
+;;; Requirements:
+;; restclient.el
+
+;;; Code:
+(require 'ob)
+(require 'ob-ref)
+(require 'ob-comint)
+(require 'ob-eval)
+(require 'restclient)
+
+(defvar org-babel-default-header-args:restclient
+  `((:results . "raw"))
+  "Default arguments for evaluating a restclient block.")
+
+(defcustom org-babel-restclient--jq-path "jq"
+  "The path to `jq', for post-processing. Uses the PATH by default")
+
+;;;###autoload
+(defun org-babel-execute:restclient (body params)
+  "Execute a block of Restclient code with org-babel.
+This function is called by `org-babel-execute-src-block'"
+  (message "executing Restclient source code block")
+  (with-temp-buffer
+    (let ((results-buffer (current-buffer))
+          (restclient-same-buffer-response t)
+          (restclient-response-body-only (org-babel-restclient--should-hide-headers-p params))
+          (restclient-same-buffer-response-name (buffer-name))
+          (display-buffer-alist
+           (cons
+            '("\\*temp\\*" display-buffer-no-window (allow-no-window . t))
+            display-buffer-alist)))
+
+      (insert (buffer-name))
+      (with-temp-buffer
+        (dolist (p params)
+          (let ((key (car p))
+                (value (cdr p)))
+            (when (eql key :var)
+              (insert (format ":%s = <<\n%s\n#\n" (car value) (cdr value))))))
+        (insert body)
+        (goto-char (point-min))
+        (delete-trailing-whitespace)
+        (goto-char (point-min))
+        (restclient-http-parse-current-and-do
+         'restclient-http-do (org-babel-restclient--raw-payload-p params) t))
+
+      (while restclient-within-call
+        (sleep-for 0.05))
+
+      (goto-char (point-min))
+      (when (equal (buffer-name) (buffer-string))
+        (error "Restclient encountered an error"))
+
+      (when-let* ((jq-header (assoc :jq params))
+                  (jq-path "jq")
+                 (jq-args (or (cdr (assoc :jq-args params)) "")))
+        (shell-command-on-region
+         (point-min)
+         (point-max)
+         (format "%s %s--args %s" org-babel-restclient--jq-path
+                (if (assq :jq-args params) (format "%s " jq-args) "")
+                 (shell-quote-argument (cdr jq-header)))
+         (current-buffer)
+         t))
+
+       ;; widen if jq but not pure payload
+      (when (and (assq :jq params)
+                 (not (assq :noheaders params))
+                 (not (org-babel-restclient--return-pure-payload-result-p params)))
+        (widen))
+
+      (when (not (org-babel-restclient--return-pure-payload-result-p params))
+        (org-babel-restclient--wrap-result))
+
+      (buffer-string))))
+
+;;;###autoload
+(defun org-babel-variable-assignments:restclient (params)
+  "Return a list of restclient statements assigning the block's variables specified in PARAMS."
+  (mapcar
+   (lambda (pair)
+     (let ((name (car pair))
+           (value (cdr pair)))
+       (format ":%s = %s" name value)))
+   (org-babel--get-vars params)))
+
+(defun org-babel-restclient--wrap-result ()
+  "Wrap the contents of the buffer in an `org-mode' src block."
+  (let ((mode-name (substring (symbol-name major-mode) 0 -5)))
+    (insert (format "#+BEGIN_SRC %s\n" mode-name))
+    (goto-char (point-max))
+    (insert "#+END_SRC\n")))
+
+(defun org-babel-restclient--should-hide-headers-p (params)
+  "Return `t' if headers should be hidden."
+  (or (org-babel-restclient--return-pure-payload-result-p params)
+                (assq :noheaders params)
+                (assq :jq params)))
+
+(defun org-babel-restclient--return-pure-payload-result-p (params)
+  "Return `t' if the `:results' key in PARAMS contains `value' or `table'."
+  (let ((result-type (cdr (assoc :results params))))
+    (when result-type
+      (string-match "value\\|table" result-type))))
+
+
+(defun org-babel-restclient--raw-payload-p (params)
+  "Return t if the `:results' key in PARAMS contain `file'."
+  (let ((result-type (cdr (assoc :results params))))
+    (when result-type
+      (string-match "file" result-type))))
+
+(provide 'ob-restclient)
+;;; ob-restclient.el ends here