Light TableでClojure入門
-
Upload
tokusei-noborio -
Category
Technology
-
view
4.093 -
download
5
description
Transcript of Light TableでClojure入門
Light TableでClojure入門
ニャンパス 登尾(@tnoborio)
資料: http://bit.ly/1d1lBSx
やること
Light Tableの使い方
Leiningenのセットアップ
InstaReplでREPLウェブアプリケーション
Light Tableの使い方
Workspace Commands
Workspaceの表示
● Control + SpaceでCommands● Commandsを出して、
“Toggle workspace tree”を選択→Workspaceが左ペインに表示
Clojureプラグインのアップデート
1. Commandsで、”Plugins: Show plugin manager”
2. Commandsで、”Plugins: Refresh plugin list”3. Clojureプラグインのアップデート4. 念のためLight Table再起動
Light TableでREPL
Commandsから”Instarepl: Open a clojure instarepl”
● (+ 1 2 3)● (println “Hello”)
Instareplでの標準出力
標準出力は、
Commands→“Console: Toggle console”
(iterate inc 1)
(apply +(take 100 (iterate inc 1)))
(re-find (re-pattern "^\\d{3}-\\d{4}$") "343-0825")
Leiningenのインストール
1. http://leiningen.org/からleinをダウンロードする。
2. パスの通ったディレクトリに置く3. 実行権限の付与
Leiningenのインストール
Macの場合
$ curl https://raw.github.com/technomancy/leiningen/stable/bin/lein$ mkdir ~/bin/$ mv lein ~/bin/$ chmod a+x ~/bin/lein
Leiningenのインストール
Windowsの場合
(@shinseitaroさんありがとうございます。)
lein.batをダウンロード
(もしくはInstallerもこちら)lein.batを適当んディレクトリに置く
そのディレクトリを環境変数にセット http://next.matrix.jp/config-path-win7.htmllein self-install
Leiningenでプロジェクト作成
適当なディレクトリに移動
lein new sample
Light Tableからコードを触ってみる
Commandsで、”Add connection”を選び
Clojureを選択し、project.cljを選択
接続
Commands→”Add folder”でWorkspaceにsampleディレクトリを追加
src/sample/core.cljを開く
Commands→”Instarepl: Make current editor an instarepl
接続のリスト
Commands→”Connect: Show connect bar”
“disconnect”で接続を切る
ウェブアプリケーション
テンプレートを使ったプロジェクト作成
lein new reloadable-compojure web
先程と同様に接続
Commands→”Connect: Add Connection”でproject.cljを指定
src/web/core.cljを開く
Commands→”Instarepl: Make current editor an instarepl
;; (start-server!)のコメントアウトを外す
Compojureテンプレートの場合のディレクトリ構造
● src/● src/web/core.clj● src/web/handler.clj● project.clj● test/
handler.clj(1)
(defroutes app-routes (GET "/" [] "Hello World") (route/resources "/") (route/not-found "Not Found"))
handler.clj(2)
(def app (-> app-routes handler/site (wrap-reload '(hoge.core)) (wrap-stacktrace)))