Browse Source

expanding

Eric Schulte 16 years ago
parent
commit
ce1726713a
1 changed files with 19 additions and 8 deletions
  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.")
   "When evaluated by Ruby this returns the return value of the last statement.")
 (defvar org-babel-ruby-eoe-indicator ":org_babel_ruby_eoe"
 (defvar org-babel-ruby-eoe-indicator ":org_babel_ruby_eoe"
   "Used to indicate that evaluation is has completed.")
   "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)
 (defun org-babel-ruby-evaluate (buffer body &optional result-type)
   "Pass BODY to the Ruby process in BUFFER.  If RESULT-TYPE equals
   "Pass BODY to the Ruby process in BUFFER.  If RESULT-TYPE equals
 'output then return a list of the outputs of the statements in
 'output then return a list of the outputs of the statements in
 BODY, if RESULT-TYPE equals 'value then return the value of the
 BODY, if RESULT-TYPE equals 'value then return the value of the
 last statement in BODY."
 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
     (case result-type
       (output (mapconcat #'identity (reverse (cdr results)) "\n"))
       (output (mapconcat #'identity (reverse (cdr results)) "\n"))
       (value (car results))
       (value (car results))