puppetlabs/hiera — pull request #31 by hunner (2012-01-05 20:05:16+00:00)
Title: Parse hiera.yaml at load-time

Before this commit `hiera.yaml` is loaded as yaml at runtime in an
atomic operation, but I desired to be able to take scope into account
for the purpose of adding yaml refereces and anchors.

With this commit, Hiera will read the contents of the `hiera.yaml`
config file, parse the contents for `%{strings}`, and then parse the
resulting file from yaml into ruby datastructures.

The Big Why: Discreet hierarchies now available!

```yaml
---
:hierarchies:
- :testing: &testing
- %{developer}
- %{operatingsystem}
- common
- :production: &production
- %{operatingsystem}
- common

:hierarchy: *%{environment}
:backends:
- yaml
:yaml:
:datadir: "/etc/puppetlabs/puppet/environments/%{environment}/hieradata"
```

This commit is a bit of a refactor. Here is what I did to accomplish
this:

- Move `parse_string` from `Hiera::Backend` to `Hiera`
- This method is used by both `Hiera::Config` and `Hiera::Backend`
- Allow `scope` to be passed into the `Hiera` constructor
- Use the `scope` when loading `hiera.yaml`

All tests pass.