浏览代码

expanding

Eric Schulte 16 年之前
父节点
当前提交
ce1726713a
共有 1 个文件被更改,包括 19 次插入8 次删除
  1. 19 8
      lisp/langs/org-babel-ruby.el

+ 19 - 8
lisp/langs/org-babel-ruby.el

@@ -115,20 +115,31 @@ then create.  Return the initialized session."
   "When evaluated by Ruby this returns the return value of the last statement.")
 (defvar org-babel-ruby-eoe-indicator ":org_babel_ruby_eoe"
   "Used to indicate that evaluation is has completed.")
+(defun org-babel-ruby-last-value-writer (file-name)
+  "Return a ruby statement to write the last value out to
+FILE-NAME."
+  (format "File.open('w', '%s'){|f| f < _}.write" file-name))
 
 (defun org-babel-ruby-evaluate (buffer body &optional result-type)
   "Pass BODY to the Ruby process in BUFFER.  If RESULT-TYPE equals
 'output then return a list of the outputs of the statements in
 BODY, if RESULT-TYPE equals 'value then return the value of the
 last statement in BODY."
-  (let* ((full-body (mapconcat #'org-babel-chomp
-                               (list body org-babel-ruby-last-value-eval org-babel-ruby-eoe-indicator) "\n"))
-         (raw (org-babel-comint-with-output buffer org-babel-ruby-eoe-indicator t
-                (insert full-body) (comint-send-input nil t)))
-         (results 
-          (cdr (member org-babel-ruby-eoe-indicator
-                               (reverse (mapcar #'org-babel-ruby-read-string
-                                                (mapcar #'org-babel-trim raw)))))))
+  (let ((full-body (mapconcat #'org-babel-chomp
+                              (list body org-babel-ruby-last-value-eval org-babel-ruby-eoe-indicator) "\n"))
+        raw result)
+    (if (and (stringp buffer) (string= buffer "none"))
+        ;; external process evaluation
+        (let ((tmp-file (make-temp-file "ruby-functional-results")))
+          ()
+          )
+        ;; comint session evaluation
+        (setq raw (org-babel-comint-with-output buffer org-babel-ruby-eoe-indicator t
+                    (insert full-body) (comint-send-input nil t)))
+      (setq results
+            (cdr (member org-babel-ruby-eoe-indicator
+                         (reverse (mapcar #'org-babel-ruby-read-string
+                                          (mapcar #'org-babel-trim raw)))))))
     (case result-type
       (output (mapconcat #'identity (reverse (cdr results)) "\n"))
       (value (car results))