Sha256: 01ad1900095bef01052f96f3e4e6b07d3d7e1d5eb89a1392d94a28490d8aad6b
Contents?: true
Size: 1.95 KB
Versions: 5
Compression:
Stored size: 1.95 KB
Contents
module AptlyCli class AptlyCommand include HTTMultiParty attr_accessor :config def initialize(config, options = nil) @config = config options ||= Options.new if options.respond_to?(:server) && options.server @config[:server] = options.server end if options.respond_to?(:port) && options.port @config[:port] = options.port end if options.respond_to?(:username) && options.username @config[:username] = options.username end if options.respond_to?(:password) && options.password @config[:password] = options.password end if options.respond_to?(:debug) && options.debug @config[:debug] = options.debug end @config.each do |k, v| if v == '${PROMPT}' @config[k.to_sym] = ask("Enter a value for #{k}:") elsif v == '${PROMPT_PASSWORD}' @config[k.to_sym] = password("Enter a value for #{k}:") elsif v == '${KEYRING}' require 'keyring' keyring = Keyring.new keychain_item_name = 'Aptly API server at ' + \ @config[:server] + ':' + @config[:port].to_s value = keyring.get_password(keychain_item_name, @config[:username]) unless value # Prompt for password... value = password("Enter a value for #{k}:") # ... and store in keyring keyring.set_password(keychain_item_name, @config[:username], value) end @config[k.to_sym] = value end end base_uri = "#{@config[:proto]}://#{@config[:server]}:#{@config[:port]}" \ '/api' self.class.base_uri base_uri if @config[:username] if @config[:password] self.class.basic_auth @config[:username].to_s, @config[:password].to_s end end if respond_to?(:debug_output) debug_output $stdout if @config[:debug] == true end end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
aptly_cli-0.3.5 | lib/aptly_command.rb |
aptly_cli-0.3.4 | lib/aptly_command.rb |
aptly_cli-0.3.3 | lib/aptly_command.rb |
aptly_cli-0.3.2 | lib/aptly_command.rb |
aptly_cli-0.3.1 | lib/aptly_command.rb |