Skip to content

Commit 0dc79dc

Browse files
committed
Allow all Formatters to accept options hash
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.
1 parent 025392a commit 0dc79dc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ appear at the top.
1313
* display more accurate string for commands with spaces being output in `Formatter::Pretty`
1414
[PR #304](https://github.com/capistrano/sshkit/pull/304)
1515
@steved
16+
* `SSHKit::Formatter::Abstract` now accepts an optional Hash of options
17+
[PR #308](https://github.com/capistrano/sshkit/pull/308) @mattbrictson
1618

1719
## 1.8.1
1820

lib/sshkit/formatters/abstract.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ module Formatter
77
class Abstract
88

99
extend Forwardable
10-
attr_reader :original_output
10+
attr_reader :original_output, :options
1111
def_delegators :@original_output, :read, :rewind
1212
def_delegators :@color, :colorize
1313

14-
def initialize(output)
14+
def initialize(output, options={})
1515
@original_output = output
16+
@options = options
1617
@color = SSHKit::Color.new(output)
1718
end
1819

0 commit comments

Comments
 (0)