Excuse
Elixirという勢いのある言語の情報ということで、この記事は大変古く、基本的に歴史的経緯の確認以上の役には立たないと思います。
そもそもElixirってなに
Elixir is a functional meta-programming aware language built on top of the Erlang VM.
-
1st class なマクロ
-
protocols による多態のサポート
-
Pattern matching
-
最終的に Erlang の VM を生成する / Erlang、OTPとの連携性
-
日本語の情報
Heroku toolbelt 入れる
Setup Erlang, rebar, & Elixir
- Homebrew でとりあえず入れてよし
brew install erlang
brew install elixir
brew install --HEAD rebar
erl
# => Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:8:8] [async-threads:0] [hipe] [kernel-poll:false] [dtrace]
rebar --version
# => rebar 2.0.0 R15B02 20121101_110141 No VCS info available.
elixir -v
# => Elixir 0.7.0
mix help
ウェブアプリケーションフレームワーク、 Dynamo を入れる
git clone https://github.com/dynamo/dynamo
cd dynamo
mix deps.get
mix install
プロジェクトを作成する
mix dynamo ../shinjuku_ex
First run!
mix deps.get
mix server
# Generated shinjuku_ex.app
# Running ShinjukuEx at localhost:4000 with Cowboy on dev
- 言われた通り
app/views/index.html.eex
を編集するとライブで反映される。
deploy to heroku
- https://github.com/goshakkk/heroku-buildpack-elixir
- README 現状とやや違うんですけどね……
heroku apps:create shinjuku-ex-official \
--buildpack "https://github.com/goshakkk/heroku-buildpack-elixir.git"
# Create Procfile
# web: mix server -p=$PORT
# specify versions
echo OTP_R15B02 > .preferred_otp_version
echo v0.7.0 > .preferred_elixir_version
git add . && git commit
# Explicitly add web process
heroku ps:scale web=1
git push heroku master
- Let's visit http://shinjuku-ex-official.herokuapp.com/
あとは
- CMS を Dynamo で作るだけですね(......)
- どっかのフォルダにおいた markdown ファイルを勝手に解釈してくれるようなやつがいいッス
- Markdown: pure erlang らしい https://github.com/erlware/erlmarkdown
- exdoc での利用例?: https://github.com/elixir-lang/exdoc/pull/23
- ドメイン取らなきゃですな
static 対応について
- https://github.com/dynamo/dynamo/pull/10
- このパッチを参考にできると思う。そもそもまだstatic fileないけど、いずれ。