BBC-News/alephant-preview — pull request #6 by stevenjack (2014-10-15 08:25:10+00:00)
Title: [WIP] Dynamic loading

### Problem

Currently the preview application only supports the static publishing model where a template is loaded with the supplied fixture. The new type of rendering using the [alpehant-publisher-request](https://www.github.com/BBC-News/alephant-publisher-request) requires that each model has a [data mapper](https://github.com/BBC-News/alephant-publisher-request#data-mapper) associated with it. Currently the data mapper isn't used by the preview application, it should be exercised as part of the preview workflow.

### Solution

We use the `Alephant::Publisher::Request::DataMapperFactory` to get a data mapper based off the component the user is requesting and use a fake connection to just pass the fixture through the data mapper rather than making a HTTP request.

For data mappers that have more than one `get` call, if you prepend the file name with an incrementing numeric number then they'll be used for each subsequent call. For example:

```bash
src
├── components
│ ├── my_test_component
│ │ ├── fixtures
│ │ │ ├── responsive_1.json
│ │ │ ├── responsive_2.json
│ │ │ ├── responsive_3.json
│ │ ├── templates
│ │ │ ├── my_test_component.mustache
│ │ ├── models
│ │ │ ├── my_test_component.rb
│ │ ├── mapper.rb
```

would mean that if there were three `get` requests in the data mapper, it would use the fixtures from 1 - 3 for each subsequent call.