From ee2a575054e3d8f44b6ea92974a22ebb455dc770 Mon Sep 17 00:00:00 2001 From: Saku Ytti Date: Fri, 22 Jun 2018 18:39:59 +0300 Subject: Remove resolve_repo smells --- lib/oxidized/node.rb | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/lib/oxidized/node.rb b/lib/oxidized/node.rb index 300221e..bc1a586 100644 --- a/lib/oxidized/node.rb +++ b/lib/oxidized/node.rb @@ -173,32 +173,18 @@ module Oxidized end def resolve_repo opt - if is_git? opt - remote_repo = Oxidized.config.output.git.repo - - if remote_repo.is_a?(::String) - if Oxidized.config.output.git.single_repo? || @group.nil? - remote_repo - else - File.join(File.dirname(remote_repo), @group + '.git') - end - else - remote_repo[@group] - end - elsif is_gitcrypt? opt - remote_repo = Oxidized.config.output.gitcrypt.repo - - if remote_repo.is_a?(::String) - if Oxidized.config.output.gitcrypt.single_repo? || @group.nil? - remote_repo - else - File.join(File.dirname(remote_repo), @group + '.git') - end + type = git_type opt + return nil unless type + + remote_repo = Oxidized.config.output.send(type).repo + if remote_repo.is_a?(::String) + if Oxidized.config.output.send(type).single_repo? || @group.nil? + remote_repo else - remote_repo[@group] + File.join(File.dirname(remote_repo), @group + '.git') end else - return + remote_repo[@group] end end @@ -237,12 +223,11 @@ module Oxidized value end - def is_git? opt - (opt[:output] || Oxidized.config.output.default) == 'git' + def git_type + type = opt[:output] || Oxidized.config.output.default + return nil unless type[0..2] == "git" + type end - def is_gitcrypt? opt - (opt[:output] || Oxidized.config.output.default) == 'gitcrypt' - end end end -- cgit v1.2.1