summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Dominik <carsten.dominik@gmail.com>2013-09-02 16:10:29 +0200
committerCarsten Dominik <carsten.dominik@gmail.com>2013-09-02 16:11:28 +0200
commitcb35fa9f4663409473c23a30f02a0a614f724e3f (patch)
tree38d3f1a0c1bbd68e65f5f95c1d4fec6fc78acec6
parent138f18d3ce692740cbca2a3af47ee57bbaa7c955 (diff)
downloadorg-mode-cb35fa9f4663409473c23a30f02a0a614f724e3f.tar.gz
Handle literal 'hline arguments passed to ruby
* lisp/ob-ruby.el: New customizations `org-babel-ruby-hline-to' and `org-babel-ruby-nil-to' (org-babel-ruby-var-to-ruby): Convert incoming 'hlines. (org-babel-ruby-table-or-string): Convert outgoing nils. Patch by Rick Frankel.
-rw-r--r--lisp/ob-ruby.el28
1 files changed, 26 insertions, 2 deletions
diff --git a/lisp/ob-ruby.el b/lisp/ob-ruby.el
index 20fb418..af52831 100644
--- a/lisp/ob-ruby.el
+++ b/lisp/ob-ruby.el
@@ -50,6 +50,22 @@
(defvar org-babel-ruby-command "ruby"
"Name of command to use for executing ruby code.")
+(defcustom org-babel-ruby-hline-to "nil"
+ "Replace hlines in incoming tables with this when translating to ruby."
+ :group 'org-babel
+ :version "24.4"
+ :package-version '(Org . "8.0")
+ :type 'string)
+
+(defcustom org-babel-ruby-nil-to 'hline
+ "Replace 'nil' in ruby tables with this before returning."
+ :group 'org-babel
+ :version "24.4"
+ :package-version '(Org . "8.0")
+ :type 'string)
+
+
+
(defun org-babel-execute:ruby (body params)
"Execute a block of Ruby code with Babel.
This function is called by `org-babel-execute-src-block'."
@@ -115,13 +131,21 @@ Convert an elisp value into a string of ruby source code
specifying a variable of the same value."
(if (listp var)
(concat "[" (mapconcat #'org-babel-ruby-var-to-ruby var ", ") "]")
- (format "%S" var)))
+ (if (equal var 'hline)
+ org-babel-ruby-hline-to
+ (format "%S" var))))
(defun org-babel-ruby-table-or-string (results)
"Convert RESULTS into an appropriate elisp value.
If RESULTS look like a table, then convert them into an
Emacs-lisp table, otherwise return the results as a string."
- (org-babel-script-escape results))
+ ((lambda (res)
+ (if (listp res)
+ (mapcar (lambda (el) (if (equal el 'nil)
+ org-babel-ruby-nil-to el))
+ res)
+ res))
+ (org-babel-script-escape results)))
(defun org-babel-ruby-initiate-session (&optional session params)
"Initiate a ruby session.