lib/aptly_repo.rb in aptly_cli-0.3.3 vs lib/aptly_repo.rb in aptly_cli-0.3.4
- old
+ new
@@ -1,10 +1,11 @@
require 'aptly_cli/version'
require 'aptly_command'
require 'aptly_load'
require 'httmultiparty'
require 'json'
+require 'uri'
module AptlyCli
# Aptly class to work with Repo API
class AptlyRepo < AptlyCommand
include HTTMultiParty
@@ -56,18 +57,15 @@
if repo_options[:name].nil?
raise ArgumentError.new('Must pass a repository name')
else
uri = '/repos/' + repo_options[:name] + '/packages'
end
- uri += if repo_options[:query]
- "?q=#{repo_options[:query]}"
- elsif repo_options[:format]
- "?format=#{repo_options[:format]}"
- elsif repo_options[:with_deps]
- '?withDeps=1'
- else
- ''
- end
+
+ qs_hash = {}
+ qs_hash['q'] = repo_options[:query] if repo_options[:query]
+ qs_hash['format'] = repo_options[:format] if repo_options[:format]
+ qs_hash['withDeps'] = 1 if repo_options[:with_deps]
+ uri += '?' + URI.encode_www_form(qs_hash) if qs_hash
self.class.get uri
end
def repo_show(name)
uri = if name.nil?