This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collection.immutable.TreeMap | |
import collection.mutable.ListBuffer | |
import reflect.Manifest | |
import util.matching.Regex | |
/* | |
Cucumber API for Scala | |
Other attempts are | |
http://gist.github.com/161702 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cuke4duke | |
/* | |
static typing to the rescue :-) | |
scala version of http://wiki.github.com/aslakhellesoy/cucumber/step-argument-transforms | |
note that this version doesn't need the 'user' hint | |
since we can provide the same hint using types in the stepdefinition | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This program is free software. It comes without any warranty, to | |
the extent permitted by applicable law. You can redistribute it | |
and/or modify it under the terms of the Do What The Fuck You Want | |
To Public License, Version 2, as published by Sam Hocevar. See | |
http://sam.zoy.org/wtfpl/COPYING for more details. | |
Uses "http://www.hilite.me/api" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//playing around with ideas from http://nilanjan-braincasting.blogspot.com/2010/01/ruby-inject-in-scala.html | |
import collection.TraversableLike | |
implicit def traversableLike2HasInject[A, Repr](t:TraversableLike[A, Repr]) = new { | |
def inject[B >: A](op:(B, A) => B):B = t.reduceLeft(op) | |
} | |
object &:+ extends ((Int, Int) => Int){ | |
override def apply(a:Int, b:Int) = a + b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// scala @ syntax in patternmatching implemented as a library | |
object `@` { | |
def unapply[A](a:A) = Some(a, a) | |
} | |
// usage | |
val Nums = """(\d),(\d)""".r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OhNoes.scala:2: error: scala.Symbol.apply("oh") of type Symbol does not take parameters | |
val bug = 'oh('noes) | |
^ | |
one error found |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* lib */ | |
trait Dynamic { | |
def _select_(name: String):Dynamic | |
def _invoke_(name: String)(args: Any*):Dynamic | |
def ~ (name: Symbol) = _select_(name.name) | |
def ~ (invocation:Invocation) = _invoke_(invocation.name)(invocation.args :_*) | |
def typed[T]:T = asInstanceOf[T] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait AkkaCometActor extends CometActor { | |
implicit val optionSelf:Option[ActorRef] = Some(Actor.actorOf(new Actor{ | |
protected def receive = { | |
case a => AkkaCometActor.this ! a | |
} | |
})) | |
override def localSetup { | |
super.localSetup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala: | |
case class Node(value:String, children:Node*) | |
def pretty(node:Node, i:String = ""):String = | |
node.children.foldLeft(i + node.value){ _ + "\n" + pretty(_:Node, i + "\t") } | |
println(pretty( | |
Node("parent", | |
Node("child1"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sbt._ | |
import Keys._ | |
import com.github.siasia.WebPlugin._ | |
lazy val web = Defaults.defaultSettings ++ webSettings ++ Seq( | |
libraryDependencies ++= Seq(jetty, lift, logback), | |
/* add a location for development only resources */ | |
jettyClasspaths <<= (jettyClasspaths, sourceDirectory).map((j, src) => j.copy(classpath = j.classpath +++ src / "development" / "resources")), | |
/* don't scan - use jrebel */ | |
jettyScanDirs := Nil, |
OlderNewer