ob-crystal
enables Org-Babel support for evaluating Crystal code.
It was created based on the usage of ob-template.
"hello world"
#+BEGIN_SRC crystal :var a=3 b=4 a+b #+END_SRC
#+RESULTS: : 7
#+NAME: tel-note | name | tel | |-------+--------| | brant | 170... | | ou | 138... |
#+BEGIN_SRC crystal :var tb=tel-note :results output table puts tb #+END_SRC
#+RESULTS: | brant | 170... | | ou | 138... |
#+BEGIN_SRC crystal :var lst='(1 2 3) :results output puts lst puts num for num in lst #+END_SRC
#+RESULTS: : [ 1, 2, 3 ] : 1 : 2 : 3
#+NAME: square #+BEGIN_SRC crystal def square(x) x * x end #+END_SRC
#+NAME: calc-square #+BEGIN_SRC crystal :var x=0 :noweb strip-export :results output <<square>> puts square(x) #+END_SRC
#+CALL: calc-square(x=5)
#+RESULTS: : 25
Tests can be executed by make test or invoking emacs directly with the command-line below:
emacs -Q --batch -q \
-L . \
-l ob-crystal.el \
-l test-ob-crystal.el \
--eval "(progn \
(setq org-confirm-babel-evaluate nil) \
(org-babel-do-load-languages \
'org-babel-load-languages '((emacs-lisp . t) \
(sh . t) \
(org . t) \
(crystal . t))))" \
-f ob-crystal-test-runall