Skip to content

Commit

Permalink
Allow all Formatters to accept options hash
Browse files Browse the repository at this point in the history
None of the built in formatters yet do anything with these options. However, it
provides a consistent #initialize API that allows us to promote "formatter
options" as a concept further up the stack in Capistrano.

For example, in Capistrano we can offer this configuration system:

set :format, ...
set :format_options, key: value, ...

We can only reasonable offer this if we are sure that the underlying formatters
all accept an options hash (i.e. the :format_options).

Most importantly, Airbrussh *does* have options, and this will allow us to have
a standard way for those options to be declared. Airbrussh will be the default
formatter in a future version of Capistrano, and this commit is part of laying
the groundwork.
  • Loading branch information
mattbrictson committed Dec 29, 2015
1 parent 58d9603 commit b9cd0df
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ appear at the top.
* display more accurate string for commands with spaces being output in `Formatter::Pretty`
[PR #304](https://github.com/capistrano/sshkit/pull/304)
@steved
* `SSHKit::Formatter::Abstract` now accepts an optional Hash of options
[PR #308](https://github.com/capistrano/sshkit/pull/308) @mattbrictson

## 1.8.1

Expand Down
5 changes: 3 additions & 2 deletions lib/sshkit/formatters/abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ module Formatter
class Abstract

extend Forwardable
attr_reader :original_output
attr_reader :original_output, :options
def_delegators :@original_output, :read, :rewind
def_delegators :@color, :colorize

def initialize(output)
def initialize(output, options={})
@original_output = output
@options = options
@color = SSHKit::Color.new(output)
end

Expand Down

0 comments on commit b9cd0df

Please sign in to comment.