Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for config.command_output
Normally airbrussh hides all stderr and stdout data returned by SSH commands. With this commit, users of airbrussh can selectively enable displaying of stderr and/or stdout data.
- Loading branch information
1 parent
af3b8a5
commit 42a16ff
Showing
5 changed files
with
137 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,29 @@ | ||
module Airbrussh | ||
class Configuration | ||
attr_accessor :log_file, :monkey_patch_rake, :color, :truncate, :banner | ||
attr_accessor :log_file, :monkey_patch_rake, :color, :truncate, :banner, | ||
:command_output | ||
|
||
def initialize | ||
self.log_file = nil | ||
self.monkey_patch_rake = false | ||
self.color = :auto | ||
self.truncate = :auto | ||
self.banner = :auto | ||
self.command_output = false | ||
end | ||
|
||
def command_output_stdout? | ||
command_output_include?(:stdout) | ||
end | ||
|
||
def command_output_stderr? | ||
command_output_include?(:stderr) | ||
end | ||
|
||
private | ||
|
||
def command_output_include?(sym) | ||
command_output == true || Array(command_output).include?(sym) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require "minitest_helper" | ||
|
||
class TestConfiguration < Minitest::Test | ||
def setup | ||
# Reset any configuration changes done by the tests | ||
Airbrussh.reset | ||
end | ||
|
||
def test_default_command_output | ||
refute(config.command_output) | ||
end | ||
|
||
def test_effects_of_command_output_true | ||
config.command_output = true | ||
assert(config.command_output_stdout?) | ||
assert(config.command_output_stderr?) | ||
end | ||
|
||
def test_effects_of_command_output_false | ||
config.command_output = false | ||
refute(config.command_output_stdout?) | ||
refute(config.command_output_stderr?) | ||
end | ||
|
||
def test_effects_of_command_output_stdout | ||
config.command_output = :stdout | ||
assert(config.command_output_stdout?) | ||
refute(config.command_output_stderr?) | ||
end | ||
|
||
def test_effects_of_command_output_stderr | ||
config.command_output = :stderr | ||
refute(config.command_output_stdout?) | ||
assert(config.command_output_stderr?) | ||
end | ||
|
||
def test_effects_of_command_output_stdout_stderr | ||
config.command_output = [:stdout, :stderr] | ||
assert(config.command_output_stdout?) | ||
assert(config.command_output_stderr?) | ||
end | ||
|
||
private | ||
|
||
def config | ||
Airbrussh.configuration | ||
end | ||
end |