swipely/docker-api — pull request #75 by ulyssecarion (2013-12-24 21:51:37+00:00)
Title: Add a block param to build_from_dir to capture Docker build output.

This addresses #74, which requests that docker-api give users a way of getting the output produced by `build_from_dir`. I sort of needed this feature the other day, so here I am. With this PR, you could now do:

```ruby
Docker::Image.build_from_dir('.') do |chunk|
logger.debug chunk # or whatever
end
```

In this PR, `Image.build_from_dir` gets an extra argument, `&block`, that will get chunks of the stream Docker produces when building an image. This simply involves using Excon's `:response_block` parameter.

It seems as though giving Excon a `:response_block` means that it will no longer return the body of the output (this seems like reasonable behavior, so I haven't looked into it much). That's why the `reponse_block_for_build` internal method needs to be passed the body parameter, so it can "build up" the body by concatenating the chunks Docker produces.

I don't think this PR is good to merge -- it doesn't make much sense to have this feature only for `build_from_dir` and not have it for `build`, so I'm mostly opening this to get an idea of what y'all think.