Org-Babel support for evaluating crystal code.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
Makefile
README.org
ob-crystal.el
test-ob-crystal.el
test-ob-crystal.org

README.org

ob-crystal

https://travis-ci.org/brantou/ob-crystal.svg?branch=masterhttps://melpa.org/packages/ob-crystal-badge.svg

Introduction

ob-crystal enables Org-Babel support for evaluating Crystal code. It was created based on the usage of ob-template.

"hello world"

Examples

variables

#+BEGIN_SRC crystal :var a=3 b=4
  a+b
#+END_SRC
#+RESULTS:
: 7

table and list

#+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

literate programming

#+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

Running tests

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