Browse Source

fixed bug related to multi-line ruby code blocks

Eric Schulte 16 years ago
parent
commit
b8fb32c4c4
2 changed files with 14 additions and 16 deletions
  1. 3 5
      litorgy/litorgy-script.el
  2. 11 11
      rorg.org

+ 3 - 5
litorgy/litorgy-script.el

@@ -85,11 +85,9 @@ executed through litorgy."
             vars "\n")
             vars "\n")
            "\n"
            "\n"
            (let ((body-lines (split-string body "[\n\r]+" t)))
            (let ((body-lines (split-string body "[\n\r]+" t)))
-             (mapconcat
-              (lambda (line)
-                (format "\t%s\n" line))
-              (butlast body-lines) "\n")
-             (format "\treturn %s\n" (car (last body-lines)))))))
+             (concat
+              (mapconcat (lambda (line) (format "\t%s" line)) (butlast body-lines) "\n")
+              (format "\n\treturn %s\n" (car (last body-lines))))))))
         ;; (message (buffer-substring (point-min) (point-max))) ;; debug script
         ;; (message (buffer-substring (point-min) (point-max))) ;; debug script
         (shell-command-on-region (point-min) (point-max) cmd nil 'replace)
         (shell-command-on-region (point-min) (point-max) cmd nil 'replace)
         ;; (message (format "shell output = %s" (buffer-string))) ;; debug results
         ;; (message (format "shell output = %s" (buffer-string))) ;; debug results

+ 11 - 11
rorg.org

@@ -423,12 +423,17 @@ example in the [[* emacs lisp source reference][emacs lisp source reference]].
 
 
 
 
 
 
-* Bugs [8/10]
+* Bugs [9/10]
 
 
-** TODO ruby new variable creation
-Ruby doesn't seem able to handle the creation of new variables
+** TODO cursor movement when evaluating source blocks
+   E.g. the pie chart example. Despite the save-window-excursion in
+   litorgy-execute:R. (I never learned how to do this properly: org-R
+   jumps all over the place...)
+
+** DONE ruby new variable creation (multi-line ruby blocks)
+Actually it looks like we were dropping all but the last line.
 
 
-#+srcname: bug-ruby-number-evaluation
+#+srcname: multi-line-ruby-test
 #+begin_src ruby :var table=bug-numerical-table :results replace
 #+begin_src ruby :var table=bug-numerical-table :results replace
 total = 0
 total = 0
 table.each{|n| total += n}
 table.each{|n| total += n}
@@ -436,13 +441,7 @@ total/table.size
 #+end_src
 #+end_src
 
 
 #+resname:
 #+resname:
-: -:4:in `main': undefined local variable or method `total' for main:Object (NameError)
-: 	from -:7
-
-** TODO cursor movement when evaluating source blocks
-   E.g. the pie chart example. Despite the save-window-excursion in
-   litorgy-execute:R. (I never learned how to do this properly: org-R
-   jumps all over the place...)
+: 2
 
 
 ** DONE R code execution seems to choke on certain inputs
 ** DONE R code execution seems to choke on certain inputs
 Currently the R code seems to work on vertical (but not landscape)
 Currently the R code seems to work on vertical (but not landscape)
@@ -674,6 +673,7 @@ litorgy functionality.
 |-------------------------+-------------------------+-----+-------------+-------------+------|
 |-------------------------+-------------------------+-----+-------------+-------------+------|
 | simple ruby arrays      | ruby-array-test         |     |           3 |           3 | pass |
 | simple ruby arrays      | ruby-array-test         |     |           3 |           3 | pass |
 | R number evaluation     | bug-R-number-evaluation |     |           2 |           2 | pass |
 | R number evaluation     | bug-R-number-evaluation |     |           2 |           2 | pass |
+| multi-line ruby blocks  | multi-line-ruby-test    |     |           2 |           2 | pass |
 #+TBLFM: $5='(if (= (length $3) 1) (progn (message (format "running %S" '(sbe $2 (n $3)))) (sbe $2 (n $3))) (sbe $2))::$6='(if (string= $4 $5) "pass" (format "expected %S but was %S" $4 $5))
 #+TBLFM: $5='(if (= (length $3) 1) (progn (message (format "running %S" '(sbe $2 (n $3)))) (sbe $2 (n $3))) (sbe $2))::$6='(if (string= $4 $5) "pass" (format "expected %S but was %S" $4 $5))
 
 
 ** basic tests
 ** basic tests