BOO的例子 7

基于boo这个语言实现的几个dsl例子,可以作为我们学习的参考 

Brail

Castle Project

http://www.castleproject.org/monorail/documentation/trunk/viewengines/brail/index.html.

It’s a text templating language, built by me, in which in you can mix code and text freely. Here’s a sample:

<h1>My name is ${name}</h1>

<ul>

<% for element in list: %>

<li>${element}</li>

<% end %>

</ul>

Rhino ETL

Rhino ETL employs the concept of steps, with data flowing from one step to the next.

Usually the first step will extract the data from some source, and the last will load it to

the final destination.

Here’s an example of a full ETL process:

operationsplit_name:

for row in rows:

continue if row.Name is null

row.FirstName, row.LastName = row.Name.Split()

yield row

processUsersToPeople:

input "source_db", Command = "SELECT id, name, email FROM Users"

split_names()

output "destination_db", Command = """

INSERT INTO People (UserId, FirstName, LastName, Email)

VALUES (@UserId, @FirstName, @LastName, @Email)

""":

row.UserId = row.Id

This code gets the users list from the source database, splits the names, and then saves

them to the destination database. This is a good example of a DSL that requires some

knowledge of the domain before you can utilize it.

http://www.ayende.com/Blog/category/545.aspx

Bake (Boo Build System)

Task "init build dir":

if not Directory.Exists("build"):

MkDir "build"

CpFileSet("lib/*.dll").Files, "build", true

http://code.google.com/p/boo-build-system/

Specter

Specter is a behavior-driven development (BDD) testing framework

context "Empty stack":

stack as Stack

setup:

stack = Stack()

specifystack.Count.Must == 0

specify "Stack must accept an item and count is then one":

stack.Push(42)

stack.Count.Must == 1

http://behaviour-driven.org/

http://specter.sourceforge.net/

posted @   2012  阅读(626)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
历史上的今天:
2011-10-12 .net下作业调度实战[quartz]
2010-10-12 jQuery使用总结 - jQuery组成和主要功能 1/4
点击右上角即可分享
微信分享提示