• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

functional-koans/clojure-koan-engine

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

functional-koans/clojure-koan-engine

开源软件地址:

https://github.com/functional-koans/clojure-koan-engine

开源编程语言:

Clojure 51.2%

开源软件介绍:

Koan Engine

Clojure-Koan-Engine is the library behind clojure-koans. It exposes the meditations macro and makes it possible to write koans of this form for any Clojure project:

(meditations
  "We shall contemplate truth by testing reality, via equality."
  (= __ true)

  "To understand reality, we must compare our expectations against reality."
  (= __ (+ 1 1)))

The student' job is to fill in the blanks in such a way that the code form throws no exceptions and returns a truthy value.

Writing your own koans

Koans are a wonderful way to teach users by example. If you maintain or use a library in Clojure, consider putting together a custom Koan project!

The easiest way to start writing koans for your library is to generate a new project with the koan-template leiningen plugin (source code on github. Make sure you have Leiningen installed. Add the plugin to your Leiningen '~/.lein/profiles.clj' file.

{:user {:plugins [
  [koan/lein-template "0.1.3"]
]}}

Use these commands to great a new project based on the koan template.

lein new koan <your-project-name>
cd <your-project-name>
chmod +x script/*

The README of the resulting project will contain everything your users need to know to get started.

Adding koan-engine to an existing project

You can also add koans to an existing library without interfering with your source tree. This is a wonderful way to introduce users to your source code.

To get started, add the lein-koan plugin (source code on github ) to your :dev-dependencies in project.clj:

[lein-koan "0.1.2"]

The plugin makes two tasks available:

lein koan run watches koan files for changes and presents the user with the most advanced unsolved koan. lein koan test checks that all koans fail without answers and pass with answers.

Customizations

The koan engine looks for koans under src/koans by default, but you can customize this by adding a :koan entry to project.clj. All options are shown here along with defaults:

:koan {:koan-root "src/koans"      ;; koan files live at this root
       :dojo-resource "dojo.clj"   ;; The forms in resources/dojo.clj are evaluted before every koan.
       :koan-resource "koans.clj"} ;; answers located at resources/koans.clj

For more information on the Dojo see the wiki page. "How to write Koans" provides more information on how to add your own koans and answers.

License

The use and distribution terms for this software are covered by the Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php) which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap