Browse Source

now passing basic-ruby test

Eric Schulte 16 years ago
parent
commit
8f9ae7314a
2 changed files with 19 additions and 12 deletions
  1. 15 9
      lisp/langs/org-babel-ruby.el
  2. 4 3
      org-babel.org

+ 15 - 9
lisp/langs/org-babel-ruby.el

@@ -54,14 +54,11 @@ called by `org-babel-execute-src-block'."
          (results (org-babel-ruby-evaluate session full-body result-type)))
     (if (member "scalar" result-params)
         results
-      (setq results (case result-type ;; process results based on the result-type
-                      ('output (let ((tmp-file (make-temp-file "org-babel-ruby")))
-                                 (with-temp-file tmp-file (insert results))
-                                 (org-babel-import-elisp-from-file tmp-file)))
-                      ('value (org-babel-ruby-table-or-results results))))
-      (if (and (member "vector" results) (not (listp results)))
-          (list (list results))
-        results))))
+      (case result-type ;; process results based on the result-type
+        ('output (let ((tmp-file (make-temp-file "org-babel-ruby")))
+                   (with-temp-file tmp-file (insert results))
+                   (org-babel-import-elisp-from-file tmp-file)))
+        ('value (org-babel-ruby-table-or-results results))))))
 
 (defun org-babel-ruby-var-to-ruby (var)
   "Convert an elisp var into a string of ruby source code
@@ -125,11 +122,20 @@ last statement in BODY."
           (setq string-buffer (substring string-buffer (match-end 0))))
       ;; split results with `comint-prompt-regexp'
       (setq results (cdr (member org-babel-ruby-eoe-indicator
-                                 (reverse (mapcar #'org-babel-trim (split-string string-buffer comint-prompt-regexp))))))
+                                 (reverse (mapcar #'org-babel-ruby-read-string
+                                                  (mapcar #'org-babel-trim
+                                                          (split-string string-buffer comint-prompt-regexp)))))))
+      (message "near-final=%S" results)
       (case result-type
         (output (mapconcat #'identity (reverse (cdr results)) "\n"))
         (value (car results))
         (t (reverse results))))))
 
+(defun org-babel-ruby-read-string (string)
+  "Strip \\\"s from around ruby string"
+  (if (string-match "\"\\([^\000]+\\)\"" string)
+      (match-string 1 string)
+    string))
+
 (provide 'org-babel-ruby)
 ;;; org-babel-ruby.el ends here

+ 4 - 3
org-babel.org

@@ -114,7 +114,8 @@ table, allowing the test suite to be run be evaluation of the table
 and the results to be collected in the same table.
 
 
-* Tasks [22/38]
+* Tasks [22/41]
+** TODO add a function to jump to a source-block by name
 ** TODO Create objects in top level (global) environment [3/5]
 *sessions*
 
@@ -1976,8 +1977,8 @@ of these tests may fail.
 | basic evaluation        |                            |     |             |             | pass |
 |-------------------------+----------------------------+-----+-------------+-------------+------|
 | emacs lisp              | basic-elisp                |     |           5 |           5 | pass |
-| shell                   | basic-shell                |     |           6 |           6 | pass |
-| ruby                    | basic-ruby                 |     |   org-babel |   org-babel | pass |
+| shell                   | basic-shell                |     |           6 | 6           | pass |
+| ruby                    | basic-ruby                 |     |   org-babel | org-babel   | pass |
 | python                  | basic-python               |     | hello world | hello world | pass |
 | R                       | basic-R                    |     |          13 |          13 | pass |
 |-------------------------+----------------------------+-----+-------------+-------------+------|