Iain Hull

A Simple REST DSL Part 2

Using a builder to construct a DSL.

In part 1, I showed the builder pattern can improve code readability and composibility of REST requests. Now, let’s discover how the builder can be used as the basis for a simple DSL. First you need to decide what words or phrases to use to bootstrap the request DSL. Do this by describing some sample requests in simple English and looking for patterns, for example: Get from url http://api.rest.org/person/ Post personJson to url http://api.

A Simple REST DSL Part 1

Creating a DSL for testing REST based Web services.

I spend a lot of time working on REST based Web services. Writing system tests for these can lead to a lot of boiler-plate code which is tedious to read and write and obscures the intention of the tests. When it comes to removing boiler plate, Scala is your friend, so lets see what you can do to improve your tests. I want to explore internal Domain Specific Languages (DSLs), an area that Scala excels at, but first I want to look at the Builder pattern.

Centos in VirtaulBox on MacOSX

Setting up a Centos virtual machine to explore Chef.

I normally prefer to use Ubuntu server (I find more things work out of the box, software is easier to find and install and the command line has been pimped to be a little friendlier). However I need to explore Chef for work which means using Centos, so my first job was to set up some Centos virtual machines to play with. First off I tried Vagrant. This looks very good, but I had some problems with bridged networking and the Centos box I was using.

Akka Dynamo 1

First experiments with implementing Dynamo in Akka.

http://lethain.com/hands-on-review-of-the-dynamo-paper/ Setup Install sbt brew install sbt Create an akka project mkdir akka-dynamo cd akka-dynamo mkdir -p src/main/scala mkdir -p src/test/scala Create build.sbt name := "Akka Dynamo" scalaVersion := "2.9.2" resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/" retrieveManaged := true libraryDependencies ++= Seq("com.typesafe.akka" % "akka-actor" % "2.0.3", "com.typesafe.akka" % "akka-remote" % "2.0.3", "com.typesafe.akka" % "akka-testkit" % "2.0.3" % "test", "org.specs2" %% "specs2" % "1.9" % "test", "junit" % "junit" % "4.5" % "test") The messages Scala is a strongly typed language so the message types have to be defined.

Moving a project from google code to github

Finally moved my old cmakeant project from google-code to github (I have been meaning to do this for ages). In case you are trying to do the same, here are the steps.

Finally moved my old cmakeant project from google-code to github (I have been meaning to do this for ages). In case you are trying to do the same, here are the steps: Download the mercurial repo from google code hg clone https://iainhull@code.google.com/p/cmakeant/ cmakeant-hg Use fast-export to convert the mercurial repository to git. Note: I needed to add mercurial on my PYTHONPATH git clone git://repo.or.cz/fast-export.git export PYTHONPATH=/usr/local/Cellar/mercurial//2.3.1/libexec/:$PYTHONPATH Create a new git repo and clone the mercurial repo