lib/travis/cli.rb in travis-1.5.0 vs lib/travis/cli.rb in travis-1.5.1
- old
+ new
@@ -10,10 +10,12 @@
end
require 'gh'
GH.set(:ssl => Travis::Client::Session::SSL_OPTIONS)
+require 'stringio'
+
module Travis
module CLI
autoload :Token, 'travis/cli/token'
autoload :ApiCommand, 'travis/cli/api_command'
autoload :Accounts, 'travis/cli/accounts'
@@ -71,10 +73,24 @@
def commands
CLI.constants.map { |n| CLI.const_get(n) }.select { |c| command? c }
end
+ def silent
+ stderr, $stderr = $stderr, dummy_io
+ stdout, $stdout = $stdout, dummy_io
+ yield
+ ensure
+ $stderr = stderr if stderr
+ $stdout = stdout if stdout
+ end
+
private
+
+ def dummy_io
+ return StringIO.new unless defined? IO::NULL and IO::NULL
+ File.open(IO::NULL, 'w')
+ end
def command?(constant)
constant and constant < Command and not constant.abstract?
end