From 0310b41dd1fbc207425d3fb1cf37f9b2a9d890f6 Mon Sep 17 00:00:00 2001 From: Zane Date: Sun, 20 Mar 2016 13:36:04 -0700 Subject: [PATCH 1/2] updating for Ruby style guide --- .rubocop_todo.yml | 168 ++++++---------------- lib/aptly_load.rb | 12 +- lib/aptly_package.rb | 19 ++- lib/aptly_repo.rb | 161 +++++++++------------ test/fixtures/dish_cassettes/repo_api.yml | 141 ++++++++++++++---- test/test_aptly_repo.rb | 2 +- 6 files changed, 241 insertions(+), 262 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 23a5d11..4d345d8 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,12 +1,12 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2016-03-18 19:51:36 -0700 using RuboCop version 0.38.0. +# on 2016-03-20 13:34:32 -0700 using RuboCop version 0.38.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 23 +# Offense count: 20 # Cop supports --auto-correct. # Configuration parameters: AlignWith, SupportedStyles. # SupportedStyles: either, start_of_block, start_of_line @@ -14,7 +14,6 @@ Lint/BlockAlignment: Exclude: - 'test/test_aptly_misc.rb' - 'test/test_aptly_package.rb' - - 'test/test_aptly_publish.rb' - 'test/test_aptly_repo.rb' - 'test/test_aptly_snapshot.rb' @@ -25,7 +24,7 @@ Lint/UnusedBlockArgument: Exclude: - 'bin/aptly-cli' -# Offense count: 60 +# Offense count: 62 Lint/UselessAssignment: Exclude: - 'test/test_aptly_cli_configure.rb' @@ -36,31 +35,31 @@ Lint/UselessAssignment: - 'test/test_aptly_repo.rb' - 'test/test_aptly_snapshot.rb' -# Offense count: 3 +# Offense count: 2 Metrics/AbcSize: - Max: 32 + Max: 31 # Offense count: 1 # Configuration parameters: CountComments. Metrics/ClassLength: - Max: 111 + Max: 108 -# Offense count: 2 +# Offense count: 1 Metrics/CyclomaticComplexity: Max: 9 -# Offense count: 153 +# Offense count: 147 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes. # URISchemes: http, https Metrics/LineLength: Max: 524 -# Offense count: 8 +# Offense count: 9 # Configuration parameters: CountComments. Metrics/MethodLength: - Max: 38 + Max: 34 -# Offense count: 2 +# Offense count: 1 Metrics/PerceivedComplexity: Max: 10 @@ -75,22 +74,22 @@ Style/AlignArray: Exclude: - 'lib/aptly_publish.rb' -# Offense count: 3 +# Offense count: 8 # Cop supports --auto-correct. # Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle, SupportedLastArgumentHashStyles. # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit Style/AlignHash: Exclude: - 'bin/aptly-cli' + - 'test/test_aptly_publish.rb' -# Offense count: 3 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: always, conditionals Style/AndOr: Exclude: - 'bin/aptly-cli' - - 'lib/aptly_repo.rb' # Offense count: 20 # Cop supports --auto-correct. @@ -102,13 +101,6 @@ Style/BracesAroundHashParameters: - 'test/test_aptly_repo.rb' - 'test/test_aptly_snapshot.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep, IndentationWidth. -# SupportedStyles: case, end -Style/CaseIndentation: - Enabled: false - # Offense count: 3 Style/ClassVars: Exclude: @@ -116,44 +108,22 @@ Style/ClassVars: # Offense count: 1 # Cop supports --auto-correct. -Style/ColonMethodCall: - Exclude: - - 'lib/aptly_load.rb' - -# Offense count: 4 -# Cop supports --auto-correct. # Configuration parameters: SingleLineConditionsOnly. Style/ConditionalAssignment: Exclude: - - 'lib/aptly_file.rb' - - 'lib/aptly_repo.rb' - 'lib/aptly_snapshot.rb' -# Offense count: 3 -# Cop supports --auto-correct. -Style/DefWithParentheses: - Exclude: - - 'lib/aptly_file.rb' - - 'lib/aptly_misc.rb' - - 'lib/aptly_repo.rb' - # Offense count: 2 # Cop supports --auto-correct. Style/DeprecatedHashMethods: Exclude: - 'lib/aptly_snapshot.rb' -# Offense count: 7 +# Offense count: 1 Style/Documentation: Exclude: - 'spec/**/*' - 'test/**/*' - - 'lib/aptly_cli.rb' - - 'lib/aptly_file.rb' - - 'lib/aptly_load.rb' - - 'lib/aptly_misc.rb' - - 'lib/aptly_package.rb' - - 'lib/aptly_repo.rb' - 'lib/aptly_snapshot.rb' # Offense count: 2 @@ -163,7 +133,7 @@ Style/EmptyLines: - 'test/test_aptly_file.rb' - 'test/test_aptly_repo.rb' -# Offense count: 50 +# Offense count: 45 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: empty_lines, no_empty_lines @@ -176,72 +146,38 @@ Style/EmptyLinesAroundBlockBody: - 'test/test_aptly_repo.rb' - 'test/test_aptly_snapshot.rb' -# Offense count: 7 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: empty_lines, no_empty_lines Style/EmptyLinesAroundClassBody: Exclude: - - 'lib/aptly_misc.rb' - - 'lib/aptly_package.rb' - - 'lib/aptly_repo.rb' - 'lib/aptly_snapshot.rb' - 'test/test_aptly_cli_configure.rb' -# Offense count: 5 +# Offense count: 3 # Cop supports --auto-correct. Style/EmptyLinesAroundMethodBody: Exclude: - - 'lib/aptly_repo.rb' - 'lib/aptly_snapshot.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, no_empty_lines -Style/EmptyLinesAroundModuleBody: - Exclude: - - 'lib/aptly_cli.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Style/EmptyLiteral: - Exclude: - - 'lib/aptly_repo.rb' - -# Offense count: 1 -# Configuration parameters: MinBodyLength. -Style/GuardClause: - Exclude: - - 'lib/aptly_repo.rb' - -# Offense count: 162 +# Offense count: 130 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues. # SupportedStyles: ruby19, ruby19_no_mixed_keys, hash_rockets Style/HashSyntax: Enabled: false -# Offense count: 13 +# Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: MaxLineLength. Style/IfUnlessModifier: Exclude: - 'bin/aptly-cli' - - 'lib/aptly_file.rb' - - 'lib/aptly_misc.rb' - - 'lib/aptly_package.rb' - - 'lib/aptly_repo.rb' + - 'lib/aptly_publish.rb' - 'lib/aptly_snapshot.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: SupportedStyles, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Style/IndentHash: - EnforcedStyle: align_braces - -# Offense count: 22 +# Offense count: 30 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: normal, rails @@ -271,14 +207,13 @@ Style/LeadingCommentSpace: Exclude: - 'test/minitest_helper.rb' -# Offense count: 9 +# Offense count: 8 # Cop supports --auto-correct. Style/MethodCallParentheses: Exclude: - 'bin/aptly-cli' - 'test/test_aptly_file.rb' - 'test/test_aptly_misc.rb' - - 'test/test_aptly_publish.rb' - 'test/test_aptly_repo.rb' # Offense count: 2 @@ -287,12 +222,6 @@ Style/MethodCallParentheses: Style/MethodName: Enabled: false -# Offense count: 4 -# Cop supports --auto-correct. -Style/NilComparison: - Exclude: - - 'lib/aptly_repo.rb' - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. @@ -300,77 +229,64 @@ Style/PercentLiteralDelimiters: Exclude: - 'aptly_cli.gemspec' -# Offense count: 2 +# Offense count: 1 # Configuration parameters: SupportedStyles. # SupportedStyles: compact, exploded Style/RaiseArgs: EnforcedStyle: compact -# Offense count: 14 +# Offense count: 15 # Cop supports --auto-correct. Style/RedundantParentheses: Exclude: - 'test/test_aptly_file.rb' - 'test/test_aptly_misc.rb' + - 'test/test_aptly_publish.rb' - 'test/test_aptly_snapshot.rb' -# Offense count: 1 +# Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: Exclude: + - 'lib/aptly_publish.rb' - 'lib/aptly_repo.rb' -# Offense count: 8 +# Offense count: 7 # Cop supports --auto-correct. Style/SpaceAfterComma: Exclude: - - 'lib/aptly_load.rb' - 'test/test_aptly_snapshot.rb' -# Offense count: 8 +# Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment. Style/SpaceAroundOperators: Exclude: - - 'lib/aptly_repo.rb' - 'lib/aptly_snapshot.rb' - 'test/test_aptly_snapshot.rb' -# Offense count: 3 +# Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space Style/SpaceInsideBlockBraces: Enabled: false -# Offense count: 65 +# Offense count: 51 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles. # SupportedStyles: space, no_space Style/SpaceInsideHashLiteralBraces: Enabled: false -# Offense count: 1 -# Cop supports --auto-correct. -Style/SpaceInsideParens: - Exclude: - - 'lib/aptly_file.rb' - -# Offense count: 249 +# Offense count: 189 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes Style/StringLiterals: Enabled: false -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiteralsInInterpolation: - Enabled: false - # Offense count: 2 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. @@ -380,15 +296,12 @@ Style/TrailingBlankLines: - 'bin/aptly-cli' - 'test/test_aptly_file.rb' -# Offense count: 104 +# Offense count: 66 # Cop supports --auto-correct. Style/TrailingWhitespace: Exclude: - 'aptly_cli.gemspec' - 'bin/aptly-cli' - - 'lib/aptly_file.rb' - - 'lib/aptly_load.rb' - - 'lib/aptly_repo.rb' - 'lib/aptly_snapshot.rb' - 'test/test_aptly_cli_configure.rb' - 'test/test_aptly_file.rb' @@ -412,14 +325,10 @@ Style/UnlessElse: Exclude: - 'lib/aptly_snapshot.rb' -# Offense count: 11 +# Offense count: 3 # Cop supports --auto-correct. Style/UnneededInterpolation: Exclude: - - 'lib/aptly_file.rb' - - 'lib/aptly_misc.rb' - - 'lib/aptly_package.rb' - - 'lib/aptly_repo.rb' - 'lib/aptly_snapshot.rb' # Offense count: 2 @@ -427,3 +336,10 @@ Style/UnneededInterpolation: Style/UnneededPercentQ: Exclude: - 'aptly_cli.gemspec' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: SupportedStyles, MinSize, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: brackets diff --git a/lib/aptly_load.rb b/lib/aptly_load.rb index a4ab085..5b613a2 100644 --- a/lib/aptly_load.rb +++ b/lib/aptly_load.rb @@ -5,6 +5,10 @@ module AptlyCli # Load aptly-cli configuration class AptlyLoad + def config + @config + end + def initialize @log = Logger.new(STDOUT) @log.level = Logger::WARN @@ -30,8 +34,8 @@ def configure_with(path_to_yaml_file) begin config = YAML.load(IO.read(path_to_yaml_file)) rescue Errno::ENOENT - @log.warn('YAML configuration file couldn\'t be found at - /etc/aptly-cli.conf. Using defaults.') + @log.warn( + 'YAML configuration file couldn\'t be found at /etc/aptly-cli.conf. Using defaults.') return @config rescue Psych::SyntaxError @log.warn( @@ -40,9 +44,5 @@ def configure_with(path_to_yaml_file) end configure(config) end - - def config - @config - end end end diff --git a/lib/aptly_package.rb b/lib/aptly_package.rb index 6417cd9..f2e7935 100644 --- a/lib/aptly_package.rb +++ b/lib/aptly_package.rb @@ -1,31 +1,28 @@ -require "aptly_cli/version" -require "aptly_load" -require "httmultiparty" -require "json" +require 'aptly_cli/version' +require 'aptly_load' +require 'httmultiparty' +require 'json' module AptlyCli + # Aptly Package API class AptlyPackage - include HTTMultiParty # Load aptly-cli.conf and establish base_uri - config = AptlyCli::AptlyLoad.new.configure_with("/etc/aptly-cli.conf") + config = AptlyCli::AptlyLoad.new.configure_with('/etc/aptly-cli.conf') base_uri "http://#{config[:server]}:#{config[:port]}/api" if config[:username] if config[:password] - basic_auth "#{config[:username]}", "#{config[:password]}" + basic_auth config[:username].to_s, config[:password].to_s end end - if config[:debug] == true - debug_output $stdout - end + debug_output $stdout if config[:debug] == true def package_show(package_key) uri = "/packages/#{package_key}" self.class.get(uri) end - end end diff --git a/lib/aptly_repo.rb b/lib/aptly_repo.rb index fa803ae..5260d35 100644 --- a/lib/aptly_repo.rb +++ b/lib/aptly_repo.rb @@ -1,154 +1,135 @@ -require "aptly_cli/version" -require "aptly_load" -require "httmultiparty" -require "json" +require 'aptly_cli/version' +require 'aptly_load' +require 'httmultiparty' +require 'json' module AptlyCli + # Aplty class to work with Repo API class AptlyRepo - include HTTMultiParty - # Load aptly-cli.conf and establish base_uri - config = AptlyCli::AptlyLoad.new.configure_with("/etc/aptly-cli.conf") + config = AptlyCli::AptlyLoad.new.configure_with('/etc/aptly-cli.conf') base_uri "http://#{config[:server]}:#{config[:port]}/api" if config[:username] if config[:password] - basic_auth "#{config[:username]}", "#{config[:password]}" + basic_auth config[:username].to_s, config[:password].to_s end end + debug_output $stdout if config[:debug] == true - if config[:debug] == true - debug_output $stdout - end - - def repo_create(repo_options = {:name => nil, :comment => nil, :DefaultDistribution => nil, :DefaultComponent => nil}) - uri = "/repos" + def repo_create(repo_options = { name: nil, + comment: nil, + DefaultDistribution: nil, + DefaultComponent: nil }) + uri = '/repos' name = repo_options[:name] comment = repo_options[:comment] default_distribution = repo_options[:DefaultDistribution] default_component = repo_options[:DefaultComponent] - - self.class.post(uri, :query => { 'Name' => name, 'Comment' => comment, 'DefaultDistribution' => default_distribution, 'DefaultComponent' => default_component }.to_json, :headers => {'Content-Type'=>'application/json'}) + self.class.post(uri, + query: + { 'Name' => name, 'Comment' => comment, + 'DefaultDistribution' => default_distribution, + 'DefaultComponent' => default_component }.to_json, + headers: { 'Content-Type' => 'application/json' }) end - def repo_delete(repo_options = {:name => nil, :force => nil}) - uri = "/repos/" + repo_options[:name] - - if repo_options[:force] == true - uri += "?force=1" - end - + def repo_delete(repo_options = { name: nil, force: nil }) + uri = '/repos/' + repo_options[:name] + uri += '?force=1' if repo_options[:force] == true self.class.delete(uri) end def repo_edit(name, repo_options = { k => v }) - repo_option = String.new - repo_value = String.new - - if name == nil - raise ArgumentError.new('Must pass a repository name') - else - uri = "/repos/" + name - end - + repo_option = '' + repo_value = '' + uri = '/repos/' + name unless name.nil? repo_options.each do |k, v| repo_option = k repo_value = v end - self.class.put(uri, :query => { repo_option => repo_value }.to_json, :headers => {'Content-Type'=>'application/json'}) + self.class.put(uri, query: { repo_option => repo_value }.to_json, + headers: { 'Content-Type' => 'application/json' }) end - def repo_list() - uri = "/repos" - + def repo_list + uri = '/repos' self.class.get(uri) end - - def repo_package_query(repo_options = {:name => nil, :query => nil, :withdeps => false, :format => nil}) - if repo_options[:name] == nil + + def repo_package_query(repo_options = { name: nil, query: nil, + with_deps: false, + format: nil }) + if repo_options[:name].nil? raise ArgumentError.new('Must pass a repository name') else - uri = "/repos/" + repo_options[:name] + "/packages" - end - - if repo_options[:query] - uri += "?q=" + repo_options[:query] - if repo_options[:withdeps] or repo_options[:format] - puts "When specifiying specific package query, other options are invalid." - end - elsif repo_options[:format] - uri += "?format=#{repo_options[:format]}" - elsif repo_options[:withdeps] == true - uri += "?withDeps=1" + uri = '/repos/' + repo_options[:name] + '/packages' end - - self.class.get uri - + 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 + self.class.get uri end def repo_show(name) - if name == nil - uri = "/repos" - else - uri = "/repos/" + name - end - - self.class.get uri + uri = if name.nil? + '/repos' + else + '/repos/' + name + end + self.class.get uri end - def repo_upload(repo_options = {:name => nil, :dir => nil, :file => nil, - :noremove => false, :forcereplace => false}) + def repo_upload(repo_options = { name: nil, dir: nil, file: nil, + noremove: false, forcereplace: false }) name = repo_options[:name] dir = repo_options[:dir] file = repo_options[:file] noremove = repo_options[:noremove] forcereplace = repo_options[:forcereplace] - - if file == nil - uri = "/repos/#{name}/file/#{dir}" - else - uri = "/repos/#{name}/file/#{dir}/#{file}" - end - - if forcereplace == true - uri += "?forceReplace=1" - end - - if noremove == true - uri += "?noRemove=1" - end - + uri = if file.nil? + "/repos/#{name}/file/#{dir}" + else + "/repos/#{name}/file/#{dir}/#{file}" + end + + uri += '?forceReplace=1' if forcereplace == true + uri += '?noRemove=1' if noremove == true response = self.class.post(uri) - + case response.code - when 404 - puts 'repository with such name does not exist' + when 404 + puts 'repository with such name does not exist' end json_response = JSON.parse(response.body) - - unless json_response["FailedFiles"].empty? + + unless json_response['FailedFiles'].empty? begin rescue StandardError => e - puts "Files that failed to upload... #{json_response["FailedFiles"]}" + puts "Files that failed to upload... #{json_response['FailedFiles']}" puts e end end - unless json_response["Report"]["Warnings"].empty? + unless json_response['Report']['Warnings'].empty? begin rescue StandardError => e - puts "File upload warning message[s]...#{json_response["Report"]["Warnings"]}" + puts "File upload warning message[s]...\ + #{json_response['Report']['Warnings']}" puts e end end - return response - - end - + end end end diff --git a/test/fixtures/dish_cassettes/repo_api.yml b/test/fixtures/dish_cassettes/repo_api.yml index bef0d3b..957699c 100644 --- a/test/fixtures/dish_cassettes/repo_api.yml +++ b/test/fixtures/dish_cassettes/repo_api.yml @@ -20,8 +20,13 @@ http_interactions: - '415' body: encoding: UTF-8 - string: | - ["Pi386 geoipupdate 2.0.0 249f3976bd06cce4","Pi386 mongodb-mms-monitoring-agent 2.4.0.101-1 bf58165444e70af6","Pi386 redis-server 2.8.3 324bb47c72149fae","Pi386 xsp 2.11.0.0-git-master-04062013 fb4f20e019c99800","Pamd64 geoipupdate 2.0.0 c7b4081a761741bb","Pamd64 mongodb-mms-monitoring-agent 2.4.0.101-1 fc25ab7d8b9d2158","Pamd64 redis-server 2.8.3 fde8566b85f0a1","Pamd64 voltdb-php-client 1.2 7f4eed5217e92df0"] + string: '["Pi386 geoipupdate 2.0.0 249f3976bd06cce4","Pi386 mongodb-mms-monitoring-agent + 2.4.0.101-1 bf58165444e70af6","Pi386 redis-server 2.8.3 324bb47c72149fae","Pi386 + xsp 2.11.0.0-git-master-04062013 fb4f20e019c99800","Pamd64 geoipupdate 2.0.0 + c7b4081a761741bb","Pamd64 mongodb-mms-monitoring-agent 2.4.0.101-1 fc25ab7d8b9d2158","Pamd64 + redis-server 2.8.3 fde8566b85f0a1","Pamd64 voltdb-php-client 1.2 7f4eed5217e92df0"] + +' http_version: recorded_at: Tue, 31 Mar 2015 05:28:32 GMT - request: @@ -44,8 +49,45 @@ http_interactions: - chunked body: encoding: UTF-8 - string: | - [{"Architecture":"i386","Description":" The MMS Monitoring Agent monitors MongoDB performance\n metrics and sends them to the MongoDB MMS hosted service.\n","Filename":"mongodb-mms-monitoring-agent_latest_i386.deb","FilesHash":"bf58165444e70af6","Homepage":"http://mms.mongodb.com","Key":"Pi386 mongodb-mms-monitoring-agent 2.4.0.101-1 bf58165444e70af6","MD5sum":"5e45518ec52cd8ae0bbe30daf0a69dad","Maintainer":"Cory Mintz \u003ccory.mintz@mongodb.com\u003e","Package":"mongodb-mms-monitoring-agent","Pre-Depends":"logrotate","SHA1":" ace44d6ca505556cd05d4f10cfbdc3512aa37ecb","SHA256":" 9468d54a83f9b715eea9e5bfcb07fac495dccdb3d99c8a3c5e59bf8abe5e015a","ShortKey":"Pi386 mongodb-mms-monitoring-agent 2.4.0.101-1","Size":"2470876","Version":"2.4.0.101-1"},{"Architecture":"i386","Depends":"libc6 (\u003e= 2.7)","Description":" no description given\n","Filename":"redis-server_2.8.3_i386-cc1.deb","FilesHash":"324bb47c72149fae","Homepage":"http://example.com/no-uri-given","Installed-Size":"13146","Key":"Pi386 redis-server 2.8.3 324bb47c72149fae","License":"unknown","MD5sum":"26e97c9f59864acab0ad38f502e7d051","Maintainer":"\u003croot@puppetmaster.georiot.com\u003e","Package":"redis-server","Priority":"extra","SHA1":" 577894765fd4c08bee2695e414d59fac31c7d614","SHA256":" 85ddeae587d3362800d652d249ddedc1db8de20c0063179b91a138747bf58062","Section":"default","ShortKey":"Pi386 redis-server 2.8.3","Size":"4360310","Vendor":"root@puppetmaster.georiot.com","Version":"2.8.3"},{"Architecture":"i386","Description":" no description given\n","Filename":"xsp_2.11.0.0-git-master-04062013_i386.deb","FilesHash":"fb4f20e019c99800","Homepage":"http://example.com/no-uri-given","Installed-Size":"920","Key":"Pi386 xsp 2.11.0.0-git-master-04062013 fb4f20e019c99800","License":"unknown","MD5sum":"7884701226877b41fd1ab77d843013c6","Maintainer":"\u003croot@puppetmaster.georiot.com\u003e","Package":"xsp","Priority":"extra","SHA1":" d332cb2f61bc204e2e3057546023d626b47eb597","SHA256":" d847c7cde23ab5590fa125223ad8bdb3ca9f92a405717ad546433959a1795803","Section":"default","ShortKey":"Pi386 xsp 2.11.0.0-git-master-04062013","Size":"407854","Vendor":"root@puppetmaster.georiot.com","Version":"2.11.0.0-git-master-04062013"},{"Architecture":"amd64","Description":" no description given\n","Filename":"geoipupdate_2.0.0_amd64.deb","FilesHash":"c7b4081a761741bb","Homepage":"http://example.com/no-uri-given","Installed-Size":"92","Key":"Pamd64 geoipupdate 2.0.0 c7b4081a761741bb","License":"unknown","MD5sum":"6d8eacf9ebc273201935c79cd7851dde","Maintainer":"\u003croot@ubuntu.zane.podzone.net\u003e","Package":"geoipupdate","Priority":"extra","SHA1":" d9445055c184d4ef42a4a2b7db52b8fc01cd3ff7","SHA256":" f15259d84acdbee42cfe8cb67743d54e34d351d8102ca9de0b55a3ebae89b9d9","Section":"default","ShortKey":"Pamd64 geoipupdate 2.0.0","Size":"39268","Vendor":"root@ubuntu.zane.podzone.net","Version":"2.0.0"},{"Architecture":"amd64","Description":" The MMS Monitoring Agent monitors MongoDB performance\n metrics and sends them to the MongoDB MMS hosted service.\n","Filename":"mongodb-mms-monitoring-agent_latest_amd64.deb","FilesHash":"fc25ab7d8b9d2158","Homepage":"http://mms.mongodb.com","Key":"Pamd64 mongodb-mms-monitoring-agent 2.4.0.101-1 fc25ab7d8b9d2158","MD5sum":"03ce337e9a0f13cf1f44673fab382fba","Maintainer":"Cory Mintz \u003ccory.mintz@mongodb.com\u003e","Package":"mongodb-mms-monitoring-agent","Pre-Depends":"logrotate","SHA1":" 802551f1255a8de7188e33fc4ae56c7eef15ce83","SHA256":" c7e177319723a901e69cfb84ab6082b61acf84e138d4af0f9f497936b60af915","ShortKey":"Pamd64 mongodb-mms-monitoring-agent 2.4.0.101-1","Size":"2558260","Version":"2.4.0.101-1"},{"Architecture":"amd64","Depends":"libc6 (\u003e= 2.7)","Description":" no description given\n","Filename":"redis-server_2.8.3_amd64-cc1.deb","FilesHash":"fde8566b85f0a1","Homepage":"http://example.com/no-uri-given","Installed-Size":"14464","Key":"Pamd64 redis-server 2.8.3 fde8566b85f0a1","License":"unknown","MD5sum":"1512b02d8d055b181ecedfa236bf0c90","Maintainer":"\u003croot@utility3-production.wdc.softlayer.georiot.com\u003e","Package":"redis-server","Priority":"extra","SHA1":" 68fc5a042bda735c2b3ccde1fd167deb6d5092aa","SHA256":" 01901e2abe5ad7d0de395b5de8267578c7e055a781ce13b255959d09f991ff3d","Section":"default","ShortKey":"Pamd64 redis-server 2.8.3","Size":"4434640","Vendor":"root@utility3-production.wdc.softlayer.georiot.com","Version":"2.8.3"},{"Architecture":"amd64","Depends":"php5-common","Description":" no description given\n","Filename":"voltdb-php-client_1.2_amd64.deb","FilesHash":"7f4eed5217e92df0","Homepage":"http://voltdb.com/","Installed-Size":"3490","Key":"Pamd64 voltdb-php-client 1.2 7f4eed5217e92df0","License":"unknown","MD5sum":"9f02812ffd20360a62ffc9f6ea18989b","Maintainer":"\u003croot@vagrant-ubuntu-precise-64\u003e","Package":"voltdb-php-client","Priority":"extra","SHA1":" 2679d4bdc171d856d0673cd67e8c3afefdf76241","SHA256":" f4df086f99a12abdbdeeb9f5c1cefd468db89869f8cba6ee5fc54a7183212f0b","Section":"optional","ShortKey":"Pamd64 voltdb-php-client 1.2","Size":"1109500","Version":"1.2"},{"Architecture":"i386","Description":" no description given\n","Filename":"geoipupdate_2.0.0_i386.deb","FilesHash":"249f3976bd06cce4","Homepage":"http://example.com/no-uri-given","Installed-Size":"73","Key":"Pi386 geoipupdate 2.0.0 249f3976bd06cce4","License":"unknown","MD5sum":"3e0d395332472cbdbb9e885ea532c2cf","Maintainer":"\u003croot@puppetmaster.georiot.com\u003e","Package":"geoipupdate","Priority":"extra","SHA1":" 95165202b8183ca9c9abcfc59857ee13fab07387","SHA256":" 5db57febcda21721878ed353c87a57da69de2a0c6a185e2862f166ab84eecb08","Section":"default","ShortKey":"Pi386 geoipupdate 2.0.0","Size":"36876","Vendor":"root@puppetmaster.georiot.com","Version":"2.0.0"}] + string: '[{"Architecture":"i386","Description":" The MMS Monitoring Agent monitors + MongoDB performance\n metrics and sends them to the MongoDB MMS + hosted service.\n","Filename":"mongodb-mms-monitoring-agent_latest_i386.deb","FilesHash":"bf58165444e70af6","Homepage":"http://mms.mongodb.com","Key":"Pi386 + mongodb-mms-monitoring-agent 2.4.0.101-1 bf58165444e70af6","MD5sum":"5e45518ec52cd8ae0bbe30daf0a69dad","Maintainer":"Cory + Mintz \u003ccory.mintz@mongodb.com\u003e","Package":"mongodb-mms-monitoring-agent","Pre-Depends":"logrotate","SHA1":" + ace44d6ca505556cd05d4f10cfbdc3512aa37ecb","SHA256":" 9468d54a83f9b715eea9e5bfcb07fac495dccdb3d99c8a3c5e59bf8abe5e015a","ShortKey":"Pi386 + mongodb-mms-monitoring-agent 2.4.0.101-1","Size":"2470876","Version":"2.4.0.101-1"},{"Architecture":"i386","Depends":"libc6 + (\u003e= 2.7)","Description":" no description given\n","Filename":"redis-server_2.8.3_i386-cc1.deb","FilesHash":"324bb47c72149fae","Homepage":"http://example.com/no-uri-given","Installed-Size":"13146","Key":"Pi386 + redis-server 2.8.3 324bb47c72149fae","License":"unknown","MD5sum":"26e97c9f59864acab0ad38f502e7d051","Maintainer":"\u003croot@puppetmaster.georiot.com\u003e","Package":"redis-server","Priority":"extra","SHA1":" + 577894765fd4c08bee2695e414d59fac31c7d614","SHA256":" 85ddeae587d3362800d652d249ddedc1db8de20c0063179b91a138747bf58062","Section":"default","ShortKey":"Pi386 + redis-server 2.8.3","Size":"4360310","Vendor":"root@puppetmaster.georiot.com","Version":"2.8.3"},{"Architecture":"i386","Description":" + no description given\n","Filename":"xsp_2.11.0.0-git-master-04062013_i386.deb","FilesHash":"fb4f20e019c99800","Homepage":"http://example.com/no-uri-given","Installed-Size":"920","Key":"Pi386 + xsp 2.11.0.0-git-master-04062013 fb4f20e019c99800","License":"unknown","MD5sum":"7884701226877b41fd1ab77d843013c6","Maintainer":"\u003croot@puppetmaster.georiot.com\u003e","Package":"xsp","Priority":"extra","SHA1":" + d332cb2f61bc204e2e3057546023d626b47eb597","SHA256":" d847c7cde23ab5590fa125223ad8bdb3ca9f92a405717ad546433959a1795803","Section":"default","ShortKey":"Pi386 + xsp 2.11.0.0-git-master-04062013","Size":"407854","Vendor":"root@puppetmaster.georiot.com","Version":"2.11.0.0-git-master-04062013"},{"Architecture":"amd64","Description":" + no description given\n","Filename":"geoipupdate_2.0.0_amd64.deb","FilesHash":"c7b4081a761741bb","Homepage":"http://example.com/no-uri-given","Installed-Size":"92","Key":"Pamd64 + geoipupdate 2.0.0 c7b4081a761741bb","License":"unknown","MD5sum":"6d8eacf9ebc273201935c79cd7851dde","Maintainer":"\u003croot@ubuntu.zane.podzone.net\u003e","Package":"geoipupdate","Priority":"extra","SHA1":" + d9445055c184d4ef42a4a2b7db52b8fc01cd3ff7","SHA256":" f15259d84acdbee42cfe8cb67743d54e34d351d8102ca9de0b55a3ebae89b9d9","Section":"default","ShortKey":"Pamd64 + geoipupdate 2.0.0","Size":"39268","Vendor":"root@ubuntu.zane.podzone.net","Version":"2.0.0"},{"Architecture":"amd64","Description":" + The MMS Monitoring Agent monitors MongoDB performance\n metrics + and sends them to the MongoDB MMS hosted service.\n","Filename":"mongodb-mms-monitoring-agent_latest_amd64.deb","FilesHash":"fc25ab7d8b9d2158","Homepage":"http://mms.mongodb.com","Key":"Pamd64 + mongodb-mms-monitoring-agent 2.4.0.101-1 fc25ab7d8b9d2158","MD5sum":"03ce337e9a0f13cf1f44673fab382fba","Maintainer":"Cory + Mintz \u003ccory.mintz@mongodb.com\u003e","Package":"mongodb-mms-monitoring-agent","Pre-Depends":"logrotate","SHA1":" + 802551f1255a8de7188e33fc4ae56c7eef15ce83","SHA256":" c7e177319723a901e69cfb84ab6082b61acf84e138d4af0f9f497936b60af915","ShortKey":"Pamd64 + mongodb-mms-monitoring-agent 2.4.0.101-1","Size":"2558260","Version":"2.4.0.101-1"},{"Architecture":"amd64","Depends":"libc6 + (\u003e= 2.7)","Description":" no description given\n","Filename":"redis-server_2.8.3_amd64-cc1.deb","FilesHash":"fde8566b85f0a1","Homepage":"http://example.com/no-uri-given","Installed-Size":"14464","Key":"Pamd64 + redis-server 2.8.3 fde8566b85f0a1","License":"unknown","MD5sum":"1512b02d8d055b181ecedfa236bf0c90","Maintainer":"\u003croot@utility3-production.wdc.softlayer.georiot.com\u003e","Package":"redis-server","Priority":"extra","SHA1":" + 68fc5a042bda735c2b3ccde1fd167deb6d5092aa","SHA256":" 01901e2abe5ad7d0de395b5de8267578c7e055a781ce13b255959d09f991ff3d","Section":"default","ShortKey":"Pamd64 + redis-server 2.8.3","Size":"4434640","Vendor":"root@utility3-production.wdc.softlayer.georiot.com","Version":"2.8.3"},{"Architecture":"amd64","Depends":"php5-common","Description":" + no description given\n","Filename":"voltdb-php-client_1.2_amd64.deb","FilesHash":"7f4eed5217e92df0","Homepage":"http://voltdb.com/","Installed-Size":"3490","Key":"Pamd64 + voltdb-php-client 1.2 7f4eed5217e92df0","License":"unknown","MD5sum":"9f02812ffd20360a62ffc9f6ea18989b","Maintainer":"\u003croot@vagrant-ubuntu-precise-64\u003e","Package":"voltdb-php-client","Priority":"extra","SHA1":" + 2679d4bdc171d856d0673cd67e8c3afefdf76241","SHA256":" f4df086f99a12abdbdeeb9f5c1cefd468db89869f8cba6ee5fc54a7183212f0b","Section":"optional","ShortKey":"Pamd64 + voltdb-php-client 1.2","Size":"1109500","Version":"1.2"},{"Architecture":"i386","Description":" + no description given\n","Filename":"geoipupdate_2.0.0_i386.deb","FilesHash":"249f3976bd06cce4","Homepage":"http://example.com/no-uri-given","Installed-Size":"73","Key":"Pi386 + geoipupdate 2.0.0 249f3976bd06cce4","License":"unknown","MD5sum":"3e0d395332472cbdbb9e885ea532c2cf","Maintainer":"\u003croot@puppetmaster.georiot.com\u003e","Package":"geoipupdate","Priority":"extra","SHA1":" + 95165202b8183ca9c9abcfc59857ee13fab07387","SHA256":" 5db57febcda21721878ed353c87a57da69de2a0c6a185e2862f166ab84eecb08","Section":"default","ShortKey":"Pi386 + geoipupdate 2.0.0","Size":"36876","Vendor":"root@puppetmaster.georiot.com","Version":"2.0.0"}] + +' http_version: recorded_at: Tue, 31 Mar 2015 05:28:32 GMT - request: @@ -68,8 +110,9 @@ http_interactions: - '50' body: encoding: UTF-8 - string: | - ["Pamd64 voltdb-php-client 1.2 7f4eed5217e92df0"] + string: '["Pamd64 voltdb-php-client 1.2 7f4eed5217e92df0"] + +' http_version: recorded_at: Tue, 31 Mar 2015 05:28:32 GMT - request: @@ -92,8 +135,10 @@ http_interactions: - '84' body: encoding: UTF-8 - string: | - [{"error":"local repo with name nothinghere not found","meta":"Operation aborted"}] + string: '[{"error":"local repo with name nothinghere not found","meta":"Operation + aborted"}] + +' http_version: recorded_at: Tue, 31 Mar 2015 05:28:32 GMT - request: @@ -118,8 +163,9 @@ http_interactions: - '130' body: encoding: UTF-8 - string: | - {"Name":"powerhouse","Comment":"This is a test repo called powerhouse","DefaultDistribution":"main","DefaultComponent":"updates"} + string: '{"Name":"powerhouse","Comment":"This is a test repo called powerhouse","DefaultDistribution":"main","DefaultComponent":"updates"} + +' http_version: recorded_at: Tue, 31 Mar 2015 05:28:32 GMT - request: @@ -144,8 +190,9 @@ http_interactions: - '132' body: encoding: UTF-8 - string: | - {"Name":"powerhouse","Comment":"This is a test repo called powerhouse","DefaultDistribution":"binary","DefaultComponent":"updates"} + string: '{"Name":"powerhouse","Comment":"This is a test repo called powerhouse","DefaultDistribution":"binary","DefaultComponent":"updates"} + +' http_version: recorded_at: Tue, 31 Mar 2015 05:29:07 GMT - request: @@ -168,8 +215,9 @@ http_interactions: - '132' body: encoding: UTF-8 - string: | - {"Name":"powerhouse","Comment":"This is a test repo called powerhouse","DefaultDistribution":"binary","DefaultComponent":"updates"} + string: '{"Name":"powerhouse","Comment":"This is a test repo called powerhouse","DefaultDistribution":"binary","DefaultComponent":"updates"} + +' http_version: recorded_at: Tue, 31 Mar 2015 05:29:25 GMT - request: @@ -192,8 +240,10 @@ http_interactions: - '309' body: encoding: UTF-8 - string: | - [{"Name":"testing-repo","Comment":"","DefaultDistribution":"","DefaultComponent":"main"},{"Name":"stable-repo","Comment":"","DefaultDistribution":"","DefaultComponent":"main"},{"Name":"powerhouse","Comment":"This is a test repo called powerhouse","DefaultDistribution":"binary","DefaultComponent":"updates"}] + string: '[{"Name":"testing-repo","Comment":"","DefaultDistribution":"","DefaultComponent":"main"},{"Name":"stable-repo","Comment":"","DefaultDistribution":"","DefaultComponent":"main"},{"Name":"powerhouse","Comment":"This + is a test repo called powerhouse","DefaultDistribution":"binary","DefaultComponent":"updates"}] + +' http_version: recorded_at: Tue, 31 Mar 2015 05:54:21 GMT - request: @@ -216,8 +266,7 @@ http_interactions: - '3' body: encoding: UTF-8 - string: | - {} + string: "{}\n" http_version: recorded_at: Tue, 31 Mar 2015 15:54:16 GMT - request: @@ -246,8 +295,10 @@ http_interactions: - '81' body: encoding: UTF-8 - string: | - [{"error":"unable to drop, local repo is published","meta":"Operation aborted"}] + string: '[{"error":"unable to drop, local repo is published","meta":"Operation + aborted"}] + +' http_version: recorded_at: Tue, 31 Mar 2015 16:03:16 GMT - request: @@ -270,8 +321,7 @@ http_interactions: - '3' body: encoding: UTF-8 - string: | - {} + string: "{}\n" http_version: recorded_at: Tue, 31 Mar 2015 16:12:05 GMT - request: @@ -294,8 +344,11 @@ http_interactions: - '260' body: encoding: UTF-8 - string: | - {"FailedFiles":["/vagrant_data/.aptly/upload/rockpackages/test_1.0_amd64.deb"],"Report":{"Warnings":["Unable to add package to repo geoipupdate_2.0.0_amd64: conflict in package geoipupdate_2.0.0_amd64"],"added":["geoipupdate_2.0.0_amd64 added"],"removed":[]}} + string: '{"FailedFiles":["/vagrant_data/.aptly/upload/rockpackages/test_1.0_amd64.deb"],"Report":{"Warnings":["Unable + to add package to repo geoipupdate_2.0.0_amd64: conflict in package geoipupdate_2.0.0_amd64"],"added":["geoipupdate_2.0.0_amd64 + added"],"removed":[]}} + +' http_version: recorded_at: Wed, 01 Apr 2015 16:22:02 GMT - request: @@ -318,8 +371,10 @@ http_interactions: - '99' body: encoding: UTF-8 - string: | - {"FailedFiles":[],"Report":{"Warnings":[],"added":["geoipupdate_2.0.0_amd64 added"],"removed":[]}} + string: '{"FailedFiles":[],"Report":{"Warnings":[],"added":["geoipupdate_2.0.0_amd64 + added"],"removed":[]}} + +' http_version: recorded_at: Wed, 01 Apr 2015 16:26:43 GMT - request: @@ -342,8 +397,38 @@ http_interactions: - '91' body: encoding: UTF-8 - string: | - {"Name":"powerhouse_show","Comment":"","DefaultDistribution":"","DefaultComponent":"main"} + string: '{"Name":"powerhouse_show","Comment":"","DefaultDistribution":"","DefaultComponent":"main"} + +' http_version: recorded_at: Mon, 19 Oct 2015 21:52:30 GMT +- request: + method: get + uri: http://127.0.0.1:8082/api/repos/stable-repo/packages?withDeps=1 + body: + encoding: US-ASCII + string: '' + headers: {} + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json; charset=utf-8 + Date: + - Sun, 20 Mar 2016 20:31:35 GMT + Content-Length: + - '367' + body: + encoding: UTF-8 + string: '["Pi386 xsp 2.11.0.0-git-master-04062013 fb4f20e019c99800","Pamd64 + geoipupdate 2.0.0 c7b4081a761741bb","Pamd64 mongodb-mms-monitoring-agent 2.4.0.101-1 + fc25ab7d8b9d2158","Pamd64 redis-server 2.8.3 fde8566b85f0a1","Pi386 geoipupdate + 2.0.0 249f3976bd06cce4","Pi386 mongodb-mms-monitoring-agent 2.4.0.101-1 bf58165444e70af6","Pi386 + redis-server 2.8.3 324bb47c72149fae"] + +' + http_version: + recorded_at: Sun, 20 Mar 2016 20:31:35 GMT recorded_with: VCR 2.9.3 diff --git a/test/test_aptly_repo.rb b/test/test_aptly_repo.rb index a83769c..dd63b8f 100644 --- a/test/test_aptly_repo.rb +++ b/test/test_aptly_repo.rb @@ -69,7 +69,7 @@ end it "records the fixture for repo package search with dependencies" do - repo_api.repo_package_query({:name => 'stable-repo', :withDeps => true}) + repo_api.repo_package_query({:name => 'stable-repo', :with_deps => true}) end it "records the fixture for repo package search with format details on" do From 2c0c41ea219522cff94d8677edf631abfda4e11b Mon Sep 17 00:00:00 2001 From: Zane Date: Tue, 29 Mar 2016 18:30:14 -0700 Subject: [PATCH 2/2] updating tests --- lib/aptly_publish.rb | 1 + test/test_aptly_repo.rb | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/aptly_publish.rb b/lib/aptly_publish.rb index 88e112f..8b90ccb 100644 --- a/lib/aptly_publish.rb +++ b/lib/aptly_publish.rb @@ -57,6 +57,7 @@ def parse_names(names, label_type) repos_to_publish << { label_type.to_s => k } end end + return repos_to_publish end def parse_gpg_options(available_gpg_options, publish_options) diff --git a/test/test_aptly_repo.rb b/test/test_aptly_repo.rb index dd63b8f..b94f684 100644 --- a/test/test_aptly_repo.rb +++ b/test/test_aptly_repo.rb @@ -65,11 +65,11 @@ end it "records the fixture for repo package search" do - repo_api.repo_package_query({:name => 'stable-repo', :query => 'voltdb-php-client'}) + repo_api.repo_package_query({ name: 'stable-repo', query: 'voltdb-php-client'}) end it "records the fixture for repo package search with dependencies" do - repo_api.repo_package_query({:name => 'stable-repo', :with_deps => true}) + repo_api.repo_package_query({ name: 'stable-repo', with_deps: true }) end it "records the fixture for repo package search with format details on" do