Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the object 'options' provided by Commander doesn't have methods to te… #137

Merged
merged 5 commits into from
Jul 24, 2016
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions lib/aptly_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
5 changes: 3 additions & 2 deletions test/test_aptly_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ def password(_prompt)
options.port = 9000
options.username = 'me'
options.password = 'secret'
options.debug = true
options.debug = false
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to revisit this. If we have this set the rake test output will include the debugging output (pretty noisy)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe default it to false?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

puts options
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

end

it 'can process an option with \'${PROMPT}\' in it' do
Expand Down