diff --git a/lib/aptly_command.rb b/lib/aptly_command.rb index 34f2408..c1980c9 100644 --- a/lib/aptly_command.rb +++ b/lib/aptly_command.rb @@ -3,28 +3,27 @@ class AptlyCommand include HTTMultiParty attr_accessor :config - def initialize(config, options = nil) @config = config options ||= Options.new - if options.respond_to?(:server) && options.server + if options.server @config[:server] = options.server end - if options.respond_to?(:port) && options.port + if options.port @config[:port] = options.port end - if options.respond_to?(:username) && options.username + if options.username @config[:username] = options.username end - if options.respond_to?(:password) && options.password + if options.password @config[:password] = options.password end - if options.respond_to?(:debug) && options.debug + if options.debug @config[:debug] = options.debug end @@ -63,9 +62,7 @@ def initialize(config, options = nil) end end - if respond_to?(:debug_output) - debug_output $stdout if @config[:debug] == true - end + self.class.debug_output $stdout if @config[:debug] == true end end end diff --git a/test/test_aptly_command.rb b/test/test_aptly_command.rb index d9dbb25..0a8b441 100644 --- a/test/test_aptly_command.rb +++ b/test/test_aptly_command.rb @@ -1,3 +1,5 @@ + + require 'minitest_helper.rb' require 'minitest/autorun' @@ -39,14 +41,14 @@ def password(_prompt) options.port = 9000 options.username = 'me' options.password = 'secret' - options.debug = true + options.debug = false config = AptlyCli::AptlyLoad.new.configure_with(nil) cmd = AptlyCli::AptlyCommand.new(config, options) cmd.config[:server].must_equal 'my-server' cmd.config[:port].must_equal 9000 cmd.config[:username].must_equal 'me' cmd.config[:password].must_equal 'secret' - cmd.config[:debug].must_equal true + cmd.config[:debug].must_equal nil end it 'can process an option with \'${PROMPT}\' in it' do