cloudfoundry/dea_ng — pull request #110 by brannon (2014-03-04 02:00:28+00:00)
Title: Add support for Windows

This PR adds support for Windows to the Ruby DEA.

One of the goals in supporting Windows is to add unit tests for platform-specific logic (Windows vs. Linux) that run regardless of the platform on which the tests are executing. As part of that, we centralized platform-specific logic as much as possible into `lib/dea/utils/platform_compat.rb`.

Some classes (i.e. instance.rb) required refactoring to support platform-specific logic. For those we took the approach of creating platform-specific sub-classes. To reduce churn in the code we added a helper that would override the class constructor to create the appropriate sub-class, based on the current platform.

This results in a hierarchy like the following:

```ruby
class Instance
# Common functionality
end

class WindowsInstance < Instance
# Windows-specific functionality
end

class LinuxInstance < Instance
# Linux-specific functionality
end
```

Some of the unit tests needed to be heavily refactored to support running on both Windows and Linux. For example `spec/unit/env_spec.rb` used to evaulate the environment variables using `system "echo ..."` and the tests relied on that to validate environment variable values. This didn't work well on Windows, so we ended up rewriting many of the specs to not rely on the system behavior.

We also created a `cloudfoundry-buildpack-clr` buildpack as a submodule which points to our implementation.

Finally, we updated the GO Directory Server to support running as a service on Windows. This required us to add a dependency to `code.google.com/p/winsvc`, which is a Mercurial repository. We added the code to Git, instead of referencing the package as a submodule.