Browse Source

org-babel: adding ruby support for returning "code" results

Eric Schulte 15 years ago
parent
commit
770305a650
1 changed files with 9 additions and 3 deletions
  1. 9 3
      contrib/babel/lisp/langs/org-babel-ruby.el

+ 9 - 3
contrib/babel/lisp/langs/org-babel-ruby.el

@@ -145,8 +145,11 @@ last statement in BODY, as elisp."
                (insert (format org-babel-ruby-wrapper-method body tmp-file))
                ;; (message "buffer=%s" (buffer-string)) ;; debugging
                (shell-command-on-region (point-min) (point-max) "ruby"))
-             (org-babel-ruby-table-or-string
-	      (with-temp-buffer (insert-file-contents tmp-file) (buffer-string)))))))
+             (let ((raw (with-temp-buffer (insert-file-contents tmp-file)
+                                          (buffer-string))))
+               (if (member "code" result-params)
+                   raw
+                 (org-babel-ruby-table-or-string raw)))))))
     ;; comint session evaluation
     (let* ((full-body
 	    (mapconcat
@@ -159,7 +162,10 @@ last statement in BODY, as elisp."
                                                   (mapcar #'org-babel-trim raw)))))))
       (case result-type
         (output (mapconcat #'identity (reverse (cdr results)) "\n"))
-        (value (org-babel-ruby-table-or-string (car results)))))))
+        (value
+         (if (member "code" result-params)
+             (car results)
+           (org-babel-ruby-table-or-string (car results))))))))
 
 (defun org-babel-ruby-read-string (string)
   "Strip \\\"s from around ruby string"